Updated corsair SDK

This adds support for custom devices (lightning node and commander). And introduced 'fan' as device type.
fixes #23
This commit is contained in:
DarthAffe committed 2018-07-08 20:04:01 +02:00
1 parent 4b2aba8447
commit c47afc4704
26 files changed
+810 -64

No files matched your search

+40 -21
View File
@@ -42,11 +42,12 @@ 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));
_corsairSetLedsColorsBufferByDeviceIndexPointer = (CorsairSetLedsColorsBufferByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsBufferByDeviceIndex"), typeof(CorsairSetLedsColorsBufferByDeviceIndexPointer));
_corsairSetLedsColorsFlushBufferPointer = (CorsairSetLedsColorsFlushBufferPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsFlushBuffer"), typeof(CorsairSetLedsColorsFlushBufferPointer));
_corsairGetLedsColorsByDeviceIndexPointer = (CorsairGetLedsColorsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColorsByDeviceIndex"), typeof(CorsairGetLedsColorsByDeviceIndexPointer));
_corsairSetLayerPriorityPointer = (CorsairSetLayerPriorityPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLayerPriority"), typeof(CorsairSetLayerPriorityPointer));
_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));
_corsairGetLedPositionsByDeviceIndexPointer = (CorsairGetLedPositionsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositionsByDeviceIndex"), typeof(CorsairGetLedPositionsByDeviceIndexPointer));
_corsairGetLedIdForKeyNamePointer = (CorsairGetLedIdForKeyNamePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedIdForKeyName"), typeof(CorsairGetLedIdForKeyNamePointer));
_corsairRequestControlPointer = (CorsairRequestControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRequestControl"), typeof(CorsairRequestControlPointer));
@@ -79,11 +80,12 @@ namespace RGB.NET.Devices.Corsair.Native
#region Pointers
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
private static CorsairGetLedsColorsPointer _corsairGetLedsColorsPointer;
private static CorsairSetLedsColorsBufferByDeviceIndexPointer _corsairSetLedsColorsBufferByDeviceIndexPointer;
private static CorsairSetLedsColorsFlushBufferPointer _corsairSetLedsColorsFlushBufferPointer;
private static CorsairGetLedsColorsByDeviceIndexPointer _corsairGetLedsColorsByDeviceIndexPointer;
private static CorsairSetLayerPriorityPointer _corsairSetLayerPriorityPointer;
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
private static CorsairGetLedIdForKeyNamePointer _corsairGetLedIdForKeyNamePointer;
private static CorsairGetLedPositionsByDeviceIndexPointer _corsairGetLedPositionsByDeviceIndexPointer;
private static CorsairRequestControlPointer _corsairRequestControlPointer;
@@ -96,10 +98,16 @@ namespace RGB.NET.Devices.Corsair.Native
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
private delegate bool CorsairSetLedsColorsBufferByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsPointer(int size, IntPtr ledsColors);
private delegate bool CorsairSetLedsColorsFlushBufferPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLayerPriorityPointer(int priority);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer();
@@ -107,9 +115,6 @@ namespace RGB.NET.Devices.Corsair.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetDeviceInfoPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex);
@@ -131,16 +136,35 @@ namespace RGB.NET.Devices.Corsair.Native
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified LEDs to some colors.
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
/// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
/// This function does not take logical layout into account.
/// </summary>
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairSetLedsColorsBufferByDeviceIndexPointer(deviceIndex, size, ledsColors);
/// <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.
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
/// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync
/// </summary>
internal static bool CorsairSetLedsColors(int size, IntPtr ledsColors) => _corsairSetLedsColorsPointer(size, ledsColors);
internal static bool CorsairSetLedsColorsFlushBuffer() => _corsairSetLedsColorsFlushBufferPointer();
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
/// </summary>
internal static bool CorsairGetLedsColors(int size, IntPtr ledsColors) => _corsairGetLedsColorsPointer(size, ledsColors);
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairGetLedsColorsByDeviceIndexPointer(deviceIndex, size, ledsColors);
/// <summary>
/// CUE-SDK: set layer priority for this shared client.
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function.
/// Layers with higher priority value are shown on top of layers with lower priority.
/// </summary>
internal static bool CorsairSetLayerPriority(int priority) => _corsairSetLayerPriorityPointer(priority);
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
@@ -151,12 +175,7 @@ namespace RGB.NET.Devices.Corsair.Native
/// CUE-SDK: returns information about device at provided index.
/// </summary>
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() => _corsairGetLedPositionsPointer();
/// <summary>
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
/// </summary>
@@ -0,0 +1,26 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelDeviceInfo
{
/// <summary>
/// CUE-SDK: type of the LED-device
/// </summary>
internal CorsairChannelDeviceType type;
/// <summary>
/// CUE-SDK: number of LEDs controlled by LED-device.
/// </summary>
internal int deviceLedCount;
}
}
@@ -0,0 +1,33 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate channel of the DIY-device.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelInfo
{
/// <summary>
/// CUE-SDK: total number of LEDs connected to the channel;
/// </summary>
internal int totalLedsCount;
/// <summary>
/// CUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device
/// </summary>
internal int devicesCount;
/// <summary>
/// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device.
/// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device.
/// </summary>
internal IntPtr devices;
}
}
@@ -0,0 +1,28 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about channels of the DIY-devices.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelsInfo
{
/// <summary>
/// CUE-SDK: number of channels controlled by the device
/// </summary>
internal int channelsCount;
/// <summary>
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
/// Index of the channel in the array is same as index of the channel on the DIY-device.
/// </summary>
internal IntPtr channels;
}
}
@@ -43,5 +43,10 @@ namespace RGB.NET.Devices.Corsair.Native
/// CUE-SDK: number of controllable LEDs on the device
/// </summary>
internal int ledsCount;
/// <summary>
/// CUE-SDK: structure that describes channels of the DIY-devices
/// </summary>
internal _CorsairChannelsInfo channels;
}
}