diff --git a/RGB.NET.Core/Devices/RGBDeviceType.cs b/RGB.NET.Core/Devices/RGBDeviceType.cs index e8e96c0..f2bd880 100644 --- a/RGB.NET.Core/Devices/RGBDeviceType.cs +++ b/RGB.NET.Core/Devices/RGBDeviceType.cs @@ -57,5 +57,10 @@ namespace RGB.NET.Core /// Represents a DRAM-bank /// DRAM = 1 << 8, + + /// + /// Represents a headset stand + /// + HeadsetStand = 1 << 9, } } diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index b0670fb..74998c0 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -147,6 +147,10 @@ namespace RGB.NET.Devices.Corsair case CorsairDeviceType.Mousepad: device = new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo)); break; + + case CorsairDeviceType.HeadsetStand: + device = new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo)); + break; // ReSharper disable once RedundantCaseLabel case CorsairDeviceType.Unknown: diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs index 4892fc6..19b7e39 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs @@ -15,6 +15,7 @@ namespace RGB.NET.Devices.Corsair Mouse = 1, Keyboard = 2, Headset = 3, - Mousepad = 4 + Mousepad = 4, + HeadsetStand = 5 }; } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs index e054e1e..8c9f0aa 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs @@ -205,5 +205,15 @@ namespace RGB.NET.Devices.Corsair Lightbar17 = 186, Lightbar18 = 187, Lightbar19 = 188, + + HeadsetStandZone1 = 191, + HeadsetStandZone2 = 192, + HeadsetStandZone3 = 193, + HeadsetStandZone4 = 194, + HeadsetStandZone5 = 195, + HeadsetStandZone6 = 196, + HeadsetStandZone7 = 197, + HeadsetStandZone8 = 198, + HeadsetStandZone9 = 199, } } diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs new file mode 100644 index 0000000..77c2d34 --- /dev/null +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -0,0 +1,60 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair +{ + /// + /// + /// Represents a corsair headset stand. + /// + public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice + { + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the headset stand + internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info) + : base(info) + { } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); + + int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); + IntPtr ptr = nativeLedPositions.pLedPosition; + + List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>(); + for (int i = 0; i < nativeLedPositions.numberOfLed; i++) + { + _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); + ptr = new IntPtr(ptr.ToInt64() + structSize); + positions.Add(ledPosition); + } + + foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) + InitializeLed(new CorsairLedId(this, ledPosition.ledId), + new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); + + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + null, PathHelper.GetAbsolutePath(@"Images\Corsair\HeadsetStands")); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs new file mode 100644 index 0000000..d8a571b --- /dev/null +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs @@ -0,0 +1,29 @@ +using System; +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair +{ + /// + /// + /// Represents a generic information for a . + /// + public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo + { + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairHeadsetStandRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.HeadsetStand, nativeInfo) + { + Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\HeadsetStands\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index 6f48b40..c44f097 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -60,6 +60,8 @@ + + @@ -89,9 +91,11 @@ + +