CoolerMaster fixes

Fixed duplicate values in the LED mappings
Added SetAllLeds for fast bulk LED updating on keyboards
This commit is contained in:
SpoinkyNL committed 2018-01-09 11:57:04 +01:00
1 parent 4c32eedee0
commit 835e5a0a32
3 files changed
+62 -2

No files matched your search

@@ -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) },
@@ -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
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
{
List<Led> 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);
}
}
/// <inheritdoc />
protected override void InitializeLayout()
{