mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
ASUS - Attempt to add lights that aren't present as keys
This commit is contained in:
parent
ca264a4603
commit
e86003f1ea
@ -45,6 +45,7 @@ namespace RGB.NET.Devices.Asus
|
|||||||
|
|
||||||
protected override void InitializeSDK()
|
protected override void InitializeSDK()
|
||||||
{
|
{
|
||||||
|
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||||
_sdk = (IAuraSdk2)new AuraSdk();
|
_sdk = (IAuraSdk2)new AuraSdk();
|
||||||
_sdk.SwitchMode();
|
_sdk.SwitchMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,13 +42,23 @@ namespace RGB.NET.Devices.Asus
|
|||||||
{
|
{
|
||||||
if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB))
|
if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB))
|
||||||
{
|
{
|
||||||
foreach ((object key, Color value) in dataSet)
|
if (Device is not IAuraSyncKeyboard keyboard)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach ((object customData, Color value) in dataSet)
|
||||||
{
|
{
|
||||||
AsusLedId index = (AsusLedId)key;
|
(bool, int) customDataTuple = ((bool, int))customData;
|
||||||
if (Device is IAuraSyncKeyboard keyboard)
|
if (customDataTuple.Item1)
|
||||||
{
|
{
|
||||||
IAuraRgbLight light = keyboard.Key[(ushort)index];
|
IAuraRgbLight light = keyboard.Key[(ushort)customDataTuple.Item2];
|
||||||
|
(_, byte r, byte g, byte b) = value.GetRGBBytes();
|
||||||
|
light.Red = r;
|
||||||
|
light.Green = g;
|
||||||
|
light.Blue = b;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IAuraRgbLight light = keyboard.Lights[customDataTuple.Item2];
|
||||||
(_, byte r, byte g, byte b) = value.GetRGBBytes();
|
(_, byte r, byte g, byte b) = value.GetRGBBytes();
|
||||||
light.Red = r;
|
light.Red = r;
|
||||||
light.Green = g;
|
light.Green = g;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using AuraServiceLib;
|
using AuraServiceLib;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ namespace RGB.NET.Devices.Asus
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private Dictionary<LedId, AsusLedId> _ledAsusLed = new();
|
private Dictionary<LedId, AsusLedId> _ledAsusLed = new();
|
||||||
|
private Dictionary<LedId, int> _ledAsusLights = new();
|
||||||
|
|
||||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||||
|
|
||||||
@ -40,10 +42,28 @@ namespace RGB.NET.Devices.Asus
|
|||||||
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
|
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
foreach (IAuraRgbKey key in ((IAuraSyncKeyboard)DeviceInfo.Device).Keys)
|
int unknownLed = (int)LedId.Unknown1;
|
||||||
|
|
||||||
|
List<IAuraRgbKey> keys = ((IAuraSyncKeyboard)DeviceInfo.Device).Keys.Cast<IAuraRgbKey>().ToList();
|
||||||
|
foreach (IAuraRgbKey key in keys)
|
||||||
{
|
{
|
||||||
if (AsusKeyboardLedMapping.MAPPING.TryGetValue((AsusLedId)key.Code, out LedId ledId))
|
if (AsusKeyboardLedMapping.MAPPING.TryGetValue((AsusLedId)key.Code, out LedId ledId))
|
||||||
AddAsusLed((AsusLedId)key.Code, ledId, new Point(pos++ * 19, 0), new Size(19, 19));
|
AddAsusLed((AsusLedId)key.Code, ledId, new Point(pos++ * 19, 0), new Size(19, 19));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddAsusLed((AsusLedId)key.Code, (LedId)unknownLed, new Point(pos++ * 19, 0), new Size(19, 19));
|
||||||
|
unknownLed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < ((IAuraSyncKeyboard)DeviceInfo.Device).Lights.Count; index++)
|
||||||
|
{
|
||||||
|
IAuraRgbLight light = ((IAuraSyncKeyboard)DeviceInfo.Device).Lights[index];
|
||||||
|
if (keys.Contains(light))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
AddAsusLed(index, (LedId)unknownLed, new Point(pos++ * 19, 0), new Size(19, 19));
|
||||||
|
unknownLed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -57,17 +77,26 @@ namespace RGB.NET.Devices.Asus
|
|||||||
private void AddAsusLed(AsusLedId asusLedId, LedId ledId, Point position, Size size)
|
private void AddAsusLed(AsusLedId asusLedId, LedId ledId, Point position, Size size)
|
||||||
{
|
{
|
||||||
if (this._ledAsusLed.TryGetValue(ledId, out AsusLedId firstAsusLed))
|
if (this._ledAsusLed.TryGetValue(ledId, out AsusLedId firstAsusLed))
|
||||||
throw new RGBDeviceException($"Got LED '{ledId}' twice, first ASUS LED '{firstAsusLed}' second ASUS LED '{asusLedId}' on device '{DeviceInfo.DeviceName}'");
|
throw new
|
||||||
|
RGBDeviceException($"Got LED '{ledId}' twice, first ASUS LED '{firstAsusLed}' second ASUS LED '{asusLedId}' on device '{DeviceInfo.DeviceName}'");
|
||||||
|
|
||||||
this._ledAsusLed.Add(ledId, asusLedId);
|
this._ledAsusLed.Add(ledId, asusLedId);
|
||||||
AddLed(ledId, position, size);
|
AddLed(ledId, position, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddAsusLed(int index, LedId ledId, Point position, Size size)
|
||||||
|
{
|
||||||
|
this._ledAsusLights.Add(ledId, index);
|
||||||
|
AddLed(ledId, position, size);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override object? GetLedCustomData(LedId ledId)
|
protected override object? GetLedCustomData(LedId ledId)
|
||||||
{
|
{
|
||||||
if (this._ledAsusLed.TryGetValue(ledId, out AsusLedId asusLedId))
|
if (this._ledAsusLed.TryGetValue(ledId, out AsusLedId asusLedId))
|
||||||
return asusLedId;
|
return (true, (int)asusLedId);
|
||||||
|
if (this._ledAsusLights.TryGetValue(ledId, out int lightIndex))
|
||||||
|
return (false, lightIndex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user