mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Updated corsair SDK to iCUE SDK v4.0.48
This commit is contained in:
parent
d60d4833ca
commit
180b0e4538
@ -11,6 +11,12 @@ namespace RGB.NET.Core;
|
||||
public class LedMapping<T> : IEnumerable<(LedId ledId, T mapping)>
|
||||
where T : notnull
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public static LedMapping<T> Empty { get; } = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly Dictionary<LedId, T> _mapping = new();
|
||||
|
||||
34
RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs
Normal file
34
RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair cooler.
|
||||
/// </summary>
|
||||
public class CorsairCoolerRGBDevice : CorsairRGBDevice<CorsairCoolerRGBDeviceInfo>, ICooler
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCoolerRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the cooler.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairCoolerRGBDevice(CorsairCoolerRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateCoolerMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
28
RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs
Normal file
28
RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCoolerRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairCoolerRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Cooler, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairCoolerRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName)
|
||||
: base(RGBDeviceType.Cooler, nativeInfo, ledCount, ledOffset, modelName)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -3,8 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
@ -28,23 +27,23 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" };
|
||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/iCUESDK.dll", "x86/CUESDK_2019.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" };
|
||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets the protocol details for the current SDK-connection.
|
||||
/// Gets or sets the timeout used when connecting to the SDK.
|
||||
/// </summary>
|
||||
public CorsairProtocolDetails? ProtocolDetails { get; private set; }
|
||||
public static TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromMilliseconds(500);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last error documented by CUE.
|
||||
/// Gets or sets a bool indicating if exclusive request should be requested through the iCUE-SDK.
|
||||
/// </summary>
|
||||
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
|
||||
public static bool ExclusiveAccess { get; set; } = false;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -64,25 +63,35 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeSDK()
|
||||
{
|
||||
_CUESDK.Reload();
|
||||
|
||||
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
|
||||
using ManualResetEventSlim waitEvent = new(false);
|
||||
|
||||
CorsairError error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(new CUEException(error), true);
|
||||
void OnSessionStateChanged(object? sender, CorsairSessionState state)
|
||||
{
|
||||
if (state == CorsairSessionState.Connected)
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
waitEvent.Set();
|
||||
}
|
||||
|
||||
if (ProtocolDetails.BreakingChanges)
|
||||
Throw(new RGBDeviceException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||
+ $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n"
|
||||
+ $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})"), true);
|
||||
try
|
||||
{
|
||||
_CUESDK.SessionStateChanged += OnSessionStateChanged;
|
||||
|
||||
// DarthAffe 02.02.2021: 127 is iCUE
|
||||
if (!_CUESDK.CorsairSetLayerPriority(128))
|
||||
Throw(new CUEException(LastError));
|
||||
CorsairError errorCode = _CUESDK.CorsairConnect();
|
||||
|
||||
if (errorCode != CorsairError.Success)
|
||||
Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (ErrorCode: {errorCode})"));
|
||||
|
||||
if (!waitEvent.Wait(ConnectionTimeout))
|
||||
Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (Timeout - Current connection state: {_CUESDK.SesionState})"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CUESDK.SessionStateChanged -= OnSessionStateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -97,116 +106,174 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
private IEnumerable<ICorsairRGBDevice> LoadCorsairDevices()
|
||||
{
|
||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||
for (int i = 0; i < deviceCount; i++)
|
||||
CorsairError error = _CUESDK.CorsairGetDevices(new _CorsairDeviceFilter(CorsairDeviceType.All), out _CorsairDeviceInfo[] devices);
|
||||
if (error != CorsairError.Success)
|
||||
Throw(new RGBDeviceException($"Failed to load devices. (ErrorCode: {error})"));
|
||||
|
||||
foreach (_CorsairDeviceInfo device in devices)
|
||||
{
|
||||
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo))!;
|
||||
if (!((CorsairDeviceCaps)nativeDeviceInfo.capsMask).HasFlag(CorsairDeviceCaps.Lighting))
|
||||
continue; // Everything that doesn't support lighting control is useless
|
||||
if (string.IsNullOrWhiteSpace(device.id)) continue;
|
||||
|
||||
CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i);
|
||||
switch (nativeDeviceInfo.type)
|
||||
error = _CUESDK.CorsairRequestControl(device.id, ExclusiveAccess ? CorsairAccessLevel.ExclusiveLightingControl : CorsairAccessLevel.Shared);
|
||||
if (error != CorsairError.Success)
|
||||
Throw(new RGBDeviceException($"Failed to take control of device '{device.id}'. (ErrorCode: {error})"));
|
||||
|
||||
CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), device);
|
||||
|
||||
Console.WriteLine("Loading " + device.model);
|
||||
int channelLedCount = 0;
|
||||
for (int i = 0; i < device.channelCount; i++)
|
||||
{
|
||||
case CorsairDeviceType.Keyboard:
|
||||
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
Console.WriteLine($"Channel {i}/{device.channelCount}");
|
||||
channelLedCount += _CUESDK.ReadDevicePropertySimpleInt32(device.id!, CorsairDevicePropertyId.ChannelLedCount, (uint)i);
|
||||
}
|
||||
|
||||
case CorsairDeviceType.Mouse:
|
||||
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
int deviceLedCount = device.ledCount - channelLedCount;
|
||||
if (deviceLedCount > 0)
|
||||
switch (device.type)
|
||||
{
|
||||
case CorsairDeviceType.Keyboard:
|
||||
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Headset:
|
||||
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.Mouse:
|
||||
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Mousepad:
|
||||
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.Headset:
|
||||
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.HeadsetStand:
|
||||
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.Mousemat:
|
||||
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.MemoryModule:
|
||||
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.HeadsetStand:
|
||||
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Mainboard:
|
||||
yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.MemoryModule:
|
||||
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.GraphicsCard:
|
||||
yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.Motherboard:
|
||||
yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Touchbar:
|
||||
yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
case CorsairDeviceType.GraphicsCard:
|
||||
yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Cooler:
|
||||
case CorsairDeviceType.CommanderPro:
|
||||
case CorsairDeviceType.LightningNodePro:
|
||||
List<_CorsairChannelInfo> channels = GetChannels(nativeDeviceInfo).ToList();
|
||||
int channelsLedCount = channels.Sum(x => x.totalLedsCount);
|
||||
int deviceLedCount = nativeDeviceInfo.ledsCount - channelsLedCount;
|
||||
case CorsairDeviceType.Touchbar:
|
||||
yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
if (deviceLedCount > 0)
|
||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, deviceLedCount), updateQueue);
|
||||
case CorsairDeviceType.Cooler:
|
||||
yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
int ledOffset = deviceLedCount;
|
||||
foreach (_CorsairChannelInfo channelInfo in channels)
|
||||
case CorsairDeviceType.FanLedController:
|
||||
case CorsairDeviceType.LedController:
|
||||
case CorsairDeviceType.Unknown:
|
||||
yield return new CorsairUnknownRGBDevice(new CorsairUnknownRGBDeviceInfo(device, deviceLedCount, 0), updateQueue);
|
||||
break;
|
||||
|
||||
default:
|
||||
Throw(new RGBDeviceException("Unknown Device-Type"));
|
||||
break;
|
||||
}
|
||||
|
||||
int offset = deviceLedCount;
|
||||
for (int i = 0; i < device.channelCount; i++)
|
||||
{
|
||||
int deviceCount = _CUESDK.ReadDevicePropertySimpleInt32(device.id!, CorsairDevicePropertyId.ChannelDeviceCount, (uint)i);
|
||||
if (deviceCount <= 0) continue; // DarthAffe 10.02.2023: There seem to be an issue in the SDK where it reports empty channels and fails when getting ledCounts and device types from them
|
||||
|
||||
int[] ledCounts = _CUESDK.ReadDevicePropertySimpleInt32Array(device.id!, CorsairDevicePropertyId.ChannelDeviceLedCountArray, (uint)i);
|
||||
int[] deviceTypes = _CUESDK.ReadDevicePropertySimpleInt32Array(device.id!, CorsairDevicePropertyId.ChannelDeviceTypeArray, (uint)i);
|
||||
|
||||
for (int j = 0; j < deviceCount; j++)
|
||||
{
|
||||
CorsairChannelDeviceType deviceType = (CorsairChannelDeviceType)deviceTypes[j];
|
||||
int ledCount = ledCounts[j];
|
||||
|
||||
switch (deviceType)
|
||||
{
|
||||
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
|
||||
IntPtr channelDeviceInfoPtr = channelInfo.devices;
|
||||
for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++)
|
||||
{
|
||||
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;
|
||||
case CorsairChannelDeviceType.FanHD:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "HD Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue);
|
||||
case CorsairChannelDeviceType.FanSP:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "SP Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
ledOffset += channelDeviceInfo.deviceLedCount;
|
||||
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
|
||||
}
|
||||
case CorsairChannelDeviceType.FanLL:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "LL Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.FanML:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "ML Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.FanQL:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "QL Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.EightLedSeriesFan:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "8-Led-Series Fan Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.DAP:
|
||||
yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "DAP Fan"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.Pump:
|
||||
yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, ledCount, offset, "Pump"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.WaterBlock:
|
||||
yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, ledCount, offset, "Water Block"), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.Strip:
|
||||
string modelName = "LED Strip";
|
||||
|
||||
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
|
||||
if ((device.model == "LS100 Starter Kit") && (ledCount == 138))
|
||||
modelName = "LS100 LED Strip (dual monitor)";
|
||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 84))
|
||||
modelName = "LS100 LED Strip (single monitor)";
|
||||
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
|
||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 15))
|
||||
modelName = "LS100 LED Strip (short)";
|
||||
else if ((device.model == "LS100 Starter Kit") && (ledCount == 27))
|
||||
modelName = "LS100 LED Strip (long)";
|
||||
|
||||
yield return new CorsairLedStripRGBDevice(new CorsairLedStripRGBDeviceInfo(device, ledCount, offset, modelName), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairChannelDeviceType.DRAM:
|
||||
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(device, ledCount, offset, "DRAM"), updateQueue);
|
||||
break;
|
||||
|
||||
default:
|
||||
Throw(new RGBDeviceException("Unknown Device-Type"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Throw(new RGBDeviceException("Unknown Device-Type"));
|
||||
break;
|
||||
offset += ledCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<_CorsairChannelInfo> GetChannels(_CorsairDeviceInfo deviceInfo)
|
||||
{
|
||||
_CorsairChannelsInfo? channelsInfo = deviceInfo.channels;
|
||||
if (channelsInfo == null) yield break;
|
||||
|
||||
IntPtr channelInfoPtr = channelsInfo.channels;
|
||||
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
|
||||
{
|
||||
yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
|
||||
|
||||
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
|
||||
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Reset()
|
||||
{
|
||||
ProtocolDetails = null;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ }
|
||||
try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ }
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair custom.
|
||||
/// </summary>
|
||||
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>, IUnknownDevice
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, new LedMapping<CorsairLedId>(), updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
Mapping.Clear();
|
||||
|
||||
_CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
|
||||
if (nativeLedPositions == null) return;
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset));
|
||||
|
||||
LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType);
|
||||
for (int i = 0; i < DeviceInfo.LedCount; i++)
|
||||
{
|
||||
LedId ledId = referenceLedId + i;
|
||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||
if (ledPosition == null)
|
||||
{
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
Mapping.Add(ledId, ledPosition.LedId);
|
||||
|
||||
Rectangle rectangle = ledPosition.ToRectangle();
|
||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
}
|
||||
}
|
||||
|
||||
private static LedId GetReferenceLed(RGBDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
RGBDeviceType.LedStripe => LedId.LedStripe1,
|
||||
RGBDeviceType.Fan => LedId.Fan1,
|
||||
RGBDeviceType.Cooler => LedId.Cooler1,
|
||||
_ => LedId.Custom1
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of LEDs this device contains.
|
||||
/// </summary>
|
||||
public int LedCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the offset used to access the LEDs of this device.
|
||||
/// </summary>
|
||||
internal int LedOffset { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair._CorsairChannelDeviceInfo" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
/// <param name="channelDeviceInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairChannelDeviceInfo"/> representing this device.</param>
|
||||
/// <param name="ledOffset">The offset used to find the LEDs of this device.</param>
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, int ledOffset)
|
||||
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
|
||||
GetModelName(nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo))
|
||||
{
|
||||
this.LedOffset = ledOffset;
|
||||
|
||||
LedCount = channelDeviceInfo.deviceLedCount;
|
||||
}
|
||||
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, int ledCount)
|
||||
: base(deviceIndex, GetDeviceType(nativeInfo.type), nativeInfo)
|
||||
{
|
||||
this.LedCount = ledCount;
|
||||
|
||||
LedOffset = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown,
|
||||
CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanML => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.DAP => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.EightLedSeriesFan => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
|
||||
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
|
||||
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static RGBDeviceType GetDeviceType(CorsairDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
CorsairDeviceType.Unknown => RGBDeviceType.Unknown,
|
||||
CorsairDeviceType.Mouse => RGBDeviceType.Mouse,
|
||||
CorsairDeviceType.Keyboard => RGBDeviceType.Keyboard,
|
||||
CorsairDeviceType.Headset => RGBDeviceType.Headset,
|
||||
CorsairDeviceType.Mousepad => RGBDeviceType.Mousepad,
|
||||
CorsairDeviceType.HeadsetStand => RGBDeviceType.HeadsetStand,
|
||||
CorsairDeviceType.CommanderPro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.LightningNodePro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.MemoryModule => RGBDeviceType.DRAM,
|
||||
CorsairDeviceType.Cooler => RGBDeviceType.Cooler,
|
||||
CorsairDeviceType.Mainboard => RGBDeviceType.Mainboard,
|
||||
CorsairDeviceType.GraphicsCard => RGBDeviceType.GraphicsCard,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo)
|
||||
{
|
||||
switch (channelDeviceInfo.type)
|
||||
{
|
||||
case CorsairChannelDeviceType.Invalid:
|
||||
return model;
|
||||
|
||||
case CorsairChannelDeviceType.FanHD:
|
||||
return "HD Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanSP:
|
||||
return "SP Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanLL:
|
||||
return "LL Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanML:
|
||||
return "ML Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanQL:
|
||||
return "QL Fan";
|
||||
|
||||
case CorsairChannelDeviceType.EightLedSeriesFan:
|
||||
return "8-Led-Series Fan Fan";
|
||||
|
||||
case CorsairChannelDeviceType.Strip:
|
||||
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
|
||||
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138))
|
||||
return "LS100 LED Strip (dual monitor)";
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84))
|
||||
return "LS100 LED Strip (single monitor)";
|
||||
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15))
|
||||
return "LS100 LED Strip (short)";
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27))
|
||||
return "LS100 LED Strip (long)";
|
||||
// Device model is "Commander Pro" for regular LED strips
|
||||
else
|
||||
return "LED Strip";
|
||||
|
||||
case CorsairChannelDeviceType.DAP:
|
||||
return "DAP Fan";
|
||||
|
||||
case CorsairChannelDeviceType.WaterBlock:
|
||||
return "Water Block";
|
||||
|
||||
case CorsairChannelDeviceType.Pump:
|
||||
return "Pump";
|
||||
|
||||
default:
|
||||
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
|
||||
throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null);
|
||||
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
30
RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs
Normal file
30
RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: Represents an SDK access level.
|
||||
/// </summary>
|
||||
public enum CorsairAccessLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: shared mode (default)
|
||||
/// </summary>
|
||||
Shared = 0,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: exclusive lightings, but shared events
|
||||
/// </summary>
|
||||
ExclusiveLightingControl = 1,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: exclusive key events, but shared lightings
|
||||
/// </summary>
|
||||
ExclusiveKeyEventsListening = 2,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: exclusive mode
|
||||
/// </summary>
|
||||
ExclusiveLightingControlAndKeyEventsListening = 3
|
||||
};
|
||||
@ -1,14 +0,0 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an SDK access mode.
|
||||
/// </summary>
|
||||
public enum CorsairAccessMode
|
||||
{
|
||||
ExclusiveLightingControl = 0
|
||||
};
|
||||
@ -1,13 +1,10 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available corsair channel device types.
|
||||
/// iCUE-SDK: Contains a list of available corsair channel device types.
|
||||
/// </summary>
|
||||
public enum CorsairChannelDeviceType
|
||||
{
|
||||
@ -16,10 +13,11 @@ public enum CorsairChannelDeviceType
|
||||
FanSP = 2,
|
||||
FanLL = 3,
|
||||
FanML = 4,
|
||||
Strip = 5,
|
||||
DAP = 6,
|
||||
Pump = 7,
|
||||
FanQL = 8,
|
||||
WaterBlock = 9,
|
||||
EightLedSeriesFan = 10 // Previously called FanSPPRO
|
||||
FanQL = 5,
|
||||
EightLedSeriesFan = 6,
|
||||
Strip = 7,
|
||||
DAP = 8,
|
||||
Pump = 9,
|
||||
DRAM = 10,
|
||||
WaterBlock = 11,
|
||||
};
|
||||
47
RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs
Normal file
47
RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs
Normal file
@ -0,0 +1,47 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains list of available property types
|
||||
/// </summary>
|
||||
public enum CorsairDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for property of type Boolean
|
||||
/// </summary>
|
||||
Boolean = 0,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for property of type Int32 or Enumeration
|
||||
/// </summary>
|
||||
Int32 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for property of type Float64
|
||||
/// </summary>
|
||||
Float64 = 2,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for property of type String
|
||||
/// </summary>
|
||||
String = 3,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for array of Boolean
|
||||
/// </summary>
|
||||
BooleanArray = 16,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for array of Int32
|
||||
/// </summary>
|
||||
Int32Array = 17,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for array of Float64
|
||||
/// </summary>
|
||||
Float64Array = 18,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for array of String
|
||||
/// </summary>
|
||||
StringArray = 19
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of corsair device capabilities.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum CorsairDeviceCaps
|
||||
{
|
||||
/// <summary>
|
||||
/// For devices that do not support any SDK functions.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// For devices that has controlled lighting.
|
||||
/// </summary>
|
||||
Lighting = 1,
|
||||
|
||||
/// <summary>
|
||||
/// For devices that provide current state through set of properties.
|
||||
/// </summary>
|
||||
PropertyLookup = 2
|
||||
};
|
||||
77
RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs
Normal file
77
RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs
Normal file
@ -0,0 +1,77 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains list of properties identifiers which can be read from device
|
||||
/// </summary>
|
||||
public enum CorsairDevicePropertyId
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: dummy value
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: array of CorsairDevicePropertyId members supported by device
|
||||
/// </summary>
|
||||
PropertyArray = 1,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: indicates Mic state (On or Off); used for headset, headset stand
|
||||
/// </summary>
|
||||
MicEnabled = 2,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: indicates Surround Sound state (On or Off); used for headset, headset stand
|
||||
/// </summary>
|
||||
SurroundSoundEnabled = 3,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: indicates Sidetone state (On or Off); used for headset (where applicable)
|
||||
/// </summary>
|
||||
SidetoneEnabled = 4,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: the number of active equalizer preset (integer, 1 - 5); used for headset, headset stand
|
||||
/// </summary>
|
||||
EqualizerPreset = 5,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: keyboard physical layout (see CorsairPhysicalLayout for valid values); used for keyboard
|
||||
/// </summary>
|
||||
PhysicalLayout = 6,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: keyboard logical layout (see CorsairLogicalLayout for valid values); used for keyboard
|
||||
/// </summary>
|
||||
LogicalLayout = 7,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: array of programmable G, M or S keys on device
|
||||
/// </summary>
|
||||
MacroKeyArray = 8,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: battery level (0 - 100); used for wireless devices
|
||||
/// </summary>
|
||||
BatteryLevel = 9,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: total number of LEDs connected to the channel
|
||||
/// </summary>
|
||||
ChannelLedCount = 10,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device
|
||||
/// </summary>
|
||||
ChannelDeviceCount = 11,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: array of integers, each element describes the number of LEDs controlled by the channel device
|
||||
/// </summary>
|
||||
ChannelDeviceLedCountArray = 12,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: array of CorsairChannelDeviceType members, each element describes the type of the channel device
|
||||
/// </summary>
|
||||
ChannelDeviceTypeArray = 13
|
||||
}
|
||||
@ -1,27 +1,83 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available corsair device types.
|
||||
/// iCUE-SDK: Contains a list of available corsair device types.
|
||||
/// </summary>
|
||||
public enum CorsairDeviceType
|
||||
[Flags]
|
||||
public enum CorsairDeviceType : uint
|
||||
{
|
||||
Unknown = 0,
|
||||
Mouse = 1,
|
||||
Keyboard = 2,
|
||||
Headset = 3,
|
||||
Mousepad = 4,
|
||||
HeadsetStand = 5,
|
||||
CommanderPro = 6,
|
||||
LightningNodePro = 7,
|
||||
MemoryModule = 8,
|
||||
Cooler = 9,
|
||||
Mainboard = 10,
|
||||
GraphicsCard = 11,
|
||||
Touchbar = 12
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for unknown/invalid devices
|
||||
/// </summary>
|
||||
Unknown = 0x0000,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for keyboards
|
||||
/// </summary>
|
||||
Keyboard = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for mice
|
||||
/// </summary>
|
||||
Mouse = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for mousemats
|
||||
/// </summary>
|
||||
Mousemat = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for headsets
|
||||
/// </summary>
|
||||
Headset = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for headset stands
|
||||
/// </summary>
|
||||
HeadsetStand = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for DIY-devices like Commander PRO
|
||||
/// </summary>
|
||||
FanLedController = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for DIY-devices like Lighting Node PRO
|
||||
/// </summary>
|
||||
LedController = 0x0040,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for memory modules
|
||||
/// </summary>
|
||||
MemoryModule = 0x0080,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for coolers
|
||||
/// </summary>
|
||||
Cooler = 0x0100,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for motherboards
|
||||
/// </summary>
|
||||
Motherboard = 0x0200,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for graphics cards
|
||||
/// </summary>
|
||||
GraphicsCard = 0x0400,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for touchbars
|
||||
/// </summary>
|
||||
Touchbar = 0x0800,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for all devices
|
||||
/// </summary>
|
||||
All = 0xFFFFFFFF
|
||||
};
|
||||
@ -4,38 +4,47 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Shared list of all errors which could happen during calling of Corsair* functions.
|
||||
/// iCUE-SDK: Shared list of all errors which could happen during calling of Corsair* functions.
|
||||
/// </summary>
|
||||
public enum CorsairError
|
||||
{
|
||||
/// <summary>
|
||||
/// If previously called function completed successfully.
|
||||
/// iCUE-SDK: if previously called function completed successfully
|
||||
/// </summary>
|
||||
Success,
|
||||
Success = 0,
|
||||
|
||||
/// <summary>
|
||||
/// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error)
|
||||
/// iCUE-SDK: if iCUE is not running or was shut down or third-party control is disabled in iCUE settings (runtime error), or if developer did not call CorsairConnect after calling CorsairDisconnect or on app start (developer error)
|
||||
/// </summary>
|
||||
ServerNotFound,
|
||||
NotConnected = 1,
|
||||
|
||||
/// <summary>
|
||||
/// If some other client has or took over exclusive control. (runtime error)
|
||||
/// iCUE-SDK: if some other client has or took over exclusive control (runtime error)
|
||||
/// </summary>
|
||||
NoControl,
|
||||
NoControl = 2,
|
||||
|
||||
/// <summary>
|
||||
/// If developer did not perform protocol handshake. (developer error)
|
||||
/// iCUE-SDK: if developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old. Check CorsairSessionDetails for details) (developer error)
|
||||
/// </summary>
|
||||
ProtocolHandshakeMissing,
|
||||
IncompatibleProtocol = 3,
|
||||
|
||||
/// <summary>
|
||||
/// If developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old.
|
||||
/// Check CorsairProtocolDetails for details). (developer error)
|
||||
/// iCUE-SDK: if developer supplied invalid arguments to the function (for specifics look at function descriptions) (developer error)
|
||||
/// </summary>
|
||||
IncompatibleProtocol,
|
||||
InvalidArguments = 4,
|
||||
|
||||
/// <summary>
|
||||
/// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error)
|
||||
/// iCUE-SDK: if developer is calling the function that is not allowed due to current state (reading improper properties from device, or setting callback when it has already been set) (developer error)
|
||||
/// </summary>
|
||||
InvalidArguments
|
||||
InvalidOperation = 5,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: if invalid device id has been supplied as an argument to the function (when device id refers to disconnected device) (runtime error)
|
||||
/// </summary>
|
||||
DeviceNotFound = 6,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: if specific functionality (key interception) is disabled in iCUE settings (runtime error)
|
||||
/// </summary>
|
||||
NotAllowed = 7
|
||||
};
|
||||
82
RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs
Normal file
82
RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs
Normal file
@ -0,0 +1,82 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains a list of led groups. Led group is used as a part of led identifier
|
||||
/// </summary>
|
||||
public enum CorsairLedGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for keyboard leds
|
||||
/// </summary>
|
||||
Keyboard = 0,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for keyboard leds on G keys
|
||||
/// </summary>
|
||||
KeyboardGKeys = 1,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for keyboard lighting pipe leds
|
||||
/// </summary>
|
||||
KeyboardEdge = 2,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for vendor specific keyboard leds (ProfileSwitch, DialRing, etc.)
|
||||
/// </summary>
|
||||
KeyboardOem = 3,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for mouse leds
|
||||
/// </summary>
|
||||
Mouse = 4,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for mousemat leds
|
||||
/// </summary>
|
||||
Mousemat = 5,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for headset leds
|
||||
/// </summary>
|
||||
Headset = 6,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for headset stand leds
|
||||
/// </summary>
|
||||
HeadsetStand = 7,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for memory module leds
|
||||
/// </summary>
|
||||
MemoryModule = 8,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for motherboard leds
|
||||
/// </summary>
|
||||
Motherboard = 9,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for graphics card leds
|
||||
/// </summary>
|
||||
GraphicsCard = 10,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for leds on the first channel of DIY devices and coolers
|
||||
/// </summary>
|
||||
DIY_Channel1 = 11,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for leds on the second channel of DIY devices and coolers
|
||||
/// </summary>
|
||||
DIY_Channel2 = 12,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for leds on the third channel of DIY devices and coolers
|
||||
/// </summary>
|
||||
DIY_Channel3 = 13,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: for touchbar leds
|
||||
/// </summary>
|
||||
Touchbar = 14
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
142
RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs
Normal file
142
RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs
Normal file
@ -0,0 +1,142 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains a list of keyboard leds that belong to CLG_Keyboard group
|
||||
/// </summary>
|
||||
public enum CorsairLedIdKeyboard
|
||||
{
|
||||
Invalid = 0,
|
||||
Escape = 1,
|
||||
F1 = 2,
|
||||
F2 = 3,
|
||||
F3 = 4,
|
||||
F4 = 5,
|
||||
F5 = 6,
|
||||
F6 = 7,
|
||||
F7 = 8,
|
||||
F8 = 9,
|
||||
F9 = 10,
|
||||
F10 = 11,
|
||||
F11 = 12,
|
||||
F12 = 13,
|
||||
GraveAccentAndTilde = 14,
|
||||
One = 15,
|
||||
Two = 16,
|
||||
Three = 17,
|
||||
Four = 18,
|
||||
Five = 19,
|
||||
Six = 20,
|
||||
Seven = 21,
|
||||
Eight = 22,
|
||||
Nine = 23,
|
||||
Zero = 24,
|
||||
MinusAndUnderscore = 25,
|
||||
EqualsAndPlus = 26,
|
||||
Backspace = 27,
|
||||
Tab = 28,
|
||||
Q = 29,
|
||||
W = 30,
|
||||
E = 31,
|
||||
R = 32,
|
||||
T = 33,
|
||||
Y = 34,
|
||||
U = 35,
|
||||
I = 36,
|
||||
O = 37,
|
||||
P = 38,
|
||||
BracketLeft = 39,
|
||||
BracketRight = 40,
|
||||
CapsLock = 41,
|
||||
A = 42,
|
||||
S = 43,
|
||||
D = 44,
|
||||
F = 45,
|
||||
G = 46,
|
||||
H = 47,
|
||||
J = 48,
|
||||
K = 49,
|
||||
L = 50,
|
||||
SemicolonAndColon = 51,
|
||||
ApostropheAndDoubleQuote = 52,
|
||||
Backslash = 53,
|
||||
Enter = 54,
|
||||
LeftShift = 55,
|
||||
NonUsBackslash = 56,
|
||||
Z = 57,
|
||||
X = 58,
|
||||
C = 59,
|
||||
V = 60,
|
||||
B = 61,
|
||||
N = 62,
|
||||
M = 63,
|
||||
CommaAndLessThan = 64,
|
||||
PeriodAndBiggerThan = 65,
|
||||
SlashAndQuestionMark = 66,
|
||||
RightShift = 67,
|
||||
LeftCtrl = 68,
|
||||
LeftGui = 69,
|
||||
LeftAlt = 70,
|
||||
Space = 71,
|
||||
RightAlt = 72,
|
||||
RightGui = 73,
|
||||
Application = 74,
|
||||
RightCtrl = 75,
|
||||
LedProgramming = 76,
|
||||
Lang1 = 77,
|
||||
Lang2 = 78,
|
||||
International1 = 79,
|
||||
International2 = 80,
|
||||
International3 = 81,
|
||||
International4 = 82,
|
||||
International5 = 83,
|
||||
PrintScreen = 84,
|
||||
ScrollLock = 85,
|
||||
PauseBreak = 86,
|
||||
Insert = 87,
|
||||
Home = 88,
|
||||
PageUp = 89,
|
||||
Delete = 90,
|
||||
End = 91,
|
||||
PageDown = 92,
|
||||
UpArrow = 93,
|
||||
LeftArrow = 94,
|
||||
DownArrow = 95,
|
||||
RightArrow = 96,
|
||||
NonUsTilde = 97,
|
||||
Brightness = 98,
|
||||
WinLock = 99,
|
||||
Mute = 100,
|
||||
Stop = 101,
|
||||
ScanPreviousTrack = 102,
|
||||
PlayPause = 103,
|
||||
ScanNextTrack = 104,
|
||||
NumLock = 105,
|
||||
KeypadSlash = 106,
|
||||
KeypadAsterisk = 107,
|
||||
KeypadMinus = 108,
|
||||
Keypad7 = 109,
|
||||
Keypad8 = 110,
|
||||
Keypad9 = 111,
|
||||
KeypadPlus = 112,
|
||||
Keypad4 = 113,
|
||||
Keypad5 = 114,
|
||||
Keypad6 = 115,
|
||||
Keypad1 = 116,
|
||||
Keypad2 = 117,
|
||||
Keypad3 = 118,
|
||||
KeypadComma = 119,
|
||||
KeypadEnter = 120,
|
||||
Keypad0 = 121,
|
||||
KeypadPeriodAndDelete = 122,
|
||||
VolumeUp = 123,
|
||||
VolumeDown = 124,
|
||||
MR = 125,
|
||||
M1 = 126,
|
||||
M2 = 127,
|
||||
M3 = 128,
|
||||
Fn = 129
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available logical layouts for corsair keyboards.
|
||||
/// iCUE-SDK: Contains a list of available logical layouts for corsair keyboards.
|
||||
/// </summary>
|
||||
public enum CorsairLogicalKeyboardLayout
|
||||
{
|
||||
Invalid = 0,
|
||||
US_Int = 1,
|
||||
NA = 2,
|
||||
EU = 3,
|
||||
|
||||
@ -4,32 +4,14 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available physical layouts for corsair keyboards.
|
||||
/// iCUE-SDK: Contains a list of available physical layouts for corsair keyboards.
|
||||
/// </summary>
|
||||
public enum CorsairPhysicalKeyboardLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// US-Keyboard
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
US = 1,
|
||||
|
||||
/// <summary>
|
||||
/// UK-Keyboard
|
||||
/// </summary>
|
||||
UK = 2,
|
||||
|
||||
/// <summary>
|
||||
/// BR-Keyboard
|
||||
/// </summary>
|
||||
BR = 3,
|
||||
|
||||
/// <summary>
|
||||
/// JP-Keyboard
|
||||
/// </summary>
|
||||
JP = 4,
|
||||
|
||||
/// <summary>
|
||||
/// KR-Keyboard
|
||||
/// </summary>
|
||||
KR = 5
|
||||
JP = 3,
|
||||
KR = 4,
|
||||
BR = 5
|
||||
}
|
||||
@ -1,107 +0,0 @@
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available physical layouts for mice.
|
||||
/// </summary>
|
||||
public enum CorsairPhysicalMouseLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// Zone1-Mouse
|
||||
/// </summary>
|
||||
Zones1 = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Zone2-Mouse
|
||||
/// </summary>
|
||||
Zones2 = 7,
|
||||
|
||||
/// <summary>
|
||||
/// Zone3-Mouse
|
||||
/// </summary>
|
||||
Zones3 = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Zone4-Mouse
|
||||
/// </summary>
|
||||
Zones4 = 9,
|
||||
|
||||
/// <summary>
|
||||
/// Zone5-Mouse
|
||||
/// </summary>
|
||||
Zones5 = 101,
|
||||
|
||||
/// <summary>
|
||||
/// Zone6-Mouse
|
||||
/// </summary>
|
||||
Zones6 = 11,
|
||||
|
||||
/// <summary>
|
||||
/// Zone7-Mouse
|
||||
/// </summary>
|
||||
Zones7 = 12,
|
||||
|
||||
/// <summary>
|
||||
/// Zone8-Mouse
|
||||
/// </summary>
|
||||
Zones8 = 13,
|
||||
|
||||
/// <summary>
|
||||
/// Zone9-Mouse
|
||||
/// </summary>
|
||||
Zones9 = 14,
|
||||
|
||||
/// <summary>
|
||||
/// Zone10-Mouse
|
||||
/// </summary>
|
||||
Zones10 = 15,
|
||||
|
||||
/// <summary>
|
||||
/// Zone11-Mouse
|
||||
/// </summary>
|
||||
Zones11 = 16,
|
||||
|
||||
/// <summary>
|
||||
/// Zone12-Mouse
|
||||
/// </summary>
|
||||
Zones12 = 17,
|
||||
|
||||
/// <summary>
|
||||
/// Zone13-Mouse
|
||||
/// </summary>
|
||||
Zones13 = 18,
|
||||
|
||||
/// <summary>
|
||||
/// Zone14-Mouse
|
||||
/// </summary>
|
||||
Zones14 = 19,
|
||||
|
||||
/// <summary>
|
||||
/// Zone15-Mouse
|
||||
/// </summary>
|
||||
Zones15 = 20,
|
||||
|
||||
/// <summary>
|
||||
/// Zone16-Mouse
|
||||
/// </summary>
|
||||
Zones16 = 21,
|
||||
|
||||
/// <summary>
|
||||
/// Zone17-Mouse
|
||||
/// </summary>
|
||||
Zones17 = 22,
|
||||
|
||||
/// <summary>
|
||||
/// Zone18-Mouse
|
||||
/// </summary>
|
||||
Zones18 = 23,
|
||||
|
||||
/// <summary>
|
||||
/// Zone19-Mouse
|
||||
/// </summary>
|
||||
Zones19 = 24,
|
||||
|
||||
/// <summary>
|
||||
/// Zone20-Mouse
|
||||
/// </summary>
|
||||
Zones20 = 25
|
||||
}
|
||||
30
RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs
Normal file
30
RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains list of operations that can be applied to the property
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum CorsairPropertyFlag
|
||||
{
|
||||
/// <summary>
|
||||
/// -
|
||||
/// </summary>
|
||||
None = 0x00,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: describes readable property
|
||||
/// </summary>
|
||||
CanRead = 0x01,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: describes writable property
|
||||
/// </summary>
|
||||
CanWrite = 0x02,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: if flag is set, then index should be used to read/write multiple properties that share the same property identifier
|
||||
/// </summary>
|
||||
Indexed = 0x04
|
||||
}
|
||||
45
RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs
Normal file
45
RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains a list of all possible session states
|
||||
/// </summary>
|
||||
public enum CorsairSessionState
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: dummy value
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: client not initialized or client closed connection (initial state)
|
||||
/// </summary>
|
||||
Closed = 1,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: client initiated connection but not connected yet
|
||||
/// </summary>
|
||||
Connecting = 2,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: server did not respond, sdk will try again
|
||||
/// </summary>
|
||||
Timeout = 3,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: server did not allow connection
|
||||
/// </summary>
|
||||
ConnectionRefused = 4,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: server closed connection
|
||||
/// </summary>
|
||||
ConnectionLost = 5,
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: successfully connected
|
||||
/// </summary>
|
||||
Connected = 6
|
||||
};
|
||||
34
RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs
Normal file
34
RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair fan.
|
||||
/// </summary>
|
||||
public class CorsairFanRGBDevice : CorsairRGBDevice<CorsairFanRGBDeviceInfo>, IFan
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairFanRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the fan.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairFanRGBDevice(CorsairFanRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateFanMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
28
RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs
Normal file
28
RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairFanRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairFanRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Fan, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairFanRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName)
|
||||
: base(RGBDeviceType.Fan, nativeInfo, ledCount, ledOffset, modelName)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -13,7 +13,8 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private int _deviceIndex;
|
||||
private readonly _CorsairDeviceInfo _device;
|
||||
private readonly nint _colorPtr;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -24,10 +25,12 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
/// </summary>
|
||||
/// <param name="updateTrigger">The update trigger used by this queue.</param>
|
||||
/// <param name="deviceIndex">The index used to identify the device.</param>
|
||||
public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIndex)
|
||||
internal CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, _CorsairDeviceInfo device)
|
||||
: base(updateTrigger)
|
||||
{
|
||||
this._deviceIndex = deviceIndex;
|
||||
this._device = device;
|
||||
|
||||
_colorPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairLedColor>() * device.ledCount);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -35,28 +38,29 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override unsafe void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length);
|
||||
IntPtr addPtr = new(ptr.ToInt64());
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length);
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
_CorsairLedColor corsairColor = new()
|
||||
{
|
||||
ledId = (int)key,
|
||||
r = color.GetR(),
|
||||
g = color.GetG(),
|
||||
b = color.GetB()
|
||||
};
|
||||
|
||||
Marshal.StructureToPtr(corsairColor, addPtr, false);
|
||||
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
||||
(object id, Color color) = dataSet[i];
|
||||
(byte a, byte r, byte g, byte b) = color.GetRGBBytes();
|
||||
colors[i] = new _CorsairLedColor((CorsairLedId)id, r, g, b, a);
|
||||
}
|
||||
|
||||
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
|
||||
_CUESDK.CorsairSetLedsColorsFlushBuffer();
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr);
|
||||
if (error != CorsairError.Success)
|
||||
throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
Marshal.FreeHGlobal(_colorPtr);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
54
RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs
Normal file
54
RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public readonly struct CorsairLedId : IComparable<CorsairLedId>, IEquatable<CorsairLedId>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public readonly uint Id;
|
||||
|
||||
public CorsairLedGroup Group => (CorsairLedGroup)(Id >> 16);
|
||||
public uint Index => Id & 0x0000FFFF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public CorsairLedId(uint id)
|
||||
{
|
||||
this.Id = id;
|
||||
}
|
||||
|
||||
public CorsairLedId(CorsairLedGroup group, CorsairLedIdKeyboard id)
|
||||
: this(group, (int)id)
|
||||
{ }
|
||||
|
||||
public CorsairLedId(CorsairLedGroup group, int index)
|
||||
{
|
||||
Id = (((uint)group) << 16) | (uint)index;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public int CompareTo(CorsairLedId other) => Id.CompareTo(other.Id);
|
||||
|
||||
public bool Equals(CorsairLedId other) => Id == other.Id;
|
||||
|
||||
public override bool Equals(object? obj) => obj is CorsairLedId other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Id.GetHashCode();
|
||||
|
||||
public static bool operator ==(CorsairLedId left, CorsairLedId right) => left.Id == right.Id;
|
||||
public static bool operator !=(CorsairLedId left, CorsairLedId right) => !(left == right);
|
||||
public static bool operator <(CorsairLedId left, CorsairLedId right) => left.Id < right.Id;
|
||||
public static bool operator <=(CorsairLedId left, CorsairLedId right) => left.Id <= right.Id;
|
||||
public static bool operator >(CorsairLedId left, CorsairLedId right) => left.Id > right.Id;
|
||||
public static bool operator >=(CorsairLedId left, CorsairLedId right) => left.Id >= right.Id;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Managed wrapper for CorsairProtocolDetails.
|
||||
/// </summary>
|
||||
public class CorsairProtocolDetails
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// String containing version of SDK(like "1.0.0.1").
|
||||
/// Always contains valid value even if there was no CUE found.
|
||||
/// </summary>
|
||||
public string? SdkVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// String containing version of CUE(like "1.0.0.1") or NULL if CUE was not found.
|
||||
/// </summary>
|
||||
public string? ServerVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Integer that specifies version of protocol that is implemented by current SDK.
|
||||
/// Numbering starts from 1.
|
||||
/// Always contains valid value even if there was no CUE found.
|
||||
/// </summary>
|
||||
public int SdkProtocolVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Integer that specifies version of protocol that is implemented by CUE.
|
||||
/// Numbering starts from 1.
|
||||
/// If CUE was not found then this value will be 0.
|
||||
/// </summary>
|
||||
public int ServerProtocolVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client.
|
||||
/// </summary>
|
||||
public bool BreakingChanges { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed CorsairProtocolDetails.
|
||||
/// </summary>
|
||||
/// <param name="nativeDetails">The native CorsairProtocolDetails-struct</param>
|
||||
internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails)
|
||||
{
|
||||
this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion);
|
||||
this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion);
|
||||
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
|
||||
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
|
||||
this.BreakingChanges = nativeDetails.breakingChanges != 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
@ -17,7 +17,7 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
|
||||
/// <summary>
|
||||
/// Gets the mapping of <see cref="LedId"/> to <see cref="CorsairLedId"/> used to update the LEDs of this device.
|
||||
/// </summary>
|
||||
protected LedMapping<CorsairLedId> Mapping { get; }
|
||||
protected LedMapping<CorsairLedId> Mapping { get; private set; } = LedMapping<CorsairLedId>.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -29,48 +29,41 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
|
||||
/// <param name="info">The generic information provided by CUE for the device.</param>
|
||||
/// <param name="mapping">The mapping <see cref="LedId"/> to <see cref="CorsairLedId"/> used to update the LEDs of this device.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
protected CorsairRGBDevice(TDeviceInfo info, LedMapping<CorsairLedId> mapping, CorsairDeviceUpdateQueue updateQueue)
|
||||
protected CorsairRGBDevice(TDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{
|
||||
this.Mapping = mapping;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
void ICorsairRGBDevice.Initialize() => InitializeLayout();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the LEDs of the device based on the data provided by the SDK.
|
||||
/// </summary>
|
||||
protected virtual void InitializeLayout()
|
||||
{
|
||||
_CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
|
||||
if (nativeLedPositions == null) return;
|
||||
CorsairError error = _CUESDK.CorsairGetLedPositions(DeviceInfo.DeviceId, out _CorsairLedPosition[] ledPositions);
|
||||
if (error != CorsairError.Success)
|
||||
throw new RGBDeviceException($"Failed to load device '{DeviceInfo.DeviceId}'. (ErrorCode: {error})");
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
IntPtr ptr = nativeLedPositions.pLedPosition;
|
||||
List<_CorsairLedPosition> deviceLeds = ledPositions.Skip(DeviceInfo.LedOffset).Take(DeviceInfo.LedCount).ToList();
|
||||
|
||||
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
||||
Mapping = CreateMapping(deviceLeds.Select(x => new CorsairLedId(x.id)));
|
||||
|
||||
foreach (_CorsairLedPosition ledPosition in deviceLeds)
|
||||
{
|
||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||
if (ledPosition == null)
|
||||
{
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
LedId ledId = Mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
|
||||
LedId ledId = Mapping.TryGetValue(new CorsairLedId(ledPosition.id), out LedId id) ? id : LedId.Invalid;
|
||||
Rectangle rectangle = ledPosition.ToRectangle();
|
||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid;
|
||||
protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : new CorsairLedId(0);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
@ -19,11 +17,6 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
||||
/// </summary>
|
||||
public CorsairDeviceType CorsairDeviceType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
public int CorsairDeviceIndex { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBDeviceType DeviceType { get; }
|
||||
|
||||
@ -44,11 +37,16 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
||||
|
||||
/// <inheritdoc />
|
||||
public object? LayoutMetadata { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of LEDs this device contains.
|
||||
/// </summary>
|
||||
public int LedCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
|
||||
/// Gets the offset used to access the LEDs of this device.
|
||||
/// </summary>
|
||||
public CorsairDeviceCaps CapsMask { get; }
|
||||
internal int LedOffset { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -60,14 +58,14 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
||||
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.</param>
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
|
||||
internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
{
|
||||
this.CorsairDeviceIndex = deviceIndex;
|
||||
this.DeviceType = deviceType;
|
||||
this.CorsairDeviceType = nativeInfo.type;
|
||||
this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
|
||||
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
||||
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
||||
this.Model = nativeInfo.model == null ? string.Empty : Regex.Replace(nativeInfo.model ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
|
||||
this.DeviceId = nativeInfo.id ?? string.Empty;
|
||||
this.LedCount = ledCount;
|
||||
this.LedOffset = ledOffset;
|
||||
|
||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||
}
|
||||
@ -79,14 +77,14 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
/// <param name="modelName">The name of the device-model (overwrites the one provided with the device info).</param>
|
||||
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName)
|
||||
internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName)
|
||||
{
|
||||
this.CorsairDeviceIndex = deviceIndex;
|
||||
this.DeviceType = deviceType;
|
||||
this.CorsairDeviceType = nativeInfo.type;
|
||||
this.Model = modelName;
|
||||
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
||||
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
||||
this.DeviceId = nativeInfo.id ?? string.Empty;
|
||||
this.LedCount = ledCount;
|
||||
this.LedOffset = ledOffset;
|
||||
|
||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||
}
|
||||
|
||||
@ -1,302 +1,210 @@
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <summary>
|
||||
/// Contains mappings for <see cref="LedId"/> to <see cref="CorsairLedId"/>.
|
||||
/// </summary>
|
||||
public static class LedMappings
|
||||
internal static class LedMappings
|
||||
{
|
||||
static LedMappings()
|
||||
#region Constants
|
||||
|
||||
private static LedMapping<CorsairLedId> KEYBOARD_MAPPING => new()
|
||||
{
|
||||
for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++)
|
||||
GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i);
|
||||
{ LedId.Invalid, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Invalid) },
|
||||
{ LedId.Keyboard_Escape, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Escape) },
|
||||
{ LedId.Keyboard_F1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F1) },
|
||||
{ LedId.Keyboard_F2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F2) },
|
||||
{ LedId.Keyboard_F3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F3) },
|
||||
{ LedId.Keyboard_F4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F4) },
|
||||
{ LedId.Keyboard_F5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F5) },
|
||||
{ LedId.Keyboard_F6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F6) },
|
||||
{ LedId.Keyboard_F7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F7) },
|
||||
{ LedId.Keyboard_F8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F8) },
|
||||
{ LedId.Keyboard_F9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F9) },
|
||||
{ LedId.Keyboard_F10, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F10) },
|
||||
{ LedId.Keyboard_F11, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F11) },
|
||||
{ LedId.Keyboard_GraveAccentAndTilde, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.GraveAccentAndTilde) },
|
||||
{ LedId.Keyboard_1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.One) },
|
||||
{ LedId.Keyboard_2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Two) },
|
||||
{ LedId.Keyboard_3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Three) },
|
||||
{ LedId.Keyboard_4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Four) },
|
||||
{ LedId.Keyboard_5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Five) },
|
||||
{ LedId.Keyboard_6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Six) },
|
||||
{ LedId.Keyboard_7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Seven) },
|
||||
{ LedId.Keyboard_8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Eight) },
|
||||
{ LedId.Keyboard_9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Nine) },
|
||||
{ LedId.Keyboard_0, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Zero) },
|
||||
{ LedId.Keyboard_MinusAndUnderscore, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.MinusAndUnderscore) },
|
||||
{ LedId.Keyboard_Tab, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Tab) },
|
||||
{ LedId.Keyboard_Q, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Q) },
|
||||
{ LedId.Keyboard_W, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.W) },
|
||||
{ LedId.Keyboard_E, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.E) },
|
||||
{ LedId.Keyboard_R, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.R) },
|
||||
{ LedId.Keyboard_T, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.T) },
|
||||
{ LedId.Keyboard_Y, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Y) },
|
||||
{ LedId.Keyboard_U, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.U) },
|
||||
{ LedId.Keyboard_I, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.I) },
|
||||
{ LedId.Keyboard_O, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.O) },
|
||||
{ LedId.Keyboard_P, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.P) },
|
||||
{ LedId.Keyboard_BracketLeft, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.BracketLeft) },
|
||||
{ LedId.Keyboard_CapsLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.CapsLock) },
|
||||
{ LedId.Keyboard_A, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.A) },
|
||||
{ LedId.Keyboard_S, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.S) },
|
||||
{ LedId.Keyboard_D, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.D) },
|
||||
{ LedId.Keyboard_F, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F) },
|
||||
{ LedId.Keyboard_G, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.G) },
|
||||
{ LedId.Keyboard_H, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.H) },
|
||||
{ LedId.Keyboard_J, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.J) },
|
||||
{ LedId.Keyboard_K, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.K) },
|
||||
{ LedId.Keyboard_L, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.L) },
|
||||
{ LedId.Keyboard_SemicolonAndColon, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.SemicolonAndColon) },
|
||||
{ LedId.Keyboard_ApostropheAndDoubleQuote, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ApostropheAndDoubleQuote) },
|
||||
{ LedId.Keyboard_LeftShift, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftShift) },
|
||||
{ LedId.Keyboard_NonUsBackslash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NonUsBackslash) },
|
||||
{ LedId.Keyboard_Z, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Z) },
|
||||
{ LedId.Keyboard_X, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.X) },
|
||||
{ LedId.Keyboard_C, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.C) },
|
||||
{ LedId.Keyboard_V, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.V) },
|
||||
{ LedId.Keyboard_B, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.B) },
|
||||
{ LedId.Keyboard_N, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.N) },
|
||||
{ LedId.Keyboard_M, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M) },
|
||||
{ LedId.Keyboard_CommaAndLessThan, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.CommaAndLessThan) },
|
||||
{ LedId.Keyboard_PeriodAndBiggerThan, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PeriodAndBiggerThan) },
|
||||
{ LedId.Keyboard_SlashAndQuestionMark, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.SlashAndQuestionMark) },
|
||||
{ LedId.Keyboard_LeftCtrl, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftCtrl) },
|
||||
{ LedId.Keyboard_LeftGui, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftGui) },
|
||||
{ LedId.Keyboard_LeftAlt, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftAlt) },
|
||||
{ LedId.Keyboard_Lang2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Lang2) },
|
||||
{ LedId.Keyboard_Space, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Space) },
|
||||
{ LedId.Keyboard_Lang1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Lang1) },
|
||||
{ LedId.Keyboard_International2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International2) },
|
||||
{ LedId.Keyboard_RightAlt, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightAlt) },
|
||||
{ LedId.Keyboard_RightGui, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightGui) },
|
||||
{ LedId.Keyboard_Application, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Application) },
|
||||
{ LedId.Keyboard_Brightness, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Brightness) },
|
||||
{ LedId.Keyboard_F12, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F12) },
|
||||
{ LedId.Keyboard_PrintScreen, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PrintScreen) },
|
||||
{ LedId.Keyboard_ScrollLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScrollLock) },
|
||||
{ LedId.Keyboard_PauseBreak, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PauseBreak) },
|
||||
{ LedId.Keyboard_Insert, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Insert) },
|
||||
{ LedId.Keyboard_Home, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Home) },
|
||||
{ LedId.Keyboard_PageUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PageUp) },
|
||||
{ LedId.Keyboard_BracketRight, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.BracketRight) },
|
||||
{ LedId.Keyboard_Backslash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Backslash) },
|
||||
{ LedId.Keyboard_NonUsTilde, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NonUsTilde) },
|
||||
{ LedId.Keyboard_Enter, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Enter) },
|
||||
{ LedId.Keyboard_International1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International1) },
|
||||
{ LedId.Keyboard_EqualsAndPlus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.EqualsAndPlus) },
|
||||
{ LedId.Keyboard_International3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International3) },
|
||||
{ LedId.Keyboard_Backspace, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Backspace) },
|
||||
{ LedId.Keyboard_Delete, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Delete) },
|
||||
{ LedId.Keyboard_End, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.End) },
|
||||
{ LedId.Keyboard_PageDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PageDown) },
|
||||
{ LedId.Keyboard_RightShift, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightShift) },
|
||||
{ LedId.Keyboard_RightCtrl, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightCtrl) },
|
||||
{ LedId.Keyboard_ArrowUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.UpArrow) },
|
||||
{ LedId.Keyboard_ArrowLeft, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftArrow) },
|
||||
{ LedId.Keyboard_ArrowDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.DownArrow) },
|
||||
{ LedId.Keyboard_ArrowRight, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightArrow) },
|
||||
{ LedId.Keyboard_WinLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.WinLock) },
|
||||
{ LedId.Keyboard_MediaMute, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Mute) },
|
||||
{ LedId.Keyboard_MediaStop, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Stop) },
|
||||
{ LedId.Keyboard_MediaPreviousTrack, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScanPreviousTrack) },
|
||||
{ LedId.Keyboard_MediaPlay, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PlayPause) },
|
||||
{ LedId.Keyboard_MediaNextTrack, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScanNextTrack) },
|
||||
{ LedId.Keyboard_NumLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NumLock) },
|
||||
{ LedId.Keyboard_NumSlash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadSlash) },
|
||||
{ LedId.Keyboard_NumAsterisk, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadAsterisk) },
|
||||
{ LedId.Keyboard_NumMinus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadMinus) },
|
||||
{ LedId.Keyboard_NumPlus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadPlus) },
|
||||
{ LedId.Keyboard_NumEnter, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadEnter) },
|
||||
{ LedId.Keyboard_Num7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad7) },
|
||||
{ LedId.Keyboard_Num8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad8) },
|
||||
{ LedId.Keyboard_Num9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad9) },
|
||||
{ LedId.Keyboard_NumComma, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadComma) },
|
||||
{ LedId.Keyboard_Num4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad4) },
|
||||
{ LedId.Keyboard_Num5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad5) },
|
||||
{ LedId.Keyboard_Num6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad6) },
|
||||
{ LedId.Keyboard_Num1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad1) },
|
||||
{ LedId.Keyboard_Num2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad2) },
|
||||
{ LedId.Keyboard_Num3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad3) },
|
||||
{ LedId.Keyboard_Num0, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad0) },
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadPeriodAndDelete) },
|
||||
{ LedId.Keyboard_MediaVolumeUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.VolumeUp) },
|
||||
{ LedId.Keyboard_MediaVolumeDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.VolumeDown) },
|
||||
{ LedId.Keyboard_MacroRecording, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.MR) },
|
||||
{ LedId.Keyboard_Macro1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M1) },
|
||||
{ LedId.Keyboard_Macro2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M2) },
|
||||
{ LedId.Keyboard_Macro3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M3) },
|
||||
{ LedId.Keyboard_International5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International5) },
|
||||
{ LedId.Keyboard_International4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International4) },
|
||||
{ LedId.Keyboard_LedProgramming, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LedProgramming) },
|
||||
{ LedId.Keyboard_Function, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Fn) }
|
||||
};
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++)
|
||||
HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i);
|
||||
#endregion
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++)
|
||||
Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i);
|
||||
#region Methods
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++)
|
||||
Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i);
|
||||
internal static LedMapping<CorsairLedId> CreateFanMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Fan1);
|
||||
internal static LedMapping<CorsairLedId> CreateCoolerMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Cooler1);
|
||||
internal static LedMapping<CorsairLedId> CreateLedStripMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.LedStripe1);
|
||||
internal static LedMapping<CorsairLedId> CreateGraphicsCardMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.GraphicsCard1);
|
||||
internal static LedMapping<CorsairLedId> CreateHeadsetStandMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.HeadsetStand1);
|
||||
internal static LedMapping<CorsairLedId> CreateMainboardMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Mainboard1);
|
||||
internal static LedMapping<CorsairLedId> CreateMemoryMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.DRAM1);
|
||||
internal static LedMapping<CorsairLedId> CreateMousepadMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Mousepad1);
|
||||
internal static LedMapping<CorsairLedId> CreateHeadsetMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Headset1);
|
||||
internal static LedMapping<CorsairLedId> CreateMouseMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Mouse1);
|
||||
internal static LedMapping<CorsairLedId> CreateUnknownMapping(IEnumerable<CorsairLedId> ids) => CreateMapping(ids, LedId.Unknown1);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++)
|
||||
Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i);
|
||||
internal static LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids, LedId referenceId)
|
||||
{
|
||||
LedMapping<CorsairLedId> mapping = new();
|
||||
int counter = 0;
|
||||
foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x))
|
||||
mapping.Add(referenceId + counter++, corsairLedId);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.OemLed100 - CorsairLedId.OemLed1); i++)
|
||||
Keyboard.Add(LedId.Custom1 + i, CorsairLedId.OemLed1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.OemLed250 - CorsairLedId.OemLed101); i++)
|
||||
Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i);
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for graphics cards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> GraphicsCard { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for headsets.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> HeadsetStand { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mainboards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mainboard { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for memory.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Memory { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mousepads.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mousepad { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for headsets.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Headset { get; } = new()
|
||||
internal static LedMapping<CorsairLedId> CreateKeyboardMapping(IEnumerable<CorsairLedId> ids)
|
||||
{
|
||||
{ LedId.Headset1, CorsairLedId.LeftLogo },
|
||||
{ LedId.Headset2, CorsairLedId.RightLogo },
|
||||
};
|
||||
Dictionary<CorsairLedGroup, int> groupCounter = new()
|
||||
{
|
||||
[CorsairLedGroup.KeyboardOem] = 0,
|
||||
[CorsairLedGroup.KeyboardGKeys] = 0,
|
||||
[CorsairLedGroup.KeyboardEdge] = 0,
|
||||
[CorsairLedGroup.Keyboard] = 0 // Workaround for unknown keys
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mice.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mouse { get; } = new()
|
||||
{
|
||||
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||
{ LedId.Mouse2, CorsairLedId.B2 },
|
||||
{ LedId.Mouse3, CorsairLedId.B3 },
|
||||
{ LedId.Mouse4, CorsairLedId.B4 },
|
||||
{ LedId.Mouse5, CorsairLedId.B5 },
|
||||
{ LedId.Mouse6, CorsairLedId.B6 },
|
||||
{ LedId.Mouse7, CorsairLedId.B7 },
|
||||
{ LedId.Mouse8, CorsairLedId.B8 },
|
||||
{ LedId.Mouse9, CorsairLedId.B9 },
|
||||
{ LedId.Mouse10, CorsairLedId.B10 },
|
||||
{ LedId.Mouse11, CorsairLedId.B11 },
|
||||
{ LedId.Mouse12, CorsairLedId.B12 },
|
||||
{ LedId.Mouse13, CorsairLedId.B13 },
|
||||
{ LedId.Mouse14, CorsairLedId.B14 },
|
||||
{ LedId.Mouse15, CorsairLedId.B15 },
|
||||
{ LedId.Mouse16, CorsairLedId.B16 },
|
||||
{ LedId.Mouse17, CorsairLedId.B17 },
|
||||
{ LedId.Mouse18, CorsairLedId.B18 },
|
||||
{ LedId.Mouse19, CorsairLedId.B19 },
|
||||
{ LedId.Mouse20, CorsairLedId.B20 },
|
||||
};
|
||||
LedMapping<CorsairLedId> mapping = KEYBOARD_MAPPING;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for keyboards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Keyboard { get; } = new()
|
||||
{
|
||||
{ LedId.Invalid, CorsairLedId.Invalid },
|
||||
{ LedId.Logo, CorsairLedId.Logo },
|
||||
{ LedId.Keyboard_Escape, CorsairLedId.Escape },
|
||||
{ LedId.Keyboard_F1, CorsairLedId.F1 },
|
||||
{ LedId.Keyboard_F2, CorsairLedId.F2 },
|
||||
{ LedId.Keyboard_F3, CorsairLedId.F3 },
|
||||
{ LedId.Keyboard_F4, CorsairLedId.F4 },
|
||||
{ LedId.Keyboard_F5, CorsairLedId.F5 },
|
||||
{ LedId.Keyboard_F6, CorsairLedId.F6 },
|
||||
{ LedId.Keyboard_F7, CorsairLedId.F7 },
|
||||
{ LedId.Keyboard_F8, CorsairLedId.F8 },
|
||||
{ LedId.Keyboard_F9, CorsairLedId.F9 },
|
||||
{ LedId.Keyboard_F10, CorsairLedId.F10 },
|
||||
{ LedId.Keyboard_F11, CorsairLedId.F11 },
|
||||
{ LedId.Keyboard_GraveAccentAndTilde, CorsairLedId.GraveAccentAndTilde },
|
||||
{ LedId.Keyboard_1, CorsairLedId.D1 },
|
||||
{ LedId.Keyboard_2, CorsairLedId.D2 },
|
||||
{ LedId.Keyboard_3, CorsairLedId.D3 },
|
||||
{ LedId.Keyboard_4, CorsairLedId.D4 },
|
||||
{ LedId.Keyboard_5, CorsairLedId.D5 },
|
||||
{ LedId.Keyboard_6, CorsairLedId.D6 },
|
||||
{ LedId.Keyboard_7, CorsairLedId.D7 },
|
||||
{ LedId.Keyboard_8, CorsairLedId.D8 },
|
||||
{ LedId.Keyboard_9, CorsairLedId.D9 },
|
||||
{ LedId.Keyboard_0, CorsairLedId.D0 },
|
||||
{ LedId.Keyboard_MinusAndUnderscore, CorsairLedId.MinusAndUnderscore },
|
||||
{ LedId.Keyboard_Tab, CorsairLedId.Tab },
|
||||
{ LedId.Keyboard_Q, CorsairLedId.Q },
|
||||
{ LedId.Keyboard_W, CorsairLedId.W },
|
||||
{ LedId.Keyboard_E, CorsairLedId.E },
|
||||
{ LedId.Keyboard_R, CorsairLedId.R },
|
||||
{ LedId.Keyboard_T, CorsairLedId.T },
|
||||
{ LedId.Keyboard_Y, CorsairLedId.Y },
|
||||
{ LedId.Keyboard_U, CorsairLedId.U },
|
||||
{ LedId.Keyboard_I, CorsairLedId.I },
|
||||
{ LedId.Keyboard_O, CorsairLedId.O },
|
||||
{ LedId.Keyboard_P, CorsairLedId.P },
|
||||
{ LedId.Keyboard_BracketLeft, CorsairLedId.BracketLeft },
|
||||
{ LedId.Keyboard_CapsLock, CorsairLedId.CapsLock },
|
||||
{ LedId.Keyboard_A, CorsairLedId.A },
|
||||
{ LedId.Keyboard_S, CorsairLedId.S },
|
||||
{ LedId.Keyboard_D, CorsairLedId.D },
|
||||
{ LedId.Keyboard_F, CorsairLedId.F },
|
||||
{ LedId.Keyboard_G, CorsairLedId.G },
|
||||
{ LedId.Keyboard_H, CorsairLedId.H },
|
||||
{ LedId.Keyboard_J, CorsairLedId.J },
|
||||
{ LedId.Keyboard_K, CorsairLedId.K },
|
||||
{ LedId.Keyboard_L, CorsairLedId.L },
|
||||
{ LedId.Keyboard_SemicolonAndColon, CorsairLedId.SemicolonAndColon },
|
||||
{ LedId.Keyboard_ApostropheAndDoubleQuote, CorsairLedId.ApostropheAndDoubleQuote },
|
||||
{ LedId.Keyboard_LeftShift, CorsairLedId.LeftShift },
|
||||
{ LedId.Keyboard_NonUsBackslash, CorsairLedId.NonUsBackslash },
|
||||
{ LedId.Keyboard_Z, CorsairLedId.Z },
|
||||
{ LedId.Keyboard_X, CorsairLedId.X },
|
||||
{ LedId.Keyboard_C, CorsairLedId.C },
|
||||
{ LedId.Keyboard_V, CorsairLedId.V },
|
||||
{ LedId.Keyboard_B, CorsairLedId.B },
|
||||
{ LedId.Keyboard_N, CorsairLedId.N },
|
||||
{ LedId.Keyboard_M, CorsairLedId.M },
|
||||
{ LedId.Keyboard_CommaAndLessThan, CorsairLedId.CommaAndLessThan },
|
||||
{ LedId.Keyboard_PeriodAndBiggerThan, CorsairLedId.PeriodAndBiggerThan },
|
||||
{ LedId.Keyboard_SlashAndQuestionMark, CorsairLedId.SlashAndQuestionMark },
|
||||
{ LedId.Keyboard_LeftCtrl, CorsairLedId.LeftCtrl },
|
||||
{ LedId.Keyboard_LeftGui, CorsairLedId.LeftGui },
|
||||
{ LedId.Keyboard_LeftAlt, CorsairLedId.LeftAlt },
|
||||
{ LedId.Keyboard_Lang2, CorsairLedId.Lang2 },
|
||||
{ LedId.Keyboard_Space, CorsairLedId.Space },
|
||||
{ LedId.Keyboard_Lang1, CorsairLedId.Lang1 },
|
||||
{ LedId.Keyboard_International2, CorsairLedId.International2 },
|
||||
{ LedId.Keyboard_RightAlt, CorsairLedId.RightAlt },
|
||||
{ LedId.Keyboard_RightGui, CorsairLedId.RightGui },
|
||||
{ LedId.Keyboard_Application, CorsairLedId.Application },
|
||||
{ LedId.Keyboard_Brightness, CorsairLedId.Brightness },
|
||||
{ LedId.Keyboard_F12, CorsairLedId.F12 },
|
||||
{ LedId.Keyboard_PrintScreen, CorsairLedId.PrintScreen },
|
||||
{ LedId.Keyboard_ScrollLock, CorsairLedId.ScrollLock },
|
||||
{ LedId.Keyboard_PauseBreak, CorsairLedId.PauseBreak },
|
||||
{ LedId.Keyboard_Insert, CorsairLedId.Insert },
|
||||
{ LedId.Keyboard_Home, CorsairLedId.Home },
|
||||
{ LedId.Keyboard_PageUp, CorsairLedId.PageUp },
|
||||
{ LedId.Keyboard_BracketRight, CorsairLedId.BracketRight },
|
||||
{ LedId.Keyboard_Backslash, CorsairLedId.Backslash },
|
||||
{ LedId.Keyboard_NonUsTilde, CorsairLedId.NonUsTilde },
|
||||
{ LedId.Keyboard_Enter, CorsairLedId.Enter },
|
||||
{ LedId.Keyboard_International1, CorsairLedId.International1 },
|
||||
{ LedId.Keyboard_EqualsAndPlus, CorsairLedId.EqualsAndPlus },
|
||||
{ LedId.Keyboard_International3, CorsairLedId.International3 },
|
||||
{ LedId.Keyboard_Backspace, CorsairLedId.Backspace },
|
||||
{ LedId.Keyboard_Delete, CorsairLedId.Delete },
|
||||
{ LedId.Keyboard_End, CorsairLedId.End },
|
||||
{ LedId.Keyboard_PageDown, CorsairLedId.PageDown },
|
||||
{ LedId.Keyboard_RightShift, CorsairLedId.RightShift },
|
||||
{ LedId.Keyboard_RightCtrl, CorsairLedId.RightCtrl },
|
||||
{ LedId.Keyboard_ArrowUp, CorsairLedId.UpArrow },
|
||||
{ LedId.Keyboard_ArrowLeft, CorsairLedId.LeftArrow },
|
||||
{ LedId.Keyboard_ArrowDown, CorsairLedId.DownArrow },
|
||||
{ LedId.Keyboard_ArrowRight, CorsairLedId.RightArrow },
|
||||
{ LedId.Keyboard_WinLock, CorsairLedId.WinLock },
|
||||
{ LedId.Keyboard_MediaMute, CorsairLedId.Mute },
|
||||
{ LedId.Keyboard_MediaStop, CorsairLedId.Stop },
|
||||
{ LedId.Keyboard_MediaPreviousTrack, CorsairLedId.ScanPreviousTrack },
|
||||
{ LedId.Keyboard_MediaPlay, CorsairLedId.PlayPause },
|
||||
{ LedId.Keyboard_MediaNextTrack, CorsairLedId.ScanNextTrack },
|
||||
{ LedId.Keyboard_NumLock, CorsairLedId.NumLock },
|
||||
{ LedId.Keyboard_NumSlash, CorsairLedId.KeypadSlash },
|
||||
{ LedId.Keyboard_NumAsterisk, CorsairLedId.KeypadAsterisk },
|
||||
{ LedId.Keyboard_NumMinus, CorsairLedId.KeypadMinus },
|
||||
{ LedId.Keyboard_NumPlus, CorsairLedId.KeypadPlus },
|
||||
{ LedId.Keyboard_NumEnter, CorsairLedId.KeypadEnter },
|
||||
{ LedId.Keyboard_Num7, CorsairLedId.Keypad7 },
|
||||
{ LedId.Keyboard_Num8, CorsairLedId.Keypad8 },
|
||||
{ LedId.Keyboard_Num9, CorsairLedId.Keypad9 },
|
||||
{ LedId.Keyboard_NumComma, CorsairLedId.KeypadComma },
|
||||
{ LedId.Keyboard_Num4, CorsairLedId.Keypad4 },
|
||||
{ LedId.Keyboard_Num5, CorsairLedId.Keypad5 },
|
||||
{ LedId.Keyboard_Num6, CorsairLedId.Keypad6 },
|
||||
{ LedId.Keyboard_Num1, CorsairLedId.Keypad1 },
|
||||
{ LedId.Keyboard_Num2, CorsairLedId.Keypad2 },
|
||||
{ LedId.Keyboard_Num3, CorsairLedId.Keypad3 },
|
||||
{ LedId.Keyboard_Num0, CorsairLedId.Keypad0 },
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, CorsairLedId.KeypadPeriodAndDelete },
|
||||
{ LedId.Keyboard_Programmable1, CorsairLedId.G1 },
|
||||
{ LedId.Keyboard_Programmable2, CorsairLedId.G2 },
|
||||
{ LedId.Keyboard_Programmable3, CorsairLedId.G3 },
|
||||
{ LedId.Keyboard_Programmable4, CorsairLedId.G4 },
|
||||
{ LedId.Keyboard_Programmable5, CorsairLedId.G5 },
|
||||
{ LedId.Keyboard_Programmable6, CorsairLedId.G6 },
|
||||
{ LedId.Keyboard_Programmable7, CorsairLedId.G7 },
|
||||
{ LedId.Keyboard_Programmable8, CorsairLedId.G8 },
|
||||
{ LedId.Keyboard_Programmable9, CorsairLedId.G9 },
|
||||
{ LedId.Keyboard_Programmable10, CorsairLedId.G10 },
|
||||
{ LedId.Keyboard_MediaVolumeUp, CorsairLedId.VolumeUp },
|
||||
{ LedId.Keyboard_MediaVolumeDown, CorsairLedId.VolumeDown },
|
||||
{ LedId.Keyboard_MacroRecording, CorsairLedId.MR },
|
||||
{ LedId.Keyboard_Macro1, CorsairLedId.M1 },
|
||||
{ LedId.Keyboard_Macro2, CorsairLedId.M2 },
|
||||
{ LedId.Keyboard_Macro3, CorsairLedId.M3 },
|
||||
{ LedId.Keyboard_Programmable11, CorsairLedId.G11 },
|
||||
{ LedId.Keyboard_Programmable12, CorsairLedId.G12 },
|
||||
{ LedId.Keyboard_Programmable13, CorsairLedId.G13 },
|
||||
{ LedId.Keyboard_Programmable14, CorsairLedId.G14 },
|
||||
{ LedId.Keyboard_Programmable15, CorsairLedId.G15 },
|
||||
{ LedId.Keyboard_Programmable16, CorsairLedId.G16 },
|
||||
{ LedId.Keyboard_Programmable17, CorsairLedId.G17 },
|
||||
{ LedId.Keyboard_Programmable18, CorsairLedId.G18 },
|
||||
{ LedId.Keyboard_International5, CorsairLedId.International5 },
|
||||
{ LedId.Keyboard_International4, CorsairLedId.International4 },
|
||||
{ LedId.Keyboard_Profile, CorsairLedId.Profile },
|
||||
{ LedId.Keyboard_LedProgramming, CorsairLedId.LedProgramming },
|
||||
{ LedId.Keyboard_Function, CorsairLedId.Fn },
|
||||
foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x).Where(x => x.Group != CorsairLedGroup.Keyboard))
|
||||
switch (corsairLedId.Group)
|
||||
{
|
||||
case CorsairLedGroup.KeyboardOem:
|
||||
mapping.Add(LedId.Keyboard_Custom1 + groupCounter[CorsairLedGroup.KeyboardOem]++, corsairLedId);
|
||||
break;
|
||||
|
||||
{ LedId.LedStripe1, CorsairLedId.Lightbar1 },
|
||||
{ LedId.LedStripe2, CorsairLedId.Lightbar2 },
|
||||
{ LedId.LedStripe3, CorsairLedId.Lightbar3 },
|
||||
{ LedId.LedStripe4, CorsairLedId.Lightbar4 },
|
||||
{ LedId.LedStripe5, CorsairLedId.Lightbar5 },
|
||||
{ LedId.LedStripe6, CorsairLedId.Lightbar6 },
|
||||
{ LedId.LedStripe7, CorsairLedId.Lightbar7 },
|
||||
{ LedId.LedStripe8, CorsairLedId.Lightbar8 },
|
||||
{ LedId.LedStripe9, CorsairLedId.Lightbar9 },
|
||||
{ LedId.LedStripe10, CorsairLedId.Lightbar10 },
|
||||
{ LedId.LedStripe11, CorsairLedId.Lightbar11 },
|
||||
{ LedId.LedStripe12, CorsairLedId.Lightbar12 },
|
||||
{ LedId.LedStripe13, CorsairLedId.Lightbar13 },
|
||||
{ LedId.LedStripe14, CorsairLedId.Lightbar14 },
|
||||
{ LedId.LedStripe15, CorsairLedId.Lightbar15 },
|
||||
{ LedId.LedStripe16, CorsairLedId.Lightbar16 },
|
||||
{ LedId.LedStripe17, CorsairLedId.Lightbar17 },
|
||||
{ LedId.LedStripe18, CorsairLedId.Lightbar18 },
|
||||
{ LedId.LedStripe19, CorsairLedId.Lightbar19 },
|
||||
{ LedId.LedStripe20, CorsairLedId.Lightbar20 },
|
||||
{ LedId.LedStripe21, CorsairLedId.Lightbar21 },
|
||||
{ LedId.LedStripe22, CorsairLedId.Lightbar22 },
|
||||
{ LedId.LedStripe23, CorsairLedId.Lightbar23 },
|
||||
{ LedId.LedStripe24, CorsairLedId.Lightbar24 },
|
||||
{ LedId.LedStripe25, CorsairLedId.Lightbar25 },
|
||||
{ LedId.LedStripe26, CorsairLedId.Lightbar26 },
|
||||
{ LedId.LedStripe27, CorsairLedId.Lightbar27 },
|
||||
{ LedId.LedStripe28, CorsairLedId.Lightbar28 },
|
||||
{ LedId.LedStripe29, CorsairLedId.Lightbar29 },
|
||||
{ LedId.LedStripe30, CorsairLedId.Lightbar30 },
|
||||
{ LedId.LedStripe31, CorsairLedId.Lightbar31 },
|
||||
{ LedId.LedStripe32, CorsairLedId.Lightbar32 },
|
||||
{ LedId.LedStripe33, CorsairLedId.Lightbar33 },
|
||||
{ LedId.LedStripe34, CorsairLedId.Lightbar34 },
|
||||
{ LedId.LedStripe35, CorsairLedId.Lightbar35 },
|
||||
{ LedId.LedStripe36, CorsairLedId.Lightbar36 },
|
||||
{ LedId.LedStripe37, CorsairLedId.Lightbar37 },
|
||||
{ LedId.LedStripe38, CorsairLedId.Lightbar38 },
|
||||
{ LedId.LedStripe39, CorsairLedId.Lightbar39 },
|
||||
{ LedId.LedStripe40, CorsairLedId.Lightbar40 },
|
||||
{ LedId.LedStripe41, CorsairLedId.Lightbar41 },
|
||||
{ LedId.LedStripe42, CorsairLedId.Lightbar42 },
|
||||
{ LedId.LedStripe43, CorsairLedId.Lightbar43 },
|
||||
{ LedId.LedStripe44, CorsairLedId.Lightbar44 },
|
||||
{ LedId.LedStripe45, CorsairLedId.Lightbar45 },
|
||||
{ LedId.LedStripe46, CorsairLedId.Lightbar46 },
|
||||
{ LedId.LedStripe47, CorsairLedId.Lightbar47 },
|
||||
{ LedId.LedStripe48, CorsairLedId.Lightbar48 },
|
||||
{ LedId.LedStripe49, CorsairLedId.Lightbar49 },
|
||||
{ LedId.LedStripe50, CorsairLedId.Lightbar50 },
|
||||
};
|
||||
case CorsairLedGroup.KeyboardGKeys:
|
||||
mapping.Add(LedId.Keyboard_Programmable1 + groupCounter[CorsairLedGroup.KeyboardGKeys]++, corsairLedId);
|
||||
break;
|
||||
|
||||
case CorsairLedGroup.KeyboardEdge:
|
||||
mapping.Add(LedId.LedStripe1 + groupCounter[CorsairLedGroup.KeyboardEdge]++, corsairLedId);
|
||||
break;
|
||||
|
||||
default:
|
||||
mapping.Add(LedId.Unknown1 + groupCounter[CorsairLedGroup.Keyboard]++, corsairLedId);
|
||||
break;
|
||||
}
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
@ -20,8 +21,14 @@ public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCard
|
||||
/// <param name="info">The specific information provided by CUE for the graphics card.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.GraphicsCard, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateGraphicsCardMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -15,13 +15,8 @@ public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairGraphicsCardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.GraphicsCard, nativeInfo)
|
||||
internal CorsairGraphicsCardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.GraphicsCard, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceI
|
||||
/// <param name="info">The specific information provided by CUE for the headset</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Headset, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateHeadsetMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -12,13 +12,8 @@ public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Headset, nativeInfo)
|
||||
internal CorsairHeadsetRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Headset, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStand
|
||||
/// <param name="info">The specific information provided by CUE for the headset stand</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.HeadsetStand, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateHeadsetStandMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -12,13 +12,8 @@ public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairHeadsetStandRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.HeadsetStand, nativeInfo)
|
||||
internal CorsairHeadsetStandRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.HeadsetStand, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -7,12 +8,25 @@ internal static class NativeExtensions
|
||||
{
|
||||
internal static Rectangle ToRectangle(this _CorsairLedPosition position)
|
||||
{
|
||||
//HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0.
|
||||
float width = position.width < 0.5f ? 10 : (float)position.width;
|
||||
float height = position.height < 0.5f ? 10 : (float)position.height;
|
||||
float posX = (float)position.left;
|
||||
float posY = (float)position.top;
|
||||
const float WIDTH = 10;
|
||||
const float HEIGHT = 10;
|
||||
float posX = (float)position.cx;
|
||||
float posY = (float)position.cy;
|
||||
|
||||
return new Rectangle(posX, posY, width, height);
|
||||
return new Rectangle(posX, posY, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
internal static T[] ToArray<T>(this nint ptr, int size)
|
||||
{
|
||||
int tSize = Marshal.SizeOf<T>();
|
||||
T[] array = new T[size];
|
||||
nint loopPtr = ptr;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
array[i] = Marshal.PtrToStructure<T>(loopPtr)!;
|
||||
loopPtr += tSize;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -26,8 +27,14 @@ public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDevic
|
||||
/// <param name="info">The specific information provided by CUE for the keyboard.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Keyboard, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateKeyboardMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -36,11 +36,12 @@ public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDevic
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Keyboard, nativeInfo)
|
||||
internal CorsairKeyboardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Keyboard, nativeInfo, ledCount, ledOffset)
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
||||
PhysicalLayout = (CorsairPhysicalKeyboardLayout)_CUESDK.ReadDevicePropertySimpleInt32(nativeInfo.id!, CorsairDevicePropertyId.PhysicalLayout);
|
||||
LogicalLayout = (CorsairLogicalKeyboardLayout)_CUESDK.ReadDevicePropertySimpleInt32(nativeInfo.id!, CorsairDevicePropertyId.LogicalLayout);
|
||||
|
||||
this.Layout = PhysicalLayout switch
|
||||
{
|
||||
CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI,
|
||||
|
||||
34
RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs
Normal file
34
RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair ledStrip.
|
||||
/// </summary>
|
||||
public class CorsairLedStripRGBDevice : CorsairRGBDevice<CorsairLedStripRGBDeviceInfo>, ILedStripe
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairLedStripRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the ledStrip.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairLedStripRGBDevice(CorsairLedStripRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateLedStripMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairLedStripRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairLedStripRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairLedStripRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName)
|
||||
: base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset, modelName)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDev
|
||||
/// <param name="info">The specific information provided by CUE for the memory.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mainboard, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateMainboardMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -15,13 +15,8 @@ public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMainboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mainboard, nativeInfo)
|
||||
internal CorsairMainboardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Mainboard, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInf
|
||||
/// <param name="info">The specific information provided by CUE for the memory.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Memory, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateMemoryMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -15,13 +15,13 @@ public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMemoryRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.DRAM, nativeInfo)
|
||||
internal CorsairMemoryRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.DRAM, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairMemoryRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName)
|
||||
: base(RGBDeviceType.DRAM, nativeInfo, ledCount, ledOffset, modelName)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>
|
||||
/// <param name="info">The specific information provided by CUE for the mouse</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mouse, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateMouseMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -9,28 +9,12 @@ namespace RGB.NET.Devices.Corsair;
|
||||
/// </summary>
|
||||
public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical layout of the mouse.
|
||||
/// </summary>
|
||||
public CorsairPhysicalMouseLayout PhysicalLayout { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mouse, nativeInfo)
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
||||
}
|
||||
internal CorsairMouseRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Mouse, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDevic
|
||||
/// <param name="info">The specific information provided by CUE for the mousepad</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mousepad, updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateMousepadMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -12,13 +12,8 @@ public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index if the <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo)
|
||||
internal CorsairMousepadRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Mousepad, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -11,12 +11,66 @@ using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
internal delegate void CorsairSessionStateChangedHandler(nint context, _CorsairSessionStateChanged eventData);
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal static class _CUESDK
|
||||
internal static unsafe class _CUESDK
|
||||
{
|
||||
#region Constants
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: small string length
|
||||
/// </summary>
|
||||
internal const int CORSAIR_STRING_SIZE_S = 64;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: medium string length
|
||||
/// </summary>
|
||||
internal const int CORSAIR_STRING_SIZE_M = 128;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: maximum level of layer’s priority that can be used in CorsairSetLayerPriority
|
||||
/// </summary>
|
||||
internal const int CORSAIR_LAYER_PRIORITY_MAX = 255;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: maximum number of devices to be discovered
|
||||
/// </summary>
|
||||
internal const int CORSAIR_DEVICE_COUNT_MAX = 64;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: maximum number of LEDs controlled by device
|
||||
/// </summary>
|
||||
internal const int CORSAIR_DEVICE_LEDCOUNT_MAX = 512;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
internal static bool IsConnected => SesionState == CorsairSessionState.Connected;
|
||||
internal static CorsairSessionState SesionState { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
internal static event EventHandler<CorsairSessionState>? SessionStateChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata)
|
||||
{
|
||||
SesionState = eventdata.state;
|
||||
SessionStateChanged?.Invoke(null, eventdata.state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Libary Management
|
||||
|
||||
private static IntPtr _handle = IntPtr.Zero;
|
||||
private static nint _handle = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the SDK.
|
||||
@ -29,7 +83,7 @@ internal static class _CUESDK
|
||||
|
||||
private static void LoadCUESDK()
|
||||
{
|
||||
if (_handle != IntPtr.Zero) return;
|
||||
if (_handle != 0) return;
|
||||
|
||||
List<string> possiblePathList = GetPossibleLibraryPaths().ToList();
|
||||
|
||||
@ -37,24 +91,31 @@ internal static class _CUESDK
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
if (!NativeLibrary.TryLoad(dllPath, out _handle))
|
||||
#if NET6_0
|
||||
#if NET6_0_OR_GREATER
|
||||
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
|
||||
#else
|
||||
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||
#endif
|
||||
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsBufferByDeviceIndex", out _corsairSetLedsColorsBufferByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsBufferByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsFlushBuffer", out _corsairSetLedsColorsFlushBufferPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsFlushBuffer'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedsColorsByDeviceIndex", out _corsairGetLedsColorsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedsColorsByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLayerPriority", out _corsairSetLayerPriorityPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLayerPriority'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceCount", out _corsairGetDeviceCountPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceCount'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceInfo", out _corsairGetDeviceInfoPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceInfo'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedIdForKeyName", out _corsairGetLedIdForKeyNamePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedIdForKeyName'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedPositionsByDeviceIndex", out _corsairGetLedPositionsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedPositionsByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairRequestControl", out _corsairRequestControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairRequestControl'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairReleaseControl", out _corsairReleaseControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairReleaseControl'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairPerformProtocolHandshake", out _corsairPerformProtocolHandshakePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairPerformProtocolHandshake'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLastError", out _corsairGetLastErrorPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLastError'");
|
||||
_corsairConnectPtr = (delegate* unmanaged[Cdecl]<CorsairSessionStateChangedHandler, nint, CorsairError>)LoadFunction("CorsairConnect");
|
||||
_corsairGetSessionDetails = (delegate* unmanaged[Cdecl]<nint, CorsairError>)LoadFunction("CorsairGetSessionDetails");
|
||||
_corsairDisconnect = (delegate* unmanaged[Cdecl]<CorsairError>)LoadFunction("CorsairDisconnect");
|
||||
_corsairGetDevices = (delegate* unmanaged[Cdecl]<_CorsairDeviceFilter, int, nint, out int, CorsairError>)LoadFunction("CorsairGetDevices");
|
||||
_corsairGetDeviceInfo = (delegate* unmanaged[Cdecl]<string, _CorsairDeviceInfo, CorsairError>)LoadFunction("CorsairGetDeviceInfo");
|
||||
_corsairGetLedPositions = (delegate* unmanaged[Cdecl]<string, int, nint, out int, CorsairError>)LoadFunction("CorsairGetLedPositions");
|
||||
_corsairSetLedColors = (delegate* unmanaged[Cdecl]<string, int, nint, CorsairError>)LoadFunction("CorsairSetLedColors");
|
||||
_corsairSetLayerPriority = (delegate* unmanaged[Cdecl]<uint, CorsairError>)LoadFunction("CorsairSetLayerPriority");
|
||||
_corsairGetLedLuidForKeyName = (delegate* unmanaged[Cdecl]<string, char, out uint, CorsairError>)LoadFunction("CorsairGetLedLuidForKeyName");
|
||||
_corsairRequestControl = (delegate* unmanaged[Cdecl]<string, CorsairAccessLevel, CorsairError>)LoadFunction("CorsairRequestControl");
|
||||
_corsairReleaseControl = (delegate* unmanaged[Cdecl]<string, CorsairError>)LoadFunction("CorsairReleaseControl");
|
||||
_getDevicePropertyInfo = (delegate* unmanaged[Cdecl]<string, CorsairDevicePropertyId, uint, out CorsairDataType, out CorsairPropertyFlag, CorsairError>)LoadFunction("CorsairGetDevicePropertyInfo");
|
||||
_readDeviceProperty = (delegate* unmanaged[Cdecl]<string, CorsairDevicePropertyId, uint, nint, CorsairError>)LoadFunction("CorsairReadDeviceProperty");
|
||||
}
|
||||
|
||||
private static nint LoadFunction(string function)
|
||||
{
|
||||
if (!NativeLibrary.TryGetExport(_handle, function, out nint ptr)) throw new RGBDeviceException($"Failed to load Corsair function '{function}'");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetPossibleLibraryPaths()
|
||||
@ -71,23 +132,24 @@ internal static class _CUESDK
|
||||
|
||||
internal static void UnloadCUESDK()
|
||||
{
|
||||
if (_handle == IntPtr.Zero) return;
|
||||
if (_handle == 0) return;
|
||||
|
||||
_corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero;
|
||||
_corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairSetLayerPriorityPointer = IntPtr.Zero;
|
||||
_corsairGetDeviceCountPointer = IntPtr.Zero;
|
||||
_corsairGetDeviceInfoPointer = IntPtr.Zero;
|
||||
_corsairGetLedIdForKeyNamePointer = IntPtr.Zero;
|
||||
_corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairRequestControlPointer = IntPtr.Zero;
|
||||
_corsairReleaseControlPointer = IntPtr.Zero;
|
||||
_corsairPerformProtocolHandshakePointer = IntPtr.Zero;
|
||||
_corsairGetLastErrorPointer = IntPtr.Zero;
|
||||
_corsairConnectPtr = null;
|
||||
_corsairGetSessionDetails = null;
|
||||
_corsairDisconnect = null;
|
||||
_corsairGetDevices = null;
|
||||
_corsairGetDeviceInfo = null;
|
||||
_corsairGetLedPositions = null;
|
||||
_corsairSetLedColors = null;
|
||||
_corsairSetLayerPriority = null;
|
||||
_corsairGetLedLuidForKeyName = null;
|
||||
_corsairRequestControl = null;
|
||||
_corsairReleaseControl = null;
|
||||
_getDevicePropertyInfo = null;
|
||||
_readDeviceProperty = null;
|
||||
|
||||
NativeLibrary.Free(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
_handle = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -96,97 +158,182 @@ internal static class _CUESDK
|
||||
|
||||
#region Pointers
|
||||
|
||||
private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
||||
private static IntPtr _corsairSetLedsColorsFlushBufferPointer;
|
||||
private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer;
|
||||
private static IntPtr _corsairSetLayerPriorityPointer;
|
||||
private static IntPtr _corsairGetDeviceCountPointer;
|
||||
private static IntPtr _corsairGetDeviceInfoPointer;
|
||||
private static IntPtr _corsairGetLedIdForKeyNamePointer;
|
||||
private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer;
|
||||
private static IntPtr _corsairRequestControlPointer;
|
||||
private static IntPtr _corsairReleaseControlPointer;
|
||||
private static IntPtr _corsairPerformProtocolHandshakePointer;
|
||||
private static IntPtr _corsairGetLastErrorPointer;
|
||||
private static delegate* unmanaged[Cdecl]<CorsairSessionStateChangedHandler, nint, CorsairError> _corsairConnectPtr;
|
||||
private static delegate* unmanaged[Cdecl]<nint, CorsairError> _corsairGetSessionDetails;
|
||||
private static delegate* unmanaged[Cdecl]<CorsairError> _corsairDisconnect;
|
||||
private static delegate* unmanaged[Cdecl]<_CorsairDeviceFilter, int, nint, out int, CorsairError> _corsairGetDevices;
|
||||
private static delegate* unmanaged[Cdecl]<string, _CorsairDeviceInfo, CorsairError> _corsairGetDeviceInfo;
|
||||
private static delegate* unmanaged[Cdecl]<string, int, nint, out int, CorsairError> _corsairGetLedPositions;
|
||||
private static delegate* unmanaged[Cdecl]<string, int, nint, CorsairError> _corsairSetLedColors;
|
||||
private static delegate* unmanaged[Cdecl]<uint, CorsairError> _corsairSetLayerPriority;
|
||||
private static delegate* unmanaged[Cdecl]<string, char, out uint, CorsairError> _corsairGetLedLuidForKeyName;
|
||||
private static delegate* unmanaged[Cdecl]<string, CorsairAccessLevel, CorsairError> _corsairRequestControl;
|
||||
private static delegate* unmanaged[Cdecl]<string, CorsairError> _corsairReleaseControl;
|
||||
private static delegate* unmanaged[Cdecl]<string, CorsairDevicePropertyId, uint, out CorsairDataType, out CorsairPropertyFlag, CorsairError> _getDevicePropertyInfo;
|
||||
private static delegate* unmanaged[Cdecl]<string, CorsairDevicePropertyId, uint, nint, CorsairError> _readDeviceProperty;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <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 unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// 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 unsafe bool CorsairSetLedsColorsFlushBuffer() => ((delegate* unmanaged[Cdecl]<bool>)ThrowIfZero(_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 unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_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 unsafe bool CorsairSetLayerPriority(int priority) => ((delegate* unmanaged[Cdecl]<int, bool>)ThrowIfZero(_corsairSetLayerPriorityPointer))(priority);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
||||
/// </summary>
|
||||
internal static unsafe int CorsairGetDeviceCount() => ((delegate* unmanaged[Cdecl]<int>)ThrowIfZero(_corsairGetDeviceCountPointer))();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns information about device at provided index.
|
||||
/// </summary>
|
||||
internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
||||
/// </summary>
|
||||
internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
||||
/// </summary>
|
||||
internal static unsafe CorsairLedId CorsairGetLedIdForKeyName(char keyName) => ((delegate* unmanaged[Cdecl]<char, CorsairLedId>)ThrowIfZero(_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 unsafe bool CorsairRequestControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl]<CorsairAccessMode, bool>)ThrowIfZero(_corsairRequestControlPointer))(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: releases previously requested control for specified access mode.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairReleaseControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl]<CorsairAccessMode, bool>)ThrowIfZero(_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 unsafe _CorsairProtocolDetails CorsairPerformProtocolHandshake() => ((delegate* unmanaged[Cdecl]<_CorsairProtocolDetails>)ThrowIfZero(_corsairPerformProtocolHandshakePointer))();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
|
||||
/// </summary>
|
||||
internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl]<CorsairError>)ThrowIfZero(_corsairGetLastErrorPointer))();
|
||||
|
||||
private static IntPtr ThrowIfZero(IntPtr ptr)
|
||||
internal static CorsairError CorsairConnect()
|
||||
{
|
||||
if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
||||
return ptr;
|
||||
if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
||||
if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected.");
|
||||
return _corsairConnectPtr(CorsairSessionStateChangedCallback, 0);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
|
||||
nint sessionDetailPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairSessionDetails>());
|
||||
try
|
||||
{
|
||||
CorsairError error = _corsairGetSessionDetails(sessionDetailPtr);
|
||||
details = Marshal.PtrToStructure<_CorsairSessionDetails>(sessionDetailPtr);
|
||||
|
||||
return error;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(sessionDetailPtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairDisconnect()
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairDisconnect();
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairGetDevices(_CorsairDeviceFilter filter, out _CorsairDeviceInfo[] devices)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
|
||||
int structSize = Marshal.SizeOf<_CorsairDeviceInfo>();
|
||||
nint devicePtr = Marshal.AllocHGlobal(structSize * CORSAIR_DEVICE_COUNT_MAX);
|
||||
try
|
||||
{
|
||||
CorsairError error = _corsairGetDevices(filter, CORSAIR_DEVICE_COUNT_MAX, devicePtr, out int size);
|
||||
devices = devicePtr.ToArray<_CorsairDeviceInfo>(size);
|
||||
|
||||
return error;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(devicePtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairGetDeviceInfo(string deviceId, _CorsairDeviceInfo deviceInfo)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairGetDeviceInfo(deviceId, deviceInfo);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairGetLedPositions(string deviceId, out _CorsairLedPosition[] ledPositions)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
|
||||
int structSize = Marshal.SizeOf<_CorsairLedPosition>();
|
||||
nint ledPositionsPtr = Marshal.AllocHGlobal(structSize * CORSAIR_DEVICE_LEDCOUNT_MAX);
|
||||
try
|
||||
{
|
||||
CorsairError error = _corsairGetLedPositions(deviceId, CORSAIR_DEVICE_LEDCOUNT_MAX, ledPositionsPtr, out int size);
|
||||
ledPositions = ledPositionsPtr.ToArray<_CorsairLedPosition>(size);
|
||||
|
||||
return error;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ledPositionsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairSetLedColors(string deviceId, int ledCount, nint ledColorsPtr)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairSetLedColors(deviceId, ledCount, ledColorsPtr);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairSetLayerPriority(uint priority)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairSetLayerPriority(priority);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairGetLedLuidForKeyName(string deviceId, char keyName, out uint ledId)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairGetLedLuidForKeyName(deviceId, keyName, out ledId);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairRequestControl(string deviceId, CorsairAccessLevel accessLevel)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairRequestControl(deviceId, accessLevel);
|
||||
}
|
||||
|
||||
internal static CorsairError CorsairReleaseControl(string deviceId)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _corsairReleaseControl(deviceId);
|
||||
}
|
||||
|
||||
internal static CorsairError GetDevicePropertyInfo(string deviceId, CorsairDevicePropertyId propertyId, uint index, out CorsairDataType dataType, out CorsairPropertyFlag flags)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
return _getDevicePropertyInfo(deviceId, propertyId, index, out dataType, out flags);
|
||||
}
|
||||
|
||||
internal static CorsairError ReadDeviceProperty(string deviceId, CorsairDevicePropertyId propertyId, uint index, out _CorsairProperty? property)
|
||||
{
|
||||
if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected.");
|
||||
|
||||
nint propertyPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairProperty>());
|
||||
try
|
||||
{
|
||||
CorsairError error = _readDeviceProperty(deviceId, propertyId, index, propertyPtr);
|
||||
property = Marshal.PtrToStructure<_CorsairProperty>(propertyPtr);
|
||||
|
||||
return error;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(propertyPtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal static int ReadDevicePropertySimpleInt32(string deviceId, CorsairDevicePropertyId propertyId, uint index = 0) => ReadDevicePropertySimple(deviceId, propertyId, CorsairDataType.Int32, index).int32;
|
||||
|
||||
internal static int[] ReadDevicePropertySimpleInt32Array(string deviceId, CorsairDevicePropertyId propertyId, uint index = 0)
|
||||
{
|
||||
_CorsairDataValue dataValue = ReadDevicePropertySimple(deviceId, propertyId, CorsairDataType.Int32Array, index);
|
||||
return dataValue.int32Array.items.ToArray<int>((int)dataValue.int32Array.count);
|
||||
}
|
||||
|
||||
internal static _CorsairDataValue ReadDevicePropertySimple(string deviceId, CorsairDevicePropertyId propertyId, CorsairDataType expectedDataType, uint index = 0)
|
||||
{
|
||||
CorsairError errorCode = GetDevicePropertyInfo(deviceId, propertyId, index, out CorsairDataType dataType, out CorsairPropertyFlag flags);
|
||||
if (errorCode != CorsairError.Success)
|
||||
throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (ErrorCode: {errorCode})");
|
||||
|
||||
if (dataType != expectedDataType)
|
||||
throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (Wrong data-type '{dataType}', expected: '{expectedDataType}')");
|
||||
|
||||
if (!flags.HasFlag(CorsairPropertyFlag.CanRead))
|
||||
throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (Not readable)");
|
||||
|
||||
errorCode = ReadDeviceProperty(deviceId, propertyId, index, out _CorsairProperty? property);
|
||||
if (errorCode != CorsairError.Success)
|
||||
throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (ErrorCode: {errorCode})");
|
||||
|
||||
if (property == null)
|
||||
throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (Invalid return value)");
|
||||
|
||||
if (property.Value.type != expectedDataType)
|
||||
throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (Wrong data-type '{dataType}', expected: '{expectedDataType}')");
|
||||
|
||||
return property.Value.value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
#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
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
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;
|
||||
}
|
||||
140
RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs
Normal file
140
RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs
Normal file
@ -0,0 +1,140 @@
|
||||
#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
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// iCUE-SDK: a union of all property data types
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct _CorsairDataValue
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Boolean
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal bool boolean;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Int32
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal int int32;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Float64
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal double float64;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_String
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal nint @string;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Boolean_Array
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal CorsairDataTypeBooleanArray booleanArray;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Int32_Array
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal CorsairDataTypeInt32Array int32Array;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_Float64_Array
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal CorsairDataTypeFloat64Array float64Array;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: actual property value if it’s type is CPDT_String_Array
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
internal CorsairDataTypeStringArray stringArray;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Types
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: represents an array of boolean values
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CorsairDataTypeBooleanArray
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE: an array of boolean values
|
||||
/// </summary>
|
||||
internal nint items;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: number of items array elements
|
||||
/// </summary>
|
||||
internal uint count;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: represents an array of integer values
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CorsairDataTypeInt32Array
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE: an array of integer values
|
||||
/// </summary>
|
||||
internal nint items;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: number of items array elements
|
||||
/// </summary>
|
||||
internal uint count;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: represents an array of double values
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CorsairDataTypeFloat64Array
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE: an array of double values
|
||||
/// </summary>
|
||||
internal nint items;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: number of items array elements
|
||||
/// </summary>
|
||||
internal uint count;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: represents an array of pointers to null terminated strings
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CorsairDataTypeStringArray
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE: an array of pointers to null terminated strings
|
||||
/// </summary>
|
||||
internal nint items;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE: number of items array elements
|
||||
/// </summary>
|
||||
internal uint count;
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -3,26 +3,34 @@
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
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.
|
||||
/// iCUE-SDK: contains device search filter
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairChannelsInfo
|
||||
internal class _CorsairDeviceFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of channels controlled by the device
|
||||
/// </summary>
|
||||
internal int channelsCount;
|
||||
#region Properties & Fields
|
||||
|
||||
/// <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.
|
||||
/// iCUE-SDK: mask that describes device types, formed as logical “or” of CorsairDeviceType enum values
|
||||
/// </summary>
|
||||
internal IntPtr channels;
|
||||
}
|
||||
internal CorsairDeviceType deviceTypeMask;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public _CorsairDeviceFilter() { }
|
||||
|
||||
public _CorsairDeviceFilter(CorsairDeviceType filter)
|
||||
{
|
||||
this.deviceTypeMask = filter;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -3,56 +3,47 @@
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about device
|
||||
/// iCUE-SDK: contains information about device
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing device type
|
||||
/// iCUE-SDK: enum describing device type
|
||||
/// </summary>
|
||||
internal CorsairDeviceType type;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated device model(like “K95RGB”)
|
||||
/// iCUE-SDK: null terminated Unicode string that contains unique device identifier serial number. Can be empty, if serial number is not available for the device
|
||||
/// </summary>
|
||||
internal IntPtr model;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)]
|
||||
internal string? id;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
|
||||
/// iCUE-SDK: null terminated Unicode string that contains device serial number. Can be empty, if serial number is not available for the device
|
||||
/// </summary>
|
||||
internal int physicalLayout;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)]
|
||||
internal string? serial;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings
|
||||
/// iCUE-SDK: null terminated Unicode string that contains device model (like “K95RGB”)
|
||||
/// </summary>
|
||||
internal int logicalLayout;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)]
|
||||
internal string? model;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
|
||||
/// iCUE-SDK: number of controllable LEDs on the device
|
||||
/// </summary>
|
||||
internal int capsMask;
|
||||
internal int ledCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of controllable LEDs on the device
|
||||
/// iCUE-SDK: number of channels controlled by the device
|
||||
/// </summary>
|
||||
internal int ledsCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: structure that describes channels of the DIY-devices
|
||||
/// </summary>
|
||||
internal _CorsairChannelsInfo? channels;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null-terminated string that contains unique device identifier that uniquely identifies device at least within session
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
internal string? deviceId;
|
||||
internal int channelCount;
|
||||
}
|
||||
@ -10,28 +10,52 @@ namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about led and its color
|
||||
/// iCUE-SDK: contains information about led and its color
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedColor
|
||||
internal struct _CorsairLedColor
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: identifier of LED to set
|
||||
/// </summary>
|
||||
internal int ledId;
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: red brightness[0..255]
|
||||
/// iCUE-SDK: identifier of LED to set
|
||||
/// </summary>
|
||||
internal int r;
|
||||
internal CorsairLedId ledId;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: green brightness[0..255]
|
||||
/// iCUE-SDK: red brightness[0..255]
|
||||
/// </summary>
|
||||
internal int g;
|
||||
internal byte r;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: blue brightness[0..255]
|
||||
/// iCUE-SDK: green brightness[0..255]
|
||||
/// </summary>
|
||||
internal int b;
|
||||
internal byte g;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: blue brightness[0..255]
|
||||
/// </summary>
|
||||
internal byte b;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: alpha channel [0..255]. The opacity of the color from 0 for completely translucent to 255 for opaque
|
||||
/// </summary>
|
||||
internal byte a;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public _CorsairLedColor() { }
|
||||
|
||||
public _CorsairLedColor(CorsairLedId ledId, byte r, byte g, byte b, byte a)
|
||||
{
|
||||
this.ledId = ledId;
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
#endregion
|
||||
};
|
||||
@ -2,41 +2,31 @@
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// ReSharper disable NotAccessedField.Global
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains led id and position of led rectangle.Most of the keys are rectangular.
|
||||
/// In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
|
||||
/// iCUE-SDK: contains led id and position of led
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: identifier of led
|
||||
/// iCUE-SDK: unique identifier of led
|
||||
/// </summary>
|
||||
internal CorsairLedId LedId;
|
||||
internal uint id;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// iCUE-SDK: for keyboards, mice, mousemats, headset stands and memory modules values are
|
||||
/// </summary>
|
||||
internal double top;
|
||||
internal double cx;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// iCUE-SDK: in mm, for DIY-devices, headsets and coolers values are in logical units
|
||||
/// </summary>
|
||||
internal double left;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double height;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double width;
|
||||
}
|
||||
internal double cy;
|
||||
};
|
||||
@ -1,26 +0,0 @@
|
||||
#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 number of leds and arrays with their positions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedPositions
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer value.Number of elements in following array
|
||||
/// </summary>
|
||||
internal int numberOfLed;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: array of led positions
|
||||
/// </summary>
|
||||
internal IntPtr pLedPosition;
|
||||
}
|
||||
@ -9,19 +9,22 @@ 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.
|
||||
/// iCUE-SDK: contains information about device property type and value
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
internal class _CorsairChannelDeviceInfo
|
||||
internal struct _CorsairProperty
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: type of the LED-device
|
||||
/// </summary>
|
||||
internal CorsairChannelDeviceType type;
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of LEDs controlled by LED-device.
|
||||
/// iCUE-SDK: type of property
|
||||
/// </summary>
|
||||
internal int deviceLedCount;
|
||||
}
|
||||
internal CorsairDataType type;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: property value
|
||||
/// </summary>
|
||||
internal _CorsairDataValue value;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
#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 SDK and CUE versions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct _CorsairProtocolDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found
|
||||
/// </summary>
|
||||
internal IntPtr sdkVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found.
|
||||
/// </summary>
|
||||
internal IntPtr serverVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer number that specifies version of protocol that is implemented by current SDK.
|
||||
/// Numbering starts from 1. Always contains valid value even if there was no CUE found
|
||||
/// </summary>
|
||||
internal int sdkProtocolVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer number that specifies version of protocol that is implemented by CUE.
|
||||
/// Numbering starts from 1. If CUE was not found then this value will be 0
|
||||
/// </summary>
|
||||
internal int serverProtocolVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: boolean value that specifies if there were breaking changes between version of protocol implemented by server and client
|
||||
/// </summary>
|
||||
internal byte breakingChanges;
|
||||
};
|
||||
32
RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs
Normal file
32
RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs
Normal file
@ -0,0 +1,32 @@
|
||||
#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
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// ReSharper disable NotAccessedField.Global
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains information about SDK and iCUE versions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairSessionDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: version of SDK client (like {4,0,1}). Always contains valid value even if there was no iCUE found. Must comply with the semantic versioning rules.
|
||||
/// </summary>
|
||||
internal _CorsairVersion clientVersion = new();
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: version of SDK server (like {4,0,1}) or empty struct ({0,0,0}) if the iCUE was not found. Must comply with the semantic versioning rules.
|
||||
/// </summary>
|
||||
internal _CorsairVersion serverVersion = new();
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: version of iCUE (like {3,33,100}) or empty struct ({0,0,0}) if the iCUE was not found.
|
||||
/// </summary>
|
||||
internal _CorsairVersion serverHostVersion = new();
|
||||
};
|
||||
@ -0,0 +1,27 @@
|
||||
#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
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// ReSharper disable NotAccessedField.Global
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains information about session state and client/server versions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairSessionStateChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// iCUE-SDK: new session state which SDK client has been transitioned to
|
||||
/// </summary>
|
||||
internal CorsairSessionState state;
|
||||
|
||||
/// <summary>
|
||||
/// iCUE-SDK: information about client/server versions
|
||||
/// </summary>
|
||||
internal _CorsairSessionDetails details = new();
|
||||
};
|
||||
31
RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs
Normal file
31
RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs
Normal file
@ -0,0 +1,31 @@
|
||||
#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
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// ReSharper disable NotAccessedField.Global
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// iCUE-SDK: contains information about version that consists of three components
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairVersion
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
internal int major;
|
||||
internal int minor;
|
||||
internal int patch;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override string ToString() => $"{major}.{minor}.{patch}";
|
||||
|
||||
#endregion
|
||||
};
|
||||
@ -11,14 +11,16 @@ surface.Load(CorsairDeviceProvider.Instance);
|
||||
This providers requires native SDK-dlls.
|
||||
You can get them directly from Corsair at [https://github.com/CorsairOfficial/cue-sdk/releases](https://github.com/CorsairOfficial/cue-sdk/releases)
|
||||
|
||||
(Developed and tested with iCUE SDK v4.0.48)
|
||||
|
||||
Since the SDK-dlls are native it's important to use the correct architecture you're building your application for. (If in doubt you can always include both.)
|
||||
|
||||
### x64
|
||||
`redist\x64\CUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x64\CUESDK.x64_2019.dll` (or simply named `CUESDK.dll`)
|
||||
`redist\x64\iCUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x64\iCUESDK.x64_2019.dll` (or simply named `iCUESDK.dll`)
|
||||
|
||||
You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX64NativePaths`.
|
||||
|
||||
### x86
|
||||
`redist\i386\CUESDK_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x86\CUESDK_2019.dll` (or simply named `CUESDK.dll`)
|
||||
`redist\i386\iCUESDK_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x86\iCUESDK_2019.dll` (or simply named `iCUESDK.dll`)
|
||||
|
||||
You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX86NativePaths`.
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=cooler/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=fan/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic_005Cupdate/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=graphicscard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=headsetstand/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ledstrip/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ledstripe/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=libs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=memory/@EntryIndexedValue">True</s:Boolean>
|
||||
@ -19,4 +23,5 @@
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=specialparts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=targets/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=touchbar/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=unknown/@EntryIndexedValue">True</s:Boolean>
|
||||
</wpf:ResourceDictionary>
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
@ -9,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
|
||||
/// <summary>
|
||||
/// Represents a corsair touchbar.
|
||||
/// </summary>
|
||||
public class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDeviceInfo>, IDRAM
|
||||
public class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDeviceInfo>, ILedStripe
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
@ -20,8 +21,14 @@ public class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDevic
|
||||
/// <param name="info">The specific information provided by CUE for the touchbar.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairTouchbarRGBDevice(CorsairTouchbarRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Keyboard, updateQueue) //TODO DarthAffe 17.07.2022: Find someone with such a device and check which LedIds are actually used
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateLedStripMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -15,13 +15,8 @@ public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairTouchbarRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairTouchbarRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairTouchbarRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Keypad, nativeInfo)
|
||||
internal CorsairTouchbarRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
34
RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs
Normal file
34
RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a unknown corsair device.
|
||||
/// </summary>
|
||||
public class CorsairUnknownRGBDevice : CorsairRGBDevice<CorsairUnknownRGBDeviceInfo>, IUnknownDevice
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairUnknownRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the unknown device.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairUnknownRGBDevice(CorsairUnknownRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids) => LedMappings.CreateUnknownMapping(ids);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairUnknownRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
internal CorsairUnknownRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset)
|
||||
: base(RGBDeviceType.Unknown, nativeInfo, ledCount, ledOffset)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user