diff --git a/CUE.NET.csproj b/CUE.NET.csproj index 72493ca..f738e4e 100644 --- a/CUE.NET.csproj +++ b/CUE.NET.csproj @@ -67,6 +67,9 @@ + + + diff --git a/CueSDK.cs b/CueSDK.cs index fbb3b5b..f38f6ee 100644 --- a/CueSDK.cs +++ b/CueSDK.cs @@ -8,6 +8,7 @@ using CUE.NET.Devices; using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Headset; +using CUE.NET.Devices.HeadsetStand; using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Mouse; using CUE.NET.Devices.Mousemat; @@ -86,11 +87,17 @@ namespace CUE.NET public static CorsairHeadset HeadsetSDK { get; private set; } /// - /// Gets the managed representation of a moustmat managed by the CUE-SDK. + /// Gets the managed representation of a mousemat managed by the CUE-SDK. /// Note that currently only one connected mousemat is supported. /// public static CorsairMousemat MousematSDK { get; private set; } + /// + /// Gets the managed representation of a headset stand managed by the CUE-SDK. + /// Note that currently only one connected headset stand is supported. + /// + public static CorsairHeadsetStand HeadsetStandSDK { get; private set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global #endregion @@ -120,6 +127,8 @@ namespace CUE.NET return HeadsetSDK != null; case CorsairDeviceType.Mousemat: return MousematSDK != null; + case CorsairDeviceType.HeadsetStand: + return HeadsetStandSDK != null; default: return true; } @@ -205,6 +214,9 @@ namespace CUE.NET case CorsairDeviceType.Mousemat: device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo)); break; + case CorsairDeviceType.HeadsetStand: + device = HeadsetStandSDK = new CorsairHeadsetStand(new CorsairHeadsetStandDeviceInfo(nativeDeviceInfo)); + break; // ReSharper disable once RedundantCaseLabel case CorsairDeviceType.Unknown: default: @@ -245,6 +257,7 @@ namespace CUE.NET MouseSDK?.ResetLeds(); HeadsetSDK?.ResetLeds(); MousematSDK?.ResetLeds(); + HeadsetStandSDK?.ResetLeds(); _CUESDK.Reload(); @@ -295,6 +308,10 @@ namespace CUE.NET if (!reloadedDevices.ContainsKey(CorsairDeviceType.Mousemat) || MousematSDK.MousematDeviceInfo.Model != reloadedDevices[CorsairDeviceType.Mousemat].Model) throw new WrapperException("The previously loaded Mousemat got disconnected."); + if (HeadsetStandSDK != null) + if (!reloadedDevices.ContainsKey(CorsairDeviceType.HeadsetStand) + || HeadsetStandSDK.HeadsetStandDeviceInfo.Model != reloadedDevices[CorsairDeviceType.HeadsetStand].Model) + throw new WrapperException("The previously loaded Headset Stand got disconnected."); IsInitialized = true; } @@ -309,6 +326,7 @@ namespace CUE.NET MouseSDK = null; HeadsetSDK = null; MousematSDK = null; + HeadsetStandSDK = null; IsInitialized = false; } diff --git a/Devices/Generic/Enums/CorsairDeviceType.cs b/Devices/Generic/Enums/CorsairDeviceType.cs index adcac29..71ec6b7 100644 --- a/Devices/Generic/Enums/CorsairDeviceType.cs +++ b/Devices/Generic/Enums/CorsairDeviceType.cs @@ -15,6 +15,7 @@ namespace CUE.NET.Devices.Generic.Enums Mouse = 1, Keyboard = 2, Headset = 3, - Mousemat = 4 + Mousemat = 4, + HeadsetStand = 5 }; } diff --git a/Devices/Generic/Enums/CorsairLedId.cs b/Devices/Generic/Enums/CorsairLedId.cs index c22c63a..6f74351 100644 --- a/Devices/Generic/Enums/CorsairLedId.cs +++ b/Devices/Generic/Enums/CorsairLedId.cs @@ -205,5 +205,15 @@ namespace CUE.NET.Devices.Generic.Enums 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/Devices/HeadsetStand/CorsairHeadsetStand.cs b/Devices/HeadsetStand/CorsairHeadsetStand.cs new file mode 100644 index 0000000..f34d1ef --- /dev/null +++ b/Devices/HeadsetStand/CorsairHeadsetStand.cs @@ -0,0 +1,91 @@ +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using CUE.NET.Devices.Generic; +using CUE.NET.Devices.Generic.Enums; +using CUE.NET.Exceptions; +using CUE.NET.Native; + +namespace CUE.NET.Devices.HeadsetStand +{ + /// + /// Represents the SDK for a corsair headset stand. + /// + public class CorsairHeadsetStand : AbstractCueDevice + { + #region Properties & Fields + + /// + /// Gets specific information provided by CUE for the headset stand. + /// + public CorsairHeadsetStandDeviceInfo HeadsetStandDeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the headset stand + internal CorsairHeadsetStand(CorsairHeadsetStandDeviceInfo info) + : base(info) + { + this.HeadsetStandDeviceInfo = info; + } + + #endregion + + #region Methods + + /// + /// Initializes the headset stand. + /// + public override void Initialize() + { + int deviceCount = _CUESDK.CorsairGetDeviceCount(); + + // Get headset stand device index + int headsetStandIndex = -1; + for (int i = 0; i < deviceCount; i++) + { + _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)); + GenericDeviceInfo info = new GenericDeviceInfo(nativeDeviceInfo); + if (info.Type != CorsairDeviceType.HeadsetStand) + continue; + + headsetStandIndex = i; + break; + } + if (headsetStandIndex < 0) + throw new WrapperException("Can't determine headset stand device index"); + + _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(headsetStandIndex), typeof(_CorsairLedPositions)); + int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); + IntPtr ptr = nativeLedPositions.pLedPosition; + + // Put the positions in an array for sorting later on + 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); + } + + // Sort for easy iteration by clients + foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) + InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); + + base.Initialize(); + } + + #endregion + } +} diff --git a/Devices/HeadsetStand/CorsairHeadsetStandDeviceInfo.cs b/Devices/HeadsetStand/CorsairHeadsetStandDeviceInfo.cs new file mode 100644 index 0000000..46bfe1c --- /dev/null +++ b/Devices/HeadsetStand/CorsairHeadsetStandDeviceInfo.cs @@ -0,0 +1,26 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global + +using CUE.NET.Devices.Generic; +using CUE.NET.Native; + +namespace CUE.NET.Devices.HeadsetStand +{ + /// + /// Represents specific information for a CUE headset stand. + /// + public class CorsairHeadsetStandDeviceInfo : GenericDeviceInfo + { + #region Constructors + + /// + /// Internal constructor of managed . + /// + /// The native -struct + internal CorsairHeadsetStandDeviceInfo(_CorsairDeviceInfo nativeInfo) + : base(nativeInfo) + { } + + #endregion + } +} \ No newline at end of file diff --git a/Devices/HeadsetStand/Enums/CorsairHeadsetStandLedId.cs b/Devices/HeadsetStand/Enums/CorsairHeadsetStandLedId.cs new file mode 100644 index 0000000..6ae1a2e --- /dev/null +++ b/Devices/HeadsetStand/Enums/CorsairHeadsetStandLedId.cs @@ -0,0 +1,26 @@ +// ReSharper disable UnusedMember.Global +// ReSharper disable InconsistentNaming + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +using CUE.NET.Devices.Generic.Enums; + +namespace CUE.NET.Devices.HeadsetStand.Enums +{ + /// + /// Contains list of all LEDs available for corsair headset stands. + /// + public static class CorsairHeadsetStandLedId + { + public const CorsairLedId Invalid = CorsairLedId.Invalid; + public const CorsairLedId HeadsetStandZone1 = CorsairLedId.HeadsetStandZone1; + public const CorsairLedId HeadsetStandZone2 = CorsairLedId.HeadsetStandZone2; + public const CorsairLedId HeadsetStandZone3 = CorsairLedId.HeadsetStandZone3; + public const CorsairLedId HeadsetStandZone4 = CorsairLedId.HeadsetStandZone4; + public const CorsairLedId HeadsetStandZone5 = CorsairLedId.HeadsetStandZone5; + public const CorsairLedId HeadsetStandZone6 = CorsairLedId.HeadsetStandZone6; + public const CorsairLedId HeadsetStandZone7 = CorsairLedId.HeadsetStandZone7; + public const CorsairLedId HeadsetStandZone8 = CorsairLedId.HeadsetStandZone8; + public const CorsairLedId HeadsetStandZone9 = CorsairLedId.HeadsetStandZone9; + } +} \ No newline at end of file diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs index 864ac94..3dbedba 100644 --- a/Devices/Mouse/CorsairMouse.cs +++ b/Devices/Mouse/CorsairMouse.cs @@ -2,10 +2,16 @@ // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedMember.Global +using System; +using System.Collections.Generic; using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; using CUE.NET.Devices.Generic; +using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Mouse.Enums; using CUE.NET.Exceptions; +using CUE.NET.Native; namespace CUE.NET.Devices.Mouse { @@ -44,6 +50,14 @@ namespace CUE.NET.Devices.Mouse /// public override void Initialize() { + // Glaive is a special flake that doesn't follow the default layout + if (MouseDeviceInfo.Model == "GLAIVE RGB") + { + InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1)); // Logo + InitializeLed(CorsairMouseLedId.B2, new RectangleF(2, 0, 1, 1)); // Front + InitializeLed(CorsairMouseLedId.B5, new RectangleF(3, 0, 1, 1)); // Sides + return; + } switch (MouseDeviceInfo.PhysicalLayout) { case CorsairPhysicalMouseLayout.Zones1: diff --git a/libs/x64/CUESDK_2015.dll b/libs/x64/CUESDK_2015.dll index 6e5da8c..139ba27 100644 Binary files a/libs/x64/CUESDK_2015.dll and b/libs/x64/CUESDK_2015.dll differ diff --git a/libs/x86/CUESDK_2015.dll b/libs/x86/CUESDK_2015.dll index 70d678f..b0e6996 100644 Binary files a/libs/x86/CUESDK_2015.dll and b/libs/x86/CUESDK_2015.dll differ