mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +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:
1 parent
4b2aba8447
commit
c47afc4704
26 files changed
+810
-64
No files matched your search
+16
-5
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// </summary>
|
||||
internal interface ICorsairRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize(CorsairUpdateQueue updateQueue);
|
||||
void Initialize(CorsairDeviceUpdateQueue deviceUpdateQueue);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user