1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Fixed not working razer headset and chroma-link devices by using type-effects not device-effects

This commit is contained in:
Darth Affe 2018-04-02 16:11:58 +02:00
parent 8d4b6d3bce
commit 2bbfe6c6f7
6 changed files with 28 additions and 4 deletions

View File

@ -34,6 +34,9 @@ namespace RGB.NET.Devices.Razer
return ptr;
}
/// <inheritdoc />
protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateChromaLinkEffect(_Defines.CHROMALINK_EFFECT_ID, effectParams, ref effectId);
#endregion
}
}

View File

@ -3,7 +3,7 @@
/// <summary>
/// Razer-SDK: Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK.
/// </summary>
public enum RazerError : long
public enum RazerError : int
{
/// <summary>
/// Razer-SDK: Invalid.
@ -88,6 +88,6 @@
/// <summary>
/// Razer-SDK: General failure.
/// </summary>
Failed = 2147500037
Failed = unchecked(-2147467259)
}
}

View File

@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer
{
IntPtr effectParams = CreateEffectParams(dataSet);
Guid effectId = Guid.NewGuid();
_RazerSDK.CreateEffect(_deviceId, _Defines.EFFECT_ID, effectParams, ref effectId);
CreateEffect(effectParams, ref effectId);
_RazerSDK.SetEffect(effectId);
@ -41,6 +41,8 @@ namespace RGB.NET.Devices.Razer
_lastEffect = effectId;
}
protected virtual void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateEffect(_deviceId, _Defines.EFFECT_ID, effectParams, ref effectId);
/// <inheritdoc />
public override void Reset()
{

View File

@ -27,13 +27,16 @@ namespace RGB.NET.Devices.Razer
colors[(int)data.Key] = new _Color(data.Value);
_HeadsetCustomEffect effectParams = new _HeadsetCustomEffect { Color = colors };
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams));
Marshal.StructureToPtr(effectParams, ptr, false);
return ptr;
}
/// <inheritdoc />
protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateHeadsetEffect(_Defines.HEADSET_EFFECT_ID, effectParams, ref effectId);
#endregion
}
}

View File

@ -3,6 +3,8 @@
internal static class _Defines
{
internal const int EFFECT_ID = 7;
internal const int HEADSET_EFFECT_ID = 4;
internal const int CHROMALINK_EFFECT_ID = 1;
internal const int KEYBOARD_MAX_ROW = 6;
internal const int KEYBOARD_MAX_COLUMN = 22;

View File

@ -46,6 +46,8 @@ namespace RGB.NET.Devices.Razer.Native
_unInitPointer = (UnInitPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "UnInit"), typeof(UnInitPointer));
_queryDevicePointer = (QueryDevicePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "QueryDevice"), typeof(QueryDevicePointer));
_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));
_setEffectPointer = (SetEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetEffect"), typeof(SetEffectPointer));
_deleteEffectPointer = (DeleteEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "DeleteEffect"), typeof(DeleteEffectPointer));
}
@ -78,6 +80,8 @@ namespace RGB.NET.Devices.Razer.Native
private static UnInitPointer _unInitPointer;
private static QueryDevicePointer _queryDevicePointer;
private static CreateEffectPointer _createEffectPointer;
private static CreateHeadsetEffectPointer _createHeadsetEffectPointer;
private static CreateChromaLinkEffectPointer _createChromaLinkEffectPointer;
private static SetEffectPointer _setEffectPointer;
private static DeleteEffectPointer _deleteEffectPointer;
@ -97,6 +101,12 @@ namespace RGB.NET.Devices.Razer.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate RazerError CreateEffectPointer(Guid deviceId, int effectType, IntPtr param, ref Guid effectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate RazerError CreateHeadsetEffectPointer(int effectType, IntPtr param, ref Guid effectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate RazerError CreateChromaLinkEffectPointer(int effectType, IntPtr param, ref Guid effectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate RazerError SetEffectPointer(Guid effectId);
@ -135,6 +145,10 @@ namespace RGB.NET.Devices.Razer.Native
internal static RazerError CreateEffect(Guid deviceId, int effectType, IntPtr param, ref Guid effectId) => _createEffectPointer(deviceId, effectType, param, ref effectId);
internal static RazerError CreateHeadsetEffect(int effectType, IntPtr param, ref Guid effectId) => _createHeadsetEffectPointer(effectType, param, ref effectId);
internal static RazerError CreateChromaLinkEffect(int effectType, IntPtr param, ref Guid effectId) => _createChromaLinkEffectPointer(effectType, param, ref effectId);
internal static RazerError SetEffect(Guid effectId) => _setEffectPointer(effectId);
internal static RazerError DeleteEffect(Guid effectId) => _deleteEffectPointer(effectId);