1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Merge pull request #72 from DarthAffe/Development

Development
This commit is contained in:
DarthAffe 2019-05-26 11:37:34 +02:00 committed by GitHub
commit 18871b9a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 275 additions and 19 deletions

View File

@ -5,7 +5,9 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Security;
using RGB.NET.Core;
namespace RGB.NET.Devices.Asus.Native
@ -184,11 +186,40 @@ namespace RGB.NET.Devices.Asus.Native
// ReSharper disable EventExceptionNotDocumented
internal static int EnumerateMbController(IntPtr handles, int size) => _enumerateMbControllerPointer(handles, size);
internal static int GetMbLedCount(IntPtr handle) => _getMbLedCountPointer(handle);
internal static void SetMbMode(IntPtr handle, int mode) => _setMbModePointer(handle, mode);
internal static void SetMbColor(IntPtr handle, byte[] colors) => _setMbColorPointer(handle, colors, colors.Length);
//HACK DarthAffe 12.05.2019: Using HandleProcessCorruptedStateExceptions and SecurityCritical allows to capture AccessViolationExceptions
// which is used here to prevent hard crashes on wrong pointers.
// Since this might cause isntabilities in the running application it's only a workaround and should be fixed in depth.
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int EnumerateMbController(IntPtr handles, int size)
{
try { return _enumerateMbControllerPointer(handles, size); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int GetMbLedCount(IntPtr handle)
{
try { return _getMbLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetMbMode(IntPtr handle, int mode)
{
try { _setMbModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetMbColor(IntPtr handle, byte[] colors)
{
try { _setMbColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static byte[] GetMbColor(IntPtr handle)
{
int count = _getMbColorPointer(handle, IntPtr.Zero, 0);
@ -200,20 +231,92 @@ namespace RGB.NET.Devices.Asus.Native
return colors;
}
internal static int EnumerateGPU(IntPtr handles, int size) => _enumerateGPUPointer(handles, size);
internal static int GetGPULedCount(IntPtr handle) => _getGPULedCountPointer(handle);
internal static void SetGPUMode(IntPtr handle, int mode) => _setGPUModePointer(handle, mode);
internal static void SetGPUColor(IntPtr handle, byte[] colors) => _setGPUColorPointer(handle, colors, colors.Length);
internal static bool CreateClaymoreKeyboard(IntPtr handle) => _createClaymoreKeyboardPointer(handle);
internal static int GetClaymoreKeyboardLedCount(IntPtr handle) => _getClaymoreKeyboardLedCountPointer(handle);
internal static void SetClaymoreKeyboardMode(IntPtr handle, int mode) => _setClaymoreKeyboardModePointer(handle, mode);
internal static void SetClaymoreKeyboardColor(IntPtr handle, byte[] colors) => _setClaymoreKeyboardColorPointer(handle, colors, colors.Length);
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int EnumerateGPU(IntPtr handles, int size)
{
try { return _enumerateGPUPointer(handles, size); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
internal static bool CreateRogMouse(IntPtr handle) => _enumerateRogMousePointer(handle);
internal static int GetRogMouseLedCount(IntPtr handle) => _getRogMouseLedCountPointer(handle);
internal static void SetRogMouseMode(IntPtr handle, int mode) => _setRogMouseModePointer(handle, mode);
internal static void SetRogMouseColor(IntPtr handle, byte[] colors) => _setRogMouseColorPointer(handle, colors, colors.Length);
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int GetGPULedCount(IntPtr handle)
{
try { return _getGPULedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetGPUMode(IntPtr handle, int mode)
{
try { _setGPUModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetGPUColor(IntPtr handle, byte[] colors)
{
try { _setGPUColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static bool CreateClaymoreKeyboard(IntPtr handle)
{
try { return _createClaymoreKeyboardPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int GetClaymoreKeyboardLedCount(IntPtr handle)
{
try { return _getClaymoreKeyboardLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetClaymoreKeyboardMode(IntPtr handle, int mode)
{
try { _setClaymoreKeyboardModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetClaymoreKeyboardColor(IntPtr handle, byte[] colors)
{
try { _setClaymoreKeyboardColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static bool CreateRogMouse(IntPtr handle)
{
try { return _enumerateRogMousePointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static int GetRogMouseLedCount(IntPtr handle)
{
try { return _getRogMouseLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetRogMouseMode(IntPtr handle, int mode)
{
try { _setRogMouseModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
internal static void SetRogMouseColor(IntPtr handle, byte[] colors)
{
try { _setRogMouseColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); };
}
//internal static int EnumerateDram(IntPtr handles, int size) => _enumerateDramPointer(handles, size);
//internal static int GetDramLedCount(IntPtr handle) => _getDramLedCountPointer(handle);

View File

@ -19,6 +19,7 @@ namespace RGB.NET.Devices.Logitech.HID
("G910", RGBDeviceType.Keyboard, 0xC32B, 0, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout
("G810", RGBDeviceType.Keyboard, 0xC337, 0, "DE", @"Keyboards\G810\UK"),
("G610", RGBDeviceType.Keyboard, 0xC333, 0, "DE", @"Keyboards\G610\UK"),
("G410", RGBDeviceType.Keyboard, 0xC330, 0, "DE", @"Keyboards\G410\UK"),
("G213", RGBDeviceType.Keyboard, 0xC336, 0, "DE", @"Keyboards\G213\UK"),
("Pro", RGBDeviceType.Keyboard, 0xC339, 0, "DE", @"Keyboards\Pro\UK"),
};
@ -30,6 +31,7 @@ namespace RGB.NET.Devices.Logitech.HID
("G19s", RGBDeviceType.Keyboard, 0xC229, 0, "DE", @"Keyboards\G19s\UK"),
("G502", RGBDeviceType.Mouse, 0xC332, 0, "default", @"Mice\G502"),
("G600", RGBDeviceType.Mouse, 0xC24A, 0, "default", @"Mice\G600"),
("G300s", RGBDeviceType.Mouse, 0xC246, 0, "default", @"Mice\G300s"),
("G510", RGBDeviceType.Keyboard, 0xC22D, 0, "DE", @"Keyboards\G510\UK"),
("G510s", RGBDeviceType.Keyboard, 0xC22E, 0, "DE", @"Keyboards\G510s\UK"),
("G13", RGBDeviceType.Keypad, 0xC21C, 0, "DE", @"Keypads\G13\UK"),
@ -48,6 +50,7 @@ namespace RGB.NET.Devices.Logitech.HID
("G703", RGBDeviceType.Mouse, 0xC087, 2, "default", @"Mice\G703"),
("G403", RGBDeviceType.Mouse, 0xC083, 2, "default", @"Mice\G403"),
("G303", RGBDeviceType.Mouse, 0xC080, 2, "default", @"Mice\G303"),
("G203", RGBDeviceType.Mouse, 0xC084, 1, "default", @"Mice\G203"),
("G Pro", RGBDeviceType.Mouse, 0xC085, 1, "default", @"Mice\GPro"),
("G633", RGBDeviceType.Headset, 0x0A5C, 2, "default", @"Headsets\G633"),
("G933", RGBDeviceType.Headset, 0x0A5B, 2, "default", @"Headsets\G933"),

View File

@ -18,6 +18,15 @@
FourZone,
[APIName("rgb-5-zone")]
FiveZone
FiveZone,
[APIName("rgb-6-zone")]
SixZone,
[APIName("rgb-7-zone")]
SevenZone,
[APIName("rgb-8-zone")]
EightZone
}
}

View File

@ -12,6 +12,16 @@
ZoneFour,
[APIName("five")]
ZoneFive,
[APIName("six")]
ZoneSix,
[APIName("seven")]
ZoneSeven,
[APIName("eight")]
ZoneEight,
[APIName("nine")]
ZoneNine,
[APIName("ten")]
ZoneTen,
[APIName("logo")]
Logo,

View File

@ -11,13 +11,144 @@ namespace RGB.NET.Devices.SteelSeries.HID
{
#region Constants
private static readonly LedMapping KEYBOARD_MAPPING_UK = new LedMapping
{
{ LedId.Logo, SteelSeriesLedId.Logo },
{ LedId.Keyboard_Escape, SteelSeriesLedId.Escape },
{ LedId.Keyboard_F1, SteelSeriesLedId.F1 },
{ LedId.Keyboard_F2, SteelSeriesLedId.F2 },
{ LedId.Keyboard_F3, SteelSeriesLedId.F3 },
{ LedId.Keyboard_F4, SteelSeriesLedId.F4 },
{ LedId.Keyboard_F5, SteelSeriesLedId.F5 },
{ LedId.Keyboard_F6, SteelSeriesLedId.F6 },
{ LedId.Keyboard_F7, SteelSeriesLedId.F7 },
{ LedId.Keyboard_F8, SteelSeriesLedId.F8 },
{ LedId.Keyboard_F9, SteelSeriesLedId.F9 },
{ LedId.Keyboard_F10, SteelSeriesLedId.F10 },
{ LedId.Keyboard_F11, SteelSeriesLedId.F11 },
{ LedId.Keyboard_GraveAccentAndTilde, SteelSeriesLedId.Backqoute },
{ LedId.Keyboard_1, SteelSeriesLedId.Keyboard1 },
{ LedId.Keyboard_2, SteelSeriesLedId.Keyboard2 },
{ LedId.Keyboard_3, SteelSeriesLedId.Keyboard3 },
{ LedId.Keyboard_4, SteelSeriesLedId.Keyboard4 },
{ LedId.Keyboard_5, SteelSeriesLedId.Keyboard5 },
{ LedId.Keyboard_6, SteelSeriesLedId.Keyboard6 },
{ LedId.Keyboard_7, SteelSeriesLedId.Keyboard7 },
{ LedId.Keyboard_8, SteelSeriesLedId.Keyboard8 },
{ LedId.Keyboard_9, SteelSeriesLedId.Keyboard9 },
{ LedId.Keyboard_0, SteelSeriesLedId.Keyboard0 },
{ LedId.Keyboard_MinusAndUnderscore, SteelSeriesLedId.Dash },
{ LedId.Keyboard_Tab, SteelSeriesLedId.Tab },
{ LedId.Keyboard_Q, SteelSeriesLedId.Q },
{ LedId.Keyboard_W, SteelSeriesLedId.W },
{ LedId.Keyboard_E, SteelSeriesLedId.E },
{ LedId.Keyboard_R, SteelSeriesLedId.R },
{ LedId.Keyboard_T, SteelSeriesLedId.T },
{ LedId.Keyboard_Y, SteelSeriesLedId.Y },
{ LedId.Keyboard_U, SteelSeriesLedId.U },
{ LedId.Keyboard_I, SteelSeriesLedId.I },
{ LedId.Keyboard_O, SteelSeriesLedId.O },
{ LedId.Keyboard_P, SteelSeriesLedId.P },
{ LedId.Keyboard_BracketLeft, SteelSeriesLedId.LBracket },
{ LedId.Keyboard_CapsLock, SteelSeriesLedId.Caps },
{ LedId.Keyboard_A, SteelSeriesLedId.A },
{ LedId.Keyboard_S, SteelSeriesLedId.S },
{ LedId.Keyboard_D, SteelSeriesLedId.D },
{ LedId.Keyboard_F, SteelSeriesLedId.F },
{ LedId.Keyboard_G, SteelSeriesLedId.G },
{ LedId.Keyboard_H, SteelSeriesLedId.H },
{ LedId.Keyboard_J, SteelSeriesLedId.J },
{ LedId.Keyboard_K, SteelSeriesLedId.K },
{ LedId.Keyboard_L, SteelSeriesLedId.L },
{ LedId.Keyboard_SemicolonAndColon, SteelSeriesLedId.Semicolon },
{ LedId.Keyboard_ApostropheAndDoubleQuote, SteelSeriesLedId.Quote },
{ LedId.Keyboard_LeftShift, SteelSeriesLedId.LShift },
{ LedId.Keyboard_NonUsTilde, SteelSeriesLedId.Pound },
{ LedId.Keyboard_Z, SteelSeriesLedId.Z },
{ LedId.Keyboard_X, SteelSeriesLedId.X },
{ LedId.Keyboard_C, SteelSeriesLedId.C },
{ LedId.Keyboard_V, SteelSeriesLedId.V },
{ LedId.Keyboard_B, SteelSeriesLedId.B },
{ LedId.Keyboard_N, SteelSeriesLedId.N },
{ LedId.Keyboard_M, SteelSeriesLedId.M },
{ LedId.Keyboard_CommaAndLessThan, SteelSeriesLedId.Comma },
{ LedId.Keyboard_PeriodAndBiggerThan, SteelSeriesLedId.Period },
{ LedId.Keyboard_SlashAndQuestionMark, SteelSeriesLedId.Slash },
{ LedId.Keyboard_LeftCtrl, SteelSeriesLedId.LCtrl },
{ LedId.Keyboard_LeftGui, SteelSeriesLedId.LWin },
{ LedId.Keyboard_LeftAlt, SteelSeriesLedId.LAlt },
{ LedId.Keyboard_Space, SteelSeriesLedId.Spacebar },
{ LedId.Keyboard_RightAlt, SteelSeriesLedId.RAlt },
{ LedId.Keyboard_RightGui, SteelSeriesLedId.RWin },
{ LedId.Keyboard_Application, SteelSeriesLedId.SSKey },
{ LedId.Keyboard_F12, SteelSeriesLedId.F12 },
{ LedId.Keyboard_PrintScreen, SteelSeriesLedId.PrintScreen },
{ LedId.Keyboard_ScrollLock, SteelSeriesLedId.ScrollLock },
{ LedId.Keyboard_PauseBreak, SteelSeriesLedId.Pause },
{ LedId.Keyboard_Insert, SteelSeriesLedId.Insert },
{ LedId.Keyboard_Home, SteelSeriesLedId.Home },
{ LedId.Keyboard_PageUp, SteelSeriesLedId.PageUp },
{ LedId.Keyboard_BracketRight, SteelSeriesLedId.RBracket },
{ LedId.Keyboard_Backslash, SteelSeriesLedId.Backslash },
{ LedId.Keyboard_Enter, SteelSeriesLedId.Return },
{ LedId.Keyboard_EqualsAndPlus, SteelSeriesLedId.Equal },
{ LedId.Keyboard_Backspace, SteelSeriesLedId.Backspace },
{ LedId.Keyboard_Delete, SteelSeriesLedId.Delete },
{ LedId.Keyboard_End, SteelSeriesLedId.End },
{ LedId.Keyboard_PageDown, SteelSeriesLedId.PageDown },
{ LedId.Keyboard_RightShift, SteelSeriesLedId.RShift },
{ LedId.Keyboard_RightCtrl, SteelSeriesLedId.RCtrl },
{ LedId.Keyboard_ArrowUp, SteelSeriesLedId.UpArrow },
{ LedId.Keyboard_ArrowLeft, SteelSeriesLedId.LeftArrow },
{ LedId.Keyboard_ArrowDown, SteelSeriesLedId.DownArrow },
{ LedId.Keyboard_ArrowRight, SteelSeriesLedId.RightArrow },
{ LedId.Keyboard_NumLock, SteelSeriesLedId.KeypadNumLock },
{ LedId.Keyboard_NumSlash, SteelSeriesLedId.KeypadDivide },
{ LedId.Keyboard_NumAsterisk, SteelSeriesLedId.KeypadTimes },
{ LedId.Keyboard_NumMinus, SteelSeriesLedId.KeypadMinus },
{ LedId.Keyboard_NumPlus, SteelSeriesLedId.KeypadPlus },
{ LedId.Keyboard_NumEnter, SteelSeriesLedId.KeypadEnter },
{ LedId.Keyboard_Num7, SteelSeriesLedId.Keypad7 },
{ LedId.Keyboard_Num8, SteelSeriesLedId.Keypad8 },
{ LedId.Keyboard_Num9, SteelSeriesLedId.Keypad9 },
{ LedId.Keyboard_Num4, SteelSeriesLedId.Keypad4 },
{ LedId.Keyboard_Num5, SteelSeriesLedId.Keypad5 },
{ LedId.Keyboard_Num6, SteelSeriesLedId.Keypad6 },
{ LedId.Keyboard_Num1, SteelSeriesLedId.Keypad1 },
{ LedId.Keyboard_Num2, SteelSeriesLedId.Keypad2 },
{ LedId.Keyboard_Num3, SteelSeriesLedId.Keypad3 },
{ LedId.Keyboard_Num0, SteelSeriesLedId.Keypad0 },
{ LedId.Keyboard_NumPeriodAndDelete, SteelSeriesLedId.KeypadPeriod }
};
private static readonly LedMapping MOUSE_TWO_ZONE = new LedMapping
{
{LedId.Mouse1, SteelSeriesLedId.ZoneOne},
{LedId.Mouse2, SteelSeriesLedId.ZoneTwo}
};
private static readonly LedMapping MOUSE_EIGHT_ZONE = new LedMapping
{
{ LedId.Mouse1, SteelSeriesLedId.ZoneOne},
{ LedId.Mouse2, SteelSeriesLedId.ZoneTwo},
{ LedId.Mouse3, SteelSeriesLedId.ZoneThree},
{ LedId.Mouse4, SteelSeriesLedId.ZoneFour},
{ LedId.Mouse5, SteelSeriesLedId.ZoneFive},
{ LedId.Mouse6, SteelSeriesLedId.ZoneSix},
{ LedId.Mouse7, SteelSeriesLedId.ZoneSeven},
{ LedId.Mouse8, SteelSeriesLedId.ZoneEight}
};
private const int VENDOR_ID = 0x1038;
//TODO DarthAffe 16.02.2019: Add devices
private static readonly DeviceDataList DEVICES = new DeviceDataList
{
("Rival 500", RGBDeviceType.Mouse, 0x170E, SteelSeriesDeviceType.TwoZone, "default", @"Mice\Rival500", new LedMapping { { LedId.Mouse1, SteelSeriesLedId.ZoneOne},
{ LedId.Mouse2, SteelSeriesLedId.ZoneTwo} }),
("Rival 600", RGBDeviceType.Mouse, 0x0616, SteelSeriesDeviceType.EightZone, "default", @"Mice\Rival600", MOUSE_EIGHT_ZONE),
("Rival 500", RGBDeviceType.Mouse, 0x170E, SteelSeriesDeviceType.TwoZone, "default", @"Mice\Rival500", MOUSE_TWO_ZONE),
("Rival 310", RGBDeviceType.Mouse, 0x1720, SteelSeriesDeviceType.TwoZone, "default", @"Mice\Rival310", MOUSE_TWO_ZONE),
("Apex M750", RGBDeviceType.Keyboard, 0x1724, SteelSeriesDeviceType.PerKey, "UK", @"Keyboards\M750\UK", KEYBOARD_MAPPING_UK),
};
#endregion