From 9be34c1bab092d91b95f41eb93ab39165ad7aa29 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 29 Mar 2018 20:55:07 +0200 Subject: [PATCH] Added logitech Pro and G Pro --- RGB.NET.Devices.Logitech/HID/DeviceChecker.cs | 2 + .../Layouts/Logitech/Keyboards/Pro/UK.xml | 189 ++++++++++++++++++ .../PerKey/BitmapMapping.cs | 2 +- .../PerKey/LogitechPerKeyUpdateQueue.cs | 27 ++- .../RGB.NET.Devices.Logitech.csproj | 3 + 5 files changed, 212 insertions(+), 11 deletions(-) create mode 100644 RGB.NET.Devices.Logitech/Layouts/Logitech/Keyboards/Pro/UK.xml diff --git a/RGB.NET.Devices.Logitech/HID/DeviceChecker.cs b/RGB.NET.Devices.Logitech/HID/DeviceChecker.cs index 3d4aacb..2caa03e 100644 --- a/RGB.NET.Devices.Logitech/HID/DeviceChecker.cs +++ b/RGB.NET.Devices.Logitech/HID/DeviceChecker.cs @@ -19,6 +19,7 @@ namespace RGB.NET.Devices.Logitech.HID ("G910", RGBDeviceType.Keyboard, 0xC32B, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout ("G810", RGBDeviceType.Keyboard, 0xC337, "DE", @"Keyboards\G810\UK"), ("G610", RGBDeviceType.Keyboard, 0xC333, "DE", @"Keyboards\G610\UK"), + ("Pro", RGBDeviceType.Keyboard, 0xC339, "DE", @"Keyboards\Pro\UK"), }; private static readonly List<(string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath)> PER_DEVICE_DEVICES @@ -27,6 +28,7 @@ namespace RGB.NET.Devices.Logitech.HID ("G903", RGBDeviceType.Mouse, 0xC086, "default", @"Mice\G903"), ("G403", RGBDeviceType.Mouse, 0xC083, "default", @"Mice\G403"), ("G502", RGBDeviceType.Mouse, 0xC332, "default", @"Mice\G502"), + ("G Pro", RGBDeviceType.Mouse, 0xC085, "default", @"Mice\GPro"), }; #endregion diff --git a/RGB.NET.Devices.Logitech/Layouts/Logitech/Keyboards/Pro/UK.xml b/RGB.NET.Devices.Logitech/Layouts/Logitech/Keyboards/Pro/UK.xml new file mode 100644 index 0000000..4d42f84 --- /dev/null +++ b/RGB.NET.Devices.Logitech/Layouts/Logitech/Keyboards/Pro/UK.xml @@ -0,0 +1,189 @@ + + + Logitech Pro Gaming Keyboard - Physical UK + Physical UK-Layout of Logitech Pro Gaming Keyboard (Logical: ???) + Darth Affe + Keyboard + Key + Logitech + Pro + 360 + 152 + Images\Logitech\Keyboards + + + + + 5 + 28 + + + + +12.667 + + + + + + + +12.667 + + + + + + + +12.667 + + + + + + + +6.75 + + + + + + + 5 + 52 + + + + + + + + + + + + + + + 2 + + + + +6.75 + + + + + + + 5 + + + 1.5 + + + + + + + + + + + + + + + M0,0 L0,0.5 L0.16666666666,0.5 L0.16666666666,1 L1,1 L1,0 Z + 1.5 + 2 + + + + +6.75 + + + + + + + 5 + + + 1.75 + + + + + + + + + + + + + + + + + 5 + + + 1.25 + + + + + + + + + + + + + + 2.75 + + + + +25.75 + + + + + 5 + + + 1.5 + + + 1.25 + + + 1.25 + + + 5.75 + + + 1.25 + + + 1.25 + + + 1.25 + + + 1.5 + + + + +6.75 + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs b/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs index 73d882b..cfb5cd9 100644 --- a/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs +++ b/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs @@ -156,7 +156,7 @@ namespace RGB.NET.Devices.Logitech internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE]; [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void SetColor(ref byte[] bitmap, int offset, Color color) + internal static void SetColor(byte[] bitmap, int offset, Color color) { bitmap[offset] = color.B; bitmap[offset + 1] = color.G; diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index 152cb8f..a14ef60 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -7,11 +7,19 @@ namespace RGB.NET.Devices.Logitech { public class LogitechPerKeyUpdateQueue : UpdateQueue { + #region Properties & Fields + + private readonly byte[] _bitmap; + + #endregion + #region Constructors public LogitechPerKeyUpdateQueue(IUpdateTrigger updateTrigger) : base(updateTrigger) - { } + { + _bitmap = BitmapMapping.CreateBitmap(); + } #endregion @@ -22,28 +30,27 @@ namespace RGB.NET.Devices.Logitech { _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB); - byte[] bitmap = null; + Array.Clear(_bitmap, 0, _bitmap.Length); + bool usesBitmap = false; foreach (KeyValuePair data in dataSet) { - (LedId id, int customData) = ((LedId, int))data.Key; + (LedId id, LogitechLedId customData) = ((LedId, LogitechLedId))data.Key; // DarthAffe 26.03.2017: This is only needed since update by name doesn't work as expected for all keys ... if (BitmapMapping.BitmapOffset.TryGetValue(id, out int bitmapOffset)) { - if (bitmap == null) - bitmap = BitmapMapping.CreateBitmap(); - - BitmapMapping.SetColor(ref bitmap, bitmapOffset, data.Value); + BitmapMapping.SetColor(_bitmap, bitmapOffset, data.Value); + usesBitmap = true; } else - _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(customData, + _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)customData, (int)Math.Round(data.Value.RPercent * 100), (int)Math.Round(data.Value.GPercent * 100), (int)Math.Round(data.Value.BPercent * 100)); } - if (bitmap != null) - _LogitechGSDK.LogiLedSetLightingFromBitmap(bitmap); + if (usesBitmap) + _LogitechGSDK.LogiLedSetLightingFromBitmap(_bitmap); } #endregion diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 3e92661..d6c6ec6 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -202,6 +202,9 @@ Designer + + Designer + Designer