Beispiel #1
0
        /// <summary>
        ///     Applies the color scheme to the keyboard.
        /// </summary>
        /// <param name="colorScheme">The color scheme to apply.</param>
        private static void ApplyToKeyboard(ColorScheme colorScheme)
        {
            var colorMap = new Dictionary <KeyName, Color>();

            foreach (KeyName key in Enum.GetValues(typeof(KeyName)))
            {
                colorMap.Add(key, colorScheme.BaseColor);
            }

            // Absolute keys do not need to be converted to QWERTY, they are already specified in QWERTY.
            foreach (var entry in colorScheme.AbsoluteKeys)
            {
                if (KeyMapping.ContainsKey(entry.Key))
                {
                    colorMap[KeyCodeToScanCode(entry.Key)] = entry.Value;
                }
            }

            // Mapped keys DO need to be converted to QWERTY before use.
            foreach (var entry in colorScheme.MappedKeys)
            {
                var qwertyKey = KSPLogitechRGBPlugin.Instance.LayoutProvider.ConvertToQwertyCode(entry.Key);

                if (KeyMapping.ContainsKey(qwertyKey))
                {
                    colorMap[KeyCodeToScanCode(qwertyKey)] = entry.Value;
                }
            }

            foreach (var entry in colorMap)
            {
                LogitechSDK.SetKeyLighting(
                    entry.Key,
                    Convert.ToInt32(entry.Value.r * 100),
                    Convert.ToInt32(entry.Value.g * 100),
                    Convert.ToInt32(entry.Value.b * 100)
                    );
            }
        }
Beispiel #2
0
 /// <summary>
 ///     Constructor. Starts the Logitech Link.
 /// </summary>
 public LogitechLEDController()
 {
     LogitechSDK.Init();
     LogitechSDK.SetTargetDevice(LogiDevicetypePerkeyRGB);
 }