1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Updated corsair SDK

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

View File

@ -204,7 +204,7 @@ namespace RGB.NET.Core
/// <inheritdoc />
public T GetSpecialDevicePart<T>()
where T : class, IRGBDeviceSpecialPart
=> SpecialDeviceParts.TryGetValue(typeof(T), out IRGBDeviceSpecialPart devicePart) ? (T)devicePart : default(T);
=> SpecialDeviceParts.TryGetValue(typeof(T), out IRGBDeviceSpecialPart devicePart) ? (T)devicePart : default;
#region Enumerator

View File

@ -73,6 +73,11 @@ namespace RGB.NET.Core
/// </summary>
Keypad = 1 << 10,
/// <summary>
/// Represents a fan.
/// </summary>
Fan = 1 << 1,
/// <summary>
/// Represents all devices.
/// </summary>

View File

@ -1002,6 +1002,72 @@ namespace RGB.NET.Core
Keypad63 = 0x00A0003F,
Keypad64 = 0x00A00040,
/*### Fan ###*/
Fan1 = 0x00B00001,
Fan2 = 0x00B00002,
Fan3 = 0x00B00003,
Fan4 = 0x00B00004,
Fan5 = 0x00B00005,
Fan6 = 0x00B00006,
Fan7 = 0x00B00007,
Fan8 = 0x00B00008,
Fan9 = 0x00B00009,
Fan10 = 0x00B0000A,
Fan11 = 0x00B0000B,
Fan12 = 0x00B0000C,
Fan13 = 0x00B0000D,
Fan14 = 0x00B0000E,
Fan15 = 0x00B0000F,
Fan16 = 0x00B00010,
Fan17 = 0x00B00011,
Fan18 = 0x00B00012,
Fan19 = 0x00B00013,
Fan20 = 0x00B00014,
Fan21 = 0x00B00015,
Fan22 = 0x00B00016,
Fan23 = 0x00B00017,
Fan24 = 0x00B00018,
Fan25 = 0x00B00019,
Fan26 = 0x00B0001A,
Fan27 = 0x00B0001B,
Fan28 = 0x00B0001C,
Fan29 = 0x00B0001D,
Fan30 = 0x00B0001E,
Fan31 = 0x00B0001F,
Fan32 = 0x00B00020,
Fan33 = 0x00B00021,
Fan34 = 0x00B00022,
Fan35 = 0x00B00023,
Fan36 = 0x00B00024,
Fan37 = 0x00B00025,
Fan38 = 0x00B00026,
Fan39 = 0x00B00027,
Fan40 = 0x00B00028,
Fan41 = 0x00B00029,
Fan42 = 0x00B0002A,
Fan43 = 0x00B0002B,
Fan44 = 0x00B0002C,
Fan45 = 0x00B0002D,
Fan46 = 0x00B0002E,
Fan47 = 0x00B0002F,
Fan48 = 0x00B00030,
Fan49 = 0x00B00031,
Fan50 = 0x00B00032,
Fan51 = 0x00B00033,
Fan52 = 0x00B00034,
Fan53 = 0x00B00035,
Fan54 = 0x00B00036,
Fan55 = 0x00B00037,
Fan56 = 0x00B00038,
Fan57 = 0x00B00039,
Fan58 = 0x00B0003A,
Fan59 = 0x00B0003B,
Fan60 = 0x00B0003C,
Fan61 = 0x00B0003D,
Fan62 = 0x00B0003E,
Fan63 = 0x00B0003F,
Fan64 = 0x00B00040,
/*### Custom ###*/
Custom1 = 0x0FF00001,
Custom2 = 0x0FF00002,

View File

@ -22,8 +22,8 @@ namespace RGB.NET.Core
/// <returns>The value represented by the given key.</returns>
public object this[string key]
{
get => _data.TryGetValue(key?.ToUpperInvariant(), out object data) ? data : default;
set => _data[key?.ToUpperInvariant()] = value;
get => _data.TryGetValue(key?.ToUpperInvariant() ?? string.Empty, out object data) ? data : default;
set => _data[key?.ToUpperInvariant() ?? string.Empty] = value;
}
#endregion

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Core
@ -8,7 +9,7 @@ namespace RGB.NET.Core
/// </summary>
/// <typeparam name="TIdentifier">The type of the key used to identify some data.</typeparam>
/// <typeparam name="TData">The type of the data.</typeparam>
public abstract class UpdateQueue<TIdentifier, TData>
public abstract class UpdateQueue<TIdentifier, TData> : IDisposable
{
#region Properties & Fields
@ -24,7 +25,7 @@ namespace RGB.NET.Core
/// Initializes a new instance of the <see cref="UpdateQueue{TIdentifier,TData}"/> class.
/// </summary>
/// <param name="updateTrigger">The <see cref="IDeviceUpdateTrigger"/> causing this queue to update.</param>
public UpdateQueue(IDeviceUpdateTrigger updateTrigger)
protected UpdateQueue(IDeviceUpdateTrigger updateTrigger)
{
this._updateTrigger = updateTrigger;
@ -99,6 +100,14 @@ namespace RGB.NET.Core
_currentDataSet = null;
}
public void Dispose()
{
_updateTrigger.Starting -= OnStartup;
_updateTrigger.Update -= OnUpdate;
Reset();
}
#endregion
}

