diff --git a/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs new file mode 100644 index 0000000..b879ab4 --- /dev/null +++ b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs @@ -0,0 +1,128 @@ +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.Logitech +{ + /// + /// Contains a list of Logitech LED IDs + /// + public enum LogitechLedId + { + ESC = 0x01, + F1 = 0x3b, + F2 = 0x3c, + F3 = 0x3d, + F4 = 0x3e, + F5 = 0x3f, + F6 = 0x40, + F7 = 0x41, + F8 = 0x42, + F9 = 0x43, + F10 = 0x44, + F11 = 0x57, + F12 = 0x58, + PRINT_SCREEN = 0x137, + SCROLL_LOCK = 0x46, + PAUSE_BREAK = 0x145, + TILDE = 0x29, + ONE = 0x02, + TWO = 0x03, + THREE = 0x04, + FOUR = 0x05, + FIVE = 0x06, + SIX = 0x07, + SEVEN = 0x08, + EIGHT = 0x09, + NINE = 0x0A, + ZERO = 0x0B, + MINUS = 0x0C, + EQUALS = 0x0D, + BACKSPACE = 0x0E, + INSERT = 0x152, + HOME = 0x147, + PAGE_UP = 0x149, + NUM_LOCK = 0x45, + NUM_SLASH = 0x135, + NUM_ASTERISK = 0x37, + NUM_MINUS = 0x4A, + TAB = 0x0F, + Q = 0x10, + W = 0x11, + E = 0x12, + R = 0x13, + T = 0x14, + Y = 0x15, + U = 0x16, + I = 0x17, + O = 0x18, + P = 0x19, + OPEN_BRACKET = 0x1A, + CLOSE_BRACKET = 0x1B, + BACKSLASH = 0x2B, + KEYBOARD_DELETE = 0x153, + END = 0x14F, + PAGE_DOWN = 0x151, + NUM_SEVEN = 0x47, + NUM_EIGHT = 0x48, + NUM_NINE = 0x49, + NUM_PLUS = 0x4E, + CAPS_LOCK = 0x3A, + A = 0x1E, + S = 0x1F, + D = 0x20, + F = 0x21, + G = 0x22, + H = 0x23, + J = 0x24, + K = 0x25, + L = 0x26, + SEMICOLON = 0x27, + APOSTROPHE = 0x28, + ENTER = 0x1C, + NUM_FOUR = 0x4B, + NUM_FIVE = 0x4C, + NUM_SIX = 0x4D, + LEFT_SHIFT = 0x2A, + Z = 0x2C, + X = 0x2D, + C = 0x2E, + V = 0x2F, + B = 0x30, + N = 0x31, + M = 0x32, + COMMA = 0x33, + PERIOD = 0x34, + FORWARD_SLASH = 0x35, + RIGHT_SHIFT = 0x36, + ARROW_UP = 0x148, + NUM_ONE = 0x4F, + NUM_TWO = 0x50, + NUM_THREE = 0x51, + NUM_ENTER = 0x11C, + LEFT_CONTROL = 0x1D, + LEFT_WINDOWS = 0x15B, + LEFT_ALT = 0x38, + SPACE = 0x39, + RIGHT_ALT = 0x138, + RIGHT_WINDOWS = 0x15C, + APPLICATION_SELECT = 0x15D, + RIGHT_CONTROL = 0x11D, + ARROW_LEFT = 0x14B, + ARROW_DOWN = 0x150, + ARROW_RIGHT = 0x14D, + NUM_ZERO = 0x52, + NUM_PERIOD = 0x53, + ISO_BACKSLASH = 0x56, + ISO_TILDE = 0x5D, + G_1 = 0xFFF1, + G_2 = 0xFFF2, + G_3 = 0xFFF3, + G_4 = 0xFFF4, + G_5 = 0xFFF5, + G_6 = 0xFFF6, + G_7 = 0xFFF7, + G_8 = 0xFFF8, + G_9 = 0xFFF9, + G_LOGO = 0xFFFF1, + G_BADGE = 0xFFFF2 + }; +} diff --git a/RGB.NET.Devices.Logitech/Generic/LedMappings.cs b/RGB.NET.Devices.Logitech/Generic/LedMappings.cs index e086a64..679a4e3 100644 --- a/RGB.NET.Devices.Logitech/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Logitech/Generic/LedMappings.cs @@ -4,138 +4,131 @@ namespace RGB.NET.Devices.Logitech { public static class LedMappings { - public static LedMapping PerKey { get; } = new() + public static LedMapping PerKey { get; } = new() { - { LedId.Keyboard_Escape, 0 }, - { LedId.Keyboard_F1, 4 }, - { LedId.Keyboard_F2, 8 }, - { LedId.Keyboard_F3, 12 }, - { LedId.Keyboard_F4, 16 }, - { LedId.Keyboard_F5, 20 }, - { LedId.Keyboard_F6, 24 }, - { LedId.Keyboard_F7, 28 }, - { LedId.Keyboard_F8, 32 }, - { LedId.Keyboard_F9, 36 }, - { LedId.Keyboard_F10, 40 }, - { LedId.Keyboard_F11, 44 }, - { LedId.Keyboard_F12, 48 }, - { LedId.Keyboard_PrintScreen, 52 }, - { LedId.Keyboard_ScrollLock, 56 }, - { LedId.Keyboard_PauseBreak, 60 }, - // { LedId.Keyboard_?, 64 }, - // { LedId.Keyboard_?, 68 }, - // { LedId.Keyboard_?, 72 }, - // { LedId.Keyboard_?, 76 }, - // { LedId.Keyboard_?, 80 }, + { LedId.Keyboard_Escape, LogitechLedId.ESC }, + { LedId.Keyboard_F1, LogitechLedId.F1 }, + { LedId.Keyboard_F2, LogitechLedId.F2}, + { LedId.Keyboard_F3, LogitechLedId.F3 }, + { LedId.Keyboard_F4, LogitechLedId.F4 }, + { LedId.Keyboard_F5, LogitechLedId.F5 }, + { LedId.Keyboard_F6, LogitechLedId.F6 }, + { LedId.Keyboard_F7, LogitechLedId.F7 }, + { LedId.Keyboard_F8, LogitechLedId.F8 }, + { LedId.Keyboard_F9, LogitechLedId.F9 }, + { LedId.Keyboard_F10, LogitechLedId.F10 }, + { LedId.Keyboard_F11, LogitechLedId.F11 }, + { LedId.Keyboard_F12, LogitechLedId.F12 }, + { LedId.Keyboard_PrintScreen, LogitechLedId.PRINT_SCREEN }, + { LedId.Keyboard_ScrollLock, LogitechLedId.SCROLL_LOCK }, + { LedId.Keyboard_PauseBreak, LogitechLedId.PAUSE_BREAK }, - { LedId.Keyboard_GraveAccentAndTilde, 84 }, - { LedId.Keyboard_1, 88 }, - { LedId.Keyboard_2, 92 }, - { LedId.Keyboard_3, 96 }, - { LedId.Keyboard_4, 100 }, - { LedId.Keyboard_5, 104 }, - { LedId.Keyboard_6, 108 }, - { LedId.Keyboard_7, 112 }, - { LedId.Keyboard_8, 116 }, - { LedId.Keyboard_9, 120 }, - { LedId.Keyboard_0, 124 }, - { LedId.Keyboard_MinusAndUnderscore, 128 }, - { LedId.Keyboard_EqualsAndPlus, 132 }, - { LedId.Keyboard_Backspace, 136 }, - { LedId.Keyboard_Insert, 140 }, - { LedId.Keyboard_Home, 144 }, - { LedId.Keyboard_PageUp, 148 }, - { LedId.Keyboard_NumLock, 152 }, - { LedId.Keyboard_NumSlash, 156 }, - { LedId.Keyboard_NumAsterisk, 160 }, - { LedId.Keyboard_NumMinus, 164 }, + { LedId.Keyboard_GraveAccentAndTilde, LogitechLedId.TILDE }, + { LedId.Keyboard_1, LogitechLedId.ONE }, + { LedId.Keyboard_2, LogitechLedId.TWO }, + { LedId.Keyboard_3, LogitechLedId.THREE }, + { LedId.Keyboard_4, LogitechLedId.FOUR }, + { LedId.Keyboard_5, LogitechLedId.FIVE }, + { LedId.Keyboard_6, LogitechLedId.SIX }, + { LedId.Keyboard_7, LogitechLedId.SEVEN }, + { LedId.Keyboard_8, LogitechLedId.EIGHT }, + { LedId.Keyboard_9, LogitechLedId.NINE }, + { LedId.Keyboard_0, LogitechLedId.ZERO }, + { LedId.Keyboard_MinusAndUnderscore, LogitechLedId.MINUS }, + { LedId.Keyboard_EqualsAndPlus, LogitechLedId.EQUALS }, + { LedId.Keyboard_Backspace, LogitechLedId.BACKSPACE }, + { LedId.Keyboard_Insert, LogitechLedId.INSERT }, + { LedId.Keyboard_Home, LogitechLedId.HOME }, + { LedId.Keyboard_PageUp, LogitechLedId.PAGE_UP }, + { LedId.Keyboard_NumLock, LogitechLedId.NUM_LOCK }, + { LedId.Keyboard_NumSlash, LogitechLedId.NUM_SLASH }, + { LedId.Keyboard_NumAsterisk, LogitechLedId.NUM_ASTERISK }, + { LedId.Keyboard_NumMinus, LogitechLedId.NUM_MINUS }, - { LedId.Keyboard_Tab, 168 }, - { LedId.Keyboard_Q, 172 }, - { LedId.Keyboard_W, 176 }, - { LedId.Keyboard_E, 180 }, - { LedId.Keyboard_R, 184 }, - { LedId.Keyboard_T, 188 }, - { LedId.Keyboard_Y, 192 }, - { LedId.Keyboard_U, 196 }, - { LedId.Keyboard_I, 200 }, - { LedId.Keyboard_O, 204 }, - { LedId.Keyboard_P, 208 }, - { LedId.Keyboard_BracketLeft, 212 }, - { LedId.Keyboard_BracketRight, 216 }, - { LedId.Keyboard_Backslash, 220 }, - { LedId.Keyboard_Delete, 224 }, - { LedId.Keyboard_End, 228 }, - { LedId.Keyboard_PageDown, 232 }, - { LedId.Keyboard_Num7, 236 }, - { LedId.Keyboard_Num8, 240 }, - { LedId.Keyboard_Num9, 244 }, - { LedId.Keyboard_NumPlus, 248 }, + { LedId.Keyboard_Tab, LogitechLedId.TAB }, + { LedId.Keyboard_Q, LogitechLedId.Q }, + { LedId.Keyboard_W, LogitechLedId.W }, + { LedId.Keyboard_E, LogitechLedId.E }, + { LedId.Keyboard_R, LogitechLedId.R }, + { LedId.Keyboard_T, LogitechLedId.T }, + { LedId.Keyboard_Y, LogitechLedId.Y }, + { LedId.Keyboard_U, LogitechLedId.U }, + { LedId.Keyboard_I, LogitechLedId.I }, + { LedId.Keyboard_O, LogitechLedId.O }, + { LedId.Keyboard_P, LogitechLedId.P }, + { LedId.Keyboard_BracketLeft, LogitechLedId.OPEN_BRACKET }, + { LedId.Keyboard_BracketRight, LogitechLedId.CLOSE_BRACKET }, + { LedId.Keyboard_Backslash, LogitechLedId.BACKSLASH }, + { LedId.Keyboard_Delete, LogitechLedId.KEYBOARD_DELETE }, + { LedId.Keyboard_End, LogitechLedId.END }, + { LedId.Keyboard_PageDown, LogitechLedId.PAGE_DOWN }, + { LedId.Keyboard_Num7, LogitechLedId.NUM_SEVEN }, + { LedId.Keyboard_Num8, LogitechLedId.NUM_EIGHT }, + { LedId.Keyboard_Num9, LogitechLedId.NUM_NINE }, + { LedId.Keyboard_NumPlus, LogitechLedId.NUM_PLUS }, - { LedId.Keyboard_CapsLock, 252 }, - { LedId.Keyboard_A, 256 }, - { LedId.Keyboard_S, 260 }, - { LedId.Keyboard_D, 264 }, - { LedId.Keyboard_F, 268 }, - { LedId.Keyboard_G, 272 }, - { LedId.Keyboard_H, 276 }, - { LedId.Keyboard_J, 280 }, - { LedId.Keyboard_K, 284 }, - { LedId.Keyboard_L, 288 }, - { LedId.Keyboard_SemicolonAndColon, 292 }, - { LedId.Keyboard_ApostropheAndDoubleQuote, 296 }, - { LedId.Keyboard_NonUsTilde, 300 }, //TODO DarthAffe 26.03.2017: Find the real ID/Name of this key - it's not documented ... - { LedId.Keyboard_Enter, 304 }, - // { LedId.Keyboard_?, 308 }, - // { LedId.Keyboard_?, 312 }, - // { LedId.Keyboard_?, 316 }, - { LedId.Keyboard_Num4, 320 }, - { LedId.Keyboard_Num5, 324 }, - { LedId.Keyboard_Num6, 328 }, - // { LedId.Keyboard_?, 332 }, + { LedId.Keyboard_CapsLock, LogitechLedId.CAPS_LOCK }, + { LedId.Keyboard_A, LogitechLedId.A }, + { LedId.Keyboard_S, LogitechLedId.S }, + { LedId.Keyboard_D, LogitechLedId.D }, + { LedId.Keyboard_F, LogitechLedId.F }, + { LedId.Keyboard_G, LogitechLedId.G }, + { LedId.Keyboard_H, LogitechLedId.H }, + { LedId.Keyboard_J, LogitechLedId.J }, + { LedId.Keyboard_K, LogitechLedId.K }, + { LedId.Keyboard_L, LogitechLedId.L }, + { LedId.Keyboard_SemicolonAndColon, LogitechLedId.SEMICOLON }, + { LedId.Keyboard_ApostropheAndDoubleQuote, LogitechLedId.APOSTROPHE }, + { LedId.Keyboard_NonUsTilde, LogitechLedId.ISO_TILDE }, + { LedId.Keyboard_Enter, LogitechLedId.ENTER }, + { LedId.Keyboard_Num4, LogitechLedId.NUM_FOUR }, + { LedId.Keyboard_Num5, LogitechLedId.NUM_FIVE }, + { LedId.Keyboard_Num6, LogitechLedId.NUM_SIX }, - { LedId.Keyboard_LeftShift, 336 }, - { LedId.Keyboard_NonUsBackslash, 340 }, - { LedId.Keyboard_Z, 344 }, - { LedId.Keyboard_X, 348 }, - { LedId.Keyboard_C, 352 }, - { LedId.Keyboard_V, 356 }, - { LedId.Keyboard_B, 360 }, - { LedId.Keyboard_N, 364 }, - { LedId.Keyboard_M, 368 }, - { LedId.Keyboard_CommaAndLessThan, 372 }, - { LedId.Keyboard_PeriodAndBiggerThan, 376 }, - { LedId.Keyboard_SlashAndQuestionMark, 380 }, - { LedId.Keyboard_RightShift, 388 }, - // { LedId.Keyboard_?, 392 }, - { LedId.Keyboard_ArrowUp, 396 }, - // { LedId.Keyboard_?, 400 }, - { LedId.Keyboard_Num1, 404 }, - { LedId.Keyboard_Num2, 408 }, - { LedId.Keyboard_Num3, 412 }, - { LedId.Keyboard_NumEnter, 416 }, + { LedId.Keyboard_LeftShift, LogitechLedId.LEFT_SHIFT }, + { LedId.Keyboard_NonUsBackslash, LogitechLedId.ISO_BACKSLASH }, + { LedId.Keyboard_Z, LogitechLedId.Z }, + { LedId.Keyboard_X, LogitechLedId.X }, + { LedId.Keyboard_C, LogitechLedId.C }, + { LedId.Keyboard_V, LogitechLedId.V }, + { LedId.Keyboard_B, LogitechLedId.B }, + { LedId.Keyboard_N, LogitechLedId.N }, + { LedId.Keyboard_M, LogitechLedId.M }, + { LedId.Keyboard_CommaAndLessThan, LogitechLedId.COMMA }, + { LedId.Keyboard_PeriodAndBiggerThan, LogitechLedId.PERIOD }, + { LedId.Keyboard_SlashAndQuestionMark, LogitechLedId.FORWARD_SLASH }, + { LedId.Keyboard_RightShift, LogitechLedId.RIGHT_SHIFT }, + { LedId.Keyboard_ArrowUp, LogitechLedId.ARROW_UP }, + { LedId.Keyboard_Num1, LogitechLedId.NUM_ONE }, + { LedId.Keyboard_Num2, LogitechLedId.NUM_TWO }, + { LedId.Keyboard_Num3, LogitechLedId.NUM_THREE }, + { LedId.Keyboard_NumEnter, LogitechLedId.NUM_ENTER }, - { LedId.Keyboard_LeftCtrl, 420 }, - { LedId.Keyboard_LeftGui, 424 }, - { LedId.Keyboard_LeftAlt, 428 }, - // { LedId.Keyboard_?, 432 }, - // { LedId.Keyboard_?, 436 }, - { LedId.Keyboard_Space, 440 }, - // { LedId.Keyboard_?, 444 }, - // { LedId.Keyboard_?, 448 }, - // { LedId.Keyboard_?, 452 }, - // { LedId.Keyboard_?, 456 }, - // { LedId.Keyboard_?, 460 }, - { LedId.Keyboard_RightAlt, 464 }, - { LedId.Keyboard_RightGui, 468 }, - { LedId.Keyboard_Application, 472 }, - { LedId.Keyboard_RightCtrl, 476 }, - { LedId.Keyboard_ArrowLeft, 480 }, - { LedId.Keyboard_ArrowDown, 484 }, - { LedId.Keyboard_ArrowRight, 488 }, - { LedId.Keyboard_Num0, 492 }, - { LedId.Keyboard_NumPeriodAndDelete, 496 }, - // { LedId.Keyboard_?, 500 }, + { LedId.Keyboard_LeftCtrl, LogitechLedId.LEFT_CONTROL }, + { LedId.Keyboard_LeftGui, LogitechLedId.LEFT_WINDOWS }, + { LedId.Keyboard_LeftAlt, LogitechLedId.LEFT_ALT }, + { LedId.Keyboard_Space, LogitechLedId.SPACE }, + { LedId.Keyboard_RightAlt, LogitechLedId.RIGHT_ALT }, + { LedId.Keyboard_RightGui, LogitechLedId.RIGHT_WINDOWS }, + { LedId.Keyboard_Application, LogitechLedId.APPLICATION_SELECT }, + { LedId.Keyboard_RightCtrl, LogitechLedId.RIGHT_CONTROL }, + { LedId.Keyboard_ArrowLeft, LogitechLedId.ARROW_LEFT }, + { LedId.Keyboard_ArrowDown, LogitechLedId.ARROW_DOWN }, + { LedId.Keyboard_ArrowRight, LogitechLedId.ARROW_RIGHT }, + { LedId.Keyboard_Num0, LogitechLedId.NUM_ZERO }, + { LedId.Keyboard_NumPeriodAndDelete, LogitechLedId.NUM_PERIOD }, + + { LedId.Keyboard_Programmable1, LogitechLedId.G_1 }, + { LedId.Keyboard_Programmable2, LogitechLedId.G_2 }, + { LedId.Keyboard_Programmable3, LogitechLedId.G_3 }, + { LedId.Keyboard_Programmable4, LogitechLedId.G_4 }, + { LedId.Keyboard_Programmable5, LogitechLedId.G_5 }, + { LedId.Keyboard_Programmable6, LogitechLedId.G_6 }, + { LedId.Keyboard_Programmable7, LogitechLedId.G_7 }, + { LedId.Keyboard_Programmable8, LogitechLedId.G_8 }, + { LedId.Keyboard_Programmable9, LogitechLedId.G_9 }, + { LedId.Logo, LogitechLedId.G_LOGO }, + { LedId.Keyboard_Custom1, LogitechLedId.G_BADGE }, }; public static LedMapping Device { get; } = new() diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index c39b1ae..b6ea867 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Logitech private const int VENDOR_ID = 0x046D; - public static HIDLoader PerKeyDeviceDefinitions { get; } = new(VENDOR_ID) + public static HIDLoader PerKeyDeviceDefinitions { get; } = new(VENDOR_ID) { { 0xC32B, RGBDeviceType.Keyboard, "G910", LedMappings.PerKey, 0 }, { 0xC335, RGBDeviceType.Keyboard, "G910v2", LedMappings.PerKey, 0 }, @@ -139,10 +139,10 @@ namespace RGB.NET.Devices.Logitech //TODO DarthAffe 04.03.2021: Rework device selection and configuration for HID-based providers protected override IEnumerable LoadDevices() { - IEnumerable<(HIDDeviceDefinition definition, HidDevice device)> perKeyDevices = PerKeyDeviceDefinitions.GetConnectedDevices(); + IEnumerable<(HIDDeviceDefinition definition, HidDevice device)> perKeyDevices = PerKeyDeviceDefinitions.GetConnectedDevices(); if ((_perKeyUpdateQueue != null) && perKeyDevices.Any()) { - (HIDDeviceDefinition definition, _) = perKeyDevices.First(); + (HIDDeviceDefinition definition, _) = perKeyDevices.First(); yield return new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.PerKeyRGB, 0), _perKeyUpdateQueue, definition.LedMapping); } @@ -150,14 +150,14 @@ namespace RGB.NET.Devices.Logitech foreach ((HIDDeviceDefinition definition, _) in perZoneDevices) { LogitechZoneUpdateQueue updateQueue = new(GetUpdateTrigger(), definition.CustomData.deviceType); - yield return new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, definition.CustomData.zones), updateQueue, definition.LedMapping); + yield return new LogitechZoneRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, definition.CustomData.zones), updateQueue, definition.LedMapping); } IEnumerable<(HIDDeviceDefinition definition, HidDevice device)> perDeviceDevices = PerDeviceDeviceDefinitions.GetConnectedDevices(); if ((_perDeviceUpdateQueue != null) && perDeviceDevices.Any()) { (HIDDeviceDefinition definition, _) = perDeviceDevices.First(); - yield return new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, 0), _perDeviceUpdateQueue, definition.LedMapping); + yield return new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, 0), _perDeviceUpdateQueue, definition.LedMapping); } } diff --git a/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs b/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs deleted file mode 100644 index c4f598d..0000000 --- a/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Runtime.CompilerServices; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Logitech -{ - internal static class BitmapMapping - { - #region Constants - - private const int BITMAP_SIZE = 21 * 6 * 4; - - #endregion - - #region Methods - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE]; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void SetColor(byte[] bitmap, int offset, Color color) - { - bitmap[offset] = color.GetB(); - bitmap[offset + 1] = color.GetG(); - bitmap[offset + 2] = color.GetR(); - bitmap[offset + 3] = color.GetA(); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs index 29e84e7..7595b25 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs @@ -11,7 +11,7 @@ namespace RGB.NET.Devices.Logitech { #region Properties & Fields - private readonly LedMapping _ledMapping; + private readonly LedMapping _ledMapping; #endregion @@ -21,7 +21,7 @@ namespace RGB.NET.Devices.Logitech /// /// Initializes a new instance of the class. /// - internal LogitechPerKeyRGBDevice(LogitechRGBDeviceInfo info, IUpdateQueue updateQueue, LedMapping ledMapping) + internal LogitechPerKeyRGBDevice(LogitechRGBDeviceInfo info, IUpdateQueue updateQueue, LedMapping ledMapping) : base(info, updateQueue) { this._ledMapping = ledMapping; @@ -32,7 +32,7 @@ namespace RGB.NET.Devices.Logitech #region Methods /// - protected override object GetLedCustomData(LedId ledId) => _ledMapping.TryGetValue(ledId, out int logitechLedId) ? logitechLedId : -1; + protected override object GetLedCustomData(LedId ledId) => _ledMapping.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : -1; /// protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index 4203842..5bc6177 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -9,12 +9,6 @@ namespace RGB.NET.Devices.Logitech /// public class LogitechPerKeyUpdateQueue : UpdateQueue { - #region Properties & Fields - - private readonly byte[] _bitmap; - - #endregion - #region Constructors /// @@ -24,7 +18,6 @@ namespace RGB.NET.Devices.Logitech public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) { - _bitmap = BitmapMapping.CreateBitmap(); } #endregion @@ -36,15 +29,15 @@ namespace RGB.NET.Devices.Logitech { _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB); - Array.Clear(_bitmap, 0, _bitmap.Length); foreach ((object key, Color color) in dataSet) { - int offset = key as int? ?? -1; - if (offset >= 0) - BitmapMapping.SetColor(_bitmap, offset, color); + // These will be LogitechLedId but the SDK expects an int and doesn't care about invalid values + int keyName = (int)key; + _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyName, + (int)MathF.Round(color.R * 100), + (int)MathF.Round(color.G * 100), + (int)MathF.Round(color.B * 100)); } - - _LogitechGSDK.LogiLedSetLightingFromBitmap(_bitmap); } #endregion