mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
ASUS - Refactored to use LedMappings
ASUS - Added laptop model detection ASUS - Added the option to provide extra LED mappings to keyboards based on model ASUS - Removed old attempts at detecting non-key LEDs on keyboards
This commit is contained in:
parent
6254eae845
commit
4055ee9b0a
@ -65,9 +65,9 @@ namespace RGB.NET.Devices.Asus
|
||||
AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()),
|
||||
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
||||
AsusDeviceType.DRAM_RGB => new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device), GetUpdateTrigger()),
|
||||
AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), GetUpdateTrigger()),
|
||||
AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()),
|
||||
AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()),
|
||||
_ => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1, GetUpdateTrigger())
|
||||
};
|
||||
|
||||
@ -2,7 +2,10 @@
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
internal enum AsusLedId : ushort
|
||||
/// <summary>
|
||||
/// Represents a LED ID as they are known by the ASUS SDK
|
||||
/// </summary>
|
||||
public enum AsusLedId : ushort
|
||||
{
|
||||
KEY_ESCAPE = 0x01,
|
||||
KEY_1 = 0x02,
|
||||
@ -149,5 +152,13 @@ namespace RGB.NET.Devices.Asus
|
||||
KEY_MAIL = 0xEC, // Mail
|
||||
KEY_MEDIASELECT = 0xED, // Media Select
|
||||
KEY_FN = 0x100, // Function key
|
||||
|
||||
// Undocumented
|
||||
UNDOCUMENTED_1 = 0x59,
|
||||
UNDOCUMENTED_2 = 0x56,
|
||||
UNDOCUMENTED_3 = 0x101,
|
||||
UNDOCUMENTED_4 = 0x102,
|
||||
UNDOCUMENTED_5 = 0x103,
|
||||
UNDOCUMENTED_6 = 0xDA, // Bottom-left function on the ROG Zephyrus Duo 15
|
||||
}
|
||||
}
|
||||
|
||||
18
RGB.NET.Devices.Asus/Enum/AsusLedType.cs
Normal file
18
RGB.NET.Devices.Asus/Enum/AsusLedType.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a type of ASUS LED as known by the ASUS SDK
|
||||
/// </summary>
|
||||
public enum AsusLedType
|
||||
{
|
||||
/// <summary>
|
||||
/// An ASUS LED that is present on a device's IAuraSyncKeyboard.Keys enumerable
|
||||
/// </summary>
|
||||
Key,
|
||||
|
||||
/// <summary>
|
||||
/// An ASUS LED that is present on a device's IAuraSyncDevice.Lights enumerable
|
||||
/// </summary>
|
||||
Light
|
||||
}
|
||||
}
|
||||
@ -44,13 +44,13 @@ namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
if (Device is not IAuraSyncKeyboard keyboard)
|
||||
return;
|
||||
|
||||
|
||||
foreach ((object customData, Color value) in dataSet)
|
||||
{
|
||||
(bool, int) customDataTuple = ((bool, int))customData;
|
||||
if (customDataTuple.Item1)
|
||||
(AsusLedType ledType, int id) = (AsusKeyboardLedCustomData)customData;
|
||||
if (ledType == AsusLedType.Key)
|
||||
{
|
||||
IAuraRgbLight light = keyboard.Key[(ushort)customDataTuple.Item2];
|
||||
IAuraRgbLight light = keyboard.Key[(ushort)id];
|
||||
(_, byte r, byte g, byte b) = value.GetRGBBytes();
|
||||
light.Red = r;
|
||||
light.Green = g;
|
||||
@ -58,7 +58,7 @@ namespace RGB.NET.Devices.Asus
|
||||
}
|
||||
else
|
||||
{
|
||||
IAuraRgbLight light = keyboard.Lights[customDataTuple.Item2];
|
||||
IAuraRgbLight light = keyboard.Lights[id];
|
||||
(_, byte r, byte g, byte b) = value.GetRGBBytes();
|
||||
light.Red = r;
|
||||
light.Green = g;
|
||||
|
||||
@ -9,13 +9,15 @@ namespace RGB.NET.Devices.Asus
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
private static readonly ManagementObjectSearcher? _systemModelSearcher;
|
||||
private static readonly ManagementObjectSearcher? _mainboardSearcher;
|
||||
private static readonly ManagementObjectSearcher? _graphicsCardSearcher;
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
private static string? _systemModelInfo;
|
||||
private static (string manufacturer, string model)? _mainboardInfo;
|
||||
private static string? _graphicsCardInfo;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -24,6 +26,7 @@ namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
_systemModelSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Model FROM Win32_ComputerSystem");
|
||||
_mainboardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Manufacturer,Product FROM Win32_BaseBoard");
|
||||
_graphicsCardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_VideoController");
|
||||
}
|
||||
@ -33,6 +36,20 @@ namespace RGB.NET.Devices.Asus
|
||||
|
||||
#region Methods
|
||||
|
||||
internal static string? GetSystemModelInfo()
|
||||
{
|
||||
if (!OperatingSystem.IsWindows()) return null;
|
||||
|
||||
if ((_systemModelInfo == null) && (_systemModelSearcher != null))
|
||||
foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get())
|
||||
{
|
||||
_systemModelInfo = managementBaseObject["Model"]?.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
return _systemModelInfo;
|
||||
}
|
||||
|
||||
internal static (string manufacturer, string model)? GetMainboardInfo()
|
||||
{
|
||||
if (!OperatingSystem.IsWindows()) return null;
|
||||
|
||||
@ -1,156 +1,189 @@
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
internal static class AsusKeyboardLedMapping
|
||||
public static class LedMappings
|
||||
{
|
||||
public static readonly Dictionary<AsusLedId, LedId> MAPPING = new()
|
||||
{
|
||||
{ AsusLedId.KEY_ESCAPE, LedId.Keyboard_Escape },
|
||||
{ AsusLedId.KEY_F1, LedId.Keyboard_F1 },
|
||||
{ AsusLedId.KEY_F2, LedId.Keyboard_F2 },
|
||||
{ AsusLedId.KEY_F3, LedId.Keyboard_F3 },
|
||||
{ AsusLedId.KEY_F4, LedId.Keyboard_F4 },
|
||||
{ AsusLedId.KEY_F5, LedId.Keyboard_F5 },
|
||||
{ AsusLedId.KEY_F6, LedId.Keyboard_F6 },
|
||||
{ AsusLedId.KEY_F7, LedId.Keyboard_F7 },
|
||||
{ AsusLedId.KEY_F8, LedId.Keyboard_F8 },
|
||||
{ AsusLedId.KEY_F9, LedId.Keyboard_F9 },
|
||||
{ AsusLedId.KEY_F10, LedId.Keyboard_F10 },
|
||||
{ AsusLedId.KEY_F11, LedId.Keyboard_F11 },
|
||||
{ AsusLedId.KEY_F12, LedId.Keyboard_F12 },
|
||||
{ AsusLedId.KEY_1, LedId.Keyboard_1 },
|
||||
{ AsusLedId.KEY_2, LedId.Keyboard_2 },
|
||||
{ AsusLedId.KEY_3, LedId.Keyboard_3 },
|
||||
{ AsusLedId.KEY_4, LedId.Keyboard_4 },
|
||||
{ AsusLedId.KEY_5, LedId.Keyboard_5 },
|
||||
{ AsusLedId.KEY_6, LedId.Keyboard_6 },
|
||||
{ AsusLedId.KEY_7, LedId.Keyboard_7 },
|
||||
{ AsusLedId.KEY_8, LedId.Keyboard_8 },
|
||||
{ AsusLedId.KEY_9, LedId.Keyboard_9 },
|
||||
{ AsusLedId.KEY_0, LedId.Keyboard_0 },
|
||||
{ AsusLedId.KEY_MINUS , LedId.Keyboard_MinusAndUnderscore },
|
||||
{ AsusLedId.KEY_EQUALS, LedId.Keyboard_EqualsAndPlus },
|
||||
{ AsusLedId.KEY_BACK, LedId.Keyboard_Backspace },
|
||||
{ AsusLedId.KEY_TAB, LedId.Keyboard_Tab },
|
||||
{ AsusLedId.KEY_Q, LedId.Keyboard_Q },
|
||||
{ AsusLedId.KEY_W, LedId.Keyboard_W },
|
||||
{ AsusLedId.KEY_E, LedId.Keyboard_E },
|
||||
{ AsusLedId.KEY_R, LedId.Keyboard_R },
|
||||
{ AsusLedId.KEY_T, LedId.Keyboard_T },
|
||||
{ AsusLedId.KEY_Y, LedId.Keyboard_Y },
|
||||
{ AsusLedId.KEY_U, LedId.Keyboard_U },
|
||||
{ AsusLedId.KEY_I, LedId.Keyboard_I },
|
||||
{ AsusLedId.KEY_O, LedId.Keyboard_O },
|
||||
{ AsusLedId.KEY_P, LedId.Keyboard_P },
|
||||
{ AsusLedId.KEY_LBRACKET, LedId.Keyboard_BracketLeft },
|
||||
{ AsusLedId.KEY_RBRACKET, LedId.Keyboard_BracketRight },
|
||||
{ AsusLedId.KEY_RETURN, LedId.Keyboard_Enter },
|
||||
{ AsusLedId.KEY_CAPITAL, LedId.Keyboard_CapsLock },
|
||||
{ AsusLedId.KEY_A, LedId.Keyboard_A },
|
||||
{ AsusLedId.KEY_S, LedId.Keyboard_S },
|
||||
{ AsusLedId.KEY_D, LedId.Keyboard_D },
|
||||
{ AsusLedId.KEY_F, LedId.Keyboard_F },
|
||||
{ AsusLedId.KEY_G, LedId.Keyboard_G },
|
||||
{ AsusLedId.KEY_H, LedId.Keyboard_H },
|
||||
{ AsusLedId.KEY_J, LedId.Keyboard_J },
|
||||
{ AsusLedId.KEY_K, LedId.Keyboard_K },
|
||||
{ AsusLedId.KEY_L, LedId.Keyboard_L },
|
||||
{ AsusLedId.KEY_SEMICOLON,LedId.Keyboard_SemicolonAndColon },
|
||||
{ AsusLedId.KEY_APOSTROPHE, LedId.Keyboard_ApostropheAndDoubleQuote },
|
||||
{ AsusLedId.KEY_GRAVE, LedId.Keyboard_GraveAccentAndTilde },
|
||||
{ AsusLedId.KEY_LSHIFT, LedId.Keyboard_LeftShift },
|
||||
{ AsusLedId.KEY_BACKSLASH, LedId.Keyboard_Backslash },
|
||||
{ AsusLedId.KEY_Z, LedId.Keyboard_Z },
|
||||
{ AsusLedId.KEY_X, LedId.Keyboard_X },
|
||||
{ AsusLedId.KEY_C, LedId.Keyboard_C },
|
||||
{ AsusLedId.KEY_V, LedId.Keyboard_V },
|
||||
{ AsusLedId.KEY_B, LedId.Keyboard_B },
|
||||
{ AsusLedId.KEY_N, LedId.Keyboard_N },
|
||||
{ AsusLedId.KEY_M, LedId.Keyboard_M },
|
||||
{ AsusLedId.KEY_COMMA, LedId.Keyboard_CommaAndLessThan },
|
||||
{ AsusLedId.KEY_PERIOD, LedId.Keyboard_PeriodAndBiggerThan },
|
||||
{ AsusLedId.KEY_SLASH, LedId.Keyboard_SlashAndQuestionMark },
|
||||
{ AsusLedId.KEY_RSHIFT, LedId.Keyboard_RightShift },
|
||||
{ AsusLedId.KEY_LCONTROL, LedId.Keyboard_LeftCtrl },
|
||||
{ AsusLedId.KEY_LWIN, LedId.Keyboard_LeftGui },
|
||||
{ AsusLedId.KEY_LMENU, LedId.Keyboard_LeftAlt },
|
||||
{ AsusLedId.KEY_SPACE, LedId.Keyboard_Space },
|
||||
{ AsusLedId.KEY_RMENU, LedId.Keyboard_RightAlt },
|
||||
{ AsusLedId.KEY_RWIN, LedId.Keyboard_RightGui },
|
||||
{ AsusLedId.KEY_APPS, LedId.Keyboard_Application },
|
||||
{ AsusLedId.KEY_RCONTROL, LedId.Keyboard_RightCtrl },
|
||||
{ AsusLedId.KEY_SYSRQ, LedId.Keyboard_PrintScreen },
|
||||
{ AsusLedId.KEY_SCROLL, LedId.Keyboard_ScrollLock },
|
||||
{ AsusLedId.KEY_PAUSE, LedId.Keyboard_PauseBreak },
|
||||
{ AsusLedId.KEY_INSERT, LedId.Keyboard_Insert },
|
||||
{ AsusLedId.KEY_HOME, LedId.Keyboard_Home },
|
||||
{ AsusLedId.KEY_PRIOR, LedId.Keyboard_PageUp },
|
||||
{ AsusLedId.KEY_DELETE, LedId.Keyboard_Delete },
|
||||
{ AsusLedId.KEY_END, LedId.Keyboard_End },
|
||||
{ AsusLedId.KEY_NEXT, LedId.Keyboard_PageDown },
|
||||
{ AsusLedId.KEY_UP, LedId.Keyboard_ArrowUp },
|
||||
{ AsusLedId.KEY_LEFT, LedId.Keyboard_ArrowLeft },
|
||||
{ AsusLedId.KEY_DOWN, LedId.Keyboard_ArrowDown },
|
||||
{ AsusLedId.KEY_RIGHT, LedId.Keyboard_ArrowRight },
|
||||
{ AsusLedId.KEY_NUMLOCK, LedId.Keyboard_NumLock },
|
||||
{ AsusLedId.KEY_DIVIDE, LedId.Keyboard_NumSlash },
|
||||
{ AsusLedId.KEY_MULTIPLY, LedId.Keyboard_NumAsterisk },
|
||||
{ AsusLedId.KEY_SUBTRACT, LedId.Keyboard_NumMinus },
|
||||
{ AsusLedId.KEY_NUMPAD7, LedId.Keyboard_Num7 },
|
||||
{ AsusLedId.KEY_NUMPAD8, LedId.Keyboard_Num8 },
|
||||
{ AsusLedId.KEY_NUMPAD9, LedId.Keyboard_Num9 },
|
||||
{ AsusLedId.KEY_DECIMAL, LedId.Keyboard_NumPeriodAndDelete },
|
||||
{ AsusLedId.KEY_ADD ,LedId.Keyboard_NumPlus },
|
||||
{ AsusLedId.KEY_NUMPAD4, LedId.Keyboard_Num4 },
|
||||
{ AsusLedId.KEY_NUMPAD5, LedId.Keyboard_Num5 },
|
||||
{ AsusLedId.KEY_NUMPAD6, LedId.Keyboard_Num6 },
|
||||
{ AsusLedId.KEY_NUMPAD1, LedId.Keyboard_Num1 },
|
||||
{ AsusLedId.KEY_NUMPAD2, LedId.Keyboard_Num2 },
|
||||
{ AsusLedId.KEY_NUMPAD3, LedId.Keyboard_Num3 },
|
||||
{ AsusLedId.KEY_NUMPAD0, LedId.Keyboard_Num0 },
|
||||
{ AsusLedId.KEY_NUMPADENTER, LedId.Keyboard_NumEnter },
|
||||
{ AsusLedId.KEY_NUMPADCOMMA, LedId.Keyboard_NumComma },
|
||||
{ AsusLedId.KEY_F13, LedId.Keyboard_Custom3 },
|
||||
{ AsusLedId.KEY_F14, LedId.Keyboard_Custom4 },
|
||||
{ AsusLedId.KEY_F15, LedId.Keyboard_Custom5 },
|
||||
{ AsusLedId.KEY_KANA, LedId.Keyboard_Custom6 },
|
||||
{ AsusLedId.KEY_ABNT_C1, LedId.Keyboard_Custom7 },
|
||||
{ AsusLedId.KEY_CONVERT, LedId.Keyboard_Custom8 },
|
||||
{ AsusLedId.KEY_NOCONVERT, LedId.Keyboard_Custom9 },
|
||||
{ AsusLedId.KEY_YEN, LedId.Keyboard_Custom10 },
|
||||
{ AsusLedId.KEY_ABNT_C2, LedId.Keyboard_Custom11 },
|
||||
{ AsusLedId.KEY_NUMPADEQUALS, LedId.Keyboard_Custom12 },
|
||||
{ AsusLedId.KEY_CIRCUMFLEX, LedId.Keyboard_Custom13 },
|
||||
{ AsusLedId.KEY_AT, LedId.Keyboard_Custom14 },
|
||||
{ AsusLedId.KEY_COLON, LedId.Keyboard_Custom15 },
|
||||
{ AsusLedId.KEY_UNDERLINE, LedId.Keyboard_Custom16 },
|
||||
{ AsusLedId.KEY_KANJI, LedId.Keyboard_Custom17 },
|
||||
{ AsusLedId.KEY_STOP, LedId.Keyboard_Custom18 },
|
||||
{ AsusLedId.KEY_AX, LedId.Keyboard_Custom19 },
|
||||
{ AsusLedId.KEY_UNLABELED, LedId.Keyboard_Custom20 },
|
||||
{ AsusLedId.KEY_NEXTTRACK, LedId.Keyboard_Custom21 },
|
||||
{ AsusLedId.KEY_CALCULATOR, LedId.Keyboard_Custom22 },
|
||||
{ AsusLedId.KEY_POWER, LedId.Keyboard_Custom23 },
|
||||
{ AsusLedId.KEY_SLEEP, LedId.Keyboard_Custom24 },
|
||||
{ AsusLedId.KEY_WAKE, LedId.Keyboard_Custom25 },
|
||||
{ AsusLedId.KEY_WEBSEARCH, LedId.Keyboard_Custom26 },
|
||||
{ AsusLedId.KEY_WEBFAVORITES, LedId.Keyboard_Custom27 },
|
||||
{ AsusLedId.KEY_WEBREFRESH, LedId.Keyboard_Custom28 },
|
||||
{ AsusLedId.KEY_WEBSTOP, LedId.Keyboard_Custom29 },
|
||||
{ AsusLedId.KEY_WEBFORWARD, LedId.Keyboard_Custom30 },
|
||||
{ AsusLedId.KEY_WEBHOME, LedId.Keyboard_Custom31 },
|
||||
{ AsusLedId.KEY_WEBBACK, LedId.Keyboard_Custom32 },
|
||||
{ AsusLedId.KEY_MYCOMPUTER, LedId.Keyboard_Custom33 },
|
||||
{ AsusLedId.KEY_MAIL, LedId.Keyboard_Custom34 },
|
||||
{ AsusLedId.KEY_MEDIASELECT, LedId.Keyboard_Custom35 },
|
||||
{ AsusLedId.KEY_FN, LedId.Keyboard_Function },
|
||||
{ AsusLedId.KEY_MUTE, LedId.Keyboard_MediaMute },
|
||||
{ AsusLedId.KEY_PLAYPAUSE, LedId.Keyboard_MediaPlay },
|
||||
{ AsusLedId.KEY_MEDIASTOP, LedId.Keyboard_MediaStop },
|
||||
{ AsusLedId.KEY_VOLUMEDOWN, LedId.Keyboard_MediaVolumeDown },
|
||||
{ AsusLedId.KEY_VOLUMEUP, LedId.Keyboard_MediaVolumeUp },
|
||||
};
|
||||
/// <summary>
|
||||
/// A LED mapping containing ASUS keyboard LED IDs
|
||||
/// </summary>
|
||||
public static readonly LedMapping<AsusLedId> KeyboardMapping =
|
||||
new()
|
||||
{
|
||||
{LedId.Keyboard_Escape, AsusLedId.KEY_ESCAPE},
|
||||
{LedId.Keyboard_F1, AsusLedId.KEY_F1},
|
||||
{LedId.Keyboard_F2, AsusLedId.KEY_F2},
|
||||
{LedId.Keyboard_F3, AsusLedId.KEY_F3},
|
||||
{LedId.Keyboard_F4, AsusLedId.KEY_F4},
|
||||
{LedId.Keyboard_F5, AsusLedId.KEY_F5},
|
||||
{LedId.Keyboard_F6, AsusLedId.KEY_F6},
|
||||
{LedId.Keyboard_F7, AsusLedId.KEY_F7},
|
||||
{LedId.Keyboard_F8, AsusLedId.KEY_F8},
|
||||
{LedId.Keyboard_F9, AsusLedId.KEY_F9},
|
||||
{LedId.Keyboard_F10, AsusLedId.KEY_F10},
|
||||
{LedId.Keyboard_F11, AsusLedId.KEY_F11},
|
||||
{LedId.Keyboard_F12, AsusLedId.KEY_F12},
|
||||
{LedId.Keyboard_1, AsusLedId.KEY_1},
|
||||
{LedId.Keyboard_2, AsusLedId.KEY_2},
|
||||
{LedId.Keyboard_3, AsusLedId.KEY_3},
|
||||
{LedId.Keyboard_4, AsusLedId.KEY_4},
|
||||
{LedId.Keyboard_5, AsusLedId.KEY_5},
|
||||
{LedId.Keyboard_6, AsusLedId.KEY_6},
|
||||
{LedId.Keyboard_7, AsusLedId.KEY_7},
|
||||
{LedId.Keyboard_8, AsusLedId.KEY_8},
|
||||
{LedId.Keyboard_9, AsusLedId.KEY_9},
|
||||
{LedId.Keyboard_0, AsusLedId.KEY_0},
|
||||
{LedId.Keyboard_MinusAndUnderscore, AsusLedId.KEY_MINUS},
|
||||
{LedId.Keyboard_EqualsAndPlus, AsusLedId.KEY_EQUALS},
|
||||
{LedId.Keyboard_Backspace, AsusLedId.KEY_BACK},
|
||||
{LedId.Keyboard_Tab, AsusLedId.KEY_TAB},
|
||||
{LedId.Keyboard_Q, AsusLedId.KEY_Q},
|
||||
{LedId.Keyboard_W, AsusLedId.KEY_W},
|
||||
{LedId.Keyboard_E, AsusLedId.KEY_E},
|
||||
{LedId.Keyboard_R, AsusLedId.KEY_R},
|
||||
{LedId.Keyboard_T, AsusLedId.KEY_T},
|
||||
{LedId.Keyboard_Y, AsusLedId.KEY_Y},
|
||||
{LedId.Keyboard_U, AsusLedId.KEY_U},
|
||||
{LedId.Keyboard_I, AsusLedId.KEY_I},
|
||||
{LedId.Keyboard_O, AsusLedId.KEY_O},
|
||||
{LedId.Keyboard_P, AsusLedId.KEY_P},
|
||||
{LedId.Keyboard_BracketLeft, AsusLedId.KEY_LBRACKET},
|
||||
{LedId.Keyboard_BracketRight, AsusLedId.KEY_RBRACKET},
|
||||
{LedId.Keyboard_Enter, AsusLedId.KEY_RETURN},
|
||||
{LedId.Keyboard_CapsLock, AsusLedId.KEY_CAPITAL},
|
||||
{LedId.Keyboard_A, AsusLedId.KEY_A},
|
||||
{LedId.Keyboard_S, AsusLedId.KEY_S},
|
||||
{LedId.Keyboard_D, AsusLedId.KEY_D},
|
||||
{LedId.Keyboard_F, AsusLedId.KEY_F},
|
||||
{LedId.Keyboard_G, AsusLedId.KEY_G},
|
||||
{LedId.Keyboard_H, AsusLedId.KEY_H},
|
||||
{LedId.Keyboard_J, AsusLedId.KEY_J},
|
||||
{LedId.Keyboard_K, AsusLedId.KEY_K},
|
||||
{LedId.Keyboard_L, AsusLedId.KEY_L},
|
||||
{LedId.Keyboard_SemicolonAndColon, AsusLedId.KEY_SEMICOLON},
|
||||
{LedId.Keyboard_ApostropheAndDoubleQuote, AsusLedId.KEY_APOSTROPHE},
|
||||
{LedId.Keyboard_GraveAccentAndTilde, AsusLedId.KEY_GRAVE},
|
||||
{LedId.Keyboard_LeftShift, AsusLedId.KEY_LSHIFT},
|
||||
{LedId.Keyboard_Backslash, AsusLedId.KEY_BACKSLASH},
|
||||
{LedId.Keyboard_Z, AsusLedId.KEY_Z},
|
||||
{LedId.Keyboard_X, AsusLedId.KEY_X},
|
||||
{LedId.Keyboard_C, AsusLedId.KEY_C},
|
||||
{LedId.Keyboard_V, AsusLedId.KEY_V},
|
||||
{LedId.Keyboard_B, AsusLedId.KEY_B},
|
||||
{LedId.Keyboard_N, AsusLedId.KEY_N},
|
||||
{LedId.Keyboard_M, AsusLedId.KEY_M},
|
||||
{LedId.Keyboard_CommaAndLessThan, AsusLedId.KEY_COMMA},
|
||||
{LedId.Keyboard_PeriodAndBiggerThan, AsusLedId.KEY_PERIOD},
|
||||
{LedId.Keyboard_SlashAndQuestionMark, AsusLedId.KEY_SLASH},
|
||||
{LedId.Keyboard_RightShift, AsusLedId.KEY_RSHIFT},
|
||||
{LedId.Keyboard_LeftCtrl, AsusLedId.KEY_LCONTROL},
|
||||
{LedId.Keyboard_LeftGui, AsusLedId.KEY_LWIN},
|
||||
{LedId.Keyboard_LeftAlt, AsusLedId.KEY_LMENU},
|
||||
{LedId.Keyboard_Space, AsusLedId.KEY_SPACE},
|
||||
{LedId.Keyboard_RightAlt, AsusLedId.KEY_RMENU},
|
||||
{LedId.Keyboard_RightGui, AsusLedId.KEY_RWIN},
|
||||
{LedId.Keyboard_Application, AsusLedId.KEY_APPS},
|
||||
{LedId.Keyboard_RightCtrl, AsusLedId.KEY_RCONTROL},
|
||||
{LedId.Keyboard_PrintScreen, AsusLedId.KEY_SYSRQ},
|
||||
{LedId.Keyboard_ScrollLock, AsusLedId.KEY_SCROLL},
|
||||
{LedId.Keyboard_PauseBreak, AsusLedId.KEY_PAUSE},
|
||||
{LedId.Keyboard_Insert, AsusLedId.KEY_INSERT},
|
||||
{LedId.Keyboard_Home, AsusLedId.KEY_HOME},
|
||||
{LedId.Keyboard_PageUp, AsusLedId.KEY_PRIOR},
|
||||
{LedId.Keyboard_Delete, AsusLedId.KEY_DELETE},
|
||||
{LedId.Keyboard_End, AsusLedId.KEY_END},
|
||||
{LedId.Keyboard_PageDown, AsusLedId.KEY_NEXT},
|
||||
{LedId.Keyboard_ArrowUp, AsusLedId.KEY_UP},
|
||||
{LedId.Keyboard_ArrowLeft, AsusLedId.KEY_LEFT},
|
||||
{LedId.Keyboard_ArrowDown, AsusLedId.KEY_DOWN},
|
||||
{LedId.Keyboard_ArrowRight, AsusLedId.KEY_RIGHT},
|
||||
{LedId.Keyboard_NumLock, AsusLedId.KEY_NUMLOCK},
|
||||
{LedId.Keyboard_NumSlash, AsusLedId.KEY_DIVIDE},
|
||||
{LedId.Keyboard_NumAsterisk, AsusLedId.KEY_MULTIPLY},
|
||||
{LedId.Keyboard_NumMinus, AsusLedId.KEY_SUBTRACT},
|
||||
{LedId.Keyboard_Num7, AsusLedId.KEY_NUMPAD7},
|
||||
{LedId.Keyboard_Num8, AsusLedId.KEY_NUMPAD8},
|
||||
{LedId.Keyboard_Num9, AsusLedId.KEY_NUMPAD9},
|
||||
{LedId.Keyboard_NumPeriodAndDelete, AsusLedId.KEY_DECIMAL},
|
||||
{LedId.Keyboard_NumPlus, AsusLedId.KEY_ADD},
|
||||
{LedId.Keyboard_Num4, AsusLedId.KEY_NUMPAD4},
|
||||
{LedId.Keyboard_Num5, AsusLedId.KEY_NUMPAD5},
|
||||
{LedId.Keyboard_Num6, AsusLedId.KEY_NUMPAD6},
|
||||
{LedId.Keyboard_Num1, AsusLedId.KEY_NUMPAD1},
|
||||
{LedId.Keyboard_Num2, AsusLedId.KEY_NUMPAD2},
|
||||
{LedId.Keyboard_Num3, AsusLedId.KEY_NUMPAD3},
|
||||
{LedId.Keyboard_Num0, AsusLedId.KEY_NUMPAD0},
|
||||
{LedId.Keyboard_NumEnter, AsusLedId.KEY_NUMPADENTER},
|
||||
{LedId.Keyboard_NonUsBackslash, AsusLedId.UNDOCUMENTED_1},
|
||||
{LedId.Keyboard_NonUsTilde, AsusLedId.UNDOCUMENTED_2},
|
||||
{LedId.Keyboard_NumComma, AsusLedId.KEY_NUMPADCOMMA},
|
||||
{LedId.Logo, AsusLedId.UNDOCUMENTED_3},
|
||||
{LedId.Keyboard_Function, AsusLedId.KEY_FN},
|
||||
{LedId.Keyboard_MediaMute, AsusLedId.KEY_MUTE},
|
||||
{LedId.Keyboard_MediaPlay, AsusLedId.KEY_PLAYPAUSE},
|
||||
{LedId.Keyboard_MediaStop, AsusLedId.KEY_MEDIASTOP},
|
||||
{LedId.Keyboard_MediaVolumeDown, AsusLedId.KEY_VOLUMEDOWN},
|
||||
{LedId.Keyboard_MediaVolumeUp, AsusLedId.KEY_VOLUMEUP},
|
||||
{LedId.Keyboard_Custom1, AsusLedId.KEY_F13},
|
||||
{LedId.Keyboard_Custom2, AsusLedId.KEY_F14},
|
||||
{LedId.Keyboard_Custom3, AsusLedId.KEY_F15},
|
||||
{LedId.Keyboard_Custom4, AsusLedId.KEY_KANA},
|
||||
{LedId.Keyboard_Custom5, AsusLedId.KEY_ABNT_C1},
|
||||
{LedId.Keyboard_Custom6, AsusLedId.KEY_CONVERT},
|
||||
{LedId.Keyboard_Custom7, AsusLedId.KEY_NOCONVERT},
|
||||
{LedId.Keyboard_Custom8, AsusLedId.KEY_YEN},
|
||||
{LedId.Keyboard_Custom9, AsusLedId.KEY_ABNT_C2},
|
||||
{LedId.Keyboard_Custom10, AsusLedId.KEY_NUMPADEQUALS},
|
||||
{LedId.Keyboard_Custom11, AsusLedId.KEY_CIRCUMFLEX},
|
||||
{LedId.Keyboard_Custom12, AsusLedId.KEY_AT},
|
||||
{LedId.Keyboard_Custom13, AsusLedId.KEY_COLON},
|
||||
{LedId.Keyboard_Custom14, AsusLedId.KEY_UNDERLINE},
|
||||
{LedId.Keyboard_Custom15, AsusLedId.KEY_KANJI},
|
||||
{LedId.Keyboard_Custom16, AsusLedId.KEY_STOP},
|
||||
{LedId.Keyboard_Custom17, AsusLedId.KEY_AX},
|
||||
{LedId.Keyboard_Custom18, AsusLedId.KEY_UNLABELED},
|
||||
{LedId.Keyboard_Custom19, AsusLedId.KEY_NEXTTRACK},
|
||||
{LedId.Keyboard_Custom20, AsusLedId.KEY_CALCULATOR},
|
||||
{LedId.Keyboard_Custom21, AsusLedId.KEY_POWER},
|
||||
{LedId.Keyboard_Custom22, AsusLedId.KEY_SLEEP},
|
||||
{LedId.Keyboard_Custom23, AsusLedId.KEY_WAKE},
|
||||
{LedId.Keyboard_Custom24, AsusLedId.KEY_WEBSEARCH},
|
||||
{LedId.Keyboard_Custom25, AsusLedId.KEY_WEBFAVORITES},
|
||||
{LedId.Keyboard_Custom26, AsusLedId.KEY_WEBREFRESH},
|
||||
{LedId.Keyboard_Custom27, AsusLedId.KEY_WEBSTOP},
|
||||
{LedId.Keyboard_Custom28, AsusLedId.KEY_WEBFORWARD},
|
||||
{LedId.Keyboard_Custom29, AsusLedId.KEY_WEBHOME},
|
||||
{LedId.Keyboard_Custom30, AsusLedId.KEY_WEBBACK},
|
||||
{LedId.Keyboard_Custom31, AsusLedId.KEY_MYCOMPUTER},
|
||||
{LedId.Keyboard_Custom32, AsusLedId.KEY_MAIL},
|
||||
{LedId.Keyboard_Custom33, AsusLedId.KEY_MEDIASELECT},
|
||||
{LedId.Keyboard_Custom34, AsusLedId.UNDOCUMENTED_4},
|
||||
{LedId.Keyboard_Custom35, AsusLedId.UNDOCUMENTED_5},
|
||||
{LedId.Keyboard_Custom36, AsusLedId.UNDOCUMENTED_6}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A LED mapping containing extra lights for the ROG Zephyrus Duo 15
|
||||
/// <para>
|
||||
/// ASUS notebooks have extra lights under wide keys like space and backspace, these do not appear as keys on the device.
|
||||
/// Instead they only appear in the Lights enumerable, this mapping maps LED IDs to the index of these lights.
|
||||
/// </para>
|
||||
/// <para>You may add more of these by further populating <see cref="AsusKeyboardRGBDevice.ExtraLedMappings"/>.</para>
|
||||
/// </summary>
|
||||
public static readonly LedMapping<int> ROGZephyrusDuo15 =
|
||||
new()
|
||||
{
|
||||
{LedId.Keyboard_Custom50, 39}, // Mapping starts at Custom50 to avoid possible conflicts with KeyboardMapping above
|
||||
{LedId.Keyboard_Custom51, 40},
|
||||
{LedId.Keyboard_Custom52, 55},
|
||||
{LedId.Keyboard_Custom53, 57},
|
||||
{LedId.Keyboard_Custom54, 97},
|
||||
{LedId.Keyboard_Custom55, 99},
|
||||
{LedId.Keyboard_Custom56, 118},
|
||||
{LedId.Keyboard_Custom57, 120},
|
||||
{LedId.Keyboard_Custom58, 130},
|
||||
{LedId.Keyboard_Custom59, 131},
|
||||
{LedId.Keyboard_Custom60, 133},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using AuraServiceLib;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents custom LED data for ASUS keyboard LEDs.
|
||||
/// </summary>
|
||||
public record AsusKeyboardLedCustomData(AsusLedType LedType, int Id);
|
||||
|
||||
/// <summary>
|
||||
/// Represents a record containing regex that matches to an ASUS device model and a LED mapping mapping to Light indexes.
|
||||
/// </summary>
|
||||
public record AsusKeyboardExtraMapping(Regex Regex, LedMapping<int> LedMapping);
|
||||
|
||||
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a Asus keyboard.
|
||||
@ -13,11 +24,22 @@ namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly LedMapping<AsusLedId>? _ledMapping;
|
||||
private Dictionary<LedId, AsusLedId> _ledAsusLed = new();
|
||||
private Dictionary<LedId, int> _ledAsusLights = new();
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of extra LED mappings to apply to modes that match the provided regex
|
||||
/// <para>Note: These LED mappings should be based on light indexes</para>
|
||||
/// </summary>
|
||||
public static List<AsusKeyboardExtraMapping> ExtraLedMappings =
|
||||
new()
|
||||
{
|
||||
new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15)
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -27,9 +49,11 @@ namespace RGB.NET.Devices.Asus
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by Asus for the keyboard.</param>
|
||||
internal AsusKeyboardRGBDevice(AsusKeyboardRGBDeviceInfo info, IDeviceUpdateTrigger updateTrigger)
|
||||
internal AsusKeyboardRGBDevice(AsusKeyboardRGBDeviceInfo info, LedMapping<AsusLedId>? ledMapping, IDeviceUpdateTrigger updateTrigger)
|
||||
: base(info, updateTrigger)
|
||||
{
|
||||
this._ledMapping = ledMapping;
|
||||
|
||||
InitializeLayout();
|
||||
}
|
||||
|
||||
@ -44,41 +68,24 @@ namespace RGB.NET.Devices.Asus
|
||||
int pos = 0;
|
||||
int unknownLed = (int)LedId.Unknown1;
|
||||
|
||||
// A device can have more lights than keys, a space bar with 4 lights per example but only the middle light is represented as a key
|
||||
// This means we want all lights but keys contain more information (a LED ID) so first pick up all keys and 'tag' them by giving them a color of 0x000001
|
||||
|
||||
// Clear tags to make sure no device is already at 0x000001
|
||||
ClearTags();
|
||||
foreach (IAuraRgbKey key in ((IAuraSyncKeyboard)DeviceInfo.Device).Keys)
|
||||
{
|
||||
if (AsusKeyboardLedMapping.MAPPING.TryGetValue((AsusLedId)key.Code, out LedId ledId))
|
||||
if ((_ledMapping != null) && _ledMapping.TryGetValue((AsusLedId)key.Code, out LedId ledId))
|
||||
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++;
|
||||
}
|
||||
|
||||
TagAsusLed(key);
|
||||
}
|
||||
|
||||
// Give the ASUS SDK some time to catch up
|
||||
Thread.Sleep(100);
|
||||
|
||||
// With keys iterated, add any light that was not tagged, these are lights that aren't represented by keys
|
||||
// Because there's no way to tell which light is which, they're all added as Unknown LEDs
|
||||
for (int index = 0; index < ((IAuraSyncKeyboard)DeviceInfo.Device).Lights.Count; index++)
|
||||
// Add extra LED mapping if required
|
||||
AsusKeyboardExtraMapping? extraMapping = ExtraLedMappings.FirstOrDefault(m => m.Regex.IsMatch(this.DeviceInfo.Model));
|
||||
if (extraMapping != null)
|
||||
{
|
||||
IAuraRgbLight light = ((IAuraSyncKeyboard)DeviceInfo.Device).Lights[index];
|
||||
if (IsAsusLedTagged(light))
|
||||
continue;
|
||||
|
||||
AddAsusLed(index, (LedId)unknownLed, new Point(pos++ * 19, 0), new Size(19, 19));
|
||||
unknownLed++;
|
||||
foreach ((LedId ledId, int lightIndex) in extraMapping.LedMapping)
|
||||
AddAsusLed(lightIndex, ledId, new Point(pos++ * 19, 0), new Size(19, 19));
|
||||
}
|
||||
|
||||
// Clear tags when done, the info is no longer relevant
|
||||
ClearTags();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -92,13 +99,12 @@ namespace RGB.NET.Devices.Asus
|
||||
protected override object? GetLedCustomData(LedId ledId)
|
||||
{
|
||||
if (this._ledAsusLed.TryGetValue(ledId, out AsusLedId asusLedId))
|
||||
return (true, (int)asusLedId);
|
||||
return new AsusKeyboardLedCustomData(AsusLedType.Key, (int)asusLedId);
|
||||
if (this._ledAsusLights.TryGetValue(ledId, out int lightIndex))
|
||||
return (false, lightIndex);
|
||||
return new AsusKeyboardLedCustomData(AsusLedType.Light, lightIndex);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add an ASUS LED by its LED ID
|
||||
/// </summary>
|
||||
@ -113,7 +119,7 @@ namespace RGB.NET.Devices.Asus
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an asus LED by its light index
|
||||
/// Add an ASUS LED by its light index
|
||||
/// </summary>
|
||||
private void AddAsusLed(int index, LedId ledId, Point position, Size size)
|
||||
{
|
||||
@ -121,34 +127,6 @@ namespace RGB.NET.Devices.Asus
|
||||
AddLed(ledId, position, size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the tags off all keys by setting their color to 0x000000
|
||||
/// </summary>
|
||||
private void ClearTags()
|
||||
{
|
||||
foreach (IAuraRgbLight light in ((IAuraSyncKeyboard)DeviceInfo.Device).Lights)
|
||||
light.Color = 0x000000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tags a LED by its key by setting its color to 0x000001
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
private void TagAsusLed(IAuraRgbKey key)
|
||||
{
|
||||
key.Color = 0x000001;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a LED is tagged by its light
|
||||
/// </summary>
|
||||
/// <param name="light"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsAsusLedTagged(IAuraRgbLight light)
|
||||
{
|
||||
return light.Color == 0x000001;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AuraServiceLib;
|
||||
using System.Collections.Generic;
|
||||
using AuraServiceLib;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
@ -10,6 +11,12 @@ namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
|
||||
/// Keep a list of those and rely on <see cref="WMIHelper.GetSystemModelInfo()"/> to get the real model
|
||||
/// </summary>
|
||||
private static List<string> GenericDeviceNames = new() {"NotebookKeyboard"};
|
||||
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
||||
|
||||
@ -23,9 +30,18 @@ namespace RGB.NET.Devices.Asus
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="IAuraSyncDevice"/> backing this RGB.NET device.</param>
|
||||
internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device)
|
||||
: base(RGBDeviceType.Keyboard, device, device.Name)
|
||||
: base(RGBDeviceType.Keyboard, device, GetKeyboardModel(device.Name))
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static string? GetKeyboardModel(string deviceName)
|
||||
{
|
||||
return GenericDeviceNames.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user