View File

@ -69,8 +69,7 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for corsair devices.
/// </summary>
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
private CorsairUpdateQueue _updateQueue;
public DeviceUpdateTrigger UpdateTrigger { get; }
#endregion
@ -86,7 +85,6 @@ namespace RGB.NET.Devices.Corsair
_instance = this;
UpdateTrigger = new DeviceUpdateTrigger();
_updateQueue = new CorsairUpdateQueue(UpdateTrigger);
}
#endregion
@ -127,6 +125,10 @@ namespace RGB.NET.Devices.Corsair
else
HasExclusiveAccess = false;
// DarthAffe 07.07.2018: 127 is CUE, we want to directly compete with it as in older versions.
if (!_CUESDK.CorsairSetLayerPriority(127))
throw new CUEException(LastError);
IList<IRGBDevice> devices = new List<IRGBDevice>();
int deviceCount = _CUESDK.CorsairGetDeviceCount();
for (int i = 0; i < deviceCount; i++)
@ -138,17 +140,23 @@ namespace RGB.NET.Devices.Corsair
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
continue; // Everything that doesn't support lighting control is useless
ICorsairRGBDevice device = GetRGBDevice(info, i, nativeDeviceInfo);
if ((device == null) || !loadFilter.HasFlag(device.DeviceInfo.DeviceType)) continue;
CorsairDeviceUpdateQueue deviceUpdateQueue = null;
foreach (ICorsairRGBDevice device in GetRGBDevice(info, i, nativeDeviceInfo))
{
if ((device == null) || !loadFilter.HasFlag(device.DeviceInfo.DeviceType)) continue;
device.Initialize(_updateQueue);
AddSpecialParts(device);
if (deviceUpdateQueue == null)
deviceUpdateQueue = new CorsairDeviceUpdateQueue(UpdateTrigger, info.CorsairDeviceIndex);
error = LastError;
if (error != CorsairError.Success)
throw new CUEException(error);
device.Initialize(deviceUpdateQueue);
AddSpecialParts(device);
devices.Add(device);
error = LastError;
if (error != CorsairError.Success)
throw new CUEException(error);
devices.Add(device);
}
}
catch { if (throwExceptions) throw; }
}
@ -168,24 +176,63 @@ namespace RGB.NET.Devices.Corsair
return true;
}
private static ICorsairRGBDevice GetRGBDevice(CorsairRGBDeviceInfo info, int i, _CorsairDeviceInfo nativeDeviceInfo)
private static IEnumerable<ICorsairRGBDevice> GetRGBDevice(CorsairRGBDeviceInfo info, int i, _CorsairDeviceInfo nativeDeviceInfo)
{
switch (info.CorsairDeviceType)
{
case CorsairDeviceType.Keyboard:
return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo));
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Mouse:
return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo));
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Headset:
return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo));
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Mousepad:
return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo));
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.HeadsetStand:
return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo));
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.CommanderPro:
case CorsairDeviceType.LightningNodePro:
_CorsairChannelsInfo channelsInfo = nativeDeviceInfo.channels;
if (channelsInfo != null)
{
IntPtr channelInfoPtr = channelsInfo.channels;
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
{
CorsairLedId referenceLed = channel == 0 ? CorsairLedId.CustomDeviceChannel1Led1 : CorsairLedId.CustomDeviceChannel2Led1;
_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; device++)
{
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo));
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(info.CorsairDeviceIndex, nativeDeviceInfo, channelDeviceInfo, referenceLed));
referenceLed += channelDeviceInfo.deviceLedCount;
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
}
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
}
}
break;
// ReSharper disable once RedundantCaseLabel
case CorsairDeviceType.Unknown:

View File

