mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +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
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user