diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs index 16db3a9..9e00530 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs @@ -42,6 +42,9 @@ namespace RGB.NET.Devices.Razer return ptr; } + /// + protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateKeyboardEffect(_Defines.KEYBOARD_EFFECT_ID, effectParams, ref effectId); + #endregion } } diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs index 6e81117..f7ddb04 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs @@ -42,6 +42,9 @@ namespace RGB.NET.Devices.Razer return ptr; } + /// + protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateMousepadEffect(_Defines.MOUSEPAD_EFFECT_ID, effectParams, ref effectId); + #endregion } } diff --git a/RGB.NET.Devices.Razer/Native/_Defines.cs b/RGB.NET.Devices.Razer/Native/_Defines.cs index 17d5167..71dbd2b 100644 --- a/RGB.NET.Devices.Razer/Native/_Defines.cs +++ b/RGB.NET.Devices.Razer/Native/_Defines.cs @@ -5,9 +5,11 @@ internal const int EFFECT_ID = 7; internal const int HEADSET_EFFECT_ID = 4; internal const int CHROMALINK_EFFECT_ID = 1; + internal const int KEYBOARD_EFFECT_ID = 9; + internal const int MOUSEPAD_EFFECT_ID = 6; - internal const int KEYBOARD_MAX_ROW = 6; - internal const int KEYBOARD_MAX_COLUMN = 22; + internal const int KEYBOARD_MAX_ROW = 8; + internal const int KEYBOARD_MAX_COLUMN = 24; internal const int KEYBOARD_MAX_LEDS = KEYBOARD_MAX_ROW * KEYBOARD_MAX_COLUMN; internal const int MOUSE_MAX_ROW = 9; @@ -16,7 +18,7 @@ internal const int HEADSET_MAX_LEDS = 5; - internal const int MOUSEPAD_MAX_LEDS = 15; + internal const int MOUSEPAD_MAX_LEDS = 20; internal const int KEYPAD_MAX_ROW = 4; internal const int KEYPAD_MAX_COLUMN = 5; diff --git a/RGB.NET.Devices.Razer/Native/_KeyboardCustomEffect.cs b/RGB.NET.Devices.Razer/Native/_KeyboardCustomEffect.cs index 5e9294f..0cef396 100644 --- a/RGB.NET.Devices.Razer/Native/_KeyboardCustomEffect.cs +++ b/RGB.NET.Devices.Razer/Native/_KeyboardCustomEffect.cs @@ -7,5 +7,10 @@ namespace RGB.NET.Devices.Razer.Native { [MarshalAs(UnmanagedType.ByValArray, SizeConst = _Defines.KEYBOARD_MAX_LEDS)] public _Color[] Color; + + //diogotr7: I don't know what these "keys" mean, they were introduced in the Keyboard::v2 + //namespace. we need to put them here to give razer the struct size it expects + [MarshalAs(UnmanagedType.ByValArray, SizeConst = _Defines.KEYBOARD_MAX_LEDS)] + public uint[] Key; } } diff --git a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs index 4802196..de3ac21 100644 --- a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs +++ b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs @@ -48,6 +48,8 @@ namespace RGB.NET.Devices.Razer.Native _createEffectPointer = (CreateEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateEffect"), typeof(CreateEffectPointer)); _createHeadsetEffectPointer = (CreateHeadsetEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateHeadsetEffect"), typeof(CreateHeadsetEffectPointer)); _createChromaLinkEffectPointer = (CreateChromaLinkEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateChromaLinkEffect"), typeof(CreateChromaLinkEffectPointer)); + _createKeyboardEffectPointer = (CreateKeyboardEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateKeyboardEffect"), typeof(CreateKeyboardEffectPointer)); + _createMousepadEffectPointer = (CreateMousepadEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateMousepadEffect"), typeof(CreateMousepadEffectPointer)); _setEffectPointer = (SetEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetEffect"), typeof(SetEffectPointer)); _deleteEffectPointer = (DeleteEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "DeleteEffect"), typeof(DeleteEffectPointer)); } @@ -82,6 +84,8 @@ namespace RGB.NET.Devices.Razer.Native private static CreateEffectPointer _createEffectPointer; private static CreateHeadsetEffectPointer _createHeadsetEffectPointer; private static CreateChromaLinkEffectPointer _createChromaLinkEffectPointer; + private static CreateKeyboardEffectPointer _createKeyboardEffectPointer; + private static CreateMousepadEffectPointer _createMousepadEffectPointer; private static SetEffectPointer _setEffectPointer; private static DeleteEffectPointer _deleteEffectPointer; @@ -107,6 +111,12 @@ namespace RGB.NET.Devices.Razer.Native [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate RazerError CreateChromaLinkEffectPointer(int effectType, IntPtr param, ref Guid effectId); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate RazerError CreateKeyboardEffectPointer(int effectType, IntPtr param, ref Guid effectId); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate RazerError CreateMousepadEffectPointer(int effectType, IntPtr param, ref Guid effectId); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate RazerError SetEffectPointer(Guid effectId); @@ -149,6 +159,10 @@ namespace RGB.NET.Devices.Razer.Native internal static RazerError CreateChromaLinkEffect(int effectType, IntPtr param, ref Guid effectId) => _createChromaLinkEffectPointer(effectType, param, ref effectId); + internal static RazerError CreateKeyboardEffect(int effectType, IntPtr param, ref Guid effectId) => _createKeyboardEffectPointer(effectType, param, ref effectId); + + internal static RazerError CreateMousepadEffect(int effectType, IntPtr param, ref Guid effectId) => _createMousepadEffectPointer(effectType, param, ref effectId); + internal static RazerError SetEffect(Guid effectId) => _setEffectPointer(effectId); internal static RazerError DeleteEffect(Guid effectId) => _deleteEffectPointer(effectId);