@ -0,0 +1,57 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <summary>
/// Represents a corsair custom.
/// </summary>
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>
{
#region Properties & Fields
private readonly Dictionary<LedId, CorsairLedId> _idMapping = new Dictionary<LedId, CorsairLedId>();
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeLayout()
{
LedId referenceId = (DeviceInfo.DeviceType == RGBDeviceType.LedStripe ? LedId.LedStripe1 : (DeviceInfo.DeviceType == RGBDeviceType.Fan ? LedId.Fan1 : LedId.Custom1));
for (int i = 0; i < DeviceInfo.LedCount; i++)
{
LedId ledId = referenceId + i;
_idMapping.Add(ledId, DeviceInfo.ReferenceCorsairLed + i);
InitializeLed(ledId, new Rectangle(i * 10, 0, 10, 10));
}
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Customs\{model}.xml"), null);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => _idMapping.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion
}
}

View File

@ -0,0 +1,78 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" />.
/// </summary>
public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Properties & Fields
public CorsairLedId ReferenceCorsairLed { get; }
public int LedCount { 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.CorsairCustomRGBDevice" />.</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>
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, CorsairLedId referenceCorsairLed)
: base(deviceIndex, channelDeviceInfo.type == CorsairChannelDeviceType.Strip ? RGBDeviceType.LedStripe : RGBDeviceType.Fan, nativeInfo, GetModelName(channelDeviceInfo.type))
{
this.ReferenceCorsairLed = referenceCorsairLed;
LedCount = channelDeviceInfo.deviceLedCount;
}
#endregion
#region Methods
private static string GetModelName(CorsairChannelDeviceType deviceType)
{
switch (deviceType)
{
case CorsairChannelDeviceType.Invalid:
return "Invalid";
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.Strip:
return "Led Strip";
case CorsairChannelDeviceType.DAP:
return "DAP Fan";
default:
throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null);
}
}
#endregion
}
}

View File

@ -0,0 +1,22 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains 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,
};
}

View File

@ -16,6 +16,8 @@ namespace RGB.NET.Devices.Corsair
Keyboard = 2,
Headset = 3,
Mousepad = 4,
HeadsetStand = 5
HeadsetStand = 5,
CommanderPro = 6,
LightningNodePro = 7
};
}

View File

@ -215,5 +215,307 @@ namespace RGB.NET.Devices.Corsair
HeadsetStandZone7 = 197,
HeadsetStandZone8 = 198,
HeadsetStandZone9 = 199,
CustomDeviceChannel1Led1 = 200,
CustomDeviceChannel1Led2 = 201,
CustomDeviceChannel1Led3 = 202,
CustomDeviceChannel1Led4 = 203,
CustomDeviceChannel1Led5 = 204,
CustomDeviceChannel1Led6 = 205,
CustomDeviceChannel1Led7 = 206,
CustomDeviceChannel1Led8 = 207,
CustomDeviceChannel1Led9 = 208,
CustomDeviceChannel1Led10 = 209,
CustomDeviceChannel1Led11 = 210,
CustomDeviceChannel1Led12 = 211,
CustomDeviceChannel1Led13 = 212,
CustomDeviceChannel1Led14 = 213,
CustomDeviceChannel1Led15 = 214,
CustomDeviceChannel1Led16 = 215,
CustomDeviceChannel1Led17 = 216,
CustomDeviceChannel1Led18 = 217,
CustomDeviceChannel1Led19 = 218,
CustomDeviceChannel1Led20 = 219,
CustomDeviceChannel1Led21 = 220,
CustomDeviceChannel1Led22 = 221,
CustomDeviceChannel1Led23 = 222,
CustomDeviceChannel1Led24 = 223,
CustomDeviceChannel1Led25 = 224,
CustomDeviceChannel1Led26 = 225,
CustomDeviceChannel1Led27 = 226,
CustomDeviceChannel1Led28 = 227,
CustomDeviceChannel1Led29 = 228,
CustomDeviceChannel1Led30 = 229,
CustomDeviceChannel1Led31 = 230,
CustomDeviceChannel1Led32 = 231,
CustomDeviceChannel1Led33 = 232,
CustomDeviceChannel1Led34 = 233,
CustomDeviceChannel1Led35 = 234,
CustomDeviceChannel1Led36 = 235,
CustomDeviceChannel1Led37 = 236,
CustomDeviceChannel1Led38 = 237,
CustomDeviceChannel1Led39 = 238,
CustomDeviceChannel1Led40 = 239,
CustomDeviceChannel1Led41 = 240,
CustomDeviceChannel1Led42 = 241,
CustomDeviceChannel1Led43 = 242,
CustomDeviceChannel1Led44 = 243,
CustomDeviceChannel1Led45 = 244,
CustomDeviceChannel1Led46 = 245,
CustomDeviceChannel1Led47 = 246,
CustomDeviceChannel1Led48 = 247,
CustomDeviceChannel1Led49 = 248,
CustomDeviceChannel1Led50 = 249,
CustomDeviceChannel1Led51 = 250,
CustomDeviceChannel1Led52 = 251,
CustomDeviceChannel1Led53 = 252,
CustomDeviceChannel1Led54 = 253,
CustomDeviceChannel1Led55 = 254,
CustomDeviceChannel1Led56 = 255,
CustomDeviceChannel1Led57 = 256,
CustomDeviceChannel1Led58 = 257,
CustomDeviceChannel1Led59 = 258,
CustomDeviceChannel1Led60 = 259,
CustomDeviceChannel1Led61 = 260,
CustomDeviceChannel1Led62 = 261,
CustomDeviceChannel1Led63 = 262,
CustomDeviceChannel1Led64 = 263,
CustomDeviceChannel1Led65 = 264,
CustomDeviceChannel1Led66 = 265,
CustomDeviceChannel1Led67 = 266,
CustomDeviceChannel1Led68 = 267,
CustomDeviceChannel1Led69 = 268,
CustomDeviceChannel1Led70 = 269,
CustomDeviceChannel1Led71 = 270,
CustomDeviceChannel1Led72 = 271,
CustomDeviceChannel1Led73 = 272,
CustomDeviceChannel1Led74 = 273,
CustomDeviceChannel1Led75 = 274,
CustomDeviceChannel1Led76 = 275,
CustomDeviceChannel1Led77 = 276,
CustomDeviceChannel1Led78 = 277,
CustomDeviceChannel1Led79 = 278,
CustomDeviceChannel1Led80 = 279,
CustomDeviceChannel1Led81 = 280,
CustomDeviceChannel1Led82 = 281,
CustomDeviceChannel1Led83 = 282,
CustomDeviceChannel1Led84 = 283,
CustomDeviceChannel1Led85 = 284,
CustomDeviceChannel1Led86 = 285,
CustomDeviceChannel1Led87 = 286,
CustomDeviceChannel1Led88 = 287,
CustomDeviceChannel1Led89 = 288,
CustomDeviceChannel1Led90 = 289,
CustomDeviceChannel1Led91 = 290,
CustomDeviceChannel1Led92 = 291,
CustomDeviceChannel1Led93 = 292,
CustomDeviceChannel1Led94 = 293,
CustomDeviceChannel1Led95 = 294,
CustomDeviceChannel1Led96 = 295,
CustomDeviceChannel1Led97 = 296,
CustomDeviceChannel1Led98 = 297,
CustomDeviceChannel1Led99 = 298,
CustomDeviceChannel1Led100 = 299,
CustomDeviceChannel1Led101 = 300,
CustomDeviceChannel1Led102 = 301,
CustomDeviceChannel1Led103 = 302,
CustomDeviceChannel1Led104 = 303,
CustomDeviceChannel1Led105 = 304,
CustomDeviceChannel1Led106 = 305,
CustomDeviceChannel1Led107 = 306,
CustomDeviceChannel1Led108 = 307,
CustomDeviceChannel1Led109 = 308,
CustomDeviceChannel1Led110 = 309,
CustomDeviceChannel1Led111 = 310,
CustomDeviceChannel1Led112 = 311,
CustomDeviceChannel1Led113 = 312,
CustomDeviceChannel1Led114 = 313,
CustomDeviceChannel1Led115 = 314,
CustomDeviceChannel1Led116 = 315,
CustomDeviceChannel1Led117 = 316,
CustomDeviceChannel1Led118 = 317,
CustomDeviceChannel1Led119 = 318,
CustomDeviceChannel1Led120 = 319,
CustomDeviceChannel1Led121 = 320,
CustomDeviceChannel1Led122 = 321,
CustomDeviceChannel1Led123 = 322,
CustomDeviceChannel1Led124 = 323,
CustomDeviceChannel1Led125 = 324,
CustomDeviceChannel1Led126 = 325,
CustomDeviceChannel1Led127 = 326,
CustomDeviceChannel1Led128 = 327,
CustomDeviceChannel1Led129 = 328,
CustomDeviceChannel1Led130 = 329,
CustomDeviceChannel1Led131 = 330,
CustomDeviceChannel1Led132 = 331,
CustomDeviceChannel1Led133 = 332,
CustomDeviceChannel1Led134 = 333,
CustomDeviceChannel1Led135 = 334,
CustomDeviceChannel1Led136 = 335,
CustomDeviceChannel1Led137 = 336,
CustomDeviceChannel1Led138 = 337,
CustomDeviceChannel1Led139 = 338,
CustomDeviceChannel1Led140 = 339,
CustomDeviceChannel1Led141 = 340,
CustomDeviceChannel1Led142 = 341,
CustomDeviceChannel1Led143 = 342,
CustomDeviceChannel1Led144 = 343,
CustomDeviceChannel1Led145 = 344,
CustomDeviceChannel1Led146 = 345,
CustomDeviceChannel1Led147 = 346,
CustomDeviceChannel1Led148 = 347,
CustomDeviceChannel1Led149 = 348,
CustomDeviceChannel1Led150 = 349,
CustomDeviceChannel2Led1 = 350,
CustomDeviceChannel2Led2 = 351,
CustomDeviceChannel2Led3 = 352,
CustomDeviceChannel2Led4 = 353,
CustomDeviceChannel2Led5 = 354,
CustomDeviceChannel2Led6 = 355,
CustomDeviceChannel2Led7 = 356,
CustomDeviceChannel2Led8 = 357,
CustomDeviceChannel2Led9 = 358,
CustomDeviceChannel2Led10 = 359,
CustomDeviceChannel2Led11 = 360,
CustomDeviceChannel2Led12 = 361,
CustomDeviceChannel2Led13 = 362,
CustomDeviceChannel2Led14 = 363,
CustomDeviceChannel2Led15 = 364,
CustomDeviceChannel2Led16 = 365,
CustomDeviceChannel2Led17 = 366,
CustomDeviceChannel2Led18 = 367,
CustomDeviceChannel2Led19 = 368,
CustomDeviceChannel2Led20 = 369,
CustomDeviceChannel2Led21 = 370,
CustomDeviceChannel2Led22 = 371,
CustomDeviceChannel2Led23 = 372,
CustomDeviceChannel2Led24 = 373,
CustomDeviceChannel2Led25 = 374,
CustomDeviceChannel2Led26 = 375,
CustomDeviceChannel2Led27 = 376,
CustomDeviceChannel2Led28 = 377,
CustomDeviceChannel2Led29 = 378,
CustomDeviceChannel2Led30 = 379,
CustomDeviceChannel2Led31 = 380,
CustomDeviceChannel2Led32 = 381,
CustomDeviceChannel2Led33 = 382,
CustomDeviceChannel2Led34 = 383,
CustomDeviceChannel2Led35 = 384,
CustomDeviceChannel2Led36 = 385,
CustomDeviceChannel2Led37 = 386,
CustomDeviceChannel2Led38 = 387,
CustomDeviceChannel2Led39 = 388,
CustomDeviceChannel2Led40 = 389,
CustomDeviceChannel2Led41 = 390,
CustomDeviceChannel2Led42 = 391,
CustomDeviceChannel2Led43 = 392,
CustomDeviceChannel2Led44 = 393,
CustomDeviceChannel2Led45 = 394,
CustomDeviceChannel2Led46 = 395,
CustomDeviceChannel2Led47 = 396,
CustomDeviceChannel2Led48 = 397,
CustomDeviceChannel2Led49 = 398,
CustomDeviceChannel2Led50 = 399,
CustomDeviceChannel2Led51 = 400,
CustomDeviceChannel2Led52 = 401,
CustomDeviceChannel2Led53 = 402,
CustomDeviceChannel2Led54 = 403,
CustomDeviceChannel2Led55 = 404,
CustomDeviceChannel2Led56 = 405,
CustomDeviceChannel2Led57 = 406,
CustomDeviceChannel2Led58 = 407,
CustomDeviceChannel2Led59 = 408,
CustomDeviceChannel2Led60 = 409,
CustomDeviceChannel2Led61 = 410,
CustomDeviceChannel2Led62 = 411,
CustomDeviceChannel2Led63 = 412,
CustomDeviceChannel2Led64 = 413,
CustomDeviceChannel2Led65 = 414,
CustomDeviceChannel2Led66 = 415,
CustomDeviceChannel2Led67 = 416,
CustomDeviceChannel2Led68 = 417,
CustomDeviceChannel2Led69 = 418,
CustomDeviceChannel2Led70 = 419,
CustomDeviceChannel2Led71 = 420,
CustomDeviceChannel2Led72 = 421,
CustomDeviceChannel2Led73 = 422,
CustomDeviceChannel2Led74 = 423,
CustomDeviceChannel2Led75 = 424,
CustomDeviceChannel2Led76 = 425,
CustomDeviceChannel2Led77 = 426,
CustomDeviceChannel2Led78 = 427,
CustomDeviceChannel2Led79 = 428,
CustomDeviceChannel2Led80 = 429,
CustomDeviceChannel2Led81 = 430,
CustomDeviceChannel2Led82 = 431,
CustomDeviceChannel2Led83 = 432,
CustomDeviceChannel2Led84 = 433,
CustomDeviceChannel2Led85 = 434,
CustomDeviceChannel2Led86 = 435,
CustomDeviceChannel2Led87 = 436,
CustomDeviceChannel2Led88 = 437,
CustomDeviceChannel2Led89 = 438,
CustomDeviceChannel2Led90 = 439,
CustomDeviceChannel2Led91 = 440,
CustomDeviceChannel2Led92 = 441,
CustomDeviceChannel2Led93 = 442,
CustomDeviceChannel2Led94 = 443,
CustomDeviceChannel2Led95 = 444,
CustomDeviceChannel2Led96 = 445,
CustomDeviceChannel2Led97 = 446,
CustomDeviceChannel2Led98 = 447,
CustomDeviceChannel2Led99 = 448,
CustomDeviceChannel2Led100 = 449,
CustomDeviceChannel2Led101 = 450,
CustomDeviceChannel2Led102 = 451,
CustomDeviceChannel2Led103 = 452,
CustomDeviceChannel2Led104 = 453,
CustomDeviceChannel2Led105 = 454,
CustomDeviceChannel2Led106 = 455,
CustomDeviceChannel2Led107 = 456,
CustomDeviceChannel2Led108 = 457,
CustomDeviceChannel2Led109 = 458,
CustomDeviceChannel2Led110 = 459,
CustomDeviceChannel2Led111 = 460,
CustomDeviceChannel2Led112 = 461,
CustomDeviceChannel2Led113 = 462,
CustomDeviceChannel2Led114 = 463,
CustomDeviceChannel2Led115 = 464,
CustomDeviceChannel2Led116 = 465,
CustomDeviceChannel2Led117 = 466,
CustomDeviceChannel2Led118 = 467,
CustomDeviceChannel2Led119 = 468,
CustomDeviceChannel2Led120 = 469,
CustomDeviceChannel2Led121 = 470,
CustomDeviceChannel2Led122 = 471,
CustomDeviceChannel2Led123 = 472,
CustomDeviceChannel2Led124 = 473,
CustomDeviceChannel2Led125 = 474,
CustomDeviceChannel2Led126 = 475,
CustomDeviceChannel2Led127 = 476,
CustomDeviceChannel2Led128 = 477,
CustomDeviceChannel2Led129 = 478,
CustomDeviceChannel2Led130 = 479,
CustomDeviceChannel2Led131 = 480,
CustomDeviceChannel2Led132 = 481,
CustomDeviceChannel2Led133 = 482,
CustomDeviceChannel2Led134 = 483,
CustomDeviceChannel2Led135 = 484,
CustomDeviceChannel2Led136 = 485,
CustomDeviceChannel2Led137 = 486,
CustomDeviceChannel2Led138 = 487,
CustomDeviceChannel2Led139 = 488,
CustomDeviceChannel2Led140 = 489,
CustomDeviceChannel2Led141 = 490,
CustomDeviceChannel2Led142 = 491,
CustomDeviceChannel2Led143 = 492,
CustomDeviceChannel2Led144 = 493,
CustomDeviceChannel2Led145 = 494,
CustomDeviceChannel2Led146 = 495,
CustomDeviceChannel2Led147 = 496,
CustomDeviceChannel2Led148 = 497,
CustomDeviceChannel2Led149 = 498,
CustomDeviceChannel2Led150 = 499,
}
}

View File

@ -10,17 +10,26 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Represents the update-queue performing updates for corsair devices.
/// </summary>
public class CorsairUpdateQueue : UpdateQueue
public class CorsairDeviceUpdateQueue : UpdateQueue
{
#region Properties & Fields
private int _deviceIndex;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairUpdateQueue"/> class.
/// Initializes a new instance of the <see cref="CorsairDeviceUpdateQueue"/> class.
/// </summary>
/// <param name="updateTrigger">The update trigger used by this queue.</param>
public CorsairUpdateQueue(IDeviceUpdateTrigger updateTrigger)
/// <param name="deviceIndex">The index used to identify the device.</param>
public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIndex)
: base(updateTrigger)
{ }
{
this._deviceIndex = deviceIndex;
}
#endregion
@ -45,7 +54,9 @@ namespace RGB.NET.Devices.Corsair
Marshal.StructureToPtr(color, addPtr, false);
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
}
_CUESDK.CorsairSetLedsColors(dataSet.Count, ptr);
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Count, ptr);
_CUESDK.CorsairSetLedsColorsFlushBuffer();
Marshal.FreeHGlobal(ptr);
}

View File

@ -33,7 +33,7 @@ namespace RGB.NET.Devices.Corsair
/// Gets or sets the update queue performing updates for this device.
/// </summary>
// ReSharper disable once MemberCanBePrivate.Global
protected CorsairUpdateQueue UpdateQueue { get; set; }
protected CorsairDeviceUpdateQueue DeviceUpdateQueue { get; set; }
#endregion
@ -67,9 +67,9 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(CorsairUpdateQueue updateQueue)
public void Initialize(CorsairDeviceUpdateQueue deviceUpdateQueue)
{
UpdateQueue = updateQueue;
DeviceUpdateQueue = deviceUpdateQueue;
InitializeLayout();
@ -94,7 +94,7 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
=> UpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))));
=> DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))));
/// <inheritdoc cref="IRGBDevice.SyncBack" />
public override void SyncBack()
@ -108,7 +108,7 @@ namespace RGB.NET.Devices.Corsair
Marshal.StructureToPtr(color, addPtr, false);
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
}
_CUESDK.CorsairGetLedsColors(LedMapping.Count, ptr);
_CUESDK.CorsairGetLedsColorsByDeviceIndex(DeviceInfo.CorsairDeviceIndex, LedMapping.Count, ptr);
IntPtr readPtr = ptr;
for (int i = 0; i < LedMapping.Count; i++)

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
@ -61,7 +62,23 @@ namespace RGB.NET.Devices.Corsair
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = nativeInfo.model == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeInfo.model);
this.Model = nativeInfo.model == IntPtr.Zero ? null : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
}
/// <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.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
}

View File

@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Corsair
/// </summary>
internal interface ICorsairRGBDevice : IRGBDevice
{
void Initialize(CorsairUpdateQueue updateQueue);
void Initialize(CorsairDeviceUpdateQueue deviceUpdateQueue);
}
}

View File

@ -49,11 +49,11 @@ namespace RGB.NET.Devices.Corsair
Dictionary<CorsairLedId, LedId> mapping = HeadsetStandIdMapping.DEFAULT.SwapKeyValue();
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle());
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => HeadsetStandIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;

View File

@ -0,0 +1,19 @@
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.
double width = position.width < 0.5 ? 10 : position.width;
double height = position.height < 0.5 ? 10 : position.height;
double posX = position.left;
double posY = position.top;
return new Rectangle(posX, posY, width, height);
}
}
}

View File

@ -33,8 +33,7 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc />
protected override void InitializeLayout()
{
_CorsairLedPositions nativeLedPositions =
(_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition;
@ -43,7 +42,7 @@ namespace RGB.NET.Devices.Corsair
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle());
ptr = new IntPtr(ptr.ToInt64() + structSize);
}

View File

@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Gets the physical layout of the mouse.
/// </summary>
public CorsairPhysicalMouseLayout PhysicalLayout { get; private set; }
public CorsairPhysicalMouseLayout PhysicalLayout { get; }
#endregion

View File

@ -49,7 +49,7 @@ namespace RGB.NET.Devices.Corsair
Dictionary<CorsairLedId, LedId> mapping = MousepadIdMapping.DEFAULT.SwapKeyValue();
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle());
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
}

View File

@ -42,11 +42,12 @@ namespace RGB.NET.Devices.Corsair.Native
_dllHandle = LoadLibrary(dllPath);
_corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer));
_corsairGetLedsColorsPointer = (CorsairGetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColors"), typeof(CorsairGetLedsColorsPointer));
_corsairSetLedsColorsBufferByDeviceIndexPointer = (CorsairSetLedsColorsBufferByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsBufferByDeviceIndex"), typeof(CorsairSetLedsColorsBufferByDeviceIndexPointer));
_corsairSetLedsColorsFlushBufferPointer = (CorsairSetLedsColorsFlushBufferPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColorsFlushBuffer"), typeof(CorsairSetLedsColorsFlushBufferPointer));
_corsairGetLedsColorsByDeviceIndexPointer = (CorsairGetLedsColorsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColorsByDeviceIndex"), typeof(CorsairGetLedsColorsByDeviceIndexPointer));
_corsairSetLayerPriorityPointer = (CorsairSetLayerPriorityPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLayerPriority"), typeof(CorsairSetLayerPriorityPointer));
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
_corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer));
_corsairGetLedPositionsByDeviceIndexPointer = (CorsairGetLedPositionsByDeviceIndexPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositionsByDeviceIndex"), typeof(CorsairGetLedPositionsByDeviceIndexPointer));
_corsairGetLedIdForKeyNamePointer = (CorsairGetLedIdForKeyNamePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedIdForKeyName"), typeof(CorsairGetLedIdForKeyNamePointer));
_corsairRequestControlPointer = (CorsairRequestControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRequestControl"), typeof(CorsairRequestControlPointer));
@ -79,11 +80,12 @@ namespace RGB.NET.Devices.Corsair.Native
#region Pointers
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
private static CorsairGetLedsColorsPointer _corsairGetLedsColorsPointer;
private static CorsairSetLedsColorsBufferByDeviceIndexPointer _corsairSetLedsColorsBufferByDeviceIndexPointer;
private static CorsairSetLedsColorsFlushBufferPointer _corsairSetLedsColorsFlushBufferPointer;
private static CorsairGetLedsColorsByDeviceIndexPointer _corsairGetLedsColorsByDeviceIndexPointer;
private static CorsairSetLayerPriorityPointer _corsairSetLayerPriorityPointer;
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
private static CorsairGetLedIdForKeyNamePointer _corsairGetLedIdForKeyNamePointer;
private static CorsairGetLedPositionsByDeviceIndexPointer _corsairGetLedPositionsByDeviceIndexPointer;
private static CorsairRequestControlPointer _corsairRequestControlPointer;
@ -96,10 +98,16 @@ namespace RGB.NET.Devices.Corsair.Native
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
private delegate bool CorsairSetLedsColorsBufferByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsPointer(int size, IntPtr ledsColors);
private delegate bool CorsairSetLedsColorsFlushBufferPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsByDeviceIndexPointer(int deviceIndex, int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLayerPriorityPointer(int priority);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer();
@ -107,9 +115,6 @@ namespace RGB.NET.Devices.Corsair.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetDeviceInfoPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex);
@ -131,16 +136,35 @@ namespace RGB.NET.Devices.Corsair.Native
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified LEDs to some colors.
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
/// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
/// This function does not take logical layout into account.
/// </summary>
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairSetLedsColorsBufferByDeviceIndexPointer(deviceIndex, size, ledsColors);
/// <summary>
/// CUE-SDK: set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account.
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
/// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync
/// </summary>
internal static bool CorsairSetLedsColors(int size, IntPtr ledsColors) => _corsairSetLedsColorsPointer(size, ledsColors);
internal static bool CorsairSetLedsColorsFlushBuffer() => _corsairSetLedsColorsFlushBufferPointer();
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
/// </summary>
internal static bool CorsairGetLedsColors(int size, IntPtr ledsColors) => _corsairGetLedsColorsPointer(size, ledsColors);
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairGetLedsColorsByDeviceIndexPointer(deviceIndex, size, ledsColors);
/// <summary>
/// CUE-SDK: set layer priority for this shared client.
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they dont call this function.
/// Layers with higher priority value are shown on top of layers with lower priority.
/// </summary>
internal static bool CorsairSetLayerPriority(int priority) => _corsairSetLayerPriorityPointer(priority);
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
@ -151,12 +175,7 @@ namespace RGB.NET.Devices.Corsair.Native
/// CUE-SDK: returns information about device at provided index.
/// </summary>
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => _corsairGetDeviceInfoPointer(deviceIndex);
/// <summary>
/// CUE-SDK: provides list of keyboard LEDs with their physical positions.
/// </summary>
internal static IntPtr CorsairGetLedPositions() => _corsairGetLedPositionsPointer();
/// <summary>
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
/// </summary>

View File

@ -0,0 +1,26 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelDeviceInfo
{
/// <summary>
/// CUE-SDK: type of the LED-device
/// </summary>
internal CorsairChannelDeviceType type;
/// <summary>
/// CUE-SDK: number of LEDs controlled by LED-device.
/// </summary>
internal int deviceLedCount;
}
}

View File

@ -0,0 +1,33 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about separate channel of the DIY-device.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelInfo
{
/// <summary>
/// CUE-SDK: total number of LEDs connected to the channel;
/// </summary>
internal int totalLedsCount;
/// <summary>
/// CUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device
/// </summary>
internal int devicesCount;
/// <summary>
/// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device.
/// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device.
/// </summary>
internal IntPtr devices;
}
}

View File

@ -0,0 +1,28 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about channels of the DIY-devices.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairChannelsInfo
{
/// <summary>
/// CUE-SDK: number of channels controlled by the device
/// </summary>
internal int channelsCount;
/// <summary>
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
/// Index of the channel in the array is same as index of the channel on the DIY-device.
/// </summary>
internal IntPtr channels;
}
}

View File

@ -43,5 +43,10 @@ namespace RGB.NET.Devices.Corsair.Native
/// CUE-SDK: number of controllable LEDs on the device
/// </summary>
internal int ledsCount;
/// <summary>
/// CUE-SDK: structure that describes channels of the DIY-devices
/// </summary>
internal _CorsairChannelsInfo channels;
}
}

View File

@ -9,6 +9,7 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mouse/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=headset/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=keyboard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=custom/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean>