mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Updated corsair-SDK to 2.18.127
This commit is contained in:
parent
83a3ea4e01
commit
86bc26233b
@ -127,6 +127,38 @@ namespace RGB.NET.Devices.Corsair
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current color-data from the device
|
||||
/// </summary>
|
||||
/// <returns>A dictionary mapping the <see cref="CorsairLedIds"/> to the current <see cref="Color"/>.</returns>
|
||||
protected Dictionary<CorsairLedIds, Color> GetColors()
|
||||
{
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * LedMapping.Count);
|
||||
IntPtr addPtr = new IntPtr(ptr.ToInt64());
|
||||
foreach (Led led in this)
|
||||
{
|
||||
_CorsairLedColor color = new _CorsairLedColor { ledId = (int)((CorsairLedId)led.Id).LedId };
|
||||
Marshal.StructureToPtr(color, addPtr, false);
|
||||
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
||||
}
|
||||
_CUESDK.CorsairGetLedsColors(LedMapping.Count, ptr);
|
||||
|
||||
IntPtr readPtr = ptr;
|
||||
Dictionary<CorsairLedIds, Color> colorData = new Dictionary<CorsairLedIds, Color>();
|
||||
for (int i = 0; i < LedMapping.Count; i++)
|
||||
{
|
||||
_CorsairLedColor ledColor = (_CorsairLedColor)Marshal.PtrToStructure(readPtr, typeof(_CorsairLedColor));
|
||||
colorData.Add((CorsairLedIds)ledColor.ledId, new Color((byte)ledColor.r, (byte)ledColor.g, (byte)ledColor.b));
|
||||
|
||||
readPtr = new IntPtr(readPtr.ToInt64() + structSize);
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
|
||||
return colorData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
|
||||
_corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer));
|
||||
_corsairGetLedsColorsPointer = (CorsairGetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColors"), typeof(CorsairGetLedsColorsPointer));
|
||||
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
|
||||
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
|
||||
_corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer));
|
||||
@ -79,6 +80,7 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
#region Pointers
|
||||
|
||||
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
|
||||
private static CorsairGetLedsColorsPointer _corsairGetLedsColorsPointer;
|
||||
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
|
||||
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
|
||||
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
|
||||
@ -96,6 +98,9 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate bool CorsairGetLedsColorsPointer(int size, IntPtr ledsColors);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate int CorsairGetDeviceCountPointer();
|
||||
|
||||
@ -130,83 +135,58 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
/// <summary>
|
||||
/// CUE-SDK: set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account.
|
||||
/// </summary>
|
||||
internal static bool CorsairSetLedsColors(int size, IntPtr ledsColors)
|
||||
{
|
||||
return _corsairSetLedsColorsPointer(size, ledsColors);
|
||||
}
|
||||
internal static bool CorsairSetLedsColors(int size, IntPtr ledsColors) => _corsairSetLedsColorsPointer(size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: get current color for the list of requested LEDs.
|
||||
/// </summary>
|
||||
internal static bool CorsairGetLedsColors(int size, IntPtr ledsColors) => _corsairGetLedsColorsPointer(size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
||||
/// </summary>
|
||||
internal static int CorsairGetDeviceCount()
|
||||
{
|
||||
return _corsairGetDeviceCountPointer();
|
||||
}
|
||||
internal static int CorsairGetDeviceCount() => _corsairGetDeviceCountPointer();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns information about device at provided index.
|
||||
/// </summary>
|
||||
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex)
|
||||
{
|
||||
return _corsairGetDeviceInfoPointer(deviceIndex);
|
||||
}
|
||||
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => _corsairGetDeviceInfoPointer(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: provides list of keyboard LEDs with their physical positions.
|
||||
/// </summary>
|
||||
internal static IntPtr CorsairGetLedPositions()
|
||||
{
|
||||
return _corsairGetLedPositionsPointer();
|
||||
}
|
||||
internal static IntPtr CorsairGetLedPositions() => _corsairGetLedPositionsPointer();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
||||
/// </summary>
|
||||
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex)
|
||||
{
|
||||
return _corsairGetLedPositionsByDeviceIndexPointer(deviceIndex);
|
||||
}
|
||||
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => _corsairGetLedPositionsByDeviceIndexPointer(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
||||
/// </summary>
|
||||
internal static CorsairLedIds CorsairGetLedIdForKeyName(char keyName)
|
||||
{
|
||||
return _corsairGetLedIdForKeyNamePointer(keyName);
|
||||
}
|
||||
internal static CorsairLedIds CorsairGetLedIdForKeyName(char keyName) => _corsairGetLedIdForKeyNamePointer(keyName);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: requestes control using specified access mode.
|
||||
/// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control.
|
||||
/// </summary>
|
||||
internal static bool CorsairRequestControl(CorsairAccessMode accessMode)
|
||||
{
|
||||
return _corsairRequestControlPointer(accessMode);
|
||||
}
|
||||
internal static bool CorsairRequestControl(CorsairAccessMode accessMode) => _corsairRequestControlPointer(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: releases previously requested control for specified access mode.
|
||||
/// </summary>
|
||||
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode)
|
||||
{
|
||||
return _corsairReleaseControlPointer(accessMode);
|
||||
}
|
||||
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode) => _corsairReleaseControlPointer(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE.
|
||||
/// </summary>
|
||||
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake()
|
||||
{
|
||||
return _corsairPerformProtocolHandshakePointer();
|
||||
}
|
||||
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake() => _corsairPerformProtocolHandshakePointer();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
|
||||
/// </summary>
|
||||
internal static CorsairError CorsairGetLastError()
|
||||
{
|
||||
return _corsairGetLastErrorPointer();
|
||||
}
|
||||
internal static CorsairError CorsairGetLastError() => _corsairGetLastErrorPointer();
|
||||
|
||||
// ReSharper restore EventExceptionNotDocumented
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user