diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs
index 3bd2dba..0febc0f 100644
--- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs
+++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs
@@ -336,7 +336,6 @@ namespace RGB.NET.Devices.CoolerMaster
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
{ LedId.Keyboard_RightShift, (4,14) },
- { LedId.Keyboard_U, (4,16) },
{ LedId.Keyboard_Num1, (4,15) },
{ LedId.Keyboard_Num2, (4,16) },
{ LedId.Keyboard_Num3, (4,17) },
@@ -439,7 +438,6 @@ namespace RGB.NET.Devices.CoolerMaster
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
{ LedId.Keyboard_RightShift, (4,14) },
- { LedId.Keyboard_U, (4,16) },
{ LedId.Keyboard_Num1, (4,15) },
{ LedId.Keyboard_Num2, (4,16) },
{ LedId.Keyboard_Num3, (4,17) },
diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs
index 922ad52..7f35bc4 100644
--- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs
+++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs
@@ -1,5 +1,7 @@
using System.Collections.Generic;
+using System.Linq;
using RGB.NET.Core;
+using RGB.NET.Devices.CoolerMaster.Native;
namespace RGB.NET.Devices.CoolerMaster
{
@@ -24,6 +26,27 @@ namespace RGB.NET.Devices.CoolerMaster
#region Methods
+ ///
+ protected override void UpdateLeds(IEnumerable ledsToUpdate)
+ {
+ List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList();
+
+ if (leds.Count > 0)
+ {
+ // 6 by 22 seems hard-coded but it's what the CM SDK expects regardless of keyboard size
+ var matrix = new _CoolerMasterSDK.COLOR_MATRIX { KeyColor = new _CoolerMasterSDK.KEY_COLOR[6, 22] };
+ foreach (Led led in leds)
+ {
+ (int row, int column) = ((int, int))led.CustomData;
+ matrix.KeyColor[row, column] = new _CoolerMasterSDK.KEY_COLOR(led.Color.R, led.Color.G, led.Color.B);
+ }
+
+ _CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex);
+ _CoolerMasterSDK.SetAllLedColor(matrix);
+ _CoolerMasterSDK.RefreshLed(false);
+ }
+ }
+
///
protected override void InitializeLayout()
{
diff --git a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs
index f59f0f8..aac65d4 100644
--- a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs
+++ b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs
@@ -49,6 +49,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
_enableLedControlPointer = (EnableLedControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "EnableLedControl"), typeof(EnableLedControlPointer));
_refreshLedPointer = (RefreshLedPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "RefreshLed"), typeof(RefreshLedPointer));
_setLedColorPointer = (SetLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetLedColor"), typeof(SetLedColorPointer));
+ _setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer));
}
private static void UnloadCMSDK()
@@ -73,6 +74,31 @@ namespace RGB.NET.Devices.CoolerMaster.Native
#region SDK-METHODS
+ #region Structs
+
+ // ReSharper disable InconsistentNaming
+ internal struct KEY_COLOR
+ {
+ public byte r;
+ public byte g;
+ public byte b;
+
+ public KEY_COLOR(byte colR, byte colG, byte colB)
+ {
+ r = colR;
+ g = colG;
+ b = colB;
+ }
+ }
+
+ internal struct COLOR_MATRIX
+ {
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 132)] public KEY_COLOR[,] KeyColor;
+ }
+ // ReSharper restore InconsistentNaming
+
+ #endregion
+
#region Pointers
private static GetSDKVersionPointer _getSDKVersionPointer;
@@ -82,6 +108,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
private static EnableLedControlPointer _enableLedControlPointer;
private static RefreshLedPointer _refreshLedPointer;
private static SetLedColorPointer _setLedColorPointer;
+ private static SetAllLedColorPointer _setAllLedColorPointer;
#endregion
@@ -112,6 +139,10 @@ namespace RGB.NET.Devices.CoolerMaster.Native
[return: MarshalAs(UnmanagedType.I1)]
private delegate bool SetLedColorPointer(int row, int column, byte r, byte g, byte b);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ [return: MarshalAs(UnmanagedType.I1)]
+ private delegate bool SetAllLedColorPointer(COLOR_MATRIX colorMatrix);
+
#endregion
// ReSharper disable EventExceptionNotDocumented
@@ -172,6 +203,14 @@ namespace RGB.NET.Devices.CoolerMaster.Native
return _setLedColorPointer(row, column, r, g, b);
}
+ ///
+ /// CM-SDK: Set Keyboard "every LED" color
+ ///
+ internal static bool SetAllLedColor(COLOR_MATRIX colorMatrix)
+ {
+ return _setAllLedColorPointer(colorMatrix);
+ }
+
// ReSharper restore EventExceptionNotDocumented
#endregion