mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 13:06:24 +00:00
Fixed custom device creation for corsair
This commit is contained in:
1 parent
5e904eb748
commit
ea44c0d203
3 files changed
+60
-43
No files matched your search
@@ -17,11 +17,6 @@ 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>
|
||||
@@ -36,7 +31,6 @@ public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
|
||||
#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" />.
|
||||
@@ -44,18 +38,24 @@ 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)
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, 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;
|
||||
}
|
||||
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, int ledCount)
|
||||
: base(deviceIndex, GetDeviceType(nativeInfo.type), nativeInfo)
|
||||
{
|
||||
this.LedCount = ledCount;
|
||||
|
||||
LedOffset = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@@ -77,6 +77,24 @@ public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static RGBDeviceType GetDeviceType(CorsairDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
CorsairDeviceType.Unknown => RGBDeviceType.Unknown,
|
||||
CorsairDeviceType.Mouse => RGBDeviceType.Mouse,
|
||||
CorsairDeviceType.Keyboard => RGBDeviceType.Keyboard,
|
||||
CorsairDeviceType.Headset => RGBDeviceType.Headset,
|
||||
CorsairDeviceType.Mousepad => RGBDeviceType.Mousepad,
|
||||
CorsairDeviceType.HeadsetStand => RGBDeviceType.HeadsetStand,
|
||||
CorsairDeviceType.CommanderPro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.LightningNodePro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.MemoryModule => RGBDeviceType.DRAM,
|
||||
CorsairDeviceType.Cooler => RGBDeviceType.Cooler,
|
||||
CorsairDeviceType.Mainboard => RGBDeviceType.Mainboard,
|
||||
CorsairDeviceType.GraphicsCard => RGBDeviceType.GraphicsCard,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo)
|
||||
{
|
||||
switch (channelDeviceInfo.type)
|
||||
|
||||
Reference in new issue
Block a user