Changed all namespaces to file-scope

This commit is contained in:
DarthAffe committed 2021-11-13 17:35:08 +01:00
1 parent a0c6ccebea
commit 30624035f1
353 files changed
+35775 -36129

No files matched your search

+203 -204
View File
@@ -7,212 +7,211 @@ using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a device provider responsible for corsair (CUE) devices.
/// </summary>
public class CorsairDeviceProvider : AbstractRGBDeviceProvider
{
/// <inheritdoc />
#region Properties & Fields
private static CorsairDeviceProvider? _instance;
/// <summary>
/// Represents a device provider responsible for corsair (CUE) devices.
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
/// </summary>
public class CorsairDeviceProvider : AbstractRGBDeviceProvider
public static CorsairDeviceProvider Instance => _instance ?? new CorsairDeviceProvider();
/// <summary>
/// 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_2015.dll", "x86/CUESDK_2013.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_2015.dll", "x64/CUESDK_2013.dll" };
/// <summary>
/// Gets the protocol details for the current SDK-connection.
/// </summary>
public CorsairProtocolDetails? ProtocolDetails { get; private set; }
/// <summary>
/// Gets the last error documented by CUE.
/// </summary>
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairDeviceProvider"/> class.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
public CorsairDeviceProvider()
{
#region Properties & Fields
private static CorsairDeviceProvider? _instance;
/// <summary>
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
/// </summary>
public static CorsairDeviceProvider Instance => _instance ?? new CorsairDeviceProvider();
/// <summary>
/// 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_2015.dll", "x86/CUESDK_2013.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_2015.dll", "x64/CUESDK_2013.dll" };
/// <summary>
/// Gets the protocol details for the current SDK-connection.
/// </summary>
public CorsairProtocolDetails? ProtocolDetails { get; private set; }
/// <summary>
/// Gets the last error documented by CUE.
/// </summary>
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairDeviceProvider"/> class.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
public CorsairDeviceProvider()
{
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
_instance = this;
}
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeSDK()
{
_CUESDK.Reload();
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
CorsairError error = LastError;
if (error != CorsairError.Success)
Throw(new CUEException(error), true);
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);
// DarthAffe 02.02.2021: 127 is iCUE
if (!_CUESDK.CorsairSetLayerPriority(128))
Throw(new CUEException(LastError));
}
/// <inheritdoc />
protected override IEnumerable<IRGBDevice> LoadDevices()
{
foreach (ICorsairRGBDevice corsairDevice in LoadCorsairDevices())
{
corsairDevice.Initialize();
yield return corsairDevice;
}
}
private IEnumerable<ICorsairRGBDevice> LoadCorsairDevices()
{
int deviceCount = _CUESDK.CorsairGetDeviceCount();
for (int i = 0; i < deviceCount; i++)
{
_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
CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i);
switch (nativeDeviceInfo.type)
{
case CorsairDeviceType.Keyboard:
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mouse:
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Headset:
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mousepad:
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.HeadsetStand:
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.MemoryModule:
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mainboard:
yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.GraphicsCard:
yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Cooler:
case CorsairDeviceType.CommanderPro:
case CorsairDeviceType.LightningNodePro:
_CorsairChannelsInfo? channelsInfo = nativeDeviceInfo.channels;
if (channelsInfo != null)
{
IntPtr channelInfoPtr = channelsInfo.channels;
int ledOffset = 0;
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
{
CorsairLedId referenceLed = GetChannelReferenceId(nativeDeviceInfo.type, channel);
if (referenceLed == CorsairLedId.Invalid) continue;
_CorsairChannelInfo channelInfo = (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
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))!;
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, referenceLed, ledOffset), updateQueue);
referenceLed += channelDeviceInfo.deviceLedCount;
ledOffset += channelDeviceInfo.deviceLedCount;
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
}
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
}
}
break;
default:
Throw(new RGBDeviceException("Unknown Device-Type"));
break;
}
}
}
private static CorsairLedId GetChannelReferenceId(CorsairDeviceType deviceType, int channel)
{
if (deviceType == CorsairDeviceType.Cooler)
return CorsairLedId.CustomLiquidCoolerChannel1Led1;
return channel switch
{
0 => CorsairLedId.CustomDeviceChannel1Led1,
1 => CorsairLedId.CustomDeviceChannel2Led1,
2 => CorsairLedId.CustomDeviceChannel3Led1,
_ => CorsairLedId.Invalid
};
}
/// <inheritdoc />
protected override void Reset()
{
ProtocolDetails = null;
base.Reset();
}
/// <inheritdoc />
public override void Dispose()
{
base.Dispose();
try { _CUESDK.UnloadCUESDK(); }
catch { /* at least we tried */ }
GC.SuppressFinalize(this);
}
#endregion
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
_instance = this;
}
}
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeSDK()
{
_CUESDK.Reload();
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
CorsairError error = LastError;
if (error != CorsairError.Success)
Throw(new CUEException(error), true);
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);
// DarthAffe 02.02.2021: 127 is iCUE
if (!_CUESDK.CorsairSetLayerPriority(128))
Throw(new CUEException(LastError));
}
/// <inheritdoc />
protected override IEnumerable<IRGBDevice> LoadDevices()
{
foreach (ICorsairRGBDevice corsairDevice in LoadCorsairDevices())
{
corsairDevice.Initialize();
yield return corsairDevice;
}
}
private IEnumerable<ICorsairRGBDevice> LoadCorsairDevices()
{
int deviceCount = _CUESDK.CorsairGetDeviceCount();
for (int i = 0; i < deviceCount; i++)
{
_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
CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i);
switch (nativeDeviceInfo.type)
{
case CorsairDeviceType.Keyboard:
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mouse:
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Headset:
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mousepad:
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.HeadsetStand:
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.MemoryModule:
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Mainboard:
yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.GraphicsCard:
yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
break;
case CorsairDeviceType.Cooler:
case CorsairDeviceType.CommanderPro:
case CorsairDeviceType.LightningNodePro:
_CorsairChannelsInfo? channelsInfo = nativeDeviceInfo.channels;
if (channelsInfo != null)
{
IntPtr channelInfoPtr = channelsInfo.channels;
int ledOffset = 0;
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
{
CorsairLedId referenceLed = GetChannelReferenceId(nativeDeviceInfo.type, channel);
if (referenceLed == CorsairLedId.Invalid) continue;
_CorsairChannelInfo channelInfo = (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
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))!;
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, referenceLed, ledOffset), updateQueue);
referenceLed += channelDeviceInfo.deviceLedCount;
ledOffset += channelDeviceInfo.deviceLedCount;
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
}
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
}
}
break;
default:
Throw(new RGBDeviceException("Unknown Device-Type"));
break;
}
}
}
private static CorsairLedId GetChannelReferenceId(CorsairDeviceType deviceType, int channel)
{
if (deviceType == CorsairDeviceType.Cooler)
return CorsairLedId.CustomLiquidCoolerChannel1Led1;
return channel switch
{
0 => CorsairLedId.CustomDeviceChannel1Led1,
1 => CorsairLedId.CustomDeviceChannel2Led1,
2 => CorsairLedId.CustomDeviceChannel3Led1,
_ => CorsairLedId.Invalid
};
}
/// <inheritdoc />
protected override void Reset()
{
ProtocolDetails = null;
base.Reset();
}
/// <inheritdoc />
public override void Dispose()
{
base.Dispose();
try { _CUESDK.UnloadCUESDK(); }
catch { /* at least we tried */ }
GC.SuppressFinalize(this);
}
#endregion
}
@@ -6,70 +6,69 @@ using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair custom.
/// </summary>
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>, IUnknownDevice
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair custom.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" /> class.
/// </summary>
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>, IUnknownDevice
/// <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()
{
#region Constructors
Mapping.Clear();
/// <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)
{ }
_CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
if (nativeLedPositions == null) return;
#endregion
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset));
#region Methods
/// <inheritdoc />
protected override void InitializeLayout()
LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType);
for (int i = 0; i < DeviceInfo.LedCount; i++)
{
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)
{
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);
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
}
}
private static LedId GetReferenceLed(RGBDeviceType deviceType)
=> deviceType switch
{
RGBDeviceType.LedStripe => LedId.LedStripe1,
RGBDeviceType.Fan => LedId.Fan1,
RGBDeviceType.Cooler => LedId.Cooler1,
_ => LedId.Custom1
};
#endregion
}
@@ -7,132 +7,131 @@ using System.Text.RegularExpressions;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
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 corsair-id of the first LED of this device.
/// </summary>
public CorsairLedId ReferenceCorsairLed { get; }
/// <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
//TODO DarthAffe 07.07.2018: DAP is a fan right now, that's most likely wrong
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDeviceInfo" />.
/// </summary>
public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
/// <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="referenceCorsairLed">The id of the first LED of 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, CorsairLedId referenceCorsairLed, 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))
{
#region Properties & Fields
this.ReferenceCorsairLed = referenceCorsairLed;
this.LedOffset = ledOffset;
/// <summary>
/// Gets the corsair-id of the first LED of this device.
/// </summary>
public CorsairLedId ReferenceCorsairLed { get; }
/// <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
//TODO DarthAffe 07.07.2018: DAP is a fan right now, that's most likely wrong
/// <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="referenceCorsairLed">The id of the first LED of 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, CorsairLedId referenceCorsairLed, 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.ReferenceCorsairLed = referenceCorsairLed;
this.LedOffset = ledOffset;
LedCount = channelDeviceInfo.deviceLedCount;
}
#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.FanSPPRO => RGBDeviceType.Fan,
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
_ => 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.FanSPPRO:
return "SP-PRO 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
LedCount = channelDeviceInfo.deviceLedCount;
}
}
#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.FanSPPRO => RGBDeviceType.Fan,
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
_ => 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.FanSPPRO:
return "SP-PRO 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
}
@@ -3,13 +3,12 @@
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Represents an SDK access mode.
/// </summary>
public enum CorsairAccessMode
{
/// <summary>
/// Represents an SDK access mode.
/// </summary>
public enum CorsairAccessMode
{
ExclusiveLightingControl = 0
};
}
ExclusiveLightingControl = 0
};
@@ -4,23 +4,22 @@
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of available corsair channel device types.
/// </summary>
public enum CorsairChannelDeviceType
{
/// <summary>
/// Contains a list of available corsair channel device types.
/// </summary>
public enum CorsairChannelDeviceType
{
Invalid = 0,
FanHD = 1,
FanSP = 2,
FanLL = 3,
FanML = 4,
Strip = 5,
DAP = 6,
Pump = 7,
FanQL = 8,
WaterBlock = 9,
FanSPPRO = 10
};
}
Invalid = 0,
FanHD = 1,
FanSP = 2,
FanLL = 3,
FanML = 4,
Strip = 5,
DAP = 6,
Pump = 7,
FanQL = 8,
WaterBlock = 9,
FanSPPRO = 10
};
@@ -3,27 +3,26 @@
using System;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of corsair device capabilities.
/// </summary>
[Flags]
public enum CorsairDeviceCaps
{
/// <summary>
/// Contains a list of corsair device capabilities.
/// For devices that do not support any SDK functions.
/// </summary>
[Flags]
public enum CorsairDeviceCaps
{
/// <summary>
/// For devices that do not support any SDK functions.
/// </summary>
None = 0,
None = 0,
/// <summary>
/// For devices that has controlled lighting.
/// </summary>
Lighting = 1,
/// <summary>
/// For devices that has controlled lighting.
/// </summary>
Lighting = 1,
/// <summary>
/// For devices that provide current state through set of properties.
/// </summary>
PropertyLookup = 2
};
}
/// <summary>
/// For devices that provide current state through set of properties.
/// </summary>
PropertyLookup = 2
};
@@ -4,24 +4,23 @@
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of available corsair device types.
/// </summary>
public enum CorsairDeviceType
{
/// <summary>
/// Contains a list of available corsair device types.
/// </summary>
public enum CorsairDeviceType
{
Unknown = 0,
Mouse = 1,
Keyboard = 2,
Headset = 3,
Mousepad = 4,
HeadsetStand = 5,
CommanderPro = 6,
LightningNodePro = 7,
MemoryModule = 8,
Cooler = 9,
Mainboard = 10,
GraphicsCard = 11
};
}
Unknown = 0,
Mouse = 1,
Keyboard = 2,
Headset = 3,
Mousepad = 4,
HeadsetStand = 5,
CommanderPro = 6,
LightningNodePro = 7,
MemoryModule = 8,
Cooler = 9,
Mainboard = 10,
GraphicsCard = 11
};
+30 -31
View File
@@ -1,42 +1,41 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Shared list of all errors which could happen during calling of Corsair* functions.
/// </summary>
public enum CorsairError
{
/// <summary>
/// Shared list of all errors which could happen during calling of Corsair* functions.
/// If previously called function completed successfully.
/// </summary>
public enum CorsairError
{
/// <summary>
/// If previously called function completed successfully.
/// </summary>
Success,
Success,
/// <summary>
/// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error)
/// </summary>
ServerNotFound,
/// <summary>
/// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error)
/// </summary>
ServerNotFound,
/// <summary>
/// If some other client has or took over exclusive control. (runtime error)
/// </summary>
NoControl,
/// <summary>
/// If some other client has or took over exclusive control. (runtime error)
/// </summary>
NoControl,
/// <summary>
/// If developer did not perform protocol handshake. (developer error)
/// </summary>
ProtocolHandshakeMissing,
/// <summary>
/// If developer did not perform protocol handshake. (developer error)
/// </summary>
ProtocolHandshakeMissing,
/// <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)
/// </summary>
IncompatibleProtocol,
/// <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)
/// </summary>
IncompatibleProtocol,
/// <summary>
/// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error)
/// </summary>
InvalidArguments
};
}
/// <summary>
/// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error)
/// </summary>
InvalidArguments
};
File diff suppressed because it is too large. Load diff
@@ -2,30 +2,29 @@
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of available logical layouts for corsair keyboards.
/// </summary>
public enum CorsairLogicalKeyboardLayout
{
/// <summary>
/// Contains a list of available logical layouts for corsair keyboards.
/// </summary>
public enum CorsairLogicalKeyboardLayout
{
US_Int = 1,
NA = 2,
EU = 3,
UK = 4,
BE = 5,
BR = 6,
CH = 7,
CN = 8,
DE = 9,
ES = 10,
FR = 11,
IT = 12,
ND = 13,
RU = 14,
JP = 15,
KR = 16,
TW = 17,
MEX = 18
};
}
US_Int = 1,
NA = 2,
EU = 3,
UK = 4,
BE = 5,
BR = 6,
CH = 7,
CN = 8,
DE = 9,
ES = 10,
FR = 11,
IT = 12,
ND = 13,
RU = 14,
JP = 15,
KR = 16,
TW = 17,
MEX = 18
};
@@ -1,36 +1,35 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of available physical layouts for corsair keyboards.
/// </summary>
public enum CorsairPhysicalKeyboardLayout
{
/// <summary>
/// Contains a list of available physical layouts for corsair keyboards.
/// US-Keyboard
/// </summary>
public enum CorsairPhysicalKeyboardLayout
{
/// <summary>
/// US-Keyboard
/// </summary>
US = 1,
US = 1,
/// <summary>
/// UK-Keyboard
/// </summary>
UK = 2,
/// <summary>
/// UK-Keyboard
/// </summary>
UK = 2,
/// <summary>
/// BR-Keyboard
/// </summary>
BR = 3,
/// <summary>
/// BR-Keyboard
/// </summary>
BR = 3,
/// <summary>
/// JP-Keyboard
/// </summary>
JP = 4,
/// <summary>
/// JP-Keyboard
/// </summary>
JP = 4,
/// <summary>
/// KR-Keyboard
/// </summary>
KR = 5
}
}
/// <summary>
/// KR-Keyboard
/// </summary>
KR = 5
}
@@ -1,108 +1,107 @@
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains a list of available physical layouts for mice.
/// </summary>
public enum CorsairPhysicalMouseLayout
{
/// <summary>
/// Contains a list of available physical layouts for mice.
/// Zone1-Mouse
/// </summary>
public enum CorsairPhysicalMouseLayout
{
/// <summary>
/// Zone1-Mouse
/// </summary>
Zones1 = 6,
Zones1 = 6,
/// <summary>
/// Zone2-Mouse
/// </summary>
Zones2 = 7,
/// <summary>
/// Zone2-Mouse
/// </summary>
Zones2 = 7,
/// <summary>
/// Zone3-Mouse
/// </summary>
Zones3 = 8,
/// <summary>
/// Zone3-Mouse
/// </summary>
Zones3 = 8,
/// <summary>
/// Zone4-Mouse
/// </summary>
Zones4 = 9,
/// <summary>
/// Zone4-Mouse
/// </summary>
Zones4 = 9,
/// <summary>
/// Zone5-Mouse
/// </summary>
Zones5 = 101,
/// <summary>
/// Zone5-Mouse
/// </summary>
Zones5 = 101,
/// <summary>
/// Zone6-Mouse
/// </summary>
Zones6 = 11,
/// <summary>
/// Zone6-Mouse
/// </summary>
Zones6 = 11,
/// <summary>
/// Zone7-Mouse
/// </summary>
Zones7 = 12,
/// <summary>
/// Zone7-Mouse
/// </summary>
Zones7 = 12,
/// <summary>
/// Zone8-Mouse
/// </summary>
Zones8 = 13,
/// <summary>
/// Zone8-Mouse
/// </summary>
Zones8 = 13,
/// <summary>
/// Zone9-Mouse
/// </summary>
Zones9 = 14,
/// <summary>
/// Zone9-Mouse
/// </summary>
Zones9 = 14,
/// <summary>
/// Zone10-Mouse
/// </summary>
Zones10 = 15,
/// <summary>
/// Zone10-Mouse
/// </summary>
Zones10 = 15,
/// <summary>
/// Zone11-Mouse
/// </summary>
Zones11 = 16,
/// <summary>
/// Zone11-Mouse
/// </summary>
Zones11 = 16,
/// <summary>
/// Zone12-Mouse
/// </summary>
Zones12 = 17,
/// <summary>
/// Zone12-Mouse
/// </summary>
Zones12 = 17,
/// <summary>
/// Zone13-Mouse
/// </summary>
Zones13 = 18,
/// <summary>
/// Zone13-Mouse
/// </summary>
Zones13 = 18,
/// <summary>
/// Zone14-Mouse
/// </summary>
Zones14 = 19,
/// <summary>
/// Zone14-Mouse
/// </summary>
Zones14 = 19,
/// <summary>
/// Zone15-Mouse
/// </summary>
Zones15 = 20,
/// <summary>
/// Zone15-Mouse
/// </summary>
Zones15 = 20,
/// <summary>
/// Zone16-Mouse
/// </summary>
Zones16 = 21,
/// <summary>
/// Zone16-Mouse
/// </summary>
Zones16 = 21,
/// <summary>
/// Zone17-Mouse
/// </summary>
Zones17 = 22,
/// <summary>
/// Zone17-Mouse
/// </summary>
Zones17 = 22,
/// <summary>
/// Zone18-Mouse
/// </summary>
Zones18 = 23,
/// <summary>
/// Zone18-Mouse
/// </summary>
Zones18 = 23,
/// <summary>
/// Zone19-Mouse
/// </summary>
Zones19 = 24,
/// <summary>
/// Zone19-Mouse
/// </summary>
Zones19 = 24,
/// <summary>
/// Zone20-Mouse
/// </summary>
Zones20 = 25
}
}
/// <summary>
/// Zone20-Mouse
/// </summary>
Zones20 = 25
}
@@ -3,35 +3,34 @@
using System;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents an exception thrown by the CUE.
/// </summary>
public class CUEException : ApplicationException
{
#region Properties & Fields
/// <summary>
/// Gets the <see cref="CorsairError" /> provided by CUE.
/// </summary>
public CorsairError Error { get; }
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents an exception thrown by the CUE.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CUEException" /> class.
/// </summary>
public class CUEException : ApplicationException
/// <param name="error">The <see cref="T:RGB.NET.Devices.Corsair.CorsairError" /> provided by CUE, which leads to this exception.</param>
public CUEException(CorsairError error)
{
#region Properties & Fields
/// <summary>
/// Gets the <see cref="CorsairError" /> provided by CUE.
/// </summary>
public CorsairError Error { get; }
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CUEException" /> class.
/// </summary>
/// <param name="error">The <see cref="T:RGB.NET.Devices.Corsair.CorsairError" /> provided by CUE, which leads to this exception.</param>
public CUEException(CorsairError error)
{
this.Error = error;
}
#endregion
this.Error = error;
}
}
#endregion
}
@@ -3,62 +3,61 @@ using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents the update-queue performing updates for corsair devices.
/// </summary>
public class CorsairDeviceUpdateQueue : UpdateQueue
{
/// <inheritdoc />
#region Properties & Fields
private int _deviceIndex;
#endregion
#region Constructors
/// <summary>
/// Represents the update-queue performing updates for corsair devices.
/// Initializes a new instance of the <see cref="CorsairDeviceUpdateQueue"/> class.
/// </summary>
public class CorsairDeviceUpdateQueue : UpdateQueue
/// <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)
: base(updateTrigger)
{
#region Properties & Fields
private int _deviceIndex;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairDeviceUpdateQueue"/> class.
/// </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)
: base(updateTrigger)
{
this._deviceIndex = deviceIndex;
}
#endregion
#region Methods
/// <inheritdoc />
protected override 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)
{
_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);
}
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
_CUESDK.CorsairSetLedsColorsFlushBuffer();
Marshal.FreeHGlobal(ptr);
}
#endregion
this._deviceIndex = deviceIndex;
}
}
#endregion
#region Methods
/// <inheritdoc />
protected override 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)
{
_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);
}
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
_CUESDK.CorsairSetLedsColorsFlushBuffer();
Marshal.FreeHGlobal(ptr);
}
#endregion
}
@@ -5,62 +5,61 @@ using System;
using System.Runtime.InteropServices;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Managed wrapper for CorsairProtocolDetails.
/// </summary>
public class CorsairProtocolDetails
{
#region Properties & Fields
/// <summary>
/// Managed wrapper for CorsairProtocolDetails.
/// String containing version of SDK(like "1.0.0.1").
/// Always contains valid value even if there was no CUE found.
/// </summary>
public class CorsairProtocolDetails
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)
{
#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
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
}
@@ -3,75 +3,74 @@ using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad).
/// </summary>
public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ICorsairRGBDevice
where TDeviceInfo : CorsairRGBDeviceInfo
{
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
#region Properties & Fields
/// <summary>
/// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad).
/// Gets the mapping of <see cref="LedId"/> to <see cref="CorsairLedId"/> used to update the LEDs of this device.
/// </summary>
public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ICorsairRGBDevice
where TDeviceInfo : CorsairRGBDeviceInfo
protected LedMapping<CorsairLedId> Mapping { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairRGBDevice{TDeviceInfo}"/> class.
/// </summary>
/// <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)
: base(info, updateQueue)
{
#region Properties & Fields
/// <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; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairRGBDevice{TDeviceInfo}"/> class.
/// </summary>
/// <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)
: 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;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition;
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{
_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;
Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
ptr = new IntPtr(ptr.ToInt64() + structSize);
}
}
/// <inheritdoc />
protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid;
#endregion
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;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition;
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{
_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;
Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
ptr = new IntPtr(ptr.ToInt64() + structSize);
}
}
/// <inheritdoc />
protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid;
#endregion
}
@@ -4,93 +4,92 @@ using System.Text.RegularExpressions;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a Corsair-<see cref="T:RGB.NET.Core.IRGBDevice" />.
/// </summary>
public class CorsairRGBDeviceInfo : IRGBDeviceInfo
{
/// <inheritdoc />
#region Properties & Fields
/// <summary>
/// Represents a generic information for a Corsair-<see cref="T:RGB.NET.Core.IRGBDevice" />.
/// Gets the corsair specific device type.
/// </summary>
public class CorsairRGBDeviceInfo : IRGBDeviceInfo
public CorsairDeviceType CorsairDeviceType { get; }
/// <summary>
/// Gets the index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.
/// </summary>
public int CorsairDeviceIndex { get; }
/// <inheritdoc />
public RGBDeviceType DeviceType { get; }
/// <inheritdoc />
public string DeviceName { get; }
/// <inheritdoc />
public string Manufacturer => "Corsair";
/// <inheritdoc />
public string Model { get; }
/// <summary>
/// Returns the unique ID provided by the Corsair-SDK.
/// Returns string.Empty for Custom devices.
/// </summary>
public string DeviceId { get; }
/// <inheritdoc />
public object? LayoutMetadata { get; set; }
/// <summary>
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
/// </summary>
public CorsairDeviceCaps CapsMask { get; }
#endregion
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
/// </summary>
/// <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)
{
#region Properties & Fields
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;
/// <summary>
/// Gets the corsair specific device type.
/// </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; }
/// <inheritdoc />
public string DeviceName { get; }
/// <inheritdoc />
public string Manufacturer => "Corsair";
/// <inheritdoc />
public string Model { get; }
/// <summary>
/// Returns the unique ID provided by the Corsair-SDK.
/// Returns string.Empty for Custom devices.
/// </summary>
public string DeviceId { get; }
/// <inheritdoc />
public object? LayoutMetadata { get; set; }
/// <summary>
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
/// </summary>
public CorsairDeviceCaps CapsMask { get; }
#endregion
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
/// </summary>
/// <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)
{
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;
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
/// <summary>
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
/// </summary>
/// <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>
/// <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)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = modelName;
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
#endregion
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
}
/// <summary>
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
/// </summary>
/// <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>
/// <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)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = modelName;
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
#endregion
}
@@ -1,12 +1,11 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Represents a corsair RGB-device.
/// </summary>
public interface ICorsairRGBDevice : IRGBDevice
{
/// <summary>
/// Represents a corsair RGB-device.
/// </summary>
public interface ICorsairRGBDevice : IRGBDevice
{
internal void Initialize();
}
}
internal void Initialize();
}
+291 -292
View File
@@ -1,303 +1,302 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Contains mappings for <see cref="LedId"/> to <see cref="CorsairLedId"/>.
/// </summary>
public static class LedMappings
{
/// <summary>
/// Contains mappings for <see cref="LedId"/> to <see cref="CorsairLedId"/>.
/// </summary>
public static class LedMappings
static LedMappings()
{
static LedMappings()
{
for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++)
GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i);
for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++)
GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i);
for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++)
HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i);
for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++)
HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i);
for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++)
Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i);
for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++)
Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i);
for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++)
Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i);
for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++)
Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i);
for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++)
Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i);
for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++)
Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i);
for (int i = 0; i <= (CorsairLedId.OemLed100 - CorsairLedId.OemLed1); i++)
Keyboard.Add(LedId.Custom1 + i, CorsairLedId.OemLed1 + i);
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);
}
/// <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()
{
{ LedId.Headset1, CorsairLedId.LeftLogo },
{ LedId.Headset2, CorsairLedId.RightLogo },
};
/// <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 },
};
/// <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 },
{ 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 },
};
for (int i = 0; i <= (CorsairLedId.OemLed250 - CorsairLedId.OemLed101); i++)
Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i);
}
}
/// <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()
{
{ LedId.Headset1, CorsairLedId.LeftLogo },
{ LedId.Headset2, CorsairLedId.RightLogo },
};
/// <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 },
};
/// <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 },
{ 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 },
};
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair graphics card.
/// </summary>
public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCardRGBDeviceInfo>, IGraphicsCard
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair graphics card.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" /> class.
/// </summary>
public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCardRGBDeviceInfo>, IGraphicsCard
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -4,26 +4,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" />.
/// </summary>
public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDeviceInfo" />.
/// </summary>
public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair headset.
/// </summary>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair headset.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" /> class.
/// </summary>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -1,26 +1,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" />.
/// </summary>
public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDeviceInfo" />.
/// </summary>
public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair headset stand.
/// </summary>
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair headset stand.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" /> class.
/// </summary>
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -1,26 +1,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" />.
/// </summary>
public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDeviceInfo" />.
/// </summary>
public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -1,13 +1,12 @@
using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
internal static class DictionaryExtension
{
internal static class DictionaryExtension
{
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary)
where TKey : notnull
where TValue : notnull
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary)
where TKey : notnull
where TValue : notnull
=> dictionary.ToDictionary(x => x.Value, x => x.Key);
}
}
}
@@ -1,19 +1,18 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
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;
namespace RGB.NET.Devices.Corsair;
return new Rectangle(posX, posY, width, height);
}
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;
return new Rectangle(posX, posY, width, height);
}
}
}
@@ -3,32 +3,31 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair keyboard.
/// </summary>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Properties & Fields
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair keyboard.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" /> class.
/// </summary>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
{
#region Properties & Fields
/// <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)
{ }
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -4,54 +4,53 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />.
/// </summary>
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo
{
#region Properties & Fields
/// <inheritdoc />
public KeyboardLayoutType Layout { get; }
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />.
/// Gets the physical layout of the keyboard.
/// </summary>
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo
public CorsairPhysicalKeyboardLayout PhysicalLayout { get; }
/// <summary>
/// Gets the logical layout of the keyboard as set in CUE settings.
/// </summary>
public CorsairLogicalKeyboardLayout LogicalLayout { get; }
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDeviceInfo" />.
/// </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)
{
#region Properties & Fields
/// <inheritdoc />
public KeyboardLayoutType Layout { get; }
/// <summary>
/// Gets the physical layout of the keyboard.
/// </summary>
public CorsairPhysicalKeyboardLayout PhysicalLayout { get; }
/// <summary>
/// Gets the logical layout of the keyboard as set in CUE settings.
/// </summary>
public CorsairLogicalKeyboardLayout LogicalLayout { get; }
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDeviceInfo" />.
/// </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)
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
this.Layout = PhysicalLayout switch
{
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
this.Layout = PhysicalLayout switch
{
CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI,
CorsairPhysicalKeyboardLayout.UK => KeyboardLayoutType.ISO,
CorsairPhysicalKeyboardLayout.BR => KeyboardLayoutType.ABNT,
CorsairPhysicalKeyboardLayout.JP => KeyboardLayoutType.JIS,
CorsairPhysicalKeyboardLayout.KR => KeyboardLayoutType.KS,
_ => KeyboardLayoutType.Unknown
};
}
#endregion
CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI,
CorsairPhysicalKeyboardLayout.UK => KeyboardLayoutType.ISO,
CorsairPhysicalKeyboardLayout.BR => KeyboardLayoutType.ABNT,
CorsairPhysicalKeyboardLayout.JP => KeyboardLayoutType.JIS,
CorsairPhysicalKeyboardLayout.KR => KeyboardLayoutType.KS,
_ => KeyboardLayoutType.Unknown
};
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair memory.
/// </summary>
public class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDeviceInfo>, IMainboard
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair memory.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" /> class.
/// </summary>
public class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDeviceInfo>, IMainboard
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -4,26 +4,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" />.
/// </summary>
public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDeviceInfo" />.
/// </summary>
public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair memory.
/// </summary>
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair memory.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" /> class.
/// </summary>
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -4,26 +4,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" />.
/// </summary>
public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDeviceInfo" />.
/// </summary>
public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair mouse.
/// </summary>
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair mouse.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" /> class.
/// </summary>
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -1,37 +1,36 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" />.
/// </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>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDeviceInfo" />.
/// </summary>
public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo
/// <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)
{
#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;
}
#endregion
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
}
}
#endregion
}
@@ -3,26 +3,25 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair mousepad.
/// </summary>
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad
{
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a corsair mousepad.
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" /> class.
/// </summary>
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad
{
#region Constructors
/// <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)
{ }
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" /> class.
/// </summary>
/// <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)
{ }
#endregion
}
}
#endregion
}
@@ -1,26 +1,25 @@
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
namespace RGB.NET.Devices.Corsair;
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" />.
/// </summary>
public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" />.
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDeviceInfo" />.
/// </summary>
public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <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)
{ }
/// <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)
{ }
#endregion
}
}
#endregion
}
+197 -198
View File
@@ -9,205 +9,204 @@ using System.Linq;
using System.Runtime.InteropServices;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair.Native
namespace RGB.NET.Devices.Corsair.Native;
// ReSharper disable once InconsistentNaming
internal static class _CUESDK
{
// ReSharper disable once InconsistentNaming
internal static class _CUESDK
{
#region Libary Management
#region Libary Management
private static IntPtr _dllHandle = IntPtr.Zero;
private static IntPtr _dllHandle = IntPtr.Zero;
/// <summary>
/// Reloads the SDK.
/// </summary>
internal static void Reload()
{
UnloadCUESDK();
LoadCUESDK();
}
private static void LoadCUESDK()
{
if (_dllHandle != IntPtr.Zero) return;
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
List<string> possiblePathList = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
string? dllPath = possiblePathList.FirstOrDefault(File.Exists);
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))}'");
_dllHandle = LoadLibrary(dllPath);
if (_dllHandle == IntPtr.Zero) throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
_corsairSetLedsColorsBufferByDeviceIndexPointer = (CorsairSetLedsColorsBufferByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsBufferByDeviceIndex"), typeof(CorsairSetLedsColorsBufferByDeviceIndexPointer));
_corsairSetLedsColorsFlushBufferPointer = (CorsairSetLedsColorsFlushBufferPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsFlushBuffer"), typeof(CorsairSetLedsColorsFlushBufferPointer));
_corsairGetLedsColorsByDeviceIndexPointer = (CorsairGetLedsColorsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColorsByDeviceIndex"), typeof(CorsairGetLedsColorsByDeviceIndexPointer));
_corsairSetLayerPriorityPointer = (CorsairSetLayerPriorityPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLayerPriority"), typeof(CorsairSetLayerPriorityPointer));
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
_corsairGetLedPositionsByDeviceIndexPointer = (CorsairGetLedPositionsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositionsByDeviceIndex"), typeof(CorsairGetLedPositionsByDeviceIndexPointer));
_corsairGetLedIdForKeyNamePointer = (CorsairGetLedIdForKeyNamePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedIdForKeyName"), typeof(CorsairGetLedIdForKeyNamePointer));
_corsairRequestControlPointer = (CorsairRequestControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRequestControl"), typeof(CorsairRequestControlPointer));
_corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer));
_corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer));
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
}
internal static void UnloadCUESDK()
{
if (_dllHandle == IntPtr.Zero) return;
// ReSharper disable once EmptyEmbeddedStatement - DarthAffe 20.02.2016: We might need to reduce the internal reference counter more than once to set the library free
while (FreeLibrary(_dllHandle)) ;
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion
#region SDK-METHODS
#region Pointers
private static CorsairSetLedsColorsBufferByDeviceIndexPointer? _corsairSetLedsColorsBufferByDeviceIndexPointer;
private static CorsairSetLedsColorsFlushBufferPointer? _corsairSetLedsColorsFlushBufferPointer;
private static CorsairGetLedsColorsByDeviceIndexPointer? _corsairGetLedsColorsByDeviceIndexPointer;
private static CorsairSetLayerPriorityPointer? _corsairSetLayerPriorityPointer;
private static CorsairGetDeviceCountPointer? _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer? _corsairGetDeviceInfoPointer;
private static CorsairGetLedIdForKeyNamePointer? _corsairGetLedIdForKeyNamePointer;
private static CorsairGetLedPositionsByDeviceIndexPointer? _corsairGetLedPositionsByDeviceIndexPointer;
private static CorsairRequestControlPointer? _corsairRequestControlPointer;
private static CorsairReleaseControlPointer? _corsairReleaseControlPointer;
private static CorsairPerformProtocolHandshakePointer? _corsairPerformProtocolHandshakePointer;
private static CorsairGetLastErrorPointer? _corsairGetLastErrorPointer;
#endregion
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsBufferByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsFlushBufferPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLayerPriorityPointer(int priority);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetDeviceInfoPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairLedId CorsairGetLedIdForKeyNamePointer(char keyName);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairRequestControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairReleaseControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate _CorsairProtocolDetails CorsairPerformProtocolHandshakePointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairError CorsairGetLastErrorPointer();
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified LEDs to some colors.
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
/// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
/// This function does not take logical layout into account.
/// </summary>
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
=> (_corsairSetLedsColorsBufferByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(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 bool CorsairSetLedsColorsFlushBuffer() => (_corsairSetLedsColorsFlushBufferPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
/// </summary>
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
=> (_corsairGetLedsColorsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex, size, ledsColors);
/// <summary>
/// CUE-SDK: set layer priority for this shared client.
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function.
/// Layers with higher priority value are shown on top of layers with lower priority.
/// </summary>
internal static bool CorsairSetLayerPriority(int priority) => (_corsairSetLayerPriorityPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(priority);
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
/// </summary>
internal static int CorsairGetDeviceCount() => (_corsairGetDeviceCountPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: returns information about device at provided index.
/// </summary>
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => (_corsairGetDeviceInfoPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
/// <summary>
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
/// </summary>
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => (_corsairGetLedPositionsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
/// <summary>
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
/// </summary>
internal static CorsairLedId CorsairGetLedIdForKeyName(char keyName) => (_corsairGetLedIdForKeyNamePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(keyName);
/// <summary>
/// CUE-SDK: requestes control using specified access mode.
/// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control.
/// </summary>
internal static bool CorsairRequestControl(CorsairAccessMode accessMode) => (_corsairRequestControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
/// <summary>
/// CUE-SDK: releases previously requested control for specified access mode.
/// </summary>
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode) => (_corsairReleaseControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
/// <summary>
/// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE.
/// </summary>
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake() => (_corsairPerformProtocolHandshakePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
/// </summary>
internal static CorsairError CorsairGetLastError() => (_corsairGetLastErrorPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
// ReSharper restore EventExceptionNotDocumented
#endregion
/// <summary>
/// Reloads the SDK.
/// </summary>
internal static void Reload()
{
UnloadCUESDK();
LoadCUESDK();
}
}
private static void LoadCUESDK()
{
if (_dllHandle != IntPtr.Zero) return;
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
List<string> possiblePathList = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
string? dllPath = possiblePathList.FirstOrDefault(File.Exists);
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))}'");
_dllHandle = LoadLibrary(dllPath);
if (_dllHandle == IntPtr.Zero) throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
_corsairSetLedsColorsBufferByDeviceIndexPointer = (CorsairSetLedsColorsBufferByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsBufferByDeviceIndex"), typeof(CorsairSetLedsColorsBufferByDeviceIndexPointer));
_corsairSetLedsColorsFlushBufferPointer = (CorsairSetLedsColorsFlushBufferPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsFlushBuffer"), typeof(CorsairSetLedsColorsFlushBufferPointer));
_corsairGetLedsColorsByDeviceIndexPointer = (CorsairGetLedsColorsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColorsByDeviceIndex"), typeof(CorsairGetLedsColorsByDeviceIndexPointer));
_corsairSetLayerPriorityPointer = (CorsairSetLayerPriorityPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLayerPriority"), typeof(CorsairSetLayerPriorityPointer));
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
_corsairGetLedPositionsByDeviceIndexPointer = (CorsairGetLedPositionsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositionsByDeviceIndex"), typeof(CorsairGetLedPositionsByDeviceIndexPointer));
_corsairGetLedIdForKeyNamePointer = (CorsairGetLedIdForKeyNamePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedIdForKeyName"), typeof(CorsairGetLedIdForKeyNamePointer));
_corsairRequestControlPointer = (CorsairRequestControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRequestControl"), typeof(CorsairRequestControlPointer));
_corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer));
_corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer));
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
}
internal static void UnloadCUESDK()
{
if (_dllHandle == IntPtr.Zero) return;
// ReSharper disable once EmptyEmbeddedStatement - DarthAffe 20.02.2016: We might need to reduce the internal reference counter more than once to set the library free
while (FreeLibrary(_dllHandle)) ;
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion
#region SDK-METHODS
#region Pointers
private static CorsairSetLedsColorsBufferByDeviceIndexPointer? _corsairSetLedsColorsBufferByDeviceIndexPointer;
private static CorsairSetLedsColorsFlushBufferPointer? _corsairSetLedsColorsFlushBufferPointer;
private static CorsairGetLedsColorsByDeviceIndexPointer? _corsairGetLedsColorsByDeviceIndexPointer;
private static CorsairSetLayerPriorityPointer? _corsairSetLayerPriorityPointer;
private static CorsairGetDeviceCountPointer? _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer? _corsairGetDeviceInfoPointer;
private static CorsairGetLedIdForKeyNamePointer? _corsairGetLedIdForKeyNamePointer;
private static CorsairGetLedPositionsByDeviceIndexPointer? _corsairGetLedPositionsByDeviceIndexPointer;
private static CorsairRequestControlPointer? _corsairRequestControlPointer;
private static CorsairReleaseControlPointer? _corsairReleaseControlPointer;
private static CorsairPerformProtocolHandshakePointer? _corsairPerformProtocolHandshakePointer;
private static CorsairGetLastErrorPointer? _corsairGetLastErrorPointer;
#endregion
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsBufferByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsFlushBufferPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLayerPriorityPointer(int priority);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetDeviceInfoPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairLedId CorsairGetLedIdForKeyNamePointer(char keyName);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairRequestControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairReleaseControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate _CorsairProtocolDetails CorsairPerformProtocolHandshakePointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairError CorsairGetLastErrorPointer();
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified LEDs to some colors.
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
/// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
/// This function does not take logical layout into account.
/// </summary>
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
=> (_corsairSetLedsColorsBufferByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(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 bool CorsairSetLedsColorsFlushBuffer() => (_corsairSetLedsColorsFlushBufferPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
/// </summary>
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
=> (_corsairGetLedsColorsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex, size, ledsColors);
/// <summary>
/// CUE-SDK: set layer priority for this shared client.
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function.
/// Layers with higher priority value are shown on top of layers with lower priority.
/// </summary>
internal static bool CorsairSetLayerPriority(int priority) => (_corsairSetLayerPriorityPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(priority);
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
/// </summary>
internal static int CorsairGetDeviceCount() => (_corsairGetDeviceCountPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: returns information about device at provided index.
/// </summary>
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => (_corsairGetDeviceInfoPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
/// <summary>
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
/// </summary>
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => (_corsairGetLedPositionsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
/// <summary>
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
/// </summary>
internal static CorsairLedId CorsairGetLedIdForKeyName(char keyName) => (_corsairGetLedIdForKeyNamePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(keyName);
/// <summary>
/// CUE-SDK: requestes control using specified access mode.
/// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control.
/// </summary>
internal static bool CorsairRequestControl(CorsairAccessMode accessMode) => (_corsairRequestControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
/// <summary>
/// CUE-SDK: releases previously requested control for specified access mode.
/// </summary>
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode) => (_corsairReleaseControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
/// <summary>
/// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE.
/// </summary>
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake() => (_corsairPerformProtocolHandshakePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
/// <summary>
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
/// </summary>
internal static CorsairError CorsairGetLastError() => (_corsairGetLastErrorPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
// ReSharper restore EventExceptionNotDocumented
#endregion
}
@@ -5,24 +5,23 @@
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
namespace RGB.NET.Devices.Corsair.Native;
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelDeviceInfo
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device.
/// CUE-SDK: type of the LED-device
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal CorsairChannelDeviceType type;
internal class _CorsairChannelDeviceInfo
{
/// <summary>
/// CUE-SDK: type of the LED-device
/// </summary>
internal CorsairChannelDeviceType type;
/// <summary>
/// CUE-SDK: number of LEDs controlled by LED-device.
/// </summary>
internal int deviceLedCount;
}
}
/// <summary>
/// CUE-SDK: number of LEDs controlled by LED-device.
/// </summary>
internal int deviceLedCount;
}
@@ -6,29 +6,28 @@
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
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
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate channel of the DIY-device.
/// CUE-SDK: total number of LEDs connected to the channel;
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelInfo
{
/// <summary>
/// CUE-SDK: total number of LEDs connected to the channel;
/// </summary>
internal int totalLedsCount;
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: 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;
}
}
/// <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;
}
@@ -6,24 +6,23 @@
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about channels of the DIY-devices.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelsInfo
{
/// <summary>
/// CUE-SDK: number of channels controlled by the device
/// </summary>
internal int channelsCount;
namespace RGB.NET.Devices.Corsair.Native;
/// <summary>
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
/// Index of the channel in the array is same as index of the channel on the DIY-device.
/// </summary>
internal IntPtr channels;
}
}
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about channels of the DIY-devices.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelsInfo
{
/// <summary>
/// CUE-SDK: number of channels controlled by the device
/// </summary>
internal int channelsCount;
/// <summary>
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
/// Index of the channel in the array is same as index of the channel on the DIY-device.
/// </summary>
internal IntPtr channels;
}
@@ -6,54 +6,53 @@
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
namespace RGB.NET.Devices.Corsair.Native;
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about device
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairDeviceInfo
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about device
/// CUE-SDK: enum describing device type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairDeviceInfo
{
/// <summary>
/// CUE-SDK: enum describing device type
/// </summary>
internal CorsairDeviceType type;
internal CorsairDeviceType type;
/// <summary>
/// CUE-SDK: null - terminated device model(like “K95RGB”)
/// </summary>
internal IntPtr model;
/// <summary>
/// CUE-SDK: null - terminated device model(like “K95RGB”)
/// </summary>
internal IntPtr model;
/// <summary>
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
/// </summary>
internal int physicalLayout;
/// <summary>
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
/// </summary>
internal int physicalLayout;
/// <summary>
/// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings
/// </summary>
internal int logicalLayout;
/// <summary>
/// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings
/// </summary>
internal int logicalLayout;
/// <summary>
/// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
/// </summary>
internal int capsMask;
/// <summary>
/// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
/// </summary>
internal int capsMask;
/// <summary>
/// CUE-SDK: number of controllable LEDs on the device
/// </summary>
internal int ledsCount;
/// <summary>
/// CUE-SDK: number of controllable LEDs on the device
/// </summary>
internal int ledsCount;
/// <summary>
/// CUE-SDK: structure that describes channels of the DIY-devices
/// </summary>
internal _CorsairChannelsInfo? channels;
/// <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;
}
}
/// <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;
}
@@ -6,33 +6,32 @@
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
namespace RGB.NET.Devices.Corsair.Native;
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about led and its color
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedColor
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about led and its color
/// CUE-SDK: identifier of LED to set
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedColor
{
/// <summary>
/// CUE-SDK: identifier of LED to set
/// </summary>
internal int ledId;
internal int ledId;
/// <summary>
/// CUE-SDK: red brightness[0..255]
/// </summary>
internal int r;
/// <summary>
/// CUE-SDK: red brightness[0..255]
/// </summary>
internal int r;
/// <summary>
/// CUE-SDK: green brightness[0..255]
/// </summary>
internal int g;
/// <summary>
/// CUE-SDK: green brightness[0..255]
/// </summary>
internal int g;
/// <summary>
/// CUE-SDK: blue brightness[0..255]
/// </summary>
internal int b;
};
}
/// <summary>
/// CUE-SDK: blue brightness[0..255]
/// </summary>
internal int b;
};
@@ -5,39 +5,38 @@
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
namespace RGB.NET.Devices.Corsair.Native;
// 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
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedPosition
{
// 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
/// CUE-SDK: identifier of led
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedPosition
{
/// <summary>
/// CUE-SDK: identifier of led
/// </summary>
internal CorsairLedId LedId;
internal CorsairLedId LedId;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double top;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double top;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double left;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double left;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double height;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double height;
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double width;
}
}
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double width;
}
@@ -5,23 +5,22 @@
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;
namespace RGB.NET.Devices.Corsair.Native;
/// <summary>
/// CUE-SDK: array of led positions
/// </summary>
internal IntPtr pLedPosition;
}
}
// 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;
}
@@ -5,40 +5,39 @@
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
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
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about SDK and CUE versions
/// 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>
[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;
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: 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 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: 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;
};
}
/// <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;
};