1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Merge pull request #225 from DarthAffe/SDK/CorsairWorkaround

Sdk/corsair workaround
This commit is contained in:
DarthAffe 2021-07-03 00:08:10 +02:00 committed by GitHub
commit 53cc40002c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View File

@ -156,7 +156,7 @@ namespace RGB.NET.Devices.Corsair
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
IntPtr channelDeviceInfoPtr = channelInfo.devices;
for (int device = 0; device < channelInfo.devicesCount; device++)
for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++)
{
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;

View File

@ -81,7 +81,7 @@ namespace RGB.NET.Devices.Corsair
switch (channelDeviceInfo.type)
{
case CorsairChannelDeviceType.Invalid:
return "Invalid";
return model;
case CorsairChannelDeviceType.FanHD:
return "HD Fan";

View File

@ -36,6 +36,12 @@ namespace RGB.NET.Devices.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; }
@ -60,6 +66,7 @@ namespace RGB.NET.Devices.Corsair
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);
@ -78,6 +85,7 @@ namespace RGB.NET.Devices.Corsair
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);

View File

@ -48,5 +48,11 @@ namespace RGB.NET.Devices.Corsair.Native
/// 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;
}
}