From d60d4833ca111e3e2febf88cdd81f887ea163fa9 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 5 Feb 2023 07:36:50 +0100 Subject: [PATCH 01/96] Reduced some allocations mostly due to boxing --- .../Color/Behaviors/DefaultColorBehavior.cs | 27 ++++++++++------- .../Color/Behaviors/IColorBehavior.cs | 8 +++++ RGB.NET.Core/Color/Color.cs | 9 +++++- RGB.NET.Core/MVVM/AbstractBindable.cs | 5 ++-- RGB.NET.Core/Positioning/Placeable.cs | 14 ++++----- RGB.NET.Core/Positioning/Point.cs | 18 ++++++----- RGB.NET.Core/Positioning/Rectangle.cs | 30 +++++++------------ RGB.NET.Core/Positioning/Rotation.cs | 2 +- RGB.NET.Core/Positioning/Scale.cs | 5 ++-- RGB.NET.Core/Positioning/Size.cs | 30 ++++++++----------- .../Textures/Sampler/AverageColorSampler.cs | 2 +- 11 files changed, 80 insertions(+), 70 deletions(-) diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index 6942325..baa3515 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Core; /// /// Represents the default-behavior for the work with colors. /// -public class DefaultColorBehavior : IColorBehavior +public sealed class DefaultColorBehavior : IColorBehavior { #region Methods @@ -14,7 +14,7 @@ public class DefaultColorBehavior : IColorBehavior /// Converts the individual byte values of this to a human-readable string. /// /// A string that contains the individual byte values of this . For example "[A: 255, R: 255, G: 0, B: 0]". - public virtual string ToString(in Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; + public string ToString(in Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; /// /// Tests whether the specified object is a and is equivalent to this . @@ -22,28 +22,35 @@ public class DefaultColorBehavior : IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public virtual bool Equals(in Color color, object? obj) + public bool Equals(in Color color, object? obj) { if (obj is not Color color2) return false; - - return color.A.EqualsInTolerance(color2.A) - && color.R.EqualsInTolerance(color2.R) - && color.G.EqualsInTolerance(color2.G) - && color.B.EqualsInTolerance(color2.B); + return Equals(color, color2); } + /// + /// Tests whether the specified object is a and is equivalent to this . + /// + /// The first color to test. + /// The second color to test. + /// true if equivalent to this ; otherwise, false. + public bool Equals(in Color color, in Color color2) => color.A.EqualsInTolerance(color2.A) + && color.R.EqualsInTolerance(color2.R) + && color.G.EqualsInTolerance(color2.G) + && color.B.EqualsInTolerance(color2.B); + /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public virtual int GetHashCode(in Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); + public int GetHashCode(in Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); /// /// Blends a over this color. /// /// The to to blend over. /// The to blend. - public virtual Color Blend(in Color baseColor, in Color blendColor) + public Color Blend(in Color baseColor, in Color blendColor) { if (blendColor.A.EqualsInTolerance(0)) return baseColor; diff --git a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs index 29b6614..f365f37 100644 --- a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs @@ -20,6 +20,14 @@ public interface IColorBehavior /// true if is a equivalent to this ; otherwise, false. bool Equals(in Color color, object? obj); + /// + /// Tests whether the specified object is a and is equivalent to this . + /// + /// The first color to test. + /// The second color to test. + /// true if equivalent to this ; otherwise, false. + bool Equals(in Color color, in Color color2); + /// /// Returns a hash code for this . /// diff --git a/RGB.NET.Core/Color/Color.cs b/RGB.NET.Core/Color/Color.cs index ae775d3..c786502 100644 --- a/RGB.NET.Core/Color/Color.cs +++ b/RGB.NET.Core/Color/Color.cs @@ -11,7 +11,7 @@ namespace RGB.NET.Core; /// Represents an ARGB (alpha, red, green, blue) color. /// [DebuggerDisplay("[A: {A}, R: {R}, G: {G}, B: {B}]")] -public readonly struct Color +public readonly struct Color : IEquatable { #region Constants @@ -196,6 +196,13 @@ public readonly struct Color /// true if is a equivalent to this ; otherwise, false. public override bool Equals(object? obj) => Behavior.Equals(this, obj); + /// + /// Tests whether the specified is equivalent to this , as defined by the current . + /// + /// The color to test. + /// true if is equivalent to this ; otherwise, false. + public bool Equals(Color other) => Behavior.Equals(this, other); + /// /// Returns a hash code for this , as defined by the current . /// diff --git a/RGB.NET.Core/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs index c58c1ae..b12f302 100644 --- a/RGB.NET.Core/MVVM/AbstractBindable.cs +++ b/RGB.NET.Core/MVVM/AbstractBindable.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; using System.Runtime.CompilerServices; namespace RGB.NET.Core; @@ -28,7 +29,7 @@ public abstract class AbstractBindable : IBindable /// Value to apply. /// true if the value needs to be updated; otherweise false. [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected virtual bool RequiresUpdate(ref T storage, T value) => !Equals(storage, value); + protected virtual bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value); /// /// Checks if the property already matches the desired value and updates it if not. diff --git a/RGB.NET.Core/Positioning/Placeable.cs b/RGB.NET.Core/Positioning/Placeable.cs index 29ca551..81b6d82 100644 --- a/RGB.NET.Core/Positioning/Placeable.cs +++ b/RGB.NET.Core/Positioning/Placeable.cs @@ -211,7 +211,7 @@ public class Placeable : AbstractBindable, IPlaceable /// protected virtual void OnLocationChanged() { - LocationChanged?.Invoke(this, new EventArgs()); + LocationChanged?.Invoke(this, EventArgs.Empty); UpdateActualPlaceableData(); } @@ -220,7 +220,7 @@ public class Placeable : AbstractBindable, IPlaceable /// protected virtual void OnSizeChanged() { - SizeChanged?.Invoke(this, new EventArgs()); + SizeChanged?.Invoke(this, EventArgs.Empty); UpdateActualPlaceableData(); } @@ -229,7 +229,7 @@ public class Placeable : AbstractBindable, IPlaceable /// protected virtual void OnScaleChanged() { - ScaleChanged?.Invoke(this, new EventArgs()); + ScaleChanged?.Invoke(this, EventArgs.Empty); UpdateActualPlaceableData(); } @@ -238,24 +238,24 @@ public class Placeable : AbstractBindable, IPlaceable /// protected virtual void OnRotationChanged() { - RotationChanged?.Invoke(this, new EventArgs()); + RotationChanged?.Invoke(this, EventArgs.Empty); UpdateActualPlaceableData(); } /// /// Called when the property was changed. /// - protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, new EventArgs()); + protected virtual void OnActualLocationChanged() => ActualLocationChanged?.Invoke(this, EventArgs.Empty); /// /// Called when the property was changed. /// - protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, new EventArgs()); + protected virtual void OnActualSizeChanged() => ActualSizeChanged?.Invoke(this, EventArgs.Empty); /// /// Called when the property was changed. /// - protected virtual void OnBoundaryChanged() => BoundaryChanged?.Invoke(this, new EventArgs()); + protected virtual void OnBoundaryChanged() => BoundaryChanged?.Invoke(this, EventArgs.Empty); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs index e2f3d97..e92c65f 100644 --- a/RGB.NET.Core/Positioning/Point.cs +++ b/RGB.NET.Core/Positioning/Point.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Core; /// Represents a point consisting of a X- and a Y-position. /// [DebuggerDisplay("[X: {X}, Y: {Y}]")] -public readonly struct Point +public readonly struct Point : IEquatable { #region Constants @@ -59,18 +59,20 @@ public readonly struct Point /// A string that contains the and of this . For example "[X: 100, Y: 20]". public override string ToString() => $"[X: {X}, Y: {Y}]"; + /// + /// Tests whether the specified is equivalent to this . + /// + /// The point to test. + /// true if is equivalent to this ; otherwise, false. + public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || X.EqualsInTolerance(other.X)) + && ((float.IsNaN(Y) && float.IsNaN(other.Y)) || Y.EqualsInTolerance(other.Y)); + /// /// Tests whether the specified object is a and is equivalent to this . /// /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object? obj) - { - if (obj is not Point comparePoint) return false; - - return ((float.IsNaN(X) && float.IsNaN(comparePoint.X)) || X.EqualsInTolerance(comparePoint.X)) - && ((float.IsNaN(Y) && float.IsNaN(comparePoint.Y)) || Y.EqualsInTolerance(comparePoint.Y)); - } + public override bool Equals(object? obj) => obj is Point other && Equals(other); /// /// Returns a hash code for this . diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index a178989..456a568 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Core; /// Represents a rectangle defined by it's position and it's size. /// [DebuggerDisplay("[Location: {Location}, Size: {Size}]")] -public readonly struct Rectangle +public readonly struct Rectangle : IEquatable { #region Properties & Fields @@ -172,35 +172,25 @@ public readonly struct Rectangle /// A string that contains the and of this . For example "[Location: [X: 100, Y: 10], Size: [Width: 20, Height: [40]]". public override string ToString() => $"[Location: {Location}, Size: {Size}]"; + /// + /// Tests whether the specified is equivalent to this . + /// + /// The rectangle to test. + /// true if is equivalent to this ; otherwise, false. + public bool Equals(Rectangle other) => (Location == other.Location) && (Size == other.Size); + /// /// Tests whether the specified object is a and is equivalent to this . /// /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object? obj) - { - if (obj is not Rectangle compareRect) - return false; - - if (GetType() != compareRect.GetType()) - return false; - - return (Location == compareRect.Location) && (Size == compareRect.Size); - } + public override bool Equals(object? obj) => obj is Rectangle other && Equals(other); /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - unchecked - { - int hashCode = Location.GetHashCode(); - hashCode = (hashCode * 397) ^ Size.GetHashCode(); - return hashCode; - } - } + public override int GetHashCode() => HashCode.Combine(Location, Size); #endregion diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs index 58903b7..e204b75 100644 --- a/RGB.NET.Core/Positioning/Rotation.cs +++ b/RGB.NET.Core/Positioning/Rotation.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Core; /// Represents an angular rotation. /// [DebuggerDisplay("[{" + nameof(Degrees) + "}°]")] -public readonly struct Rotation +public readonly struct Rotation : IEquatable { #region Constants diff --git a/RGB.NET.Core/Positioning/Scale.cs b/RGB.NET.Core/Positioning/Scale.cs index 8c88406..973bf9c 100644 --- a/RGB.NET.Core/Positioning/Scale.cs +++ b/RGB.NET.Core/Positioning/Scale.cs @@ -1,6 +1,7 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global +using System; using System.Diagnostics; namespace RGB.NET.Core; @@ -9,7 +10,7 @@ namespace RGB.NET.Core; /// Represents a scaling. /// [DebuggerDisplay("[Horizontal: {Horizontal}, Vertical: {Vertical}]")] -public readonly struct Scale +public readonly struct Scale : IEquatable { #region Properties & Fields @@ -67,7 +68,7 @@ public readonly struct Scale /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public override int GetHashCode() { unchecked { return (Horizontal.GetHashCode() * 397) ^ Vertical.GetHashCode(); } } + public override int GetHashCode() => HashCode.Combine(Horizontal, Vertical); /// /// Deconstructs the scale into the horizontal and vertical value. diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs index daba2ff..1a9a6d6 100644 --- a/RGB.NET.Core/Positioning/Size.cs +++ b/RGB.NET.Core/Positioning/Size.cs @@ -1,6 +1,7 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global +using System; using System.Diagnostics; namespace RGB.NET.Core; @@ -9,7 +10,7 @@ namespace RGB.NET.Core; /// Represents a size consisting of a width and a height. /// [DebuggerDisplay("[Width: {Width}, Height: {Height}]")] -public readonly struct Size +public readonly struct Size : IEquatable { #region Constants @@ -67,33 +68,26 @@ public readonly struct Size /// A string that contains the and of this . For example "[Width: 100, Height: 20]". public override string ToString() => $"[Width: {Width}, Height: {Height}]"; + /// + /// Tests whether the specified is equivalent to this . + /// + /// The size to test. + /// true if is equivalent to this ; otherwise, false. + public bool Equals(Size other) => ((float.IsNaN(Width) && float.IsNaN(other.Width)) || Width.EqualsInTolerance(other.Width)) + && ((float.IsNaN(Height) && float.IsNaN(other.Height)) || Height.EqualsInTolerance(other.Height)); + /// /// Tests whether the specified object is a and is equivalent to this . /// /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object? obj) - { - if (obj is not Size size) return false; - - (float width, float height) = size; - return ((float.IsNaN(Width) && float.IsNaN(width)) || Width.EqualsInTolerance(width)) - && ((float.IsNaN(Height) && float.IsNaN(height)) || Height.EqualsInTolerance(height)); - } + public override bool Equals(object? obj) => obj is Size other && Equals(other); /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - unchecked - { - int hashCode = Width.GetHashCode(); - hashCode = (hashCode * 397) ^ Height.GetHashCode(); - return hashCode; - } - } + public override int GetHashCode() => HashCode.Combine(Width, Height); /// /// Deconstructs the size into the width and height value. diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index f93d212..d8fd006 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Core; /// /// Averages all components (A, R, G, B) of the colors separately which isn't ideal in cases where multiple different colors are combined. /// -public class AverageColorSampler : ISampler +public sealed class AverageColorSampler : ISampler { #region Constants From 7c165f51af362a0c8ac08a4b58a68bafe5405d64 Mon Sep 17 00:00:00 2001 From: Markus Mohoritsch Date: Sun, 5 Feb 2023 12:29:40 +0100 Subject: [PATCH 02/96] Add new PID to list of known Lightspeed Receivers Logitech is using a new PID 0xC547 for some of it's Lightspeed receivers. --- RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs index a536a1e..69cdce1 100644 --- a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs +++ b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs @@ -28,7 +28,8 @@ public class LightspeedHIDLoader : IEnumerable : IEnumerable Date: Mon, 6 Feb 2023 13:43:05 +1100 Subject: [PATCH 03/96] Update RazerDeviceProvider.cs Added: - Mouse: Razer Naga Pro - Headset: Razer Nari - Other: Razer Mouse Dock Changed: - Chroma Hardware Development Kit (HDK): This is a LED Controller - Addressable RGB Controller: This is a LED Controller --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 09f1a27..fd34e77 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -164,6 +164,7 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0084, RGBDeviceType.Mouse, "DeathAdder V2", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008A, RGBDeviceType.Mouse, "Viper Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008D, RGBDeviceType.Mouse, "Naga Left Handed Edition", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0090, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0091, RGBDeviceType.Mouse, "Viper 8khz", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0096, RGBDeviceType.Mouse, "Naga X", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0099, RGBDeviceType.Mouse, "Basilisk v3", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -182,6 +183,7 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0506, RGBDeviceType.Headset, "Kraken 7.1", LedMappings.Headset, RazerEndpointType.Headset }, { 0x0510, RGBDeviceType.Headset, "Kraken 7.1 V2", LedMappings.Headset, RazerEndpointType.Headset }, { 0x051A, RGBDeviceType.Headset, "Nari Ultimate", LedMappings.Headset, RazerEndpointType.Headset }, + { 0x051C, RGBDeviceType.Headset, "Nari", LedMappings.Headset, RazerEndpointType.Headset }, { 0x0527, RGBDeviceType.Headset, "Kraken Ultimate", LedMappings.Headset, RazerEndpointType.Headset }, { 0x0F19, RGBDeviceType.Headset, "Kraken Kitty Edition", LedMappings.Headset, RazerEndpointType.Headset }, @@ -198,13 +200,15 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0215, RGBDeviceType.GraphicsCard, "Core", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F08, RGBDeviceType.HeadsetStand, "Base Station Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 16.12.2022: Not tested but based on the V2 I assume this is also a mousepad { 0x0F20, RGBDeviceType.HeadsetStand, "Base Station V2 Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 16.12.2022: Not sure why, but it's handled as a mousepad + { 0x007E, RGBDeviceType.LedStripe, "Razer Mouse Dock Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, //roxaskeyheart 06.02.2023: Probably handled the same as a mousepad { 0x0517, RGBDeviceType.Speaker, "Nommo Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0518, RGBDeviceType.Speaker, "Nommo Pro", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F07, RGBDeviceType.Unknown, "Chroma Mug Holder", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, - { 0x0F09, RGBDeviceType.Unknown, "Chroma Hardware Development Kit (HDK)", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, + { 0x0F09, RGBDeviceType.LedController, "Chroma Hardware Development Kit (HDK)", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F13, RGBDeviceType.Unknown, "Lian Li O11", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F1D, RGBDeviceType.Unknown, "Mouse Bungee V3 Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, - { 0x0F1F, RGBDeviceType.Unknown, "Addressable RGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink } + { 0x0F1F, RGBDeviceType.LedController, "Addressable RGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, + }; #endregion From 43ecc7374e12219ee06b27545851e852efb295ad Mon Sep 17 00:00:00 2001 From: Danielle Date: Mon, 6 Feb 2023 13:47:34 +1100 Subject: [PATCH 04/96] Update RazerDeviceProvider.cs --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index fd34e77..daeec43 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -164,7 +164,8 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0084, RGBDeviceType.Mouse, "DeathAdder V2", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008A, RGBDeviceType.Mouse, "Viper Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008D, RGBDeviceType.Mouse, "Naga Left Handed Edition", LedMappings.Mouse, RazerEndpointType.Mouse }, - { 0x0090, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x008F, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via usb connection + { 0x0090, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via bluetooth connection { 0x0091, RGBDeviceType.Mouse, "Viper 8khz", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0096, RGBDeviceType.Mouse, "Naga X", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0099, RGBDeviceType.Mouse, "Basilisk v3", LedMappings.Mouse, RazerEndpointType.Mouse }, From 180b0e45383007920e7a883a746916dc972b73eb Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 10 Feb 2023 19:23:34 +0100 Subject: [PATCH 05/96] Updated corsair SDK to iCUE SDK v4.0.48 --- RGB.NET.Core/Leds/LedMapping.cs | 6 + .../Cooler/CorsairCoolerRGBDevice.cs | 34 + .../Cooler/CorsairCoolerRGBDeviceInfo.cs | 28 + .../CorsairDeviceProvider.cs | 271 ++- .../Custom/CorsairCustomRGBDevice.cs | 74 - .../Custom/CorsairCustomRGBDeviceInfo.cs | 155 -- .../Enum/CorsairAccessLevel.cs | 30 + .../Enum/CorsairAccessMode.cs | 14 - .../Enum/CorsairChannelDeviceType.cs | 18 +- .../Enum/CorsairDataType.cs | 47 + .../Enum/CorsairDeviceCaps.cs | 28 - .../Enum/CorsairDevicePropertyId.cs | 77 + .../Enum/CorsairDeviceType.cs | 90 +- RGB.NET.Devices.Corsair/Enum/CorsairError.cs | 37 +- .../Enum/CorsairLedGroup.cs | 82 + RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs | 1742 ----------------- .../Enum/CorsairLedIdKeyboard.cs | 142 ++ .../Enum/CorsairLogicalKeyboardLayout.cs | 4 +- .../Enum/CorsairPhysicalKeyboardLayout.cs | 28 +- .../Enum/CorsairPhysicalMouseLayout.cs | 107 - .../Enum/CorsairPropertyFlag.cs | 30 + .../Enum/CorsairSessionState.cs | 45 + .../Fan/CorsairFanRGBDevice.cs | 34 + .../Fan/CorsairFanRGBDeviceInfo.cs | 28 + .../Generic/CorsairDeviceUpdateQueue.cs | 46 +- .../Generic/CorsairLedId.cs | 54 + .../Generic/CorsairProtocolDetails.cs | 65 - .../Generic/CorsairRGBDevice.cs | 41 +- .../Generic/CorsairRGBDeviceInfo.cs | 36 +- .../Generic/LedMappings.cs | 472 ++--- .../CorsairGraphicsCardRGBDevice.cs | 9 +- .../CorsairGraphicsCardRGBDeviceInfo.cs | 9 +- .../Headset/CorsairHeadsetRGBDevice.cs | 9 +- .../Headset/CorsairHeadsetRGBDeviceInfo.cs | 9 +- .../CorsairHeadsetStandRGBDevice.cs | 9 +- .../CorsairHeadsetStandRGBDeviceInfo.cs | 9 +- .../Helper/NativeExtensions.cs | 26 +- .../Keyboard/CorsairKeyboardRGBDevice.cs | 9 +- .../Keyboard/CorsairKeyboardRGBDeviceInfo.cs | 9 +- .../LedStrip/CorsairLedStripGBDevice.cs | 34 + .../LedStrip/CorsairLedStripRGBDeviceInfo.cs | 28 + .../Mainboard/CorsairMainboardRGBDevice.cs | 9 +- .../CorsairMainboardRGBDeviceInfo.cs | 9 +- .../Memory/CorsairMemoryRGBDevice.cs | 9 +- .../Memory/CorsairMemoryRGBDeviceInfo.cs | 14 +- .../Mouse/CorsairMouseRGBDevice.cs | 9 +- .../Mouse/CorsairMouseRGBDeviceInfo.cs | 22 +- .../Mousepad/CorsairMousepadRGBDevice.cs | 9 +- .../Mousepad/CorsairMousepadRGBDeviceInfo.cs | 9 +- RGB.NET.Devices.Corsair/Native/_CUESDK.cs | 381 ++-- .../Native/_CorsairChannelInfo.cs | 33 - .../Native/_CorsairDataValue.cs | 140 ++ ...hannelsInfo.cs => _CorsairDeviceFilter.cs} | 30 +- .../Native/_CorsairDeviceInfo.cs | 39 +- .../Native/_CorsairLedColor.cs | 48 +- .../Native/_CorsairLedPosition.cs | 30 +- .../Native/_CorsairLedPositions.cs | 26 - ...annelDeviceInfo.cs => _CorsairProperty.cs} | 23 +- .../Native/_CorsairProtocolDetails.cs | 43 - .../Native/_CorsairSessionDetails.cs | 32 + .../Native/_CorsairSessionStateChanged.cs | 27 + .../Native/_CorsairVersion.cs | 31 + RGB.NET.Devices.Corsair/README.md | 6 +- ...RGB.NET.Devices.Corsair.csproj.DotSettings | 5 + .../Touchbar/CorsairTouchbarRGBDevice.cs | 11 +- .../Touchbar/CorsairTouchbarRGBDeviceInfo.cs | 9 +- .../Unknown/CorsairUnknownRGBDevice.cs | 34 + .../Unknown/CorsairUnknownRGBDeviceInfo.cs | 23 + 68 files changed, 2001 insertions(+), 3085 deletions(-) create mode 100644 RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs delete mode 100644 RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs delete mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs delete mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs delete mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs delete mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs create mode 100644 RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs create mode 100644 RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs delete mode 100644 RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs create mode 100644 RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairChannelInfo.cs create mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs rename RGB.NET.Devices.Corsair/Native/{_CorsairChannelsInfo.cs => _CorsairDeviceFilter.cs} (50%) delete mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairLedPositions.cs rename RGB.NET.Devices.Corsair/Native/{_CorsairChannelDeviceInfo.cs => _CorsairProperty.cs} (60%) delete mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairProtocolDetails.cs create mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs create mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs create mode 100644 RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs create mode 100644 RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs diff --git a/RGB.NET.Core/Leds/LedMapping.cs b/RGB.NET.Core/Leds/LedMapping.cs index e2866d3..05a10ec 100644 --- a/RGB.NET.Core/Leds/LedMapping.cs +++ b/RGB.NET.Core/Leds/LedMapping.cs @@ -11,6 +11,12 @@ namespace RGB.NET.Core; public class LedMapping : IEnumerable<(LedId ledId, T mapping)> where T : notnull { + #region Constants + + public static LedMapping Empty { get; } = new(); + + #endregion + #region Properties & Fields private readonly Dictionary _mapping = new(); diff --git a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs new file mode 100644 index 0000000..fd5b89b --- /dev/null +++ b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs @@ -0,0 +1,34 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using System.Collections.Generic; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a corsair cooler. +/// +public class CorsairCoolerRGBDevice : CorsairRGBDevice, ICooler +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the cooler. + /// The queue used to update this device. + internal CorsairCoolerRGBDevice(CorsairCoolerRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { } + + #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateCoolerMapping(ids); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs new file mode 100644 index 0000000..958f129 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + internal CorsairCoolerRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Cooler, nativeInfo, ledCount, ledOffset) + { } + + /// + internal CorsairCoolerRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) + : base(RGBDeviceType.Cooler, nativeInfo, ledCount, ledOffset, modelName) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 7acd75e..7a1abe0 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -3,8 +3,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; +using System.Threading; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; @@ -28,23 +27,23 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" }; + public static List PossibleX86NativePaths { get; } = new() { "x86/iCUESDK.dll", "x86/CUESDK_2019.dll" }; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" }; + public static List PossibleX64NativePaths { get; } = new() { "x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll" }; /// - /// Gets the protocol details for the current SDK-connection. + /// Gets or sets the timeout used when connecting to the SDK. /// - public CorsairProtocolDetails? ProtocolDetails { get; private set; } + public static TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromMilliseconds(500); /// - /// Gets the last error documented by CUE. + /// Gets or sets a bool indicating if exclusive request should be requested through the iCUE-SDK. /// - public static CorsairError LastError => _CUESDK.CorsairGetLastError(); + public static bool ExclusiveAccess { get; set; } = false; #endregion @@ -64,25 +63,35 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider #region Methods - /// protected override void InitializeSDK() { _CUESDK.Reload(); - ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake()); + using ManualResetEventSlim waitEvent = new(false); - CorsairError error = LastError; - if (error != CorsairError.Success) - Throw(new CUEException(error), true); + void OnSessionStateChanged(object? sender, CorsairSessionState state) + { + if (state == CorsairSessionState.Connected) + // ReSharper disable once AccessToDisposedClosure + waitEvent.Set(); + } - if (ProtocolDetails.BreakingChanges) - Throw(new RGBDeviceException("The SDK currently used isn't compatible with the installed version of CUE.\r\n" - + $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n" - + $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})"), true); + try + { + _CUESDK.SessionStateChanged += OnSessionStateChanged; - // DarthAffe 02.02.2021: 127 is iCUE - if (!_CUESDK.CorsairSetLayerPriority(128)) - Throw(new CUEException(LastError)); + CorsairError errorCode = _CUESDK.CorsairConnect(); + + if (errorCode != CorsairError.Success) + Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (ErrorCode: {errorCode})")); + + if (!waitEvent.Wait(ConnectionTimeout)) + Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (Timeout - Current connection state: {_CUESDK.SesionState})")); + } + finally + { + _CUESDK.SessionStateChanged -= OnSessionStateChanged; + } } /// @@ -97,116 +106,174 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider private IEnumerable LoadCorsairDevices() { - int deviceCount = _CUESDK.CorsairGetDeviceCount(); - for (int i = 0; i < deviceCount; i++) + CorsairError error = _CUESDK.CorsairGetDevices(new _CorsairDeviceFilter(CorsairDeviceType.All), out _CorsairDeviceInfo[] devices); + if (error != CorsairError.Success) + Throw(new RGBDeviceException($"Failed to load devices. (ErrorCode: {error})")); + + foreach (_CorsairDeviceInfo device in devices) { - _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo))!; - if (!((CorsairDeviceCaps)nativeDeviceInfo.capsMask).HasFlag(CorsairDeviceCaps.Lighting)) - continue; // Everything that doesn't support lighting control is useless + if (string.IsNullOrWhiteSpace(device.id)) continue; - CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i); - switch (nativeDeviceInfo.type) + error = _CUESDK.CorsairRequestControl(device.id, ExclusiveAccess ? CorsairAccessLevel.ExclusiveLightingControl : CorsairAccessLevel.Shared); + if (error != CorsairError.Success) + Throw(new RGBDeviceException($"Failed to take control of device '{device.id}'. (ErrorCode: {error})")); + + CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), device); + + Console.WriteLine("Loading " + device.model); + int channelLedCount = 0; + for (int i = 0; i < device.channelCount; i++) { - case CorsairDeviceType.Keyboard: - yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + Console.WriteLine($"Channel {i}/{device.channelCount}"); + channelLedCount += _CUESDK.ReadDevicePropertySimpleInt32(device.id!, CorsairDevicePropertyId.ChannelLedCount, (uint)i); + } - case CorsairDeviceType.Mouse: - yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + int deviceLedCount = device.ledCount - channelLedCount; + if (deviceLedCount > 0) + switch (device.type) + { + case CorsairDeviceType.Keyboard: + yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.Headset: - yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.Mouse: + yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.Mousepad: - yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.Headset: + yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.HeadsetStand: - yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.Mousemat: + yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.MemoryModule: - yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.HeadsetStand: + yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.Mainboard: - yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.MemoryModule: + yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.GraphicsCard: - yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.Motherboard: + yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.Touchbar: - yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); - break; + case CorsairDeviceType.GraphicsCard: + yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - case CorsairDeviceType.Cooler: - case CorsairDeviceType.CommanderPro: - case CorsairDeviceType.LightningNodePro: - List<_CorsairChannelInfo> channels = GetChannels(nativeDeviceInfo).ToList(); - int channelsLedCount = channels.Sum(x => x.totalLedsCount); - int deviceLedCount = nativeDeviceInfo.ledsCount - channelsLedCount; + case CorsairDeviceType.Touchbar: + yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - if (deviceLedCount > 0) - yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, deviceLedCount), updateQueue); + case CorsairDeviceType.Cooler: + yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; - int ledOffset = deviceLedCount; - foreach (_CorsairChannelInfo channelInfo in channels) + case CorsairDeviceType.FanLedController: + case CorsairDeviceType.LedController: + case CorsairDeviceType.Unknown: + yield return new CorsairUnknownRGBDevice(new CorsairUnknownRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; + + default: + Throw(new RGBDeviceException("Unknown Device-Type")); + break; + } + + int offset = deviceLedCount; + for (int i = 0; i < device.channelCount; i++) + { + int deviceCount = _CUESDK.ReadDevicePropertySimpleInt32(device.id!, CorsairDevicePropertyId.ChannelDeviceCount, (uint)i); + if (deviceCount <= 0) continue; // DarthAffe 10.02.2023: There seem to be an issue in the SDK where it reports empty channels and fails when getting ledCounts and device types from them + + int[] ledCounts = _CUESDK.ReadDevicePropertySimpleInt32Array(device.id!, CorsairDevicePropertyId.ChannelDeviceLedCountArray, (uint)i); + int[] deviceTypes = _CUESDK.ReadDevicePropertySimpleInt32Array(device.id!, CorsairDevicePropertyId.ChannelDeviceTypeArray, (uint)i); + + for (int j = 0; j < deviceCount; j++) + { + CorsairChannelDeviceType deviceType = (CorsairChannelDeviceType)deviceTypes[j]; + int ledCount = ledCounts[j]; + + switch (deviceType) { - int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo)); - IntPtr channelDeviceInfoPtr = channelInfo.devices; - for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++) - { - _CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!; + case CorsairChannelDeviceType.FanHD: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "HD Fan"), updateQueue); + break; - yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue); + case CorsairChannelDeviceType.FanSP: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "SP Fan"), updateQueue); + break; - ledOffset += channelDeviceInfo.deviceLedCount; - channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize); - } + case CorsairChannelDeviceType.FanLL: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "LL Fan"), updateQueue); + break; + + case CorsairChannelDeviceType.FanML: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "ML Fan"), updateQueue); + break; + + case CorsairChannelDeviceType.FanQL: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "QL Fan"), updateQueue); + break; + + case CorsairChannelDeviceType.EightLedSeriesFan: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "8-Led-Series Fan Fan"), updateQueue); + break; + + case CorsairChannelDeviceType.DAP: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "DAP Fan"), updateQueue); + break; + + case CorsairChannelDeviceType.Pump: + yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, ledCount, offset, "Pump"), updateQueue); + break; + + case CorsairChannelDeviceType.WaterBlock: + yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, ledCount, offset, "Water Block"), updateQueue); + break; + + case CorsairChannelDeviceType.Strip: + string modelName = "LED Strip"; + + // LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single + if ((device.model == "LS100 Starter Kit") && (ledCount == 138)) + modelName = "LS100 LED Strip (dual monitor)"; + else if ((device.model == "LS100 Starter Kit") && (ledCount == 84)) + modelName = "LS100 LED Strip (single monitor)"; + // Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long + else if ((device.model == "LS100 Starter Kit") && (ledCount == 15)) + modelName = "LS100 LED Strip (short)"; + else if ((device.model == "LS100 Starter Kit") && (ledCount == 27)) + modelName = "LS100 LED Strip (long)"; + + yield return new CorsairLedStripRGBDevice(new CorsairLedStripRGBDeviceInfo(device, ledCount, offset, modelName), updateQueue); + break; + + case CorsairChannelDeviceType.DRAM: + yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(device, ledCount, offset, "DRAM"), updateQueue); + break; + + default: + Throw(new RGBDeviceException("Unknown Device-Type")); + break; } - break; - default: - Throw(new RGBDeviceException("Unknown Device-Type")); - break; + offset += ledCount; + } } } } - private static IEnumerable<_CorsairChannelInfo> GetChannels(_CorsairDeviceInfo deviceInfo) - { - _CorsairChannelsInfo? channelsInfo = deviceInfo.channels; - if (channelsInfo == null) yield break; - - IntPtr channelInfoPtr = channelsInfo.channels; - for (int channel = 0; channel < channelsInfo.channelsCount; channel++) - { - yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!; - - int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo)); - channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize); - } - } - - /// - protected override void Reset() - { - ProtocolDetails = null; - - base.Reset(); - } - /// public override void Dispose() { base.Dispose(); - try { _CUESDK.UnloadCUESDK(); } - catch { /* at least we tried */ } + try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ } + try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ } GC.SuppressFinalize(this); } diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs deleted file mode 100644 index 1bc3b6e..0000000 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs +++ /dev/null @@ -1,74 +0,0 @@ -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedMember.Global - -using System; -using System.Runtime.InteropServices; -using RGB.NET.Core; -using RGB.NET.Devices.Corsair.Native; - -namespace RGB.NET.Devices.Corsair; - -/// -/// -/// Represents a corsair custom. -/// -public class CorsairCustomRGBDevice : CorsairRGBDevice, IUnknownDevice -{ - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - /// The specific information provided by CUE for the custom-device. - /// The queue used to update this device. - internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, new LedMapping(), updateQueue) - { } - - #endregion - - #region Methods - - /// - protected override void InitializeLayout() - { - Mapping.Clear(); - - _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); - if (nativeLedPositions == null) return; - - int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); - IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset)); - - LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType); - for (int i = 0; i < DeviceInfo.LedCount; i++) - { - LedId ledId = referenceLedId + i; - _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); - if (ledPosition == null) - { - ptr = new IntPtr(ptr.ToInt64() + structSize); - continue; - } - - Mapping.Add(ledId, ledPosition.LedId); - - Rectangle rectangle = ledPosition.ToRectangle(); - AddLed(ledId, rectangle.Location, rectangle.Size); - - ptr = new IntPtr(ptr.ToInt64() + structSize); - } - } - - private static LedId GetReferenceLed(RGBDeviceType deviceType) - => deviceType switch - { - RGBDeviceType.LedStripe => LedId.LedStripe1, - RGBDeviceType.Fan => LedId.Fan1, - RGBDeviceType.Cooler => LedId.Cooler1, - _ => LedId.Custom1 - }; - - #endregion -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs deleted file mode 100644 index 5d0858a..0000000 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs +++ /dev/null @@ -1,155 +0,0 @@ -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedMember.Global - -using System; -using System.Runtime.InteropServices; -using System.Text.RegularExpressions; -using RGB.NET.Core; -using RGB.NET.Devices.Corsair.Native; - -namespace RGB.NET.Devices.Corsair; - -/// -/// -/// Represents a generic information for a . -/// -public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo -{ - #region Properties & Fields - - /// - /// Gets the amount of LEDs this device contains. - /// - public int LedCount { get; } - - /// - /// Gets the offset used to access the LEDs of this device. - /// - internal int LedOffset { get; } - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - /// The native representing this device. - /// The offset used to find the LEDs of this device. - 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.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 - - private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType) - => deviceType switch - { - CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown, - CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan, - CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan, - CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan, - CorsairChannelDeviceType.FanML => RGBDeviceType.Fan, - CorsairChannelDeviceType.DAP => RGBDeviceType.Fan, - CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan, - CorsairChannelDeviceType.EightLedSeriesFan => RGBDeviceType.Fan, - CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe, - CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler, - CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler, - _ => 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) - { - case CorsairChannelDeviceType.Invalid: - return model; - - 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.FanQL: - return "QL Fan"; - - case CorsairChannelDeviceType.EightLedSeriesFan: - return "8-Led-Series Fan Fan"; - - case CorsairChannelDeviceType.Strip: - // LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single - if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138)) - return "LS100 LED Strip (dual monitor)"; - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84)) - return "LS100 LED Strip (single monitor)"; - // Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15)) - return "LS100 LED Strip (short)"; - else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27)) - return "LS100 LED Strip (long)"; - // Device model is "Commander Pro" for regular LED strips - else - return "LED Strip"; - - case CorsairChannelDeviceType.DAP: - return "DAP Fan"; - - case CorsairChannelDeviceType.WaterBlock: - return "Water Block"; - - case CorsairChannelDeviceType.Pump: - return "Pump"; - - default: -#pragma warning disable CA2208 // Instantiate argument exceptions correctly - throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null); -#pragma warning restore CA2208 // Instantiate argument exceptions correctly - } - } - - #endregion -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs b/RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs new file mode 100644 index 0000000..33a87e0 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairAccessLevel.cs @@ -0,0 +1,30 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: Represents an SDK access level. +/// +public enum CorsairAccessLevel +{ + /// + /// iCUE-SDK: shared mode (default) + /// + Shared = 0, + + /// + /// iCUE-SDK: exclusive lightings, but shared events + /// + ExclusiveLightingControl = 1, + + /// + /// iCUE-SDK: exclusive key events, but shared lightings + /// + ExclusiveKeyEventsListening = 2, + + /// + /// iCUE-SDK: exclusive mode + /// + ExclusiveLightingControlAndKeyEventsListening = 3 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs b/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs deleted file mode 100644 index 1ecdda4..0000000 --- a/RGB.NET.Devices.Corsair/Enum/CorsairAccessMode.cs +++ /dev/null @@ -1,14 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.Corsair; - -/// -/// Represents an SDK access mode. -/// -public enum CorsairAccessMode -{ - ExclusiveLightingControl = 0 -}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs index 8c89470..65a38fa 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs @@ -1,13 +1,10 @@ // ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Global - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - namespace RGB.NET.Devices.Corsair; /// -/// Contains a list of available corsair channel device types. +/// iCUE-SDK: Contains a list of available corsair channel device types. /// public enum CorsairChannelDeviceType { @@ -16,10 +13,11 @@ public enum CorsairChannelDeviceType FanSP = 2, FanLL = 3, FanML = 4, - Strip = 5, - DAP = 6, - Pump = 7, - FanQL = 8, - WaterBlock = 9, - EightLedSeriesFan = 10 // Previously called FanSPPRO + FanQL = 5, + EightLedSeriesFan = 6, + Strip = 7, + DAP = 8, + Pump = 9, + DRAM = 10, + WaterBlock = 11, }; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs new file mode 100644 index 0000000..e9bf894 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDataType.cs @@ -0,0 +1,47 @@ +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains list of available property types +/// +public enum CorsairDataType +{ + /// + /// iCUE-SDK: for property of type Boolean + /// + Boolean = 0, + + /// + /// iCUE-SDK: for property of type Int32 or Enumeration + /// + Int32 = 1, + + /// + /// iCUE-SDK: for property of type Float64 + /// + Float64 = 2, + + /// + /// iCUE-SDK: for property of type String + /// + String = 3, + + /// + /// iCUE-SDK: for array of Boolean + /// + BooleanArray = 16, + + /// + /// iCUE-SDK: for array of Int32 + /// + Int32Array = 17, + + /// + /// iCUE-SDK: for array of Float64 + /// + Float64Array = 18, + + /// + /// iCUE-SDK: for array of String + /// + StringArray = 19 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs deleted file mode 100644 index c92807b..0000000 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs +++ /dev/null @@ -1,28 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global - -using System; - -namespace RGB.NET.Devices.Corsair; - -/// -/// Contains a list of corsair device capabilities. -/// -[Flags] -public enum CorsairDeviceCaps -{ - /// - /// For devices that do not support any SDK functions. - /// - None = 0, - - /// - /// For devices that has controlled lighting. - /// - Lighting = 1, - - /// - /// For devices that provide current state through set of properties. - /// - PropertyLookup = 2 -}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs new file mode 100644 index 0000000..0646355 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDevicePropertyId.cs @@ -0,0 +1,77 @@ +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains list of properties identifiers which can be read from device +/// +public enum CorsairDevicePropertyId +{ + /// + /// iCUE-SDK: dummy value + /// + Invalid = 0, + + /// + /// iCUE-SDK: array of CorsairDevicePropertyId members supported by device + /// + PropertyArray = 1, + + /// + /// iCUE-SDK: indicates Mic state (On or Off); used for headset, headset stand + /// + MicEnabled = 2, + + /// + /// iCUE-SDK: indicates Surround Sound state (On or Off); used for headset, headset stand + /// + SurroundSoundEnabled = 3, + + /// + /// iCUE-SDK: indicates Sidetone state (On or Off); used for headset (where applicable) + /// + SidetoneEnabled = 4, + + /// + /// iCUE-SDK: the number of active equalizer preset (integer, 1 - 5); used for headset, headset stand + /// + EqualizerPreset = 5, + + /// + /// iCUE-SDK: keyboard physical layout (see CorsairPhysicalLayout for valid values); used for keyboard + /// + PhysicalLayout = 6, + + /// + /// iCUE-SDK: keyboard logical layout (see CorsairLogicalLayout for valid values); used for keyboard + /// + LogicalLayout = 7, + + /// + /// iCUE-SDK: array of programmable G, M or S keys on device + /// + MacroKeyArray = 8, + + /// + /// iCUE-SDK: battery level (0 - 100); used for wireless devices + /// + BatteryLevel = 9, + + /// + /// iCUE-SDK: total number of LEDs connected to the channel + /// + ChannelLedCount = 10, + + /// + /// iCUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device + /// + ChannelDeviceCount = 11, + + /// + /// iCUE-SDK: array of integers, each element describes the number of LEDs controlled by the channel device + /// + ChannelDeviceLedCountArray = 12, + + /// + /// iCUE-SDK: array of CorsairChannelDeviceType members, each element describes the type of the channel device + /// + ChannelDeviceTypeArray = 13 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs index a409c5d..b41be14 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs @@ -1,27 +1,83 @@ // ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Global - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member +using System; namespace RGB.NET.Devices.Corsair; /// -/// Contains a list of available corsair device types. +/// iCUE-SDK: Contains a list of available corsair device types. /// -public enum CorsairDeviceType +[Flags] +public enum CorsairDeviceType : uint { - Unknown = 0, - Mouse = 1, - Keyboard = 2, - Headset = 3, - Mousepad = 4, - HeadsetStand = 5, - CommanderPro = 6, - LightningNodePro = 7, - MemoryModule = 8, - Cooler = 9, - Mainboard = 10, - GraphicsCard = 11, - Touchbar = 12 + /// + /// iCUE-SDK: for unknown/invalid devices + /// + Unknown = 0x0000, + + /// + /// iCUE-SDK: for keyboards + /// + Keyboard = 0x0001, + + /// + /// iCUE-SDK: for mice + /// + Mouse = 0x0002, + + /// + /// iCUE-SDK: for mousemats + /// + Mousemat = 0x0004, + + /// + /// iCUE-SDK: for headsets + /// + Headset = 0x0008, + + /// + /// iCUE-SDK: for headset stands + /// + HeadsetStand = 0x0010, + + /// + /// iCUE-SDK: for DIY-devices like Commander PRO + /// + FanLedController = 0x0020, + + /// + /// iCUE-SDK: for DIY-devices like Lighting Node PRO + /// + LedController = 0x0040, + + /// + /// iCUE-SDK: for memory modules + /// + MemoryModule = 0x0080, + + /// + /// iCUE-SDK: for coolers + /// + Cooler = 0x0100, + + /// + /// iCUE-SDK: for motherboards + /// + Motherboard = 0x0200, + + /// + /// iCUE-SDK: for graphics cards + /// + GraphicsCard = 0x0400, + + /// + /// iCUE-SDK: for touchbars + /// + Touchbar = 0x0800, + + /// + /// iCUE-SDK: for all devices + /// + All = 0xFFFFFFFF }; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairError.cs b/RGB.NET.Devices.Corsair/Enum/CorsairError.cs index 977c2cf..d2fb672 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairError.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairError.cs @@ -4,38 +4,47 @@ namespace RGB.NET.Devices.Corsair; /// -/// Shared list of all errors which could happen during calling of Corsair* functions. +/// iCUE-SDK: Shared list of all errors which could happen during calling of Corsair* functions. /// public enum CorsairError { /// - /// If previously called function completed successfully. + /// iCUE-SDK: if previously called function completed successfully /// - Success, + Success = 0, /// - /// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error) + /// iCUE-SDK: if iCUE is not running or was shut down or third-party control is disabled in iCUE settings (runtime error), or if developer did not call CorsairConnect after calling CorsairDisconnect or on app start (developer error) /// - ServerNotFound, + NotConnected = 1, /// - /// If some other client has or took over exclusive control. (runtime error) + /// iCUE-SDK: if some other client has or took over exclusive control (runtime error) /// - NoControl, + NoControl = 2, /// - /// If developer did not perform protocol handshake. (developer error) + /// iCUE-SDK: if developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old. Check CorsairSessionDetails for details) (developer error) /// - ProtocolHandshakeMissing, + IncompatibleProtocol = 3, /// - /// If developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old. - /// Check CorsairProtocolDetails for details). (developer error) + /// iCUE-SDK: if developer supplied invalid arguments to the function (for specifics look at function descriptions) (developer error) /// - IncompatibleProtocol, + InvalidArguments = 4, /// - /// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error) + /// iCUE-SDK: if developer is calling the function that is not allowed due to current state (reading improper properties from device, or setting callback when it has already been set) (developer error) /// - InvalidArguments + InvalidOperation = 5, + + /// + /// iCUE-SDK: if invalid device id has been supplied as an argument to the function (when device id refers to disconnected device) (runtime error) + /// + DeviceNotFound = 6, + + /// + /// iCUE-SDK: if specific functionality (key interception) is disabled in iCUE settings (runtime error) + /// + NotAllowed = 7 }; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs new file mode 100644 index 0000000..7281323 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs @@ -0,0 +1,82 @@ +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains a list of led groups. Led group is used as a part of led identifier +/// +public enum CorsairLedGroup +{ + /// + /// iCUE-SDK: for keyboard leds + /// + Keyboard = 0, + + /// + /// iCUE-SDK: for keyboard leds on G keys + /// + KeyboardGKeys = 1, + + /// + /// iCUE-SDK: for keyboard lighting pipe leds + /// + KeyboardEdge = 2, + + /// + /// iCUE-SDK: for vendor specific keyboard leds (ProfileSwitch, DialRing, etc.) + /// + KeyboardOem = 3, + + /// + /// iCUE-SDK: for mouse leds + /// + Mouse = 4, + + /// + /// iCUE-SDK: for mousemat leds + /// + Mousemat = 5, + + /// + /// iCUE-SDK: for headset leds + /// + Headset = 6, + + /// + /// iCUE-SDK: for headset stand leds + /// + HeadsetStand = 7, + + /// + /// iCUE-SDK: for memory module leds + /// + MemoryModule = 8, + + /// + /// iCUE-SDK: for motherboard leds + /// + Motherboard = 9, + + /// + /// iCUE-SDK: for graphics card leds + /// + GraphicsCard = 10, + + /// + /// iCUE-SDK: for leds on the first channel of DIY devices and coolers + /// + DIY_Channel1 = 11, + + /// + /// iCUE-SDK: for leds on the second channel of DIY devices and coolers + /// + DIY_Channel2 = 12, + + /// + /// iCUE-SDK: for leds on the third channel of DIY devices and coolers + /// + DIY_Channel3 = 13, + + /// + /// iCUE-SDK: for touchbar leds + /// + Touchbar = 14 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs deleted file mode 100644 index a0cfeab..0000000 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs +++ /dev/null @@ -1,1742 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global -#pragma warning disable 1591 - -namespace RGB.NET.Devices.Corsair; - -/// -/// Contains a list of all LEDs available for all corsair devices. -/// -public enum CorsairLedId -{ - Invalid = 0, - Escape = 1, - F1 = 2, - F2 = 3, - F3 = 4, - F4 = 5, - F5 = 6, - F6 = 7, - F7 = 8, - F8 = 9, - F9 = 10, - F10 = 11, - F11 = 12, - GraveAccentAndTilde = 13, - D1 = 14, - D2 = 15, - D3 = 16, - D4 = 17, - D5 = 18, - D6 = 19, - D7 = 20, - D8 = 21, - D9 = 22, - D0 = 23, - MinusAndUnderscore = 24, - Tab = 25, - Q = 26, - W = 27, - E = 28, - R = 29, - T = 30, - Y = 31, - U = 32, - I = 33, - O = 34, - P = 35, - BracketLeft = 36, - CapsLock = 37, - A = 38, - S = 39, - D = 40, - F = 41, - G = 42, - H = 43, - J = 44, - K = 45, - L = 46, - SemicolonAndColon = 47, - ApostropheAndDoubleQuote = 48, - LeftShift = 49, - NonUsBackslash = 50, - Z = 51, - X = 52, - C = 53, - V = 54, - B = 55, - N = 56, - M = 57, - CommaAndLessThan = 58, - PeriodAndBiggerThan = 59, - SlashAndQuestionMark = 60, - LeftCtrl = 61, - LeftGui = 62, - LeftAlt = 63, - Lang2 = 64, - Space = 65, - Lang1 = 66, - International2 = 67, - RightAlt = 68, - RightGui = 69, - Application = 70, - LedProgramming = 71, - Brightness = 72, - F12 = 73, - PrintScreen = 74, - ScrollLock = 75, - PauseBreak = 76, - Insert = 77, - Home = 78, - PageUp = 79, - BracketRight = 80, - Backslash = 81, - NonUsTilde = 82, - Enter = 83, - International1 = 84, - EqualsAndPlus = 85, - International3 = 86, - Backspace = 87, - Delete = 88, - End = 89, - PageDown = 90, - RightShift = 91, - RightCtrl = 92, - UpArrow = 93, - LeftArrow = 94, - DownArrow = 95, - RightArrow = 96, - WinLock = 97, - Mute = 98, - Stop = 99, - ScanPreviousTrack = 100, - PlayPause = 101, - ScanNextTrack = 102, - NumLock = 103, - KeypadSlash = 104, - KeypadAsterisk = 105, - KeypadMinus = 106, - KeypadPlus = 107, - KeypadEnter = 108, - Keypad7 = 109, - Keypad8 = 110, - Keypad9 = 111, - KeypadComma = 112, - Keypad4 = 113, - Keypad5 = 114, - Keypad6 = 115, - Keypad1 = 116, - Keypad2 = 117, - Keypad3 = 118, - Keypad0 = 119, - KeypadPeriodAndDelete = 120, - G1 = 121, - G2 = 122, - G3 = 123, - G4 = 124, - G5 = 125, - G6 = 126, - G7 = 127, - G8 = 128, - G9 = 129, - G10 = 130, - VolumeUp = 131, - VolumeDown = 132, - MR = 133, - M1 = 134, - M2 = 135, - M3 = 136, - G11 = 137, - G12 = 138, - G13 = 139, - G14 = 140, - G15 = 141, - G16 = 142, - G17 = 143, - G18 = 144, - International5 = 145, - International4 = 146, - Fn = 147, - - B1 = 148, - B2 = 149, - B3 = 150, - B4 = 151, - - LeftLogo = 152, - RightLogo = 153, - - Logo = 154, - - Zone1 = 155, - Zone2 = 156, - Zone3 = 157, - Zone4 = 158, - Zone5 = 159, - Zone6 = 160, - Zone7 = 161, - Zone8 = 162, - Zone9 = 163, - Zone10 = 164, - Zone11 = 165, - Zone12 = 166, - Zone13 = 167, - Zone14 = 168, - Zone15 = 169, - - Lightbar1 = 170, - Lightbar2 = 171, - Lightbar3 = 172, - Lightbar4 = 173, - Lightbar5 = 174, - Lightbar6 = 175, - Lightbar7 = 176, - Lightbar8 = 177, - Lightbar9 = 178, - Lightbar10 = 179, - Lightbar11 = 180, - Lightbar12 = 181, - Lightbar13 = 182, - Lightbar14 = 183, - Lightbar15 = 184, - Lightbar16 = 185, - Lightbar17 = 186, - Lightbar18 = 187, - Lightbar19 = 188, - - B5 = 189, - B6 = 190, - - HeadsetStandZone1 = 191, - HeadsetStandZone2 = 192, - HeadsetStandZone3 = 193, - HeadsetStandZone4 = 194, - HeadsetStandZone5 = 195, - HeadsetStandZone6 = 196, - HeadsetStandZone7 = 197, - HeadsetStandZone8 = 198, - HeadsetStandZone9 = 199, - - CustomDeviceChannel1Led1 = 200, - CustomDeviceChannel1Led2 = 201, - CustomDeviceChannel1Led3 = 202, - CustomDeviceChannel1Led4 = 203, - CustomDeviceChannel1Led5 = 204, - CustomDeviceChannel1Led6 = 205, - CustomDeviceChannel1Led7 = 206, - CustomDeviceChannel1Led8 = 207, - CustomDeviceChannel1Led9 = 208, - CustomDeviceChannel1Led10 = 209, - CustomDeviceChannel1Led11 = 210, - CustomDeviceChannel1Led12 = 211, - CustomDeviceChannel1Led13 = 212, - CustomDeviceChannel1Led14 = 213, - CustomDeviceChannel1Led15 = 214, - CustomDeviceChannel1Led16 = 215, - CustomDeviceChannel1Led17 = 216, - CustomDeviceChannel1Led18 = 217, - CustomDeviceChannel1Led19 = 218, - CustomDeviceChannel1Led20 = 219, - CustomDeviceChannel1Led21 = 220, - CustomDeviceChannel1Led22 = 221, - CustomDeviceChannel1Led23 = 222, - CustomDeviceChannel1Led24 = 223, - CustomDeviceChannel1Led25 = 224, - CustomDeviceChannel1Led26 = 225, - CustomDeviceChannel1Led27 = 226, - CustomDeviceChannel1Led28 = 227, - CustomDeviceChannel1Led29 = 228, - CustomDeviceChannel1Led30 = 229, - CustomDeviceChannel1Led31 = 230, - CustomDeviceChannel1Led32 = 231, - CustomDeviceChannel1Led33 = 232, - CustomDeviceChannel1Led34 = 233, - CustomDeviceChannel1Led35 = 234, - CustomDeviceChannel1Led36 = 235, - CustomDeviceChannel1Led37 = 236, - CustomDeviceChannel1Led38 = 237, - CustomDeviceChannel1Led39 = 238, - CustomDeviceChannel1Led40 = 239, - CustomDeviceChannel1Led41 = 240, - CustomDeviceChannel1Led42 = 241, - CustomDeviceChannel1Led43 = 242, - CustomDeviceChannel1Led44 = 243, - CustomDeviceChannel1Led45 = 244, - CustomDeviceChannel1Led46 = 245, - CustomDeviceChannel1Led47 = 246, - CustomDeviceChannel1Led48 = 247, - CustomDeviceChannel1Led49 = 248, - CustomDeviceChannel1Led50 = 249, - CustomDeviceChannel1Led51 = 250, - CustomDeviceChannel1Led52 = 251, - CustomDeviceChannel1Led53 = 252, - CustomDeviceChannel1Led54 = 253, - CustomDeviceChannel1Led55 = 254, - CustomDeviceChannel1Led56 = 255, - CustomDeviceChannel1Led57 = 256, - CustomDeviceChannel1Led58 = 257, - CustomDeviceChannel1Led59 = 258, - CustomDeviceChannel1Led60 = 259, - CustomDeviceChannel1Led61 = 260, - CustomDeviceChannel1Led62 = 261, - CustomDeviceChannel1Led63 = 262, - CustomDeviceChannel1Led64 = 263, - CustomDeviceChannel1Led65 = 264, - CustomDeviceChannel1Led66 = 265, - CustomDeviceChannel1Led67 = 266, - CustomDeviceChannel1Led68 = 267, - CustomDeviceChannel1Led69 = 268, - CustomDeviceChannel1Led70 = 269, - CustomDeviceChannel1Led71 = 270, - CustomDeviceChannel1Led72 = 271, - CustomDeviceChannel1Led73 = 272, - CustomDeviceChannel1Led74 = 273, - CustomDeviceChannel1Led75 = 274, - CustomDeviceChannel1Led76 = 275, - CustomDeviceChannel1Led77 = 276, - CustomDeviceChannel1Led78 = 277, - CustomDeviceChannel1Led79 = 278, - CustomDeviceChannel1Led80 = 279, - CustomDeviceChannel1Led81 = 280, - CustomDeviceChannel1Led82 = 281, - CustomDeviceChannel1Led83 = 282, - CustomDeviceChannel1Led84 = 283, - CustomDeviceChannel1Led85 = 284, - CustomDeviceChannel1Led86 = 285, - CustomDeviceChannel1Led87 = 286, - CustomDeviceChannel1Led88 = 287, - CustomDeviceChannel1Led89 = 288, - CustomDeviceChannel1Led90 = 289, - CustomDeviceChannel1Led91 = 290, - CustomDeviceChannel1Led92 = 291, - CustomDeviceChannel1Led93 = 292, - CustomDeviceChannel1Led94 = 293, - CustomDeviceChannel1Led95 = 294, - CustomDeviceChannel1Led96 = 295, - CustomDeviceChannel1Led97 = 296, - CustomDeviceChannel1Led98 = 297, - CustomDeviceChannel1Led99 = 298, - CustomDeviceChannel1Led100 = 299, - CustomDeviceChannel1Led101 = 300, - CustomDeviceChannel1Led102 = 301, - CustomDeviceChannel1Led103 = 302, - CustomDeviceChannel1Led104 = 303, - CustomDeviceChannel1Led105 = 304, - CustomDeviceChannel1Led106 = 305, - CustomDeviceChannel1Led107 = 306, - CustomDeviceChannel1Led108 = 307, - CustomDeviceChannel1Led109 = 308, - CustomDeviceChannel1Led110 = 309, - CustomDeviceChannel1Led111 = 310, - CustomDeviceChannel1Led112 = 311, - CustomDeviceChannel1Led113 = 312, - CustomDeviceChannel1Led114 = 313, - CustomDeviceChannel1Led115 = 314, - CustomDeviceChannel1Led116 = 315, - CustomDeviceChannel1Led117 = 316, - CustomDeviceChannel1Led118 = 317, - CustomDeviceChannel1Led119 = 318, - CustomDeviceChannel1Led120 = 319, - CustomDeviceChannel1Led121 = 320, - CustomDeviceChannel1Led122 = 321, - CustomDeviceChannel1Led123 = 322, - CustomDeviceChannel1Led124 = 323, - CustomDeviceChannel1Led125 = 324, - CustomDeviceChannel1Led126 = 325, - CustomDeviceChannel1Led127 = 326, - CustomDeviceChannel1Led128 = 327, - CustomDeviceChannel1Led129 = 328, - CustomDeviceChannel1Led130 = 329, - CustomDeviceChannel1Led131 = 330, - CustomDeviceChannel1Led132 = 331, - CustomDeviceChannel1Led133 = 332, - CustomDeviceChannel1Led134 = 333, - CustomDeviceChannel1Led135 = 334, - CustomDeviceChannel1Led136 = 335, - CustomDeviceChannel1Led137 = 336, - CustomDeviceChannel1Led138 = 337, - CustomDeviceChannel1Led139 = 338, - CustomDeviceChannel1Led140 = 339, - CustomDeviceChannel1Led141 = 340, - CustomDeviceChannel1Led142 = 341, - CustomDeviceChannel1Led143 = 342, - CustomDeviceChannel1Led144 = 343, - CustomDeviceChannel1Led145 = 344, - CustomDeviceChannel1Led146 = 345, - CustomDeviceChannel1Led147 = 346, - CustomDeviceChannel1Led148 = 347, - CustomDeviceChannel1Led149 = 348, - CustomDeviceChannel1Led150 = 349, - - CustomDeviceChannel2Led1 = 350, - CustomDeviceChannel2Led2 = 351, - CustomDeviceChannel2Led3 = 352, - CustomDeviceChannel2Led4 = 353, - CustomDeviceChannel2Led5 = 354, - CustomDeviceChannel2Led6 = 355, - CustomDeviceChannel2Led7 = 356, - CustomDeviceChannel2Led8 = 357, - CustomDeviceChannel2Led9 = 358, - CustomDeviceChannel2Led10 = 359, - CustomDeviceChannel2Led11 = 360, - CustomDeviceChannel2Led12 = 361, - CustomDeviceChannel2Led13 = 362, - CustomDeviceChannel2Led14 = 363, - CustomDeviceChannel2Led15 = 364, - CustomDeviceChannel2Led16 = 365, - CustomDeviceChannel2Led17 = 366, - CustomDeviceChannel2Led18 = 367, - CustomDeviceChannel2Led19 = 368, - CustomDeviceChannel2Led20 = 369, - CustomDeviceChannel2Led21 = 370, - CustomDeviceChannel2Led22 = 371, - CustomDeviceChannel2Led23 = 372, - CustomDeviceChannel2Led24 = 373, - CustomDeviceChannel2Led25 = 374, - CustomDeviceChannel2Led26 = 375, - CustomDeviceChannel2Led27 = 376, - CustomDeviceChannel2Led28 = 377, - CustomDeviceChannel2Led29 = 378, - CustomDeviceChannel2Led30 = 379, - CustomDeviceChannel2Led31 = 380, - CustomDeviceChannel2Led32 = 381, - CustomDeviceChannel2Led33 = 382, - CustomDeviceChannel2Led34 = 383, - CustomDeviceChannel2Led35 = 384, - CustomDeviceChannel2Led36 = 385, - CustomDeviceChannel2Led37 = 386, - CustomDeviceChannel2Led38 = 387, - CustomDeviceChannel2Led39 = 388, - CustomDeviceChannel2Led40 = 389, - CustomDeviceChannel2Led41 = 390, - CustomDeviceChannel2Led42 = 391, - CustomDeviceChannel2Led43 = 392, - CustomDeviceChannel2Led44 = 393, - CustomDeviceChannel2Led45 = 394, - CustomDeviceChannel2Led46 = 395, - CustomDeviceChannel2Led47 = 396, - CustomDeviceChannel2Led48 = 397, - CustomDeviceChannel2Led49 = 398, - CustomDeviceChannel2Led50 = 399, - CustomDeviceChannel2Led51 = 400, - CustomDeviceChannel2Led52 = 401, - CustomDeviceChannel2Led53 = 402, - CustomDeviceChannel2Led54 = 403, - CustomDeviceChannel2Led55 = 404, - CustomDeviceChannel2Led56 = 405, - CustomDeviceChannel2Led57 = 406, - CustomDeviceChannel2Led58 = 407, - CustomDeviceChannel2Led59 = 408, - CustomDeviceChannel2Led60 = 409, - CustomDeviceChannel2Led61 = 410, - CustomDeviceChannel2Led62 = 411, - CustomDeviceChannel2Led63 = 412, - CustomDeviceChannel2Led64 = 413, - CustomDeviceChannel2Led65 = 414, - CustomDeviceChannel2Led66 = 415, - CustomDeviceChannel2Led67 = 416, - CustomDeviceChannel2Led68 = 417, - CustomDeviceChannel2Led69 = 418, - CustomDeviceChannel2Led70 = 419, - CustomDeviceChannel2Led71 = 420, - CustomDeviceChannel2Led72 = 421, - CustomDeviceChannel2Led73 = 422, - CustomDeviceChannel2Led74 = 423, - CustomDeviceChannel2Led75 = 424, - CustomDeviceChannel2Led76 = 425, - CustomDeviceChannel2Led77 = 426, - CustomDeviceChannel2Led78 = 427, - CustomDeviceChannel2Led79 = 428, - CustomDeviceChannel2Led80 = 429, - CustomDeviceChannel2Led81 = 430, - CustomDeviceChannel2Led82 = 431, - CustomDeviceChannel2Led83 = 432, - CustomDeviceChannel2Led84 = 433, - CustomDeviceChannel2Led85 = 434, - CustomDeviceChannel2Led86 = 435, - CustomDeviceChannel2Led87 = 436, - CustomDeviceChannel2Led88 = 437, - CustomDeviceChannel2Led89 = 438, - CustomDeviceChannel2Led90 = 439, - CustomDeviceChannel2Led91 = 440, - CustomDeviceChannel2Led92 = 441, - CustomDeviceChannel2Led93 = 442, - CustomDeviceChannel2Led94 = 443, - CustomDeviceChannel2Led95 = 444, - CustomDeviceChannel2Led96 = 445, - CustomDeviceChannel2Led97 = 446, - CustomDeviceChannel2Led98 = 447, - CustomDeviceChannel2Led99 = 448, - CustomDeviceChannel2Led100 = 449, - CustomDeviceChannel2Led101 = 450, - CustomDeviceChannel2Led102 = 451, - CustomDeviceChannel2Led103 = 452, - CustomDeviceChannel2Led104 = 453, - CustomDeviceChannel2Led105 = 454, - CustomDeviceChannel2Led106 = 455, - CustomDeviceChannel2Led107 = 456, - CustomDeviceChannel2Led108 = 457, - CustomDeviceChannel2Led109 = 458, - CustomDeviceChannel2Led110 = 459, - CustomDeviceChannel2Led111 = 460, - CustomDeviceChannel2Led112 = 461, - CustomDeviceChannel2Led113 = 462, - CustomDeviceChannel2Led114 = 463, - CustomDeviceChannel2Led115 = 464, - CustomDeviceChannel2Led116 = 465, - CustomDeviceChannel2Led117 = 466, - CustomDeviceChannel2Led118 = 467, - CustomDeviceChannel2Led119 = 468, - CustomDeviceChannel2Led120 = 469, - CustomDeviceChannel2Led121 = 470, - CustomDeviceChannel2Led122 = 471, - CustomDeviceChannel2Led123 = 472, - CustomDeviceChannel2Led124 = 473, - CustomDeviceChannel2Led125 = 474, - CustomDeviceChannel2Led126 = 475, - CustomDeviceChannel2Led127 = 476, - CustomDeviceChannel2Led128 = 477, - CustomDeviceChannel2Led129 = 478, - CustomDeviceChannel2Led130 = 479, - CustomDeviceChannel2Led131 = 480, - CustomDeviceChannel2Led132 = 481, - CustomDeviceChannel2Led133 = 482, - CustomDeviceChannel2Led134 = 483, - CustomDeviceChannel2Led135 = 484, - CustomDeviceChannel2Led136 = 485, - CustomDeviceChannel2Led137 = 486, - CustomDeviceChannel2Led138 = 487, - CustomDeviceChannel2Led139 = 488, - CustomDeviceChannel2Led140 = 489, - CustomDeviceChannel2Led141 = 490, - CustomDeviceChannel2Led142 = 491, - CustomDeviceChannel2Led143 = 492, - CustomDeviceChannel2Led144 = 493, - CustomDeviceChannel2Led145 = 494, - CustomDeviceChannel2Led146 = 495, - CustomDeviceChannel2Led147 = 496, - CustomDeviceChannel2Led148 = 497, - CustomDeviceChannel2Led149 = 498, - CustomDeviceChannel2Led150 = 499, - - OemLed1 = 500, - OemLed2 = 501, - OemLed3 = 502, - OemLed4 = 503, - OemLed5 = 504, - OemLed6 = 505, - OemLed7 = 506, - OemLed8 = 507, - OemLed9 = 508, - OemLed10 = 509, - OemLed11 = 510, - OemLed12 = 511, - OemLed13 = 512, - OemLed14 = 513, - OemLed15 = 514, - OemLed16 = 515, - OemLed17 = 516, - OemLed18 = 517, - OemLed19 = 518, - OemLed20 = 519, - OemLed21 = 520, - OemLed22 = 521, - OemLed23 = 522, - OemLed24 = 523, - OemLed25 = 524, - OemLed26 = 525, - OemLed27 = 526, - OemLed28 = 527, - OemLed29 = 528, - OemLed30 = 529, - OemLed31 = 530, - OemLed32 = 531, - OemLed33 = 532, - OemLed34 = 533, - OemLed35 = 534, - OemLed36 = 535, - OemLed37 = 536, - OemLed38 = 537, - OemLed39 = 538, - OemLed40 = 539, - OemLed41 = 540, - OemLed42 = 541, - OemLed43 = 542, - OemLed44 = 543, - OemLed45 = 544, - OemLed46 = 545, - OemLed47 = 546, - OemLed48 = 547, - OemLed49 = 548, - OemLed50 = 549, - OemLed51 = 550, - OemLed52 = 551, - OemLed53 = 552, - OemLed54 = 553, - OemLed55 = 554, - OemLed56 = 555, - OemLed57 = 556, - OemLed58 = 557, - OemLed59 = 558, - OemLed60 = 559, - OemLed61 = 560, - OemLed62 = 561, - OemLed63 = 562, - OemLed64 = 563, - OemLed65 = 564, - OemLed66 = 565, - OemLed67 = 566, - OemLed68 = 567, - OemLed69 = 568, - OemLed70 = 569, - OemLed71 = 570, - OemLed72 = 571, - OemLed73 = 572, - OemLed74 = 573, - OemLed75 = 574, - OemLed76 = 575, - OemLed77 = 576, - OemLed78 = 577, - OemLed79 = 578, - OemLed80 = 579, - OemLed81 = 580, - OemLed82 = 581, - OemLed83 = 582, - OemLed84 = 583, - OemLed85 = 584, - OemLed86 = 585, - OemLed87 = 586, - OemLed88 = 587, - OemLed89 = 588, - OemLed90 = 589, - OemLed91 = 590, - OemLed92 = 591, - OemLed93 = 592, - OemLed94 = 593, - OemLed95 = 594, - OemLed96 = 595, - OemLed97 = 596, - OemLed98 = 597, - OemLed99 = 598, - OemLed100 = 599, - - DRAM1 = 600, - DRAM2 = 601, - DRAM3 = 602, - DRAM4 = 603, - DRAM5 = 604, - DRAM6 = 605, - DRAM7 = 606, - DRAM8 = 607, - DRAM9 = 608, - DRAM10 = 609, - DRAM11 = 610, - DRAM12 = 611, - - CustomDeviceChannel3Led1 = 612, - CustomDeviceChannel3Led2 = 613, - CustomDeviceChannel3Led3 = 614, - CustomDeviceChannel3Led4 = 615, - CustomDeviceChannel3Led5 = 616, - CustomDeviceChannel3Led6 = 617, - CustomDeviceChannel3Led7 = 618, - CustomDeviceChannel3Led8 = 619, - CustomDeviceChannel3Led9 = 620, - CustomDeviceChannel3Led10 = 621, - CustomDeviceChannel3Led11 = 622, - CustomDeviceChannel3Led12 = 623, - CustomDeviceChannel3Led13 = 624, - CustomDeviceChannel3Led14 = 625, - CustomDeviceChannel3Led15 = 626, - CustomDeviceChannel3Led16 = 627, - CustomDeviceChannel3Led17 = 628, - CustomDeviceChannel3Led18 = 629, - CustomDeviceChannel3Led19 = 630, - CustomDeviceChannel3Led20 = 631, - CustomDeviceChannel3Led21 = 632, - CustomDeviceChannel3Led22 = 633, - CustomDeviceChannel3Led23 = 634, - CustomDeviceChannel3Led24 = 635, - CustomDeviceChannel3Led25 = 636, - CustomDeviceChannel3Led26 = 637, - CustomDeviceChannel3Led27 = 638, - CustomDeviceChannel3Led28 = 639, - CustomDeviceChannel3Led29 = 640, - CustomDeviceChannel3Led30 = 641, - CustomDeviceChannel3Led31 = 642, - CustomDeviceChannel3Led32 = 643, - CustomDeviceChannel3Led33 = 644, - CustomDeviceChannel3Led34 = 645, - CustomDeviceChannel3Led35 = 646, - CustomDeviceChannel3Led36 = 647, - CustomDeviceChannel3Led37 = 648, - CustomDeviceChannel3Led38 = 649, - CustomDeviceChannel3Led39 = 650, - CustomDeviceChannel3Led40 = 651, - CustomDeviceChannel3Led41 = 652, - CustomDeviceChannel3Led42 = 653, - CustomDeviceChannel3Led43 = 654, - CustomDeviceChannel3Led44 = 655, - CustomDeviceChannel3Led45 = 656, - CustomDeviceChannel3Led46 = 657, - CustomDeviceChannel3Led47 = 658, - CustomDeviceChannel3Led48 = 659, - CustomDeviceChannel3Led49 = 660, - CustomDeviceChannel3Led50 = 661, - CustomDeviceChannel3Led51 = 662, - CustomDeviceChannel3Led52 = 663, - CustomDeviceChannel3Led53 = 664, - CustomDeviceChannel3Led54 = 665, - CustomDeviceChannel3Led55 = 666, - CustomDeviceChannel3Led56 = 667, - CustomDeviceChannel3Led57 = 668, - CustomDeviceChannel3Led58 = 669, - CustomDeviceChannel3Led59 = 670, - CustomDeviceChannel3Led60 = 671, - CustomDeviceChannel3Led61 = 672, - CustomDeviceChannel3Led62 = 673, - CustomDeviceChannel3Led63 = 674, - CustomDeviceChannel3Led64 = 675, - CustomDeviceChannel3Led65 = 676, - CustomDeviceChannel3Led66 = 677, - CustomDeviceChannel3Led67 = 678, - CustomDeviceChannel3Led68 = 679, - CustomDeviceChannel3Led69 = 680, - CustomDeviceChannel3Led70 = 681, - CustomDeviceChannel3Led71 = 682, - CustomDeviceChannel3Led72 = 683, - CustomDeviceChannel3Led73 = 684, - CustomDeviceChannel3Led74 = 685, - CustomDeviceChannel3Led75 = 686, - CustomDeviceChannel3Led76 = 687, - CustomDeviceChannel3Led77 = 688, - CustomDeviceChannel3Led78 = 689, - CustomDeviceChannel3Led79 = 690, - CustomDeviceChannel3Led80 = 691, - CustomDeviceChannel3Led81 = 692, - CustomDeviceChannel3Led82 = 693, - CustomDeviceChannel3Led83 = 694, - CustomDeviceChannel3Led84 = 695, - CustomDeviceChannel3Led85 = 696, - CustomDeviceChannel3Led86 = 697, - CustomDeviceChannel3Led87 = 698, - CustomDeviceChannel3Led88 = 699, - CustomDeviceChannel3Led89 = 700, - CustomDeviceChannel3Led90 = 701, - CustomDeviceChannel3Led91 = 702, - CustomDeviceChannel3Led92 = 703, - CustomDeviceChannel3Led93 = 704, - CustomDeviceChannel3Led94 = 705, - CustomDeviceChannel3Led95 = 706, - CustomDeviceChannel3Led96 = 707, - CustomDeviceChannel3Led97 = 708, - CustomDeviceChannel3Led98 = 709, - CustomDeviceChannel3Led99 = 710, - CustomDeviceChannel3Led100 = 711, - CustomDeviceChannel3Led101 = 712, - CustomDeviceChannel3Led102 = 713, - CustomDeviceChannel3Led103 = 714, - CustomDeviceChannel3Led104 = 715, - CustomDeviceChannel3Led105 = 716, - CustomDeviceChannel3Led106 = 717, - CustomDeviceChannel3Led107 = 718, - CustomDeviceChannel3Led108 = 719, - CustomDeviceChannel3Led109 = 720, - CustomDeviceChannel3Led110 = 721, - CustomDeviceChannel3Led111 = 722, - CustomDeviceChannel3Led112 = 723, - CustomDeviceChannel3Led113 = 724, - CustomDeviceChannel3Led114 = 725, - CustomDeviceChannel3Led115 = 726, - CustomDeviceChannel3Led116 = 727, - CustomDeviceChannel3Led117 = 728, - CustomDeviceChannel3Led118 = 729, - CustomDeviceChannel3Led119 = 730, - CustomDeviceChannel3Led120 = 731, - CustomDeviceChannel3Led121 = 732, - CustomDeviceChannel3Led122 = 733, - CustomDeviceChannel3Led123 = 734, - CustomDeviceChannel3Led124 = 735, - CustomDeviceChannel3Led125 = 736, - CustomDeviceChannel3Led126 = 737, - CustomDeviceChannel3Led127 = 738, - CustomDeviceChannel3Led128 = 739, - CustomDeviceChannel3Led129 = 740, - CustomDeviceChannel3Led130 = 741, - CustomDeviceChannel3Led131 = 742, - CustomDeviceChannel3Led132 = 743, - CustomDeviceChannel3Led133 = 744, - CustomDeviceChannel3Led134 = 745, - CustomDeviceChannel3Led135 = 746, - CustomDeviceChannel3Led136 = 747, - CustomDeviceChannel3Led137 = 748, - CustomDeviceChannel3Led138 = 749, - CustomDeviceChannel3Led139 = 750, - CustomDeviceChannel3Led140 = 751, - CustomDeviceChannel3Led141 = 752, - CustomDeviceChannel3Led142 = 753, - CustomDeviceChannel3Led143 = 754, - CustomDeviceChannel3Led144 = 755, - CustomDeviceChannel3Led145 = 756, - CustomDeviceChannel3Led146 = 757, - CustomDeviceChannel3Led147 = 758, - CustomDeviceChannel3Led148 = 759, - CustomDeviceChannel3Led149 = 760, - CustomDeviceChannel3Led150 = 761, - - CustomLiquidCoolerChannel1Led1 = 762, - CustomLiquidCoolerChannel1Led2 = 763, - CustomLiquidCoolerChannel1Led3 = 764, - CustomLiquidCoolerChannel1Led4 = 765, - CustomLiquidCoolerChannel1Led5 = 766, - CustomLiquidCoolerChannel1Led6 = 767, - CustomLiquidCoolerChannel1Led7 = 768, - CustomLiquidCoolerChannel1Led8 = 769, - CustomLiquidCoolerChannel1Led9 = 770, - CustomLiquidCoolerChannel1Led10 = 771, - CustomLiquidCoolerChannel1Led11 = 772, - CustomLiquidCoolerChannel1Led12 = 773, - CustomLiquidCoolerChannel1Led13 = 774, - CustomLiquidCoolerChannel1Led14 = 775, - CustomLiquidCoolerChannel1Led15 = 776, - CustomLiquidCoolerChannel1Led16 = 777, - CustomLiquidCoolerChannel1Led17 = 778, - CustomLiquidCoolerChannel1Led18 = 779, - CustomLiquidCoolerChannel1Led19 = 780, - CustomLiquidCoolerChannel1Led20 = 781, - CustomLiquidCoolerChannel1Led21 = 782, - CustomLiquidCoolerChannel1Led22 = 783, - CustomLiquidCoolerChannel1Led23 = 784, - CustomLiquidCoolerChannel1Led24 = 785, - CustomLiquidCoolerChannel1Led25 = 786, - CustomLiquidCoolerChannel1Led26 = 787, - CustomLiquidCoolerChannel1Led27 = 788, - CustomLiquidCoolerChannel1Led28 = 789, - CustomLiquidCoolerChannel1Led29 = 790, - CustomLiquidCoolerChannel1Led30 = 791, - CustomLiquidCoolerChannel1Led31 = 792, - CustomLiquidCoolerChannel1Led32 = 793, - CustomLiquidCoolerChannel1Led33 = 794, - CustomLiquidCoolerChannel1Led34 = 795, - CustomLiquidCoolerChannel1Led35 = 796, - CustomLiquidCoolerChannel1Led36 = 797, - CustomLiquidCoolerChannel1Led37 = 798, - CustomLiquidCoolerChannel1Led38 = 799, - CustomLiquidCoolerChannel1Led39 = 800, - CustomLiquidCoolerChannel1Led40 = 801, - CustomLiquidCoolerChannel1Led41 = 802, - CustomLiquidCoolerChannel1Led42 = 803, - CustomLiquidCoolerChannel1Led43 = 804, - CustomLiquidCoolerChannel1Led44 = 805, - CustomLiquidCoolerChannel1Led45 = 806, - CustomLiquidCoolerChannel1Led46 = 807, - CustomLiquidCoolerChannel1Led47 = 808, - CustomLiquidCoolerChannel1Led48 = 809, - CustomLiquidCoolerChannel1Led49 = 810, - CustomLiquidCoolerChannel1Led50 = 811, - CustomLiquidCoolerChannel1Led51 = 812, - CustomLiquidCoolerChannel1Led52 = 813, - CustomLiquidCoolerChannel1Led53 = 814, - CustomLiquidCoolerChannel1Led54 = 815, - CustomLiquidCoolerChannel1Led55 = 816, - CustomLiquidCoolerChannel1Led56 = 817, - CustomLiquidCoolerChannel1Led57 = 818, - CustomLiquidCoolerChannel1Led58 = 819, - CustomLiquidCoolerChannel1Led59 = 820, - CustomLiquidCoolerChannel1Led60 = 821, - CustomLiquidCoolerChannel1Led61 = 822, - CustomLiquidCoolerChannel1Led62 = 823, - CustomLiquidCoolerChannel1Led63 = 824, - CustomLiquidCoolerChannel1Led64 = 825, - CustomLiquidCoolerChannel1Led65 = 826, - CustomLiquidCoolerChannel1Led66 = 827, - CustomLiquidCoolerChannel1Led67 = 828, - CustomLiquidCoolerChannel1Led68 = 829, - CustomLiquidCoolerChannel1Led69 = 830, - CustomLiquidCoolerChannel1Led70 = 831, - CustomLiquidCoolerChannel1Led71 = 832, - CustomLiquidCoolerChannel1Led72 = 833, - CustomLiquidCoolerChannel1Led73 = 834, - CustomLiquidCoolerChannel1Led74 = 835, - CustomLiquidCoolerChannel1Led75 = 836, - CustomLiquidCoolerChannel1Led76 = 837, - CustomLiquidCoolerChannel1Led77 = 838, - CustomLiquidCoolerChannel1Led78 = 839, - CustomLiquidCoolerChannel1Led79 = 840, - CustomLiquidCoolerChannel1Led80 = 841, - CustomLiquidCoolerChannel1Led81 = 842, - CustomLiquidCoolerChannel1Led82 = 843, - CustomLiquidCoolerChannel1Led83 = 844, - CustomLiquidCoolerChannel1Led84 = 845, - CustomLiquidCoolerChannel1Led85 = 846, - CustomLiquidCoolerChannel1Led86 = 847, - CustomLiquidCoolerChannel1Led87 = 848, - CustomLiquidCoolerChannel1Led88 = 849, - CustomLiquidCoolerChannel1Led89 = 850, - CustomLiquidCoolerChannel1Led90 = 851, - CustomLiquidCoolerChannel1Led91 = 852, - CustomLiquidCoolerChannel1Led92 = 853, - CustomLiquidCoolerChannel1Led93 = 854, - CustomLiquidCoolerChannel1Led94 = 855, - CustomLiquidCoolerChannel1Led95 = 856, - CustomLiquidCoolerChannel1Led96 = 857, - CustomLiquidCoolerChannel1Led97 = 858, - CustomLiquidCoolerChannel1Led98 = 859, - CustomLiquidCoolerChannel1Led99 = 860, - CustomLiquidCoolerChannel1Led100 = 861, - CustomLiquidCoolerChannel1Led101 = 862, - CustomLiquidCoolerChannel1Led102 = 863, - CustomLiquidCoolerChannel1Led103 = 864, - CustomLiquidCoolerChannel1Led104 = 865, - CustomLiquidCoolerChannel1Led105 = 866, - CustomLiquidCoolerChannel1Led106 = 867, - CustomLiquidCoolerChannel1Led107 = 868, - CustomLiquidCoolerChannel1Led108 = 869, - CustomLiquidCoolerChannel1Led109 = 870, - CustomLiquidCoolerChannel1Led110 = 871, - CustomLiquidCoolerChannel1Led111 = 872, - CustomLiquidCoolerChannel1Led112 = 873, - CustomLiquidCoolerChannel1Led113 = 874, - CustomLiquidCoolerChannel1Led114 = 875, - CustomLiquidCoolerChannel1Led115 = 876, - CustomLiquidCoolerChannel1Led116 = 877, - CustomLiquidCoolerChannel1Led117 = 878, - CustomLiquidCoolerChannel1Led118 = 879, - CustomLiquidCoolerChannel1Led119 = 880, - CustomLiquidCoolerChannel1Led120 = 881, - CustomLiquidCoolerChannel1Led121 = 882, - CustomLiquidCoolerChannel1Led122 = 883, - CustomLiquidCoolerChannel1Led123 = 884, - CustomLiquidCoolerChannel1Led124 = 885, - CustomLiquidCoolerChannel1Led125 = 886, - CustomLiquidCoolerChannel1Led126 = 887, - CustomLiquidCoolerChannel1Led127 = 888, - CustomLiquidCoolerChannel1Led128 = 889, - CustomLiquidCoolerChannel1Led129 = 890, - CustomLiquidCoolerChannel1Led130 = 891, - CustomLiquidCoolerChannel1Led131 = 892, - CustomLiquidCoolerChannel1Led132 = 893, - CustomLiquidCoolerChannel1Led133 = 894, - CustomLiquidCoolerChannel1Led134 = 895, - CustomLiquidCoolerChannel1Led135 = 896, - CustomLiquidCoolerChannel1Led136 = 897, - CustomLiquidCoolerChannel1Led137 = 898, - CustomLiquidCoolerChannel1Led138 = 899, - CustomLiquidCoolerChannel1Led139 = 900, - CustomLiquidCoolerChannel1Led140 = 901, - CustomLiquidCoolerChannel1Led141 = 902, - CustomLiquidCoolerChannel1Led142 = 903, - CustomLiquidCoolerChannel1Led143 = 904, - CustomLiquidCoolerChannel1Led144 = 905, - CustomLiquidCoolerChannel1Led145 = 906, - CustomLiquidCoolerChannel1Led146 = 907, - CustomLiquidCoolerChannel1Led147 = 908, - CustomLiquidCoolerChannel1Led148 = 909, - CustomLiquidCoolerChannel1Led149 = 910, - CustomLiquidCoolerChannel1Led150 = 911, - - CustomDeviceChannel1Led151 = 912, - CustomDeviceChannel1Led152 = 913, - CustomDeviceChannel1Led153 = 914, - CustomDeviceChannel1Led154 = 915, - CustomDeviceChannel1Led155 = 916, - CustomDeviceChannel1Led156 = 917, - CustomDeviceChannel1Led157 = 918, - CustomDeviceChannel1Led158 = 919, - CustomDeviceChannel1Led159 = 920, - CustomDeviceChannel1Led160 = 921, - CustomDeviceChannel1Led161 = 922, - CustomDeviceChannel1Led162 = 923, - CustomDeviceChannel1Led163 = 924, - CustomDeviceChannel1Led164 = 925, - CustomDeviceChannel1Led165 = 926, - CustomDeviceChannel1Led166 = 927, - CustomDeviceChannel1Led167 = 928, - CustomDeviceChannel1Led168 = 929, - CustomDeviceChannel1Led169 = 930, - CustomDeviceChannel1Led170 = 931, - CustomDeviceChannel1Led171 = 932, - CustomDeviceChannel1Led172 = 933, - CustomDeviceChannel1Led173 = 934, - CustomDeviceChannel1Led174 = 935, - CustomDeviceChannel1Led175 = 936, - CustomDeviceChannel1Led176 = 937, - CustomDeviceChannel1Led177 = 938, - CustomDeviceChannel1Led178 = 939, - CustomDeviceChannel1Led179 = 940, - CustomDeviceChannel1Led180 = 941, - CustomDeviceChannel1Led181 = 942, - CustomDeviceChannel1Led182 = 943, - CustomDeviceChannel1Led183 = 944, - CustomDeviceChannel1Led184 = 945, - CustomDeviceChannel1Led185 = 946, - CustomDeviceChannel1Led186 = 947, - CustomDeviceChannel1Led187 = 948, - CustomDeviceChannel1Led188 = 949, - CustomDeviceChannel1Led189 = 950, - CustomDeviceChannel1Led190 = 951, - CustomDeviceChannel1Led191 = 952, - CustomDeviceChannel1Led192 = 953, - CustomDeviceChannel1Led193 = 954, - CustomDeviceChannel1Led194 = 955, - CustomDeviceChannel1Led195 = 956, - CustomDeviceChannel1Led196 = 957, - CustomDeviceChannel1Led197 = 958, - CustomDeviceChannel1Led198 = 959, - CustomDeviceChannel1Led199 = 960, - CustomDeviceChannel1Led200 = 961, - CustomDeviceChannel1Led201 = 962, - CustomDeviceChannel1Led202 = 963, - CustomDeviceChannel1Led203 = 964, - CustomDeviceChannel1Led204 = 965, - CustomDeviceChannel1Led205 = 966, - CustomDeviceChannel1Led206 = 967, - CustomDeviceChannel1Led207 = 968, - CustomDeviceChannel1Led208 = 969, - CustomDeviceChannel1Led209 = 970, - CustomDeviceChannel1Led210 = 971, - CustomDeviceChannel1Led211 = 972, - CustomDeviceChannel1Led212 = 973, - CustomDeviceChannel1Led213 = 974, - CustomDeviceChannel1Led214 = 975, - CustomDeviceChannel1Led215 = 976, - CustomDeviceChannel1Led216 = 977, - CustomDeviceChannel1Led217 = 978, - CustomDeviceChannel1Led218 = 979, - CustomDeviceChannel1Led219 = 980, - CustomDeviceChannel1Led220 = 981, - CustomDeviceChannel1Led221 = 982, - CustomDeviceChannel1Led222 = 983, - CustomDeviceChannel1Led223 = 984, - CustomDeviceChannel1Led224 = 985, - CustomDeviceChannel1Led225 = 986, - CustomDeviceChannel1Led226 = 987, - CustomDeviceChannel1Led227 = 988, - CustomDeviceChannel1Led228 = 989, - CustomDeviceChannel1Led229 = 990, - CustomDeviceChannel1Led230 = 991, - CustomDeviceChannel1Led231 = 992, - CustomDeviceChannel1Led232 = 993, - CustomDeviceChannel1Led233 = 994, - CustomDeviceChannel1Led234 = 995, - CustomDeviceChannel1Led235 = 996, - CustomDeviceChannel1Led236 = 997, - CustomDeviceChannel1Led237 = 998, - CustomDeviceChannel1Led238 = 999, - CustomDeviceChannel1Led239 = 1000, - CustomDeviceChannel1Led240 = 1001, - CustomDeviceChannel1Led241 = 1002, - CustomDeviceChannel1Led242 = 1003, - CustomDeviceChannel1Led243 = 1004, - CustomDeviceChannel1Led244 = 1005, - CustomDeviceChannel1Led245 = 1006, - CustomDeviceChannel1Led246 = 1007, - CustomDeviceChannel1Led247 = 1008, - CustomDeviceChannel1Led248 = 1009, - CustomDeviceChannel1Led249 = 1010, - CustomDeviceChannel1Led250 = 1011, - CustomDeviceChannel1Led251 = 1012, - CustomDeviceChannel1Led252 = 1013, - CustomDeviceChannel1Led253 = 1014, - CustomDeviceChannel1Led254 = 1015, - CustomDeviceChannel1Led255 = 1016, - CustomDeviceChannel1Led256 = 1017, - CustomDeviceChannel1Led257 = 1018, - CustomDeviceChannel1Led258 = 1019, - CustomDeviceChannel1Led259 = 1020, - CustomDeviceChannel1Led260 = 1021, - CustomDeviceChannel1Led261 = 1022, - CustomDeviceChannel1Led262 = 1023, - CustomDeviceChannel1Led263 = 1024, - CustomDeviceChannel1Led264 = 1025, - CustomDeviceChannel1Led265 = 1026, - CustomDeviceChannel1Led266 = 1027, - CustomDeviceChannel1Led267 = 1028, - CustomDeviceChannel1Led268 = 1029, - CustomDeviceChannel1Led269 = 1030, - CustomDeviceChannel1Led270 = 1031, - CustomDeviceChannel1Led271 = 1032, - CustomDeviceChannel1Led272 = 1033, - CustomDeviceChannel1Led273 = 1034, - CustomDeviceChannel1Led274 = 1035, - CustomDeviceChannel1Led275 = 1036, - CustomDeviceChannel1Led276 = 1037, - CustomDeviceChannel1Led277 = 1038, - CustomDeviceChannel1Led278 = 1039, - CustomDeviceChannel1Led279 = 1040, - CustomDeviceChannel1Led280 = 1041, - CustomDeviceChannel1Led281 = 1042, - CustomDeviceChannel1Led282 = 1043, - CustomDeviceChannel1Led283 = 1044, - CustomDeviceChannel1Led284 = 1045, - CustomDeviceChannel1Led285 = 1046, - CustomDeviceChannel1Led286 = 1047, - CustomDeviceChannel1Led287 = 1048, - CustomDeviceChannel1Led288 = 1049, - CustomDeviceChannel1Led289 = 1050, - CustomDeviceChannel1Led290 = 1051, - CustomDeviceChannel1Led291 = 1052, - CustomDeviceChannel1Led292 = 1053, - CustomDeviceChannel1Led293 = 1054, - CustomDeviceChannel1Led294 = 1055, - CustomDeviceChannel1Led295 = 1056, - CustomDeviceChannel1Led296 = 1057, - CustomDeviceChannel1Led297 = 1058, - CustomDeviceChannel1Led298 = 1059, - CustomDeviceChannel1Led299 = 1060, - CustomDeviceChannel1Led300 = 1061, - - CustomDeviceChannel2Led151 = 1062, - CustomDeviceChannel2Led152 = 1063, - CustomDeviceChannel2Led153 = 1064, - CustomDeviceChannel2Led154 = 1065, - CustomDeviceChannel2Led155 = 1066, - CustomDeviceChannel2Led156 = 1067, - CustomDeviceChannel2Led157 = 1068, - CustomDeviceChannel2Led158 = 1069, - CustomDeviceChannel2Led159 = 1070, - CustomDeviceChannel2Led160 = 1071, - CustomDeviceChannel2Led161 = 1072, - CustomDeviceChannel2Led162 = 1073, - CustomDeviceChannel2Led163 = 1074, - CustomDeviceChannel2Led164 = 1075, - CustomDeviceChannel2Led165 = 1076, - CustomDeviceChannel2Led166 = 1077, - CustomDeviceChannel2Led167 = 1078, - CustomDeviceChannel2Led168 = 1079, - CustomDeviceChannel2Led169 = 1080, - CustomDeviceChannel2Led170 = 1081, - CustomDeviceChannel2Led171 = 1082, - CustomDeviceChannel2Led172 = 1083, - CustomDeviceChannel2Led173 = 1084, - CustomDeviceChannel2Led174 = 1085, - CustomDeviceChannel2Led175 = 1086, - CustomDeviceChannel2Led176 = 1087, - CustomDeviceChannel2Led177 = 1088, - CustomDeviceChannel2Led178 = 1089, - CustomDeviceChannel2Led179 = 1090, - CustomDeviceChannel2Led180 = 1091, - CustomDeviceChannel2Led181 = 1092, - CustomDeviceChannel2Led182 = 1093, - CustomDeviceChannel2Led183 = 1094, - CustomDeviceChannel2Led184 = 1095, - CustomDeviceChannel2Led185 = 1096, - CustomDeviceChannel2Led186 = 1097, - CustomDeviceChannel2Led187 = 1098, - CustomDeviceChannel2Led188 = 1099, - CustomDeviceChannel2Led189 = 1100, - CustomDeviceChannel2Led190 = 1101, - CustomDeviceChannel2Led191 = 1102, - CustomDeviceChannel2Led192 = 1103, - CustomDeviceChannel2Led193 = 1104, - CustomDeviceChannel2Led194 = 1105, - CustomDeviceChannel2Led195 = 1106, - CustomDeviceChannel2Led196 = 1107, - CustomDeviceChannel2Led197 = 1108, - CustomDeviceChannel2Led198 = 1109, - CustomDeviceChannel2Led199 = 1110, - CustomDeviceChannel2Led200 = 1111, - CustomDeviceChannel2Led201 = 1112, - CustomDeviceChannel2Led202 = 1113, - CustomDeviceChannel2Led203 = 1114, - CustomDeviceChannel2Led204 = 1115, - CustomDeviceChannel2Led205 = 1116, - CustomDeviceChannel2Led206 = 1117, - CustomDeviceChannel2Led207 = 1118, - CustomDeviceChannel2Led208 = 1119, - CustomDeviceChannel2Led209 = 1120, - CustomDeviceChannel2Led210 = 1121, - CustomDeviceChannel2Led211 = 1122, - CustomDeviceChannel2Led212 = 1123, - CustomDeviceChannel2Led213 = 1124, - CustomDeviceChannel2Led214 = 1125, - CustomDeviceChannel2Led215 = 1126, - CustomDeviceChannel2Led216 = 1127, - CustomDeviceChannel2Led217 = 1128, - CustomDeviceChannel2Led218 = 1129, - CustomDeviceChannel2Led219 = 1130, - CustomDeviceChannel2Led220 = 1131, - CustomDeviceChannel2Led221 = 1132, - CustomDeviceChannel2Led222 = 1133, - CustomDeviceChannel2Led223 = 1134, - CustomDeviceChannel2Led224 = 1135, - CustomDeviceChannel2Led225 = 1136, - CustomDeviceChannel2Led226 = 1137, - CustomDeviceChannel2Led227 = 1138, - CustomDeviceChannel2Led228 = 1139, - CustomDeviceChannel2Led229 = 1140, - CustomDeviceChannel2Led230 = 1141, - CustomDeviceChannel2Led231 = 1142, - CustomDeviceChannel2Led232 = 1143, - CustomDeviceChannel2Led233 = 1144, - CustomDeviceChannel2Led234 = 1145, - CustomDeviceChannel2Led235 = 1146, - CustomDeviceChannel2Led236 = 1147, - CustomDeviceChannel2Led237 = 1148, - CustomDeviceChannel2Led238 = 1149, - CustomDeviceChannel2Led239 = 1150, - CustomDeviceChannel2Led240 = 1151, - CustomDeviceChannel2Led241 = 1152, - CustomDeviceChannel2Led242 = 1153, - CustomDeviceChannel2Led243 = 1154, - CustomDeviceChannel2Led244 = 1155, - CustomDeviceChannel2Led245 = 1156, - CustomDeviceChannel2Led246 = 1157, - CustomDeviceChannel2Led247 = 1158, - CustomDeviceChannel2Led248 = 1159, - CustomDeviceChannel2Led249 = 1160, - CustomDeviceChannel2Led250 = 1161, - CustomDeviceChannel2Led251 = 1162, - CustomDeviceChannel2Led252 = 1163, - CustomDeviceChannel2Led253 = 1164, - CustomDeviceChannel2Led254 = 1165, - CustomDeviceChannel2Led255 = 1166, - CustomDeviceChannel2Led256 = 1167, - CustomDeviceChannel2Led257 = 1168, - CustomDeviceChannel2Led258 = 1169, - CustomDeviceChannel2Led259 = 1170, - CustomDeviceChannel2Led260 = 1171, - CustomDeviceChannel2Led261 = 1172, - CustomDeviceChannel2Led262 = 1173, - CustomDeviceChannel2Led263 = 1174, - CustomDeviceChannel2Led264 = 1175, - CustomDeviceChannel2Led265 = 1176, - CustomDeviceChannel2Led266 = 1177, - CustomDeviceChannel2Led267 = 1178, - CustomDeviceChannel2Led268 = 1179, - CustomDeviceChannel2Led269 = 1180, - CustomDeviceChannel2Led270 = 1181, - CustomDeviceChannel2Led271 = 1182, - CustomDeviceChannel2Led272 = 1183, - CustomDeviceChannel2Led273 = 1184, - CustomDeviceChannel2Led274 = 1185, - CustomDeviceChannel2Led275 = 1186, - CustomDeviceChannel2Led276 = 1187, - CustomDeviceChannel2Led277 = 1188, - CustomDeviceChannel2Led278 = 1189, - CustomDeviceChannel2Led279 = 1190, - CustomDeviceChannel2Led280 = 1191, - CustomDeviceChannel2Led281 = 1192, - CustomDeviceChannel2Led282 = 1193, - CustomDeviceChannel2Led283 = 1194, - CustomDeviceChannel2Led284 = 1195, - CustomDeviceChannel2Led285 = 1196, - CustomDeviceChannel2Led286 = 1197, - CustomDeviceChannel2Led287 = 1198, - CustomDeviceChannel2Led288 = 1199, - CustomDeviceChannel2Led289 = 1200, - CustomDeviceChannel2Led290 = 1201, - CustomDeviceChannel2Led291 = 1202, - CustomDeviceChannel2Led292 = 1203, - CustomDeviceChannel2Led293 = 1204, - CustomDeviceChannel2Led294 = 1205, - CustomDeviceChannel2Led295 = 1206, - CustomDeviceChannel2Led296 = 1207, - CustomDeviceChannel2Led297 = 1208, - CustomDeviceChannel2Led298 = 1209, - CustomDeviceChannel2Led299 = 1210, - CustomDeviceChannel2Led300 = 1211, - - CustomDeviceChannel3Led151 = 1212, - CustomDeviceChannel3Led152 = 1213, - CustomDeviceChannel3Led153 = 1214, - CustomDeviceChannel3Led154 = 1215, - CustomDeviceChannel3Led155 = 1216, - CustomDeviceChannel3Led156 = 1217, - CustomDeviceChannel3Led157 = 1218, - CustomDeviceChannel3Led158 = 1219, - CustomDeviceChannel3Led159 = 1220, - CustomDeviceChannel3Led160 = 1221, - CustomDeviceChannel3Led161 = 1222, - CustomDeviceChannel3Led162 = 1223, - CustomDeviceChannel3Led163 = 1224, - CustomDeviceChannel3Led164 = 1225, - CustomDeviceChannel3Led165 = 1226, - CustomDeviceChannel3Led166 = 1227, - CustomDeviceChannel3Led167 = 1228, - CustomDeviceChannel3Led168 = 1229, - CustomDeviceChannel3Led169 = 1230, - CustomDeviceChannel3Led170 = 1231, - CustomDeviceChannel3Led171 = 1232, - CustomDeviceChannel3Led172 = 1233, - CustomDeviceChannel3Led173 = 1234, - CustomDeviceChannel3Led174 = 1235, - CustomDeviceChannel3Led175 = 1236, - CustomDeviceChannel3Led176 = 1237, - CustomDeviceChannel3Led177 = 1238, - CustomDeviceChannel3Led178 = 1239, - CustomDeviceChannel3Led179 = 1240, - CustomDeviceChannel3Led180 = 1241, - CustomDeviceChannel3Led181 = 1242, - CustomDeviceChannel3Led182 = 1243, - CustomDeviceChannel3Led183 = 1244, - CustomDeviceChannel3Led184 = 1245, - CustomDeviceChannel3Led185 = 1246, - CustomDeviceChannel3Led186 = 1247, - CustomDeviceChannel3Led187 = 1248, - CustomDeviceChannel3Led188 = 1249, - CustomDeviceChannel3Led189 = 1250, - CustomDeviceChannel3Led190 = 1251, - CustomDeviceChannel3Led191 = 1252, - CustomDeviceChannel3Led192 = 1253, - CustomDeviceChannel3Led193 = 1254, - CustomDeviceChannel3Led194 = 1255, - CustomDeviceChannel3Led195 = 1256, - CustomDeviceChannel3Led196 = 1257, - CustomDeviceChannel3Led197 = 1258, - CustomDeviceChannel3Led198 = 1259, - CustomDeviceChannel3Led199 = 1260, - CustomDeviceChannel3Led200 = 1261, - CustomDeviceChannel3Led201 = 1262, - CustomDeviceChannel3Led202 = 1263, - CustomDeviceChannel3Led203 = 1264, - CustomDeviceChannel3Led204 = 1265, - CustomDeviceChannel3Led205 = 1266, - CustomDeviceChannel3Led206 = 1267, - CustomDeviceChannel3Led207 = 1268, - CustomDeviceChannel3Led208 = 1269, - CustomDeviceChannel3Led209 = 1270, - CustomDeviceChannel3Led210 = 1271, - CustomDeviceChannel3Led211 = 1272, - CustomDeviceChannel3Led212 = 1273, - CustomDeviceChannel3Led213 = 1274, - CustomDeviceChannel3Led214 = 1275, - CustomDeviceChannel3Led215 = 1276, - CustomDeviceChannel3Led216 = 1277, - CustomDeviceChannel3Led217 = 1278, - CustomDeviceChannel3Led218 = 1279, - CustomDeviceChannel3Led219 = 1280, - CustomDeviceChannel3Led220 = 1281, - CustomDeviceChannel3Led221 = 1282, - CustomDeviceChannel3Led222 = 1283, - CustomDeviceChannel3Led223 = 1284, - CustomDeviceChannel3Led224 = 1285, - CustomDeviceChannel3Led225 = 1286, - CustomDeviceChannel3Led226 = 1287, - CustomDeviceChannel3Led227 = 1288, - CustomDeviceChannel3Led228 = 1289, - CustomDeviceChannel3Led229 = 1290, - CustomDeviceChannel3Led230 = 1291, - CustomDeviceChannel3Led231 = 1292, - CustomDeviceChannel3Led232 = 1293, - CustomDeviceChannel3Led233 = 1294, - CustomDeviceChannel3Led234 = 1295, - CustomDeviceChannel3Led235 = 1296, - CustomDeviceChannel3Led236 = 1297, - CustomDeviceChannel3Led237 = 1298, - CustomDeviceChannel3Led238 = 1299, - CustomDeviceChannel3Led239 = 1300, - CustomDeviceChannel3Led240 = 1301, - CustomDeviceChannel3Led241 = 1302, - CustomDeviceChannel3Led242 = 1303, - CustomDeviceChannel3Led243 = 1304, - CustomDeviceChannel3Led244 = 1305, - CustomDeviceChannel3Led245 = 1306, - CustomDeviceChannel3Led246 = 1307, - CustomDeviceChannel3Led247 = 1308, - CustomDeviceChannel3Led248 = 1309, - CustomDeviceChannel3Led249 = 1310, - CustomDeviceChannel3Led250 = 1311, - CustomDeviceChannel3Led251 = 1312, - CustomDeviceChannel3Led252 = 1313, - CustomDeviceChannel3Led253 = 1314, - CustomDeviceChannel3Led254 = 1315, - CustomDeviceChannel3Led255 = 1316, - CustomDeviceChannel3Led256 = 1317, - CustomDeviceChannel3Led257 = 1318, - CustomDeviceChannel3Led258 = 1319, - CustomDeviceChannel3Led259 = 1320, - CustomDeviceChannel3Led260 = 1321, - CustomDeviceChannel3Led261 = 1322, - CustomDeviceChannel3Led262 = 1323, - CustomDeviceChannel3Led263 = 1324, - CustomDeviceChannel3Led264 = 1325, - CustomDeviceChannel3Led265 = 1326, - CustomDeviceChannel3Led266 = 1327, - CustomDeviceChannel3Led267 = 1328, - CustomDeviceChannel3Led268 = 1329, - CustomDeviceChannel3Led269 = 1330, - CustomDeviceChannel3Led270 = 1331, - CustomDeviceChannel3Led271 = 1332, - CustomDeviceChannel3Led272 = 1333, - CustomDeviceChannel3Led273 = 1334, - CustomDeviceChannel3Led274 = 1335, - CustomDeviceChannel3Led275 = 1336, - CustomDeviceChannel3Led276 = 1337, - CustomDeviceChannel3Led277 = 1338, - CustomDeviceChannel3Led278 = 1339, - CustomDeviceChannel3Led279 = 1340, - CustomDeviceChannel3Led280 = 1341, - CustomDeviceChannel3Led281 = 1342, - CustomDeviceChannel3Led282 = 1343, - CustomDeviceChannel3Led283 = 1344, - CustomDeviceChannel3Led284 = 1345, - CustomDeviceChannel3Led285 = 1346, - CustomDeviceChannel3Led286 = 1347, - CustomDeviceChannel3Led287 = 1348, - CustomDeviceChannel3Led288 = 1349, - CustomDeviceChannel3Led289 = 1350, - CustomDeviceChannel3Led290 = 1351, - CustomDeviceChannel3Led291 = 1352, - CustomDeviceChannel3Led292 = 1353, - CustomDeviceChannel3Led293 = 1354, - CustomDeviceChannel3Led294 = 1355, - CustomDeviceChannel3Led295 = 1356, - CustomDeviceChannel3Led296 = 1357, - CustomDeviceChannel3Led297 = 1358, - CustomDeviceChannel3Led298 = 1359, - CustomDeviceChannel3Led299 = 1360, - CustomDeviceChannel3Led300 = 1361, - - Mainboard1 = 1362, - Mainboard2 = 1363, - Mainboard3 = 1364, - Mainboard4 = 1365, - Mainboard5 = 1366, - Mainboard6 = 1367, - Mainboard7 = 1368, - Mainboard8 = 1369, - Mainboard9 = 1370, - Mainboard10 = 1371, - Mainboard11 = 1372, - Mainboard12 = 1373, - Mainboard13 = 1374, - Mainboard14 = 1375, - Mainboard15 = 1376, - Mainboard16 = 1377, - Mainboard17 = 1378, - Mainboard18 = 1379, - Mainboard19 = 1380, - Mainboard20 = 1381, - Mainboard21 = 1382, - Mainboard22 = 1383, - Mainboard23 = 1384, - Mainboard24 = 1385, - Mainboard25 = 1386, - Mainboard26 = 1387, - Mainboard27 = 1388, - Mainboard28 = 1389, - Mainboard29 = 1390, - Mainboard30 = 1391, - Mainboard31 = 1392, - Mainboard32 = 1393, - Mainboard33 = 1394, - Mainboard34 = 1395, - Mainboard35 = 1396, - Mainboard36 = 1397, - Mainboard37 = 1398, - Mainboard38 = 1399, - Mainboard39 = 1400, - Mainboard40 = 1401, - Mainboard41 = 1402, - Mainboard42 = 1403, - Mainboard43 = 1404, - Mainboard44 = 1405, - Mainboard45 = 1406, - Mainboard46 = 1407, - Mainboard47 = 1408, - Mainboard48 = 1409, - Mainboard49 = 1410, - Mainboard50 = 1411, - Mainboard51 = 1412, - Mainboard52 = 1413, - Mainboard53 = 1414, - Mainboard54 = 1415, - Mainboard55 = 1416, - Mainboard56 = 1417, - Mainboard57 = 1418, - Mainboard58 = 1419, - Mainboard59 = 1420, - Mainboard60 = 1421, - Mainboard61 = 1422, - Mainboard62 = 1423, - Mainboard63 = 1424, - Mainboard64 = 1425, - Mainboard65 = 1426, - Mainboard66 = 1427, - Mainboard67 = 1428, - Mainboard68 = 1429, - Mainboard69 = 1430, - Mainboard70 = 1431, - Mainboard71 = 1432, - Mainboard72 = 1433, - Mainboard73 = 1434, - Mainboard74 = 1435, - Mainboard75 = 1436, - Mainboard76 = 1437, - Mainboard77 = 1438, - Mainboard78 = 1439, - Mainboard79 = 1440, - Mainboard80 = 1441, - Mainboard81 = 1442, - Mainboard82 = 1443, - Mainboard83 = 1444, - Mainboard84 = 1445, - Mainboard85 = 1446, - Mainboard86 = 1447, - Mainboard87 = 1448, - Mainboard88 = 1449, - Mainboard89 = 1450, - Mainboard90 = 1451, - Mainboard91 = 1452, - Mainboard92 = 1453, - Mainboard93 = 1454, - Mainboard94 = 1455, - Mainboard95 = 1456, - Mainboard96 = 1457, - Mainboard97 = 1458, - Mainboard98 = 1459, - Mainboard99 = 1460, - Mainboard100 = 1461, - - GPU1 = 1462, - GPU2 = 1463, - GPU3 = 1464, - GPU4 = 1465, - GPU5 = 1466, - GPU6 = 1467, - GPU7 = 1468, - GPU8 = 1469, - GPU9 = 1470, - GPU10 = 1471, - GPU11 = 1472, - GPU12 = 1473, - GPU13 = 1474, - GPU14 = 1475, - GPU15 = 1476, - GPU16 = 1477, - GPU17 = 1478, - GPU18 = 1479, - GPU19 = 1480, - GPU20 = 1481, - GPU21 = 1482, - GPU22 = 1483, - GPU23 = 1484, - GPU24 = 1485, - GPU25 = 1486, - GPU26 = 1487, - GPU27 = 1488, - GPU28 = 1489, - GPU29 = 1490, - GPU30 = 1491, - GPU31 = 1492, - GPU32 = 1493, - GPU33 = 1494, - GPU34 = 1495, - GPU35 = 1496, - GPU36 = 1497, - GPU37 = 1498, - GPU38 = 1499, - GPU39 = 1500, - GPU40 = 1501, - GPU41 = 1502, - GPU42 = 1503, - GPU43 = 1504, - GPU44 = 1505, - GPU45 = 1506, - GPU46 = 1507, - GPU47 = 1508, - GPU48 = 1509, - GPU49 = 1510, - GPU50 = 1511, - - Lightbar20 = 1512, - Lightbar21 = 1513, - Lightbar22 = 1514, - Lightbar23 = 1515, - Lightbar24 = 1516, - Lightbar25 = 1517, - Lightbar26 = 1518, - Lightbar27 = 1519, - Lightbar28 = 1520, - Lightbar29 = 1521, - Lightbar30 = 1522, - Lightbar31 = 1523, - Lightbar32 = 1524, - Lightbar33 = 1525, - Lightbar34 = 1526, - Lightbar35 = 1527, - Lightbar36 = 1528, - Lightbar37 = 1529, - Lightbar38 = 1530, - Lightbar39 = 1531, - Lightbar40 = 1532, - Lightbar41 = 1533, - Lightbar42 = 1534, - Lightbar43 = 1535, - Lightbar44 = 1536, - Lightbar45 = 1537, - Lightbar46 = 1538, - Lightbar47 = 1539, - Lightbar48 = 1540, - Lightbar49 = 1541, - Lightbar50 = 1542, - - Profile = 1543, - - OemLed101 = 1544, - OemLed102 = 1545, - OemLed103 = 1546, - OemLed104 = 1547, - OemLed105 = 1548, - OemLed106 = 1549, - OemLed107 = 1550, - OemLed108 = 1551, - OemLed109 = 1552, - OemLed110 = 1553, - OemLed111 = 1554, - OemLed112 = 1555, - OemLed113 = 1556, - OemLed114 = 1557, - OemLed115 = 1558, - OemLed116 = 1559, - OemLed117 = 1560, - OemLed118 = 1561, - OemLed119 = 1562, - OemLed120 = 1563, - OemLed121 = 1564, - OemLed122 = 1565, - OemLed123 = 1566, - OemLed124 = 1567, - OemLed125 = 1568, - OemLed126 = 1569, - OemLed127 = 1570, - OemLed128 = 1571, - OemLed129 = 1572, - OemLed130 = 1573, - OemLed131 = 1574, - OemLed132 = 1575, - OemLed133 = 1576, - OemLed134 = 1577, - OemLed135 = 1578, - OemLed136 = 1579, - OemLed137 = 1580, - OemLed138 = 1581, - OemLed139 = 1582, - OemLed140 = 1583, - OemLed141 = 1584, - OemLed142 = 1585, - OemLed143 = 1586, - OemLed144 = 1587, - OemLed145 = 1588, - OemLed146 = 1589, - OemLed147 = 1590, - OemLed148 = 1591, - OemLed149 = 1592, - OemLed150 = 1593, - OemLed151 = 1594, - OemLed152 = 1595, - OemLed153 = 1596, - OemLed154 = 1597, - OemLed155 = 1598, - OemLed156 = 1599, - OemLed157 = 1600, - OemLed158 = 1601, - OemLed159 = 1602, - OemLed160 = 1603, - OemLed161 = 1604, - OemLed162 = 1605, - OemLed163 = 1606, - OemLed164 = 1607, - OemLed165 = 1608, - OemLed166 = 1609, - OemLed167 = 1610, - OemLed168 = 1611, - OemLed169 = 1612, - OemLed170 = 1613, - OemLed171 = 1614, - OemLed172 = 1615, - OemLed173 = 1616, - OemLed174 = 1617, - OemLed175 = 1618, - OemLed176 = 1619, - OemLed177 = 1620, - OemLed178 = 1621, - OemLed179 = 1622, - OemLed180 = 1623, - OemLed181 = 1624, - OemLed182 = 1625, - OemLed183 = 1626, - OemLed184 = 1627, - OemLed185 = 1628, - OemLed186 = 1629, - OemLed187 = 1630, - OemLed188 = 1631, - OemLed189 = 1632, - OemLed190 = 1633, - OemLed191 = 1634, - OemLed192 = 1635, - OemLed193 = 1636, - OemLed194 = 1637, - OemLed195 = 1638, - OemLed196 = 1639, - OemLed197 = 1640, - OemLed198 = 1641, - OemLed199 = 1642, - OemLed200 = 1643, - OemLed201 = 1644, - OemLed202 = 1645, - OemLed203 = 1646, - OemLed204 = 1647, - OemLed205 = 1648, - OemLed206 = 1649, - OemLed207 = 1650, - OemLed208 = 1651, - OemLed209 = 1652, - OemLed210 = 1653, - OemLed211 = 1654, - OemLed212 = 1655, - OemLed213 = 1656, - OemLed214 = 1657, - OemLed215 = 1658, - OemLed216 = 1659, - OemLed217 = 1660, - OemLed218 = 1661, - OemLed219 = 1662, - OemLed220 = 1663, - OemLed221 = 1664, - OemLed222 = 1665, - OemLed223 = 1666, - OemLed224 = 1667, - OemLed225 = 1668, - OemLed226 = 1669, - OemLed227 = 1670, - OemLed228 = 1671, - OemLed229 = 1672, - OemLed230 = 1673, - OemLed231 = 1674, - OemLed232 = 1675, - OemLed233 = 1676, - OemLed234 = 1677, - OemLed235 = 1678, - OemLed236 = 1679, - OemLed237 = 1680, - OemLed238 = 1681, - OemLed239 = 1682, - OemLed240 = 1683, - OemLed241 = 1684, - OemLed242 = 1685, - OemLed243 = 1686, - OemLed244 = 1687, - OemLed245 = 1688, - OemLed246 = 1689, - OemLed247 = 1690, - OemLed248 = 1691, - OemLed249 = 1692, - OemLed250 = 1693, - - B7 = 1694, - B8 = 1695, - B9 = 1696, - B10 = 1697, - B11 = 1698, - B12 = 1699, - B13 = 1700, - B14 = 1701, - B15 = 1702, - B16 = 1703, - B17 = 1704, - B18 = 1705, - B19 = 1706, - B20 = 1707, -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs new file mode 100644 index 0000000..3b5ad52 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedIdKeyboard.cs @@ -0,0 +1,142 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global +#pragma warning disable 1591 + +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains a list of keyboard leds that belong to CLG_Keyboard group +/// +public enum CorsairLedIdKeyboard +{ + Invalid = 0, + Escape = 1, + F1 = 2, + F2 = 3, + F3 = 4, + F4 = 5, + F5 = 6, + F6 = 7, + F7 = 8, + F8 = 9, + F9 = 10, + F10 = 11, + F11 = 12, + F12 = 13, + GraveAccentAndTilde = 14, + One = 15, + Two = 16, + Three = 17, + Four = 18, + Five = 19, + Six = 20, + Seven = 21, + Eight = 22, + Nine = 23, + Zero = 24, + MinusAndUnderscore = 25, + EqualsAndPlus = 26, + Backspace = 27, + Tab = 28, + Q = 29, + W = 30, + E = 31, + R = 32, + T = 33, + Y = 34, + U = 35, + I = 36, + O = 37, + P = 38, + BracketLeft = 39, + BracketRight = 40, + CapsLock = 41, + A = 42, + S = 43, + D = 44, + F = 45, + G = 46, + H = 47, + J = 48, + K = 49, + L = 50, + SemicolonAndColon = 51, + ApostropheAndDoubleQuote = 52, + Backslash = 53, + Enter = 54, + LeftShift = 55, + NonUsBackslash = 56, + Z = 57, + X = 58, + C = 59, + V = 60, + B = 61, + N = 62, + M = 63, + CommaAndLessThan = 64, + PeriodAndBiggerThan = 65, + SlashAndQuestionMark = 66, + RightShift = 67, + LeftCtrl = 68, + LeftGui = 69, + LeftAlt = 70, + Space = 71, + RightAlt = 72, + RightGui = 73, + Application = 74, + RightCtrl = 75, + LedProgramming = 76, + Lang1 = 77, + Lang2 = 78, + International1 = 79, + International2 = 80, + International3 = 81, + International4 = 82, + International5 = 83, + PrintScreen = 84, + ScrollLock = 85, + PauseBreak = 86, + Insert = 87, + Home = 88, + PageUp = 89, + Delete = 90, + End = 91, + PageDown = 92, + UpArrow = 93, + LeftArrow = 94, + DownArrow = 95, + RightArrow = 96, + NonUsTilde = 97, + Brightness = 98, + WinLock = 99, + Mute = 100, + Stop = 101, + ScanPreviousTrack = 102, + PlayPause = 103, + ScanNextTrack = 104, + NumLock = 105, + KeypadSlash = 106, + KeypadAsterisk = 107, + KeypadMinus = 108, + Keypad7 = 109, + Keypad8 = 110, + Keypad9 = 111, + KeypadPlus = 112, + Keypad4 = 113, + Keypad5 = 114, + Keypad6 = 115, + Keypad1 = 116, + Keypad2 = 117, + Keypad3 = 118, + KeypadComma = 119, + KeypadEnter = 120, + Keypad0 = 121, + KeypadPeriodAndDelete = 122, + VolumeUp = 123, + VolumeDown = 124, + MR = 125, + M1 = 126, + M2 = 127, + M3 = 128, + Fn = 129 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs index ebc4e1b..d5325bb 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLogicalKeyboardLayout.cs @@ -1,14 +1,14 @@ // ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Global -#pragma warning disable 1591 namespace RGB.NET.Devices.Corsair; /// -/// Contains a list of available logical layouts for corsair keyboards. +/// iCUE-SDK: Contains a list of available logical layouts for corsair keyboards. /// public enum CorsairLogicalKeyboardLayout { + Invalid = 0, US_Int = 1, NA = 2, EU = 3, diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs index 9f5c1c3..f02cd6c 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalKeyboardLayout.cs @@ -4,32 +4,14 @@ namespace RGB.NET.Devices.Corsair; /// -/// Contains a list of available physical layouts for corsair keyboards. +/// iCUE-SDK: Contains a list of available physical layouts for corsair keyboards. /// public enum CorsairPhysicalKeyboardLayout { - /// - /// US-Keyboard - /// + Invalid = 0, US = 1, - - /// - /// UK-Keyboard - /// UK = 2, - - /// - /// BR-Keyboard - /// - BR = 3, - - /// - /// JP-Keyboard - /// - JP = 4, - - /// - /// KR-Keyboard - /// - KR = 5 + JP = 3, + KR = 4, + BR = 5 } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs b/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs deleted file mode 100644 index 33c317c..0000000 --- a/RGB.NET.Devices.Corsair/Enum/CorsairPhysicalMouseLayout.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace RGB.NET.Devices.Corsair; - -/// -/// Contains a list of available physical layouts for mice. -/// -public enum CorsairPhysicalMouseLayout -{ - /// - /// Zone1-Mouse - /// - Zones1 = 6, - - /// - /// Zone2-Mouse - /// - Zones2 = 7, - - /// - /// Zone3-Mouse - /// - Zones3 = 8, - - /// - /// Zone4-Mouse - /// - Zones4 = 9, - - /// - /// Zone5-Mouse - /// - Zones5 = 101, - - /// - /// Zone6-Mouse - /// - Zones6 = 11, - - /// - /// Zone7-Mouse - /// - Zones7 = 12, - - /// - /// Zone8-Mouse - /// - Zones8 = 13, - - /// - /// Zone9-Mouse - /// - Zones9 = 14, - - /// - /// Zone10-Mouse - /// - Zones10 = 15, - - /// - /// Zone11-Mouse - /// - Zones11 = 16, - - /// - /// Zone12-Mouse - /// - Zones12 = 17, - - /// - /// Zone13-Mouse - /// - Zones13 = 18, - - /// - /// Zone14-Mouse - /// - Zones14 = 19, - - /// - /// Zone15-Mouse - /// - Zones15 = 20, - - /// - /// Zone16-Mouse - /// - Zones16 = 21, - - /// - /// Zone17-Mouse - /// - Zones17 = 22, - - /// - /// Zone18-Mouse - /// - Zones18 = 23, - - /// - /// Zone19-Mouse - /// - Zones19 = 24, - - /// - /// Zone20-Mouse - /// - Zones20 = 25 -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs b/RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs new file mode 100644 index 0000000..f0e4506 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairPropertyFlag.cs @@ -0,0 +1,30 @@ +using System; + +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains list of operations that can be applied to the property +/// +[Flags] +public enum CorsairPropertyFlag +{ + /// + /// - + /// + None = 0x00, + + /// + /// iCUE-SDK: describes readable property + /// + CanRead = 0x01, + + /// + /// iCUE-SDK: describes writable property + /// + CanWrite = 0x02, + + /// + /// iCUE-SDK: if flag is set, then index should be used to read/write multiple properties that share the same property identifier + /// + Indexed = 0x04 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs b/RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs new file mode 100644 index 0000000..c78dce1 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Enum/CorsairSessionState.cs @@ -0,0 +1,45 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +namespace RGB.NET.Devices.Corsair; + +/// +/// iCUE-SDK: contains a list of all possible session states +/// +public enum CorsairSessionState +{ + /// + /// iCUE-SDK: dummy value + /// + Invalid = 0, + + /// + /// iCUE-SDK: client not initialized or client closed connection (initial state) + /// + Closed = 1, + + /// + /// iCUE-SDK: client initiated connection but not connected yet + /// + Connecting = 2, + + /// + /// iCUE-SDK: server did not respond, sdk will try again + /// + Timeout = 3, + + /// + /// iCUE-SDK: server did not allow connection + /// + ConnectionRefused = 4, + + /// + /// iCUE-SDK: server closed connection + /// + ConnectionLost = 5, + + /// + /// iCUE-SDK: successfully connected + /// + Connected = 6 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs new file mode 100644 index 0000000..6520081 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs @@ -0,0 +1,34 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using System.Collections.Generic; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a corsair fan. +/// +public class CorsairFanRGBDevice : CorsairRGBDevice, IFan +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the fan. + /// The queue used to update this device. + internal CorsairFanRGBDevice(CorsairFanRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { } + + #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateFanMapping(ids); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs new file mode 100644 index 0000000..f4973c5 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + internal CorsairFanRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Fan, nativeInfo, ledCount, ledOffset) + { } + + /// + internal CorsairFanRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) + : base(RGBDeviceType.Fan, nativeInfo, ledCount, ledOffset, modelName) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index 408e907..1d42dc2 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -13,7 +13,8 @@ public class CorsairDeviceUpdateQueue : UpdateQueue { #region Properties & Fields - private int _deviceIndex; + private readonly _CorsairDeviceInfo _device; + private readonly nint _colorPtr; #endregion @@ -24,10 +25,12 @@ public class CorsairDeviceUpdateQueue : UpdateQueue /// /// The update trigger used by this queue. /// The index used to identify the device. - public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIndex) + internal CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, _CorsairDeviceInfo device) : base(updateTrigger) { - this._deviceIndex = deviceIndex; + this._device = device; + + _colorPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairLedColor>() * device.ledCount); } #endregion @@ -35,28 +38,29 @@ public class CorsairDeviceUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override unsafe void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - int structSize = Marshal.SizeOf(typeof(_CorsairLedColor)); - IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length); - IntPtr addPtr = new(ptr.ToInt64()); - foreach ((object key, Color color) in dataSet) + Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length); + for (int i = 0; i < colors.Length; i++) { - _CorsairLedColor corsairColor = new() - { - ledId = (int)key, - r = color.GetR(), - g = color.GetG(), - b = color.GetB() - }; - - Marshal.StructureToPtr(corsairColor, addPtr, false); - addPtr = new IntPtr(addPtr.ToInt64() + structSize); + (object id, Color color) = dataSet[i]; + (byte a, byte r, byte g, byte b) = color.GetRGBBytes(); + colors[i] = new _CorsairLedColor((CorsairLedId)id, r, g, b, a); } - _CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr); - _CUESDK.CorsairSetLedsColorsFlushBuffer(); - Marshal.FreeHGlobal(ptr); + CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr); + if (error != CorsairError.Success) + throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})"); + } + + /// + public override void Dispose() + { + base.Dispose(); + + Marshal.FreeHGlobal(_colorPtr); + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs new file mode 100644 index 0000000..e8c5c5b --- /dev/null +++ b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs @@ -0,0 +1,54 @@ +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.Corsair; + +[StructLayout(LayoutKind.Sequential)] +public readonly struct CorsairLedId : IComparable, IEquatable +{ + #region Properties & Fields + + public readonly uint Id; + + public CorsairLedGroup Group => (CorsairLedGroup)(Id >> 16); + public uint Index => Id & 0x0000FFFF; + + #endregion + + #region Constructors + + public CorsairLedId(uint id) + { + this.Id = id; + } + + public CorsairLedId(CorsairLedGroup group, CorsairLedIdKeyboard id) + : this(group, (int)id) + { } + + public CorsairLedId(CorsairLedGroup group, int index) + { + Id = (((uint)group) << 16) | (uint)index; + } + + #endregion + + #region Methods + + public int CompareTo(CorsairLedId other) => Id.CompareTo(other.Id); + + public bool Equals(CorsairLedId other) => Id == other.Id; + + public override bool Equals(object? obj) => obj is CorsairLedId other && Equals(other); + + public override int GetHashCode() => Id.GetHashCode(); + + public static bool operator ==(CorsairLedId left, CorsairLedId right) => left.Id == right.Id; + public static bool operator !=(CorsairLedId left, CorsairLedId right) => !(left == right); + public static bool operator <(CorsairLedId left, CorsairLedId right) => left.Id < right.Id; + public static bool operator <=(CorsairLedId left, CorsairLedId right) => left.Id <= right.Id; + public static bool operator >(CorsairLedId left, CorsairLedId right) => left.Id > right.Id; + public static bool operator >=(CorsairLedId left, CorsairLedId right) => left.Id >= right.Id; + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs deleted file mode 100644 index e764e08..0000000 --- a/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs +++ /dev/null @@ -1,65 +0,0 @@ -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global - -using System; -using System.Runtime.InteropServices; -using RGB.NET.Devices.Corsair.Native; - -namespace RGB.NET.Devices.Corsair; - -/// -/// Managed wrapper for CorsairProtocolDetails. -/// -public class CorsairProtocolDetails -{ - #region Properties & Fields - - /// - /// String containing version of SDK(like "1.0.0.1"). - /// Always contains valid value even if there was no CUE found. - /// - public string? SdkVersion { get; } - - /// - /// String containing version of CUE(like "1.0.0.1") or NULL if CUE was not found. - /// - public string? ServerVersion { get; } - - /// - /// Integer that specifies version of protocol that is implemented by current SDK. - /// Numbering starts from 1. - /// Always contains valid value even if there was no CUE found. - /// - public int SdkProtocolVersion { get; } - - /// - /// Integer that specifies version of protocol that is implemented by CUE. - /// Numbering starts from 1. - /// If CUE was not found then this value will be 0. - /// - public int ServerProtocolVersion { get; } - - /// - /// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client. - /// - public bool BreakingChanges { get; } - - #endregion - - #region Constructors - - /// - /// Internal constructor of managed CorsairProtocolDetails. - /// - /// The native CorsairProtocolDetails-struct - internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails) - { - this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion); - this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion); - this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion; - this.ServerProtocolVersion = nativeDetails.serverProtocolVersion; - this.BreakingChanges = nativeDetails.breakingChanges != 0; - } - - #endregion -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index 57912a5..94fd49c 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -1,5 +1,5 @@ -using System; -using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Linq; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; @@ -17,7 +17,7 @@ public abstract class CorsairRGBDevice : AbstractRGBDevice /// Gets the mapping of to used to update the LEDs of this device. /// - protected LedMapping Mapping { get; } + protected LedMapping Mapping { get; private set; } = LedMapping.Empty; #endregion @@ -29,48 +29,41 @@ public abstract class CorsairRGBDevice : AbstractRGBDeviceThe generic information provided by CUE for the device. /// The mapping to used to update the LEDs of this device. /// The queue used to update this device. - protected CorsairRGBDevice(TDeviceInfo info, LedMapping mapping, CorsairDeviceUpdateQueue updateQueue) + protected CorsairRGBDevice(TDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) : base(info, updateQueue) - { - this.Mapping = mapping; - } + { } #endregion #region Methods void ICorsairRGBDevice.Initialize() => InitializeLayout(); - + /// /// Initializes the LEDs of the device based on the data provided by the SDK. /// protected virtual void InitializeLayout() { - _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); - if (nativeLedPositions == null) return; + CorsairError error = _CUESDK.CorsairGetLedPositions(DeviceInfo.DeviceId, out _CorsairLedPosition[] ledPositions); + if (error != CorsairError.Success) + throw new RGBDeviceException($"Failed to load device '{DeviceInfo.DeviceId}'. (ErrorCode: {error})"); - int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); - IntPtr ptr = nativeLedPositions.pLedPosition; + List<_CorsairLedPosition> deviceLeds = ledPositions.Skip(DeviceInfo.LedOffset).Take(DeviceInfo.LedCount).ToList(); - for (int i = 0; i < nativeLedPositions.numberOfLed; i++) + Mapping = CreateMapping(deviceLeds.Select(x => new CorsairLedId(x.id))); + + foreach (_CorsairLedPosition ledPosition in deviceLeds) { - _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); - if (ledPosition == null) - { - ptr = new IntPtr(ptr.ToInt64() + structSize); - continue; - } - - LedId ledId = Mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid; + LedId ledId = Mapping.TryGetValue(new CorsairLedId(ledPosition.id), out LedId id) ? id : LedId.Invalid; Rectangle rectangle = ledPosition.ToRectangle(); AddLed(ledId, rectangle.Location, rectangle.Size); - - ptr = new IntPtr(ptr.ToInt64() + structSize); } } + protected abstract LedMapping CreateMapping(IEnumerable ids); + /// - protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid; + protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : new CorsairLedId(0); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs index 27c882d..6137b95 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs @@ -1,6 +1,4 @@ -using System; -using System.Runtime.InteropServices; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; @@ -19,11 +17,6 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo /// public CorsairDeviceType CorsairDeviceType { get; } - /// - /// Gets the index of the . - /// - public int CorsairDeviceIndex { get; } - /// public RGBDeviceType DeviceType { get; } @@ -44,11 +37,16 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo /// public object? LayoutMetadata { get; set; } + + /// + /// Gets the amount of LEDs this device contains. + /// + public int LedCount { get; } /// - /// Gets a flag that describes device capabilities. () + /// Gets the offset used to access the LEDs of this device. /// - public CorsairDeviceCaps CapsMask { get; } + internal int LedOffset { get; } #endregion @@ -60,14 +58,14 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo /// The index of the . /// The type of the . /// The native -struct - internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo) + internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) { - this.CorsairDeviceIndex = deviceIndex; this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; - this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); - this.DeviceId = nativeInfo.deviceId ?? string.Empty; - this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; + this.Model = nativeInfo.model == null ? string.Empty : Regex.Replace(nativeInfo.model ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); + this.DeviceId = nativeInfo.id ?? string.Empty; + this.LedCount = ledCount; + this.LedOffset = ledOffset; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } @@ -79,14 +77,14 @@ public class CorsairRGBDeviceInfo : IRGBDeviceInfo /// The type of the . /// The native -struct /// The name of the device-model (overwrites the one provided with the device info). - internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName) + internal CorsairRGBDeviceInfo(RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) { - this.CorsairDeviceIndex = deviceIndex; this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; this.Model = modelName; - this.DeviceId = nativeInfo.deviceId ?? string.Empty; - this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; + this.DeviceId = nativeInfo.id ?? string.Empty; + this.LedCount = ledCount; + this.LedOffset = ledOffset; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } diff --git a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs index 911e58f..8166070 100644 --- a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs @@ -1,302 +1,210 @@ -using RGB.NET.Core; +using System.Collections.Generic; +using System.Linq; +using RGB.NET.Core; namespace RGB.NET.Devices.Corsair; /// /// Contains mappings for to . /// -public static class LedMappings +internal static class LedMappings { - static LedMappings() + #region Constants + + private static LedMapping KEYBOARD_MAPPING => new() { - for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++) - GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i); + { LedId.Invalid, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Invalid) }, + { LedId.Keyboard_Escape, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Escape) }, + { LedId.Keyboard_F1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F1) }, + { LedId.Keyboard_F2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F2) }, + { LedId.Keyboard_F3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F3) }, + { LedId.Keyboard_F4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F4) }, + { LedId.Keyboard_F5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F5) }, + { LedId.Keyboard_F6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F6) }, + { LedId.Keyboard_F7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F7) }, + { LedId.Keyboard_F8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F8) }, + { LedId.Keyboard_F9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F9) }, + { LedId.Keyboard_F10, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F10) }, + { LedId.Keyboard_F11, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F11) }, + { LedId.Keyboard_GraveAccentAndTilde, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.GraveAccentAndTilde) }, + { LedId.Keyboard_1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.One) }, + { LedId.Keyboard_2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Two) }, + { LedId.Keyboard_3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Three) }, + { LedId.Keyboard_4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Four) }, + { LedId.Keyboard_5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Five) }, + { LedId.Keyboard_6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Six) }, + { LedId.Keyboard_7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Seven) }, + { LedId.Keyboard_8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Eight) }, + { LedId.Keyboard_9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Nine) }, + { LedId.Keyboard_0, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Zero) }, + { LedId.Keyboard_MinusAndUnderscore, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.MinusAndUnderscore) }, + { LedId.Keyboard_Tab, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Tab) }, + { LedId.Keyboard_Q, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Q) }, + { LedId.Keyboard_W, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.W) }, + { LedId.Keyboard_E, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.E) }, + { LedId.Keyboard_R, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.R) }, + { LedId.Keyboard_T, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.T) }, + { LedId.Keyboard_Y, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Y) }, + { LedId.Keyboard_U, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.U) }, + { LedId.Keyboard_I, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.I) }, + { LedId.Keyboard_O, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.O) }, + { LedId.Keyboard_P, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.P) }, + { LedId.Keyboard_BracketLeft, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.BracketLeft) }, + { LedId.Keyboard_CapsLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.CapsLock) }, + { LedId.Keyboard_A, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.A) }, + { LedId.Keyboard_S, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.S) }, + { LedId.Keyboard_D, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.D) }, + { LedId.Keyboard_F, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F) }, + { LedId.Keyboard_G, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.G) }, + { LedId.Keyboard_H, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.H) }, + { LedId.Keyboard_J, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.J) }, + { LedId.Keyboard_K, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.K) }, + { LedId.Keyboard_L, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.L) }, + { LedId.Keyboard_SemicolonAndColon, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.SemicolonAndColon) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ApostropheAndDoubleQuote) }, + { LedId.Keyboard_LeftShift, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftShift) }, + { LedId.Keyboard_NonUsBackslash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NonUsBackslash) }, + { LedId.Keyboard_Z, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Z) }, + { LedId.Keyboard_X, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.X) }, + { LedId.Keyboard_C, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.C) }, + { LedId.Keyboard_V, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.V) }, + { LedId.Keyboard_B, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.B) }, + { LedId.Keyboard_N, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.N) }, + { LedId.Keyboard_M, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M) }, + { LedId.Keyboard_CommaAndLessThan, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.CommaAndLessThan) }, + { LedId.Keyboard_PeriodAndBiggerThan, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PeriodAndBiggerThan) }, + { LedId.Keyboard_SlashAndQuestionMark, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.SlashAndQuestionMark) }, + { LedId.Keyboard_LeftCtrl, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftCtrl) }, + { LedId.Keyboard_LeftGui, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftGui) }, + { LedId.Keyboard_LeftAlt, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftAlt) }, + { LedId.Keyboard_Lang2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Lang2) }, + { LedId.Keyboard_Space, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Space) }, + { LedId.Keyboard_Lang1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Lang1) }, + { LedId.Keyboard_International2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International2) }, + { LedId.Keyboard_RightAlt, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightAlt) }, + { LedId.Keyboard_RightGui, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightGui) }, + { LedId.Keyboard_Application, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Application) }, + { LedId.Keyboard_Brightness, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Brightness) }, + { LedId.Keyboard_F12, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.F12) }, + { LedId.Keyboard_PrintScreen, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PrintScreen) }, + { LedId.Keyboard_ScrollLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScrollLock) }, + { LedId.Keyboard_PauseBreak, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PauseBreak) }, + { LedId.Keyboard_Insert, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Insert) }, + { LedId.Keyboard_Home, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Home) }, + { LedId.Keyboard_PageUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PageUp) }, + { LedId.Keyboard_BracketRight, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.BracketRight) }, + { LedId.Keyboard_Backslash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Backslash) }, + { LedId.Keyboard_NonUsTilde, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NonUsTilde) }, + { LedId.Keyboard_Enter, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Enter) }, + { LedId.Keyboard_International1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International1) }, + { LedId.Keyboard_EqualsAndPlus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.EqualsAndPlus) }, + { LedId.Keyboard_International3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International3) }, + { LedId.Keyboard_Backspace, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Backspace) }, + { LedId.Keyboard_Delete, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Delete) }, + { LedId.Keyboard_End, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.End) }, + { LedId.Keyboard_PageDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PageDown) }, + { LedId.Keyboard_RightShift, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightShift) }, + { LedId.Keyboard_RightCtrl, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightCtrl) }, + { LedId.Keyboard_ArrowUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.UpArrow) }, + { LedId.Keyboard_ArrowLeft, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LeftArrow) }, + { LedId.Keyboard_ArrowDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.DownArrow) }, + { LedId.Keyboard_ArrowRight, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.RightArrow) }, + { LedId.Keyboard_WinLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.WinLock) }, + { LedId.Keyboard_MediaMute, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Mute) }, + { LedId.Keyboard_MediaStop, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Stop) }, + { LedId.Keyboard_MediaPreviousTrack, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScanPreviousTrack) }, + { LedId.Keyboard_MediaPlay, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.PlayPause) }, + { LedId.Keyboard_MediaNextTrack, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.ScanNextTrack) }, + { LedId.Keyboard_NumLock, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.NumLock) }, + { LedId.Keyboard_NumSlash, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadSlash) }, + { LedId.Keyboard_NumAsterisk, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadAsterisk) }, + { LedId.Keyboard_NumMinus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadMinus) }, + { LedId.Keyboard_NumPlus, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadPlus) }, + { LedId.Keyboard_NumEnter, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadEnter) }, + { LedId.Keyboard_Num7, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad7) }, + { LedId.Keyboard_Num8, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad8) }, + { LedId.Keyboard_Num9, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad9) }, + { LedId.Keyboard_NumComma, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadComma) }, + { LedId.Keyboard_Num4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad4) }, + { LedId.Keyboard_Num5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad5) }, + { LedId.Keyboard_Num6, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad6) }, + { LedId.Keyboard_Num1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad1) }, + { LedId.Keyboard_Num2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad2) }, + { LedId.Keyboard_Num3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad3) }, + { LedId.Keyboard_Num0, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Keypad0) }, + { LedId.Keyboard_NumPeriodAndDelete, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.KeypadPeriodAndDelete) }, + { LedId.Keyboard_MediaVolumeUp, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.VolumeUp) }, + { LedId.Keyboard_MediaVolumeDown, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.VolumeDown) }, + { LedId.Keyboard_MacroRecording, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.MR) }, + { LedId.Keyboard_Macro1, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M1) }, + { LedId.Keyboard_Macro2, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M2) }, + { LedId.Keyboard_Macro3, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.M3) }, + { LedId.Keyboard_International5, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International5) }, + { LedId.Keyboard_International4, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.International4) }, + { LedId.Keyboard_LedProgramming, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.LedProgramming) }, + { LedId.Keyboard_Function, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Fn) } + }; - for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++) - HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i); + #endregion - for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++) - Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i); + #region Methods - for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++) - Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i); + internal static LedMapping CreateFanMapping(IEnumerable ids) => CreateMapping(ids, LedId.Fan1); + internal static LedMapping CreateCoolerMapping(IEnumerable ids) => CreateMapping(ids, LedId.Cooler1); + internal static LedMapping CreateLedStripMapping(IEnumerable ids) => CreateMapping(ids, LedId.LedStripe1); + internal static LedMapping CreateGraphicsCardMapping(IEnumerable ids) => CreateMapping(ids, LedId.GraphicsCard1); + internal static LedMapping CreateHeadsetStandMapping(IEnumerable ids) => CreateMapping(ids, LedId.HeadsetStand1); + internal static LedMapping CreateMainboardMapping(IEnumerable ids) => CreateMapping(ids, LedId.Mainboard1); + internal static LedMapping CreateMemoryMapping(IEnumerable ids) => CreateMapping(ids, LedId.DRAM1); + internal static LedMapping CreateMousepadMapping(IEnumerable ids) => CreateMapping(ids, LedId.Mousepad1); + internal static LedMapping CreateHeadsetMapping(IEnumerable ids) => CreateMapping(ids, LedId.Headset1); + internal static LedMapping CreateMouseMapping(IEnumerable ids) => CreateMapping(ids, LedId.Mouse1); + internal static LedMapping CreateUnknownMapping(IEnumerable ids) => CreateMapping(ids, LedId.Unknown1); - for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++) - Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i); + internal static LedMapping CreateMapping(IEnumerable ids, LedId referenceId) + { + LedMapping mapping = new(); + int counter = 0; + foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x)) + mapping.Add(referenceId + counter++, corsairLedId); - for (int i = 0; i <= (CorsairLedId.OemLed100 - CorsairLedId.OemLed1); i++) - Keyboard.Add(LedId.Custom1 + i, CorsairLedId.OemLed1 + i); - - for (int i = 0; i <= (CorsairLedId.OemLed250 - CorsairLedId.OemLed101); i++) - Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i); + return mapping; } - /// - /// Gets the mapping for graphics cards. - /// - public static LedMapping GraphicsCard { get; } = new(); - - /// - /// Gets the mapping for headsets. - /// - public static LedMapping HeadsetStand { get; } = new(); - - /// - /// Gets the mapping for mainboards. - /// - public static LedMapping Mainboard { get; } = new(); - - /// - /// Gets the mapping for memory. - /// - public static LedMapping Memory { get; } = new(); - - /// - /// Gets the mapping for mousepads. - /// - public static LedMapping Mousepad { get; } = new(); - - /// - /// Gets the mapping for headsets. - /// - public static LedMapping Headset { get; } = new() + internal static LedMapping CreateKeyboardMapping(IEnumerable ids) { - { LedId.Headset1, CorsairLedId.LeftLogo }, - { LedId.Headset2, CorsairLedId.RightLogo }, - }; + Dictionary groupCounter = new() + { + [CorsairLedGroup.KeyboardOem] = 0, + [CorsairLedGroup.KeyboardGKeys] = 0, + [CorsairLedGroup.KeyboardEdge] = 0, + [CorsairLedGroup.Keyboard] = 0 // Workaround for unknown keys + }; - /// - /// Gets the mapping for mice. - /// - public static LedMapping Mouse { get; } = new() - { - { LedId.Mouse1, CorsairLedId.B1 }, - { LedId.Mouse2, CorsairLedId.B2 }, - { LedId.Mouse3, CorsairLedId.B3 }, - { LedId.Mouse4, CorsairLedId.B4 }, - { LedId.Mouse5, CorsairLedId.B5 }, - { LedId.Mouse6, CorsairLedId.B6 }, - { LedId.Mouse7, CorsairLedId.B7 }, - { LedId.Mouse8, CorsairLedId.B8 }, - { LedId.Mouse9, CorsairLedId.B9 }, - { LedId.Mouse10, CorsairLedId.B10 }, - { LedId.Mouse11, CorsairLedId.B11 }, - { LedId.Mouse12, CorsairLedId.B12 }, - { LedId.Mouse13, CorsairLedId.B13 }, - { LedId.Mouse14, CorsairLedId.B14 }, - { LedId.Mouse15, CorsairLedId.B15 }, - { LedId.Mouse16, CorsairLedId.B16 }, - { LedId.Mouse17, CorsairLedId.B17 }, - { LedId.Mouse18, CorsairLedId.B18 }, - { LedId.Mouse19, CorsairLedId.B19 }, - { LedId.Mouse20, CorsairLedId.B20 }, - }; + LedMapping mapping = KEYBOARD_MAPPING; - /// - /// Gets the mapping for keyboards. - /// - public static LedMapping Keyboard { get; } = new() - { - { LedId.Invalid, CorsairLedId.Invalid }, - { LedId.Logo, CorsairLedId.Logo }, - { LedId.Keyboard_Escape, CorsairLedId.Escape }, - { LedId.Keyboard_F1, CorsairLedId.F1 }, - { LedId.Keyboard_F2, CorsairLedId.F2 }, - { LedId.Keyboard_F3, CorsairLedId.F3 }, - { LedId.Keyboard_F4, CorsairLedId.F4 }, - { LedId.Keyboard_F5, CorsairLedId.F5 }, - { LedId.Keyboard_F6, CorsairLedId.F6 }, - { LedId.Keyboard_F7, CorsairLedId.F7 }, - { LedId.Keyboard_F8, CorsairLedId.F8 }, - { LedId.Keyboard_F9, CorsairLedId.F9 }, - { LedId.Keyboard_F10, CorsairLedId.F10 }, - { LedId.Keyboard_F11, CorsairLedId.F11 }, - { LedId.Keyboard_GraveAccentAndTilde, CorsairLedId.GraveAccentAndTilde }, - { LedId.Keyboard_1, CorsairLedId.D1 }, - { LedId.Keyboard_2, CorsairLedId.D2 }, - { LedId.Keyboard_3, CorsairLedId.D3 }, - { LedId.Keyboard_4, CorsairLedId.D4 }, - { LedId.Keyboard_5, CorsairLedId.D5 }, - { LedId.Keyboard_6, CorsairLedId.D6 }, - { LedId.Keyboard_7, CorsairLedId.D7 }, - { LedId.Keyboard_8, CorsairLedId.D8 }, - { LedId.Keyboard_9, CorsairLedId.D9 }, - { LedId.Keyboard_0, CorsairLedId.D0 }, - { LedId.Keyboard_MinusAndUnderscore, CorsairLedId.MinusAndUnderscore }, - { LedId.Keyboard_Tab, CorsairLedId.Tab }, - { LedId.Keyboard_Q, CorsairLedId.Q }, - { LedId.Keyboard_W, CorsairLedId.W }, - { LedId.Keyboard_E, CorsairLedId.E }, - { LedId.Keyboard_R, CorsairLedId.R }, - { LedId.Keyboard_T, CorsairLedId.T }, - { LedId.Keyboard_Y, CorsairLedId.Y }, - { LedId.Keyboard_U, CorsairLedId.U }, - { LedId.Keyboard_I, CorsairLedId.I }, - { LedId.Keyboard_O, CorsairLedId.O }, - { LedId.Keyboard_P, CorsairLedId.P }, - { LedId.Keyboard_BracketLeft, CorsairLedId.BracketLeft }, - { LedId.Keyboard_CapsLock, CorsairLedId.CapsLock }, - { LedId.Keyboard_A, CorsairLedId.A }, - { LedId.Keyboard_S, CorsairLedId.S }, - { LedId.Keyboard_D, CorsairLedId.D }, - { LedId.Keyboard_F, CorsairLedId.F }, - { LedId.Keyboard_G, CorsairLedId.G }, - { LedId.Keyboard_H, CorsairLedId.H }, - { LedId.Keyboard_J, CorsairLedId.J }, - { LedId.Keyboard_K, CorsairLedId.K }, - { LedId.Keyboard_L, CorsairLedId.L }, - { LedId.Keyboard_SemicolonAndColon, CorsairLedId.SemicolonAndColon }, - { LedId.Keyboard_ApostropheAndDoubleQuote, CorsairLedId.ApostropheAndDoubleQuote }, - { LedId.Keyboard_LeftShift, CorsairLedId.LeftShift }, - { LedId.Keyboard_NonUsBackslash, CorsairLedId.NonUsBackslash }, - { LedId.Keyboard_Z, CorsairLedId.Z }, - { LedId.Keyboard_X, CorsairLedId.X }, - { LedId.Keyboard_C, CorsairLedId.C }, - { LedId.Keyboard_V, CorsairLedId.V }, - { LedId.Keyboard_B, CorsairLedId.B }, - { LedId.Keyboard_N, CorsairLedId.N }, - { LedId.Keyboard_M, CorsairLedId.M }, - { LedId.Keyboard_CommaAndLessThan, CorsairLedId.CommaAndLessThan }, - { LedId.Keyboard_PeriodAndBiggerThan, CorsairLedId.PeriodAndBiggerThan }, - { LedId.Keyboard_SlashAndQuestionMark, CorsairLedId.SlashAndQuestionMark }, - { LedId.Keyboard_LeftCtrl, CorsairLedId.LeftCtrl }, - { LedId.Keyboard_LeftGui, CorsairLedId.LeftGui }, - { LedId.Keyboard_LeftAlt, CorsairLedId.LeftAlt }, - { LedId.Keyboard_Lang2, CorsairLedId.Lang2 }, - { LedId.Keyboard_Space, CorsairLedId.Space }, - { LedId.Keyboard_Lang1, CorsairLedId.Lang1 }, - { LedId.Keyboard_International2, CorsairLedId.International2 }, - { LedId.Keyboard_RightAlt, CorsairLedId.RightAlt }, - { LedId.Keyboard_RightGui, CorsairLedId.RightGui }, - { LedId.Keyboard_Application, CorsairLedId.Application }, - { LedId.Keyboard_Brightness, CorsairLedId.Brightness }, - { LedId.Keyboard_F12, CorsairLedId.F12 }, - { LedId.Keyboard_PrintScreen, CorsairLedId.PrintScreen }, - { LedId.Keyboard_ScrollLock, CorsairLedId.ScrollLock }, - { LedId.Keyboard_PauseBreak, CorsairLedId.PauseBreak }, - { LedId.Keyboard_Insert, CorsairLedId.Insert }, - { LedId.Keyboard_Home, CorsairLedId.Home }, - { LedId.Keyboard_PageUp, CorsairLedId.PageUp }, - { LedId.Keyboard_BracketRight, CorsairLedId.BracketRight }, - { LedId.Keyboard_Backslash, CorsairLedId.Backslash }, - { LedId.Keyboard_NonUsTilde, CorsairLedId.NonUsTilde }, - { LedId.Keyboard_Enter, CorsairLedId.Enter }, - { LedId.Keyboard_International1, CorsairLedId.International1 }, - { LedId.Keyboard_EqualsAndPlus, CorsairLedId.EqualsAndPlus }, - { LedId.Keyboard_International3, CorsairLedId.International3 }, - { LedId.Keyboard_Backspace, CorsairLedId.Backspace }, - { LedId.Keyboard_Delete, CorsairLedId.Delete }, - { LedId.Keyboard_End, CorsairLedId.End }, - { LedId.Keyboard_PageDown, CorsairLedId.PageDown }, - { LedId.Keyboard_RightShift, CorsairLedId.RightShift }, - { LedId.Keyboard_RightCtrl, CorsairLedId.RightCtrl }, - { LedId.Keyboard_ArrowUp, CorsairLedId.UpArrow }, - { LedId.Keyboard_ArrowLeft, CorsairLedId.LeftArrow }, - { LedId.Keyboard_ArrowDown, CorsairLedId.DownArrow }, - { LedId.Keyboard_ArrowRight, CorsairLedId.RightArrow }, - { LedId.Keyboard_WinLock, CorsairLedId.WinLock }, - { LedId.Keyboard_MediaMute, CorsairLedId.Mute }, - { LedId.Keyboard_MediaStop, CorsairLedId.Stop }, - { LedId.Keyboard_MediaPreviousTrack, CorsairLedId.ScanPreviousTrack }, - { LedId.Keyboard_MediaPlay, CorsairLedId.PlayPause }, - { LedId.Keyboard_MediaNextTrack, CorsairLedId.ScanNextTrack }, - { LedId.Keyboard_NumLock, CorsairLedId.NumLock }, - { LedId.Keyboard_NumSlash, CorsairLedId.KeypadSlash }, - { LedId.Keyboard_NumAsterisk, CorsairLedId.KeypadAsterisk }, - { LedId.Keyboard_NumMinus, CorsairLedId.KeypadMinus }, - { LedId.Keyboard_NumPlus, CorsairLedId.KeypadPlus }, - { LedId.Keyboard_NumEnter, CorsairLedId.KeypadEnter }, - { LedId.Keyboard_Num7, CorsairLedId.Keypad7 }, - { LedId.Keyboard_Num8, CorsairLedId.Keypad8 }, - { LedId.Keyboard_Num9, CorsairLedId.Keypad9 }, - { LedId.Keyboard_NumComma, CorsairLedId.KeypadComma }, - { LedId.Keyboard_Num4, CorsairLedId.Keypad4 }, - { LedId.Keyboard_Num5, CorsairLedId.Keypad5 }, - { LedId.Keyboard_Num6, CorsairLedId.Keypad6 }, - { LedId.Keyboard_Num1, CorsairLedId.Keypad1 }, - { LedId.Keyboard_Num2, CorsairLedId.Keypad2 }, - { LedId.Keyboard_Num3, CorsairLedId.Keypad3 }, - { LedId.Keyboard_Num0, CorsairLedId.Keypad0 }, - { LedId.Keyboard_NumPeriodAndDelete, CorsairLedId.KeypadPeriodAndDelete }, - { LedId.Keyboard_Programmable1, CorsairLedId.G1 }, - { LedId.Keyboard_Programmable2, CorsairLedId.G2 }, - { LedId.Keyboard_Programmable3, CorsairLedId.G3 }, - { LedId.Keyboard_Programmable4, CorsairLedId.G4 }, - { LedId.Keyboard_Programmable5, CorsairLedId.G5 }, - { LedId.Keyboard_Programmable6, CorsairLedId.G6 }, - { LedId.Keyboard_Programmable7, CorsairLedId.G7 }, - { LedId.Keyboard_Programmable8, CorsairLedId.G8 }, - { LedId.Keyboard_Programmable9, CorsairLedId.G9 }, - { LedId.Keyboard_Programmable10, CorsairLedId.G10 }, - { LedId.Keyboard_MediaVolumeUp, CorsairLedId.VolumeUp }, - { LedId.Keyboard_MediaVolumeDown, CorsairLedId.VolumeDown }, - { LedId.Keyboard_MacroRecording, CorsairLedId.MR }, - { LedId.Keyboard_Macro1, CorsairLedId.M1 }, - { LedId.Keyboard_Macro2, CorsairLedId.M2 }, - { LedId.Keyboard_Macro3, CorsairLedId.M3 }, - { LedId.Keyboard_Programmable11, CorsairLedId.G11 }, - { LedId.Keyboard_Programmable12, CorsairLedId.G12 }, - { LedId.Keyboard_Programmable13, CorsairLedId.G13 }, - { LedId.Keyboard_Programmable14, CorsairLedId.G14 }, - { LedId.Keyboard_Programmable15, CorsairLedId.G15 }, - { LedId.Keyboard_Programmable16, CorsairLedId.G16 }, - { LedId.Keyboard_Programmable17, CorsairLedId.G17 }, - { LedId.Keyboard_Programmable18, CorsairLedId.G18 }, - { LedId.Keyboard_International5, CorsairLedId.International5 }, - { LedId.Keyboard_International4, CorsairLedId.International4 }, - { LedId.Keyboard_Profile, CorsairLedId.Profile }, - { LedId.Keyboard_LedProgramming, CorsairLedId.LedProgramming }, - { LedId.Keyboard_Function, CorsairLedId.Fn }, + foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x).Where(x => x.Group != CorsairLedGroup.Keyboard)) + switch (corsairLedId.Group) + { + case CorsairLedGroup.KeyboardOem: + mapping.Add(LedId.Keyboard_Custom1 + groupCounter[CorsairLedGroup.KeyboardOem]++, corsairLedId); + break; - { LedId.LedStripe1, CorsairLedId.Lightbar1 }, - { LedId.LedStripe2, CorsairLedId.Lightbar2 }, - { LedId.LedStripe3, CorsairLedId.Lightbar3 }, - { LedId.LedStripe4, CorsairLedId.Lightbar4 }, - { LedId.LedStripe5, CorsairLedId.Lightbar5 }, - { LedId.LedStripe6, CorsairLedId.Lightbar6 }, - { LedId.LedStripe7, CorsairLedId.Lightbar7 }, - { LedId.LedStripe8, CorsairLedId.Lightbar8 }, - { LedId.LedStripe9, CorsairLedId.Lightbar9 }, - { LedId.LedStripe10, CorsairLedId.Lightbar10 }, - { LedId.LedStripe11, CorsairLedId.Lightbar11 }, - { LedId.LedStripe12, CorsairLedId.Lightbar12 }, - { LedId.LedStripe13, CorsairLedId.Lightbar13 }, - { LedId.LedStripe14, CorsairLedId.Lightbar14 }, - { LedId.LedStripe15, CorsairLedId.Lightbar15 }, - { LedId.LedStripe16, CorsairLedId.Lightbar16 }, - { LedId.LedStripe17, CorsairLedId.Lightbar17 }, - { LedId.LedStripe18, CorsairLedId.Lightbar18 }, - { LedId.LedStripe19, CorsairLedId.Lightbar19 }, - { LedId.LedStripe20, CorsairLedId.Lightbar20 }, - { LedId.LedStripe21, CorsairLedId.Lightbar21 }, - { LedId.LedStripe22, CorsairLedId.Lightbar22 }, - { LedId.LedStripe23, CorsairLedId.Lightbar23 }, - { LedId.LedStripe24, CorsairLedId.Lightbar24 }, - { LedId.LedStripe25, CorsairLedId.Lightbar25 }, - { LedId.LedStripe26, CorsairLedId.Lightbar26 }, - { LedId.LedStripe27, CorsairLedId.Lightbar27 }, - { LedId.LedStripe28, CorsairLedId.Lightbar28 }, - { LedId.LedStripe29, CorsairLedId.Lightbar29 }, - { LedId.LedStripe30, CorsairLedId.Lightbar30 }, - { LedId.LedStripe31, CorsairLedId.Lightbar31 }, - { LedId.LedStripe32, CorsairLedId.Lightbar32 }, - { LedId.LedStripe33, CorsairLedId.Lightbar33 }, - { LedId.LedStripe34, CorsairLedId.Lightbar34 }, - { LedId.LedStripe35, CorsairLedId.Lightbar35 }, - { LedId.LedStripe36, CorsairLedId.Lightbar36 }, - { LedId.LedStripe37, CorsairLedId.Lightbar37 }, - { LedId.LedStripe38, CorsairLedId.Lightbar38 }, - { LedId.LedStripe39, CorsairLedId.Lightbar39 }, - { LedId.LedStripe40, CorsairLedId.Lightbar40 }, - { LedId.LedStripe41, CorsairLedId.Lightbar41 }, - { LedId.LedStripe42, CorsairLedId.Lightbar42 }, - { LedId.LedStripe43, CorsairLedId.Lightbar43 }, - { LedId.LedStripe44, CorsairLedId.Lightbar44 }, - { LedId.LedStripe45, CorsairLedId.Lightbar45 }, - { LedId.LedStripe46, CorsairLedId.Lightbar46 }, - { LedId.LedStripe47, CorsairLedId.Lightbar47 }, - { LedId.LedStripe48, CorsairLedId.Lightbar48 }, - { LedId.LedStripe49, CorsairLedId.Lightbar49 }, - { LedId.LedStripe50, CorsairLedId.Lightbar50 }, - }; + case CorsairLedGroup.KeyboardGKeys: + mapping.Add(LedId.Keyboard_Programmable1 + groupCounter[CorsairLedGroup.KeyboardGKeys]++, corsairLedId); + break; + + case CorsairLedGroup.KeyboardEdge: + mapping.Add(LedId.LedStripe1 + groupCounter[CorsairLedGroup.KeyboardEdge]++, corsairLedId); + break; + + default: + mapping.Add(LedId.Unknown1 + groupCounter[CorsairLedGroup.Keyboard]++, corsairLedId); + break; + } + + return mapping; + } + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs index b1238c1..ce7fb8c 100644 --- a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs @@ -1,6 +1,7 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global +using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairGraphicsCardRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the graphics card. /// The queue used to update this device. internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.GraphicsCard, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateGraphicsCardMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs index d58120c..ec5b436 100644 --- a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs @@ -15,13 +15,8 @@ public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairGraphicsCardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.GraphicsCard, nativeInfo) + internal CorsairGraphicsCardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.GraphicsCard, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index f52d548..c2336d6 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairHeadsetRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the headset /// The queue used to update this device. internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Headset, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateHeadsetMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs index fb3e696..5bac705 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs @@ -12,13 +12,8 @@ public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Headset, nativeInfo) + internal CorsairHeadsetRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Headset, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs index def410d..7103b76 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairHeadsetStandRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the headset stand /// The queue used to update this device. internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.HeadsetStand, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateHeadsetStandMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs index b880a6c..cc6b274 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs @@ -12,13 +12,8 @@ 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) + internal CorsairHeadsetStandRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.HeadsetStand, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs b/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs index b78851b..e60424e 100644 --- a/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs +++ b/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs @@ -1,5 +1,6 @@ using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; +using System.Runtime.InteropServices; namespace RGB.NET.Devices.Corsair; @@ -7,12 +8,25 @@ internal static class NativeExtensions { internal static Rectangle ToRectangle(this _CorsairLedPosition position) { - //HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0. - float width = position.width < 0.5f ? 10 : (float)position.width; - float height = position.height < 0.5f ? 10 : (float)position.height; - float posX = (float)position.left; - float posY = (float)position.top; + const float WIDTH = 10; + const float HEIGHT = 10; + float posX = (float)position.cx; + float posY = (float)position.cy; - return new Rectangle(posX, posY, width, height); + return new Rectangle(posX, posY, WIDTH, HEIGHT); + } + + internal static T[] ToArray(this nint ptr, int size) + { + int tSize = Marshal.SizeOf(); + T[] array = new T[size]; + nint loopPtr = ptr; + for (int i = 0; i < size; i++) + { + array[i] = Marshal.PtrToStructure(loopPtr)!; + loopPtr += tSize; + } + + return array; } } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index bdc9425..d1fa931 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -26,8 +27,14 @@ public class CorsairKeyboardRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the keyboard. /// The queue used to update this device. internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Keyboard, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateKeyboardMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs index efa40a8..dcab088 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs @@ -36,11 +36,12 @@ public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDevic /// /// The index of the . /// The native -struct - internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Keyboard, nativeInfo) + internal CorsairKeyboardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Keyboard, nativeInfo, ledCount, ledOffset) { - this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout; - this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout; + PhysicalLayout = (CorsairPhysicalKeyboardLayout)_CUESDK.ReadDevicePropertySimpleInt32(nativeInfo.id!, CorsairDevicePropertyId.PhysicalLayout); + LogicalLayout = (CorsairLogicalKeyboardLayout)_CUESDK.ReadDevicePropertySimpleInt32(nativeInfo.id!, CorsairDevicePropertyId.LogicalLayout); + this.Layout = PhysicalLayout switch { CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI, diff --git a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs new file mode 100644 index 0000000..53eb5b0 --- /dev/null +++ b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs @@ -0,0 +1,34 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using System.Collections.Generic; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a corsair ledStrip. +/// +public class CorsairLedStripRGBDevice : CorsairRGBDevice, ILedStripe +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the ledStrip. + /// The queue used to update this device. + internal CorsairLedStripRGBDevice(CorsairLedStripRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { } + + #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateLedStripMapping(ids); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs new file mode 100644 index 0000000..35006b8 --- /dev/null +++ b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + internal CorsairLedStripRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset) + { } + + /// + internal CorsairLedStripRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) + : base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset, modelName) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs index fc23e18..55ab92c 100644 --- a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairMainboardRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the memory. /// The queue used to update this device. internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Mainboard, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateMainboardMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs index 94d836c..4058d10 100644 --- a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs @@ -15,13 +15,8 @@ public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairMainboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Mainboard, nativeInfo) + internal CorsairMainboardRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Mainboard, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs index f44d7ee..48b2eb3 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairMemoryRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the memory. /// The queue used to update this device. internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Memory, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateMemoryMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs index afd8843..8d779f7 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs @@ -15,13 +15,13 @@ public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairMemoryRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.DRAM, nativeInfo) + internal CorsairMemoryRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.DRAM, nativeInfo, ledCount, ledOffset) + { } + + /// + internal CorsairMemoryRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset, string modelName) + : base(RGBDeviceType.DRAM, nativeInfo, ledCount, ledOffset, modelName) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index 5c81249..89f25c4 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairMouseRGBDevice : CorsairRGBDevice /// The specific information provided by CUE for the mouse /// The queue used to update this device. internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Mouse, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateMouseMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs index a501466..422b18a 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs @@ -9,28 +9,12 @@ namespace RGB.NET.Devices.Corsair; /// public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo { - #region Properties & Fields - - /// - /// Gets the physical layout of the mouse. - /// - public CorsairPhysicalMouseLayout PhysicalLayout { get; } - - #endregion - #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Mouse, nativeInfo) - { - this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout; - } + internal CorsairMouseRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Mouse, nativeInfo, ledCount, ledOffset) + { } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index 65c0f00..ac7a9b3 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -20,8 +21,14 @@ public class CorsairMousepadRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the mousepad /// The queue used to update this device. internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Mousepad, updateQueue) + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateMousepadMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs index 8c5d62c..6b469c0 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs @@ -12,13 +12,8 @@ public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index if the . - /// The native -struct - internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo) + internal CorsairMousepadRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Mousepad, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index 9455cb3..d3593ee 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -11,12 +11,66 @@ using RGB.NET.Core; namespace RGB.NET.Devices.Corsair.Native; +internal delegate void CorsairSessionStateChangedHandler(nint context, _CorsairSessionStateChanged eventData); + // ReSharper disable once InconsistentNaming -internal static class _CUESDK +internal static unsafe class _CUESDK { + #region Constants + + /// + /// iCUE-SDK: small string length + /// + internal const int CORSAIR_STRING_SIZE_S = 64; + + /// + /// iCUE-SDK: medium string length + /// + internal const int CORSAIR_STRING_SIZE_M = 128; + + /// + /// iCUE-SDK: maximum level of layer’s priority that can be used in CorsairSetLayerPriority + /// + internal const int CORSAIR_LAYER_PRIORITY_MAX = 255; + + /// + /// iCUE-SDK: maximum number of devices to be discovered + /// + internal const int CORSAIR_DEVICE_COUNT_MAX = 64; + + /// + /// iCUE-SDK: maximum number of LEDs controlled by device + /// + internal const int CORSAIR_DEVICE_LEDCOUNT_MAX = 512; + + #endregion + + #region Properties & Fields + + internal static bool IsConnected => SesionState == CorsairSessionState.Connected; + internal static CorsairSessionState SesionState { get; private set; } + + #endregion + + #region Events + + internal static event EventHandler? SessionStateChanged; + + #endregion + + #region Methods + + private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata) + { + SesionState = eventdata.state; + SessionStateChanged?.Invoke(null, eventdata.state); + } + + #endregion + #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. @@ -29,7 +83,7 @@ internal static class _CUESDK private static void LoadCUESDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -37,24 +91,31 @@ internal static class _CUESDK if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); if (!NativeLibrary.TryLoad(dllPath, out _handle)) -#if NET6_0 +#if NET6_0_OR_GREATER throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}"); #else throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}"); #endif - if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsBufferByDeviceIndex", out _corsairSetLedsColorsBufferByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsBufferByDeviceIndex'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsFlushBuffer", out _corsairSetLedsColorsFlushBufferPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsFlushBuffer'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedsColorsByDeviceIndex", out _corsairGetLedsColorsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedsColorsByDeviceIndex'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLayerPriority", out _corsairSetLayerPriorityPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLayerPriority'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceCount", out _corsairGetDeviceCountPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceCount'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceInfo", out _corsairGetDeviceInfoPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceInfo'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedIdForKeyName", out _corsairGetLedIdForKeyNamePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedIdForKeyName'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedPositionsByDeviceIndex", out _corsairGetLedPositionsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedPositionsByDeviceIndex'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairRequestControl", out _corsairRequestControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairRequestControl'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairReleaseControl", out _corsairReleaseControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairReleaseControl'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairPerformProtocolHandshake", out _corsairPerformProtocolHandshakePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairPerformProtocolHandshake'"); - if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLastError", out _corsairGetLastErrorPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLastError'"); + _corsairConnectPtr = (delegate* unmanaged[Cdecl])LoadFunction("CorsairConnect"); + _corsairGetSessionDetails = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetSessionDetails"); + _corsairDisconnect = (delegate* unmanaged[Cdecl])LoadFunction("CorsairDisconnect"); + _corsairGetDevices = (delegate* unmanaged[Cdecl]<_CorsairDeviceFilter, int, nint, out int, CorsairError>)LoadFunction("CorsairGetDevices"); + _corsairGetDeviceInfo = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetDeviceInfo"); + _corsairGetLedPositions = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetLedPositions"); + _corsairSetLedColors = (delegate* unmanaged[Cdecl])LoadFunction("CorsairSetLedColors"); + _corsairSetLayerPriority = (delegate* unmanaged[Cdecl])LoadFunction("CorsairSetLayerPriority"); + _corsairGetLedLuidForKeyName = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetLedLuidForKeyName"); + _corsairRequestControl = (delegate* unmanaged[Cdecl])LoadFunction("CorsairRequestControl"); + _corsairReleaseControl = (delegate* unmanaged[Cdecl])LoadFunction("CorsairReleaseControl"); + _getDevicePropertyInfo = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetDevicePropertyInfo"); + _readDeviceProperty = (delegate* unmanaged[Cdecl])LoadFunction("CorsairReadDeviceProperty"); + } + + private static nint LoadFunction(string function) + { + if (!NativeLibrary.TryGetExport(_handle, function, out nint ptr)) throw new RGBDeviceException($"Failed to load Corsair function '{function}'"); + return ptr; } private static IEnumerable GetPossibleLibraryPaths() @@ -71,23 +132,24 @@ internal static class _CUESDK internal static void UnloadCUESDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; - _corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero; - _corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero; - _corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero; - _corsairSetLayerPriorityPointer = IntPtr.Zero; - _corsairGetDeviceCountPointer = IntPtr.Zero; - _corsairGetDeviceInfoPointer = IntPtr.Zero; - _corsairGetLedIdForKeyNamePointer = IntPtr.Zero; - _corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero; - _corsairRequestControlPointer = IntPtr.Zero; - _corsairReleaseControlPointer = IntPtr.Zero; - _corsairPerformProtocolHandshakePointer = IntPtr.Zero; - _corsairGetLastErrorPointer = IntPtr.Zero; + _corsairConnectPtr = null; + _corsairGetSessionDetails = null; + _corsairDisconnect = null; + _corsairGetDevices = null; + _corsairGetDeviceInfo = null; + _corsairGetLedPositions = null; + _corsairSetLedColors = null; + _corsairSetLayerPriority = null; + _corsairGetLedLuidForKeyName = null; + _corsairRequestControl = null; + _corsairReleaseControl = null; + _getDevicePropertyInfo = null; + _readDeviceProperty = null; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } #endregion @@ -96,97 +158,182 @@ internal static class _CUESDK #region Pointers - private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer; - private static IntPtr _corsairSetLedsColorsFlushBufferPointer; - private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer; - private static IntPtr _corsairSetLayerPriorityPointer; - private static IntPtr _corsairGetDeviceCountPointer; - private static IntPtr _corsairGetDeviceInfoPointer; - private static IntPtr _corsairGetLedIdForKeyNamePointer; - private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer; - private static IntPtr _corsairRequestControlPointer; - private static IntPtr _corsairReleaseControlPointer; - private static IntPtr _corsairPerformProtocolHandshakePointer; - private static IntPtr _corsairGetLastErrorPointer; + private static delegate* unmanaged[Cdecl] _corsairConnectPtr; + private static delegate* unmanaged[Cdecl] _corsairGetSessionDetails; + private static delegate* unmanaged[Cdecl] _corsairDisconnect; + private static delegate* unmanaged[Cdecl]<_CorsairDeviceFilter, int, nint, out int, CorsairError> _corsairGetDevices; + private static delegate* unmanaged[Cdecl] _corsairGetDeviceInfo; + private static delegate* unmanaged[Cdecl] _corsairGetLedPositions; + private static delegate* unmanaged[Cdecl] _corsairSetLedColors; + private static delegate* unmanaged[Cdecl] _corsairSetLayerPriority; + private static delegate* unmanaged[Cdecl] _corsairGetLedLuidForKeyName; + private static delegate* unmanaged[Cdecl] _corsairRequestControl; + private static delegate* unmanaged[Cdecl] _corsairReleaseControl; + private static delegate* unmanaged[Cdecl] _getDevicePropertyInfo; + private static delegate* unmanaged[Cdecl] _readDeviceProperty; #endregion - /// - /// CUE-SDK: set specified LEDs to some colors. - /// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync. - /// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device - /// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer. - /// This function does not take logical layout into account. - /// - internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors); - - /// - /// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function. - /// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync - /// - internal static unsafe bool CorsairSetLedsColorsFlushBuffer() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsFlushBufferPointer))(); - - /// - /// CUE-SDK: get current color for the list of requested LEDs. - /// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input. - /// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices. - /// - internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors); - - /// - /// CUE-SDK: set layer priority for this shared client. - /// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function. - /// Layers with higher priority value are shown on top of layers with lower priority. - /// - internal static unsafe bool CorsairSetLayerPriority(int priority) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLayerPriorityPointer))(priority); - - /// - /// CUE-SDK: returns number of connected Corsair devices that support lighting control. - /// - internal static unsafe int CorsairGetDeviceCount() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceCountPointer))(); - - /// - /// CUE-SDK: returns information about device at provided index. - /// - internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex); - - /// - /// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions. - /// - internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex); - - /// - /// CUE-SDK: retrieves led id for key name taking logical layout into account. - /// - internal static unsafe CorsairLedId CorsairGetLedIdForKeyName(char keyName) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedIdForKeyNamePointer))(keyName); - - /// - /// CUE-SDK: requestes control using specified access mode. - /// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control. - /// - internal static unsafe bool CorsairRequestControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairRequestControlPointer))(accessMode); - - /// - /// CUE-SDK: releases previously requested control for specified access mode. - /// - internal static unsafe bool CorsairReleaseControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairReleaseControlPointer))(accessMode); - - /// - /// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE. - /// - internal static unsafe _CorsairProtocolDetails CorsairPerformProtocolHandshake() => ((delegate* unmanaged[Cdecl]<_CorsairProtocolDetails>)ThrowIfZero(_corsairPerformProtocolHandshakePointer))(); - - /// - /// CUE-SDK: returns last error that occured while using any of Corsair* functions. - /// - internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLastErrorPointer))(); - - private static IntPtr ThrowIfZero(IntPtr ptr) + internal static CorsairError CorsairConnect() { - if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized."); - return ptr; + if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized."); + if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected."); + return _corsairConnectPtr(CorsairSessionStateChangedCallback, 0); + } + + internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + + nint sessionDetailPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairSessionDetails>()); + try + { + CorsairError error = _corsairGetSessionDetails(sessionDetailPtr); + details = Marshal.PtrToStructure<_CorsairSessionDetails>(sessionDetailPtr); + + return error; + } + finally + { + Marshal.FreeHGlobal(sessionDetailPtr); + } + } + + internal static CorsairError CorsairDisconnect() + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairDisconnect(); + } + + internal static CorsairError CorsairGetDevices(_CorsairDeviceFilter filter, out _CorsairDeviceInfo[] devices) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + + int structSize = Marshal.SizeOf<_CorsairDeviceInfo>(); + nint devicePtr = Marshal.AllocHGlobal(structSize * CORSAIR_DEVICE_COUNT_MAX); + try + { + CorsairError error = _corsairGetDevices(filter, CORSAIR_DEVICE_COUNT_MAX, devicePtr, out int size); + devices = devicePtr.ToArray<_CorsairDeviceInfo>(size); + + return error; + } + finally + { + Marshal.FreeHGlobal(devicePtr); + } + } + + internal static CorsairError CorsairGetDeviceInfo(string deviceId, _CorsairDeviceInfo deviceInfo) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairGetDeviceInfo(deviceId, deviceInfo); + } + + internal static CorsairError CorsairGetLedPositions(string deviceId, out _CorsairLedPosition[] ledPositions) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + + int structSize = Marshal.SizeOf<_CorsairLedPosition>(); + nint ledPositionsPtr = Marshal.AllocHGlobal(structSize * CORSAIR_DEVICE_LEDCOUNT_MAX); + try + { + CorsairError error = _corsairGetLedPositions(deviceId, CORSAIR_DEVICE_LEDCOUNT_MAX, ledPositionsPtr, out int size); + ledPositions = ledPositionsPtr.ToArray<_CorsairLedPosition>(size); + + return error; + } + finally + { + Marshal.FreeHGlobal(ledPositionsPtr); + } + } + + internal static CorsairError CorsairSetLedColors(string deviceId, int ledCount, nint ledColorsPtr) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairSetLedColors(deviceId, ledCount, ledColorsPtr); + } + + internal static CorsairError CorsairSetLayerPriority(uint priority) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairSetLayerPriority(priority); + } + + internal static CorsairError CorsairGetLedLuidForKeyName(string deviceId, char keyName, out uint ledId) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairGetLedLuidForKeyName(deviceId, keyName, out ledId); + } + + internal static CorsairError CorsairRequestControl(string deviceId, CorsairAccessLevel accessLevel) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairRequestControl(deviceId, accessLevel); + } + + internal static CorsairError CorsairReleaseControl(string deviceId) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _corsairReleaseControl(deviceId); + } + + internal static CorsairError GetDevicePropertyInfo(string deviceId, CorsairDevicePropertyId propertyId, uint index, out CorsairDataType dataType, out CorsairPropertyFlag flags) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + return _getDevicePropertyInfo(deviceId, propertyId, index, out dataType, out flags); + } + + internal static CorsairError ReadDeviceProperty(string deviceId, CorsairDevicePropertyId propertyId, uint index, out _CorsairProperty? property) + { + if (!IsConnected) throw new RGBDeviceException("The Corsair-SDK is not connected."); + + nint propertyPtr = Marshal.AllocHGlobal(Marshal.SizeOf<_CorsairProperty>()); + try + { + CorsairError error = _readDeviceProperty(deviceId, propertyId, index, propertyPtr); + property = Marshal.PtrToStructure<_CorsairProperty>(propertyPtr); + + return error; + } + finally + { + Marshal.FreeHGlobal(propertyPtr); + } + } + + internal static int ReadDevicePropertySimpleInt32(string deviceId, CorsairDevicePropertyId propertyId, uint index = 0) => ReadDevicePropertySimple(deviceId, propertyId, CorsairDataType.Int32, index).int32; + + internal static int[] ReadDevicePropertySimpleInt32Array(string deviceId, CorsairDevicePropertyId propertyId, uint index = 0) + { + _CorsairDataValue dataValue = ReadDevicePropertySimple(deviceId, propertyId, CorsairDataType.Int32Array, index); + return dataValue.int32Array.items.ToArray((int)dataValue.int32Array.count); + } + + internal static _CorsairDataValue ReadDevicePropertySimple(string deviceId, CorsairDevicePropertyId propertyId, CorsairDataType expectedDataType, uint index = 0) + { + CorsairError errorCode = GetDevicePropertyInfo(deviceId, propertyId, index, out CorsairDataType dataType, out CorsairPropertyFlag flags); + if (errorCode != CorsairError.Success) + throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (ErrorCode: {errorCode})"); + + if (dataType != expectedDataType) + throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (Wrong data-type '{dataType}', expected: '{expectedDataType}')"); + + if (!flags.HasFlag(CorsairPropertyFlag.CanRead)) + throw new RGBDeviceException($"Failed to read device-property-info '{propertyId}' for corsair device '{deviceId}'. (Not readable)"); + + errorCode = ReadDeviceProperty(deviceId, propertyId, index, out _CorsairProperty? property); + if (errorCode != CorsairError.Success) + throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (ErrorCode: {errorCode})"); + + if (property == null) + throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (Invalid return value)"); + + if (property.Value.type != expectedDataType) + throw new RGBDeviceException($"Failed to read device-property '{propertyId}' for corsair device '{deviceId}'. (Wrong data-type '{dataType}', expected: '{expectedDataType}')"); + + return property.Value.value; } #endregion diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairChannelInfo.cs b/RGB.NET.Devices.Corsair/Native/_CorsairChannelInfo.cs deleted file mode 100644 index 3190b87..0000000 --- a/RGB.NET.Devices.Corsair/Native/_CorsairChannelInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -#pragma warning disable 169 // Field 'x' is never used -#pragma warning disable 414 // Field 'x' is assigned but its value never used -#pragma warning disable 649 // Field 'x' is never assigned -#pragma warning disable IDE1006 // Naming Styles - -using System; -using System.Runtime.InteropServices; - -namespace RGB.NET.Devices.Corsair.Native; - -// ReSharper disable once InconsistentNaming -/// -/// CUE-SDK: contains information about separate channel of the DIY-device. -/// -[StructLayout(LayoutKind.Sequential)] -internal class _CorsairChannelInfo -{ - /// - /// CUE-SDK: total number of LEDs connected to the channel; - /// - internal int totalLedsCount; - - /// - /// CUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device - /// - internal int devicesCount; - - /// - /// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device. - /// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device. - /// - internal IntPtr devices; -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs new file mode 100644 index 0000000..bfb5e3d --- /dev/null +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDataValue.cs @@ -0,0 +1,140 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.Corsair.Native; + +// ReSharper disable once InconsistentNaming +/// +/// iCUE-SDK: a union of all property data types +/// +[StructLayout(LayoutKind.Explicit)] +internal struct _CorsairDataValue +{ + #region Properties & Fields + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Boolean + /// + [FieldOffset(0)] + internal bool boolean; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Int32 + /// + [FieldOffset(0)] + internal int int32; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Float64 + /// + [FieldOffset(0)] + internal double float64; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_String + /// + [FieldOffset(0)] + internal nint @string; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Boolean_Array + /// + [FieldOffset(0)] + internal CorsairDataTypeBooleanArray booleanArray; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Int32_Array + /// + [FieldOffset(0)] + internal CorsairDataTypeInt32Array int32Array; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_Float64_Array + /// + [FieldOffset(0)] + internal CorsairDataTypeFloat64Array float64Array; + + /// + /// iCUE-SDK: actual property value if it’s type is CPDT_String_Array + /// + [FieldOffset(0)] + internal CorsairDataTypeStringArray stringArray; + + #endregion + + #region Data Types + + /// + /// iCUE: represents an array of boolean values + /// + [StructLayout(LayoutKind.Sequential)] + internal struct CorsairDataTypeBooleanArray + { + /// + /// iCUE: an array of boolean values + /// + internal nint items; + + /// + /// iCUE: number of items array elements + /// + internal uint count; + }; + + /// + /// iCUE: represents an array of integer values + /// + [StructLayout(LayoutKind.Sequential)] + internal struct CorsairDataTypeInt32Array + { + /// + /// iCUE: an array of integer values + /// + internal nint items; + + /// + /// iCUE: number of items array elements + /// + internal uint count; + }; + + /// + /// iCUE: represents an array of double values + /// + [StructLayout(LayoutKind.Sequential)] + internal struct CorsairDataTypeFloat64Array + { + /// + /// iCUE: an array of double values + /// + internal nint items; + + /// + /// iCUE: number of items array elements + /// + internal uint count; + }; + + /// + /// iCUE: represents an array of pointers to null terminated strings + /// + [StructLayout(LayoutKind.Sequential)] + internal struct CorsairDataTypeStringArray + { + /// + /// iCUE: an array of pointers to null terminated strings + /// + internal nint items; + + /// + /// iCUE: number of items array elements + /// + internal uint count; + }; + + #endregion +} diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairChannelsInfo.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs similarity index 50% rename from RGB.NET.Devices.Corsair/Native/_CorsairChannelsInfo.cs rename to RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs index e2a5a12..76f179d 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairChannelsInfo.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs @@ -3,26 +3,34 @@ #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.Corsair.Native; // ReSharper disable once InconsistentNaming /// -/// CUE-SDK: contains information about channels of the DIY-devices. +/// iCUE-SDK: contains device search filter /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairChannelsInfo +internal class _CorsairDeviceFilter { - /// - /// CUE-SDK: number of channels controlled by the device - /// - internal int channelsCount; + #region Properties & Fields /// - /// CUE-SDK: array containing information about each separate channel of the DIY-device. - /// Index of the channel in the array is same as index of the channel on the DIY-device. + /// iCUE-SDK: mask that describes device types, formed as logical “or” of CorsairDeviceType enum values /// - internal IntPtr channels; -} \ No newline at end of file + internal CorsairDeviceType deviceTypeMask; + + #endregion + + #region Constructors + + public _CorsairDeviceFilter() { } + + public _CorsairDeviceFilter(CorsairDeviceType filter) + { + this.deviceTypeMask = filter; + } + + #endregion +} diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs index 799fc5a..f122879 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs @@ -3,56 +3,47 @@ #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.Corsair.Native; // ReSharper disable once InconsistentNaming /// -/// CUE-SDK: contains information about device +/// iCUE-SDK: contains information about device /// [StructLayout(LayoutKind.Sequential)] internal class _CorsairDeviceInfo { /// - /// CUE-SDK: enum describing device type + /// iCUE-SDK: enum describing device type /// internal CorsairDeviceType type; /// - /// CUE-SDK: null - terminated device model(like “K95RGB”) + /// iCUE-SDK: null terminated Unicode string that contains unique device identifier serial number. Can be empty, if serial number is not available for the device /// - internal IntPtr model; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)] + internal string? id; /// - /// CUE-SDK: enum describing physical layout of the keyboard or mouse + /// iCUE-SDK: null terminated Unicode string that contains device serial number. Can be empty, if serial number is not available for the device /// - internal int physicalLayout; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)] + internal string? serial; /// - /// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings + /// iCUE-SDK: null terminated Unicode string that contains device model (like “K95RGB”) /// - internal int logicalLayout; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = _CUESDK.CORSAIR_STRING_SIZE_M)] + internal string? model; /// - /// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values + /// iCUE-SDK: number of controllable LEDs on the device /// - internal int capsMask; + internal int ledCount; /// - /// CUE-SDK: number of controllable LEDs on the device + /// iCUE-SDK: number of channels controlled by the device /// - internal int ledsCount; - - /// - /// CUE-SDK: structure that describes channels of the DIY-devices - /// - internal _CorsairChannelsInfo? channels; - - /// - /// CUE-SDK: null-terminated string that contains unique device identifier that uniquely identifies device at least within session - /// - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - internal string? deviceId; + internal int channelCount; } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairLedColor.cs b/RGB.NET.Devices.Corsair/Native/_CorsairLedColor.cs index 004b36a..60e6496 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairLedColor.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairLedColor.cs @@ -10,28 +10,52 @@ namespace RGB.NET.Devices.Corsair.Native; // ReSharper disable once InconsistentNaming /// -/// CUE-SDK: contains information about led and its color +/// iCUE-SDK: contains information about led and its color /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairLedColor +internal struct _CorsairLedColor { - /// - /// CUE-SDK: identifier of LED to set - /// - internal int ledId; + #region Properties & Fields /// - /// CUE-SDK: red brightness[0..255] + /// iCUE-SDK: identifier of LED to set /// - internal int r; + internal CorsairLedId ledId; /// - /// CUE-SDK: green brightness[0..255] + /// iCUE-SDK: red brightness[0..255] /// - internal int g; + internal byte r; /// - /// CUE-SDK: blue brightness[0..255] + /// iCUE-SDK: green brightness[0..255] /// - internal int b; + internal byte g; + + /// + /// iCUE-SDK: blue brightness[0..255] + /// + internal byte b; + + /// + /// iCUE-SDK: alpha channel [0..255]. The opacity of the color from 0 for completely translucent to 255 for opaque + /// + internal byte a; + + #endregion + + #region Constructors + + public _CorsairLedColor() { } + + public _CorsairLedColor(CorsairLedId ledId, byte r, byte g, byte b, byte a) + { + this.ledId = ledId; + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + + #endregion }; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs index 34f4108..b2ff0fe 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs @@ -2,41 +2,31 @@ #pragma warning disable 414 // Field 'x' is assigned but its value never used #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles +// ReSharper disable NotAccessedField.Global using System.Runtime.InteropServices; namespace RGB.NET.Devices.Corsair.Native; -// ReSharper disable once InconsistentNaming +// ReSharper disable once InconsistentNaming /// -/// CUE-SDK: contains led id and position of led rectangle.Most of the keys are rectangular. -/// In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key +/// iCUE-SDK: contains led id and position of led /// [StructLayout(LayoutKind.Sequential)] internal class _CorsairLedPosition { /// - /// CUE-SDK: identifier of led + /// iCUE-SDK: unique identifier of led /// - internal CorsairLedId LedId; + internal uint id; /// - /// CUE-SDK: values in mm + /// iCUE-SDK: for keyboards, mice, mousemats, headset stands and memory modules values are /// - internal double top; + internal double cx; /// - /// CUE-SDK: values in mm + /// iCUE-SDK: in mm, for DIY-devices, headsets and coolers values are in logical units /// - internal double left; - - /// - /// CUE-SDK: values in mm - /// - internal double height; - - /// - /// CUE-SDK: values in mm - /// - internal double width; -} \ No newline at end of file + internal double cy; +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairLedPositions.cs b/RGB.NET.Devices.Corsair/Native/_CorsairLedPositions.cs deleted file mode 100644 index c3186d3..0000000 --- a/RGB.NET.Devices.Corsair/Native/_CorsairLedPositions.cs +++ /dev/null @@ -1,26 +0,0 @@ -#pragma warning disable 169 // Field 'x' is never used -#pragma warning disable 414 // Field 'x' is assigned but its value never used -#pragma warning disable 649 // Field 'x' is never assigned - -using System; -using System.Runtime.InteropServices; - -namespace RGB.NET.Devices.Corsair.Native; - -// ReSharper disable once InconsistentNaming -/// -/// CUE-SDK: contains number of leds and arrays with their positions -/// -[StructLayout(LayoutKind.Sequential)] -internal class _CorsairLedPositions -{ - /// - /// CUE-SDK: integer value.Number of elements in following array - /// - internal int numberOfLed; - - /// - /// CUE-SDK: array of led positions - /// - internal IntPtr pLedPosition; -} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairChannelDeviceInfo.cs b/RGB.NET.Devices.Corsair/Native/_CorsairProperty.cs similarity index 60% rename from RGB.NET.Devices.Corsair/Native/_CorsairChannelDeviceInfo.cs rename to RGB.NET.Devices.Corsair/Native/_CorsairProperty.cs index 3f44c7a..4a275b2 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairChannelDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairProperty.cs @@ -9,19 +9,22 @@ namespace RGB.NET.Devices.Corsair.Native; // ReSharper disable once InconsistentNaming /// -/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device. +/// iCUE-SDK: contains information about device property type and value /// [StructLayout(LayoutKind.Sequential)] - -internal class _CorsairChannelDeviceInfo +internal struct _CorsairProperty { - /// - /// CUE-SDK: type of the LED-device - /// - internal CorsairChannelDeviceType type; + #region Properties & Fields /// - /// CUE-SDK: number of LEDs controlled by LED-device. + /// iCUE-SDK: type of property /// - internal int deviceLedCount; -} \ No newline at end of file + internal CorsairDataType type; + + /// + /// iCUE-SDK: property value + /// + internal _CorsairDataValue value; + + #endregion +} diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair/Native/_CorsairProtocolDetails.cs deleted file mode 100644 index cd6bf6e..0000000 --- a/RGB.NET.Devices.Corsair/Native/_CorsairProtocolDetails.cs +++ /dev/null @@ -1,43 +0,0 @@ -#pragma warning disable 169 // Field 'x' is never used -#pragma warning disable 414 // Field 'x' is assigned but its value never used -#pragma warning disable 649 // Field 'x' is never assigned - -using System; -using System.Runtime.InteropServices; - -namespace RGB.NET.Devices.Corsair.Native; - -// ReSharper disable once InconsistentNaming -/// -/// CUE-SDK: contains information about SDK and CUE versions -/// -[StructLayout(LayoutKind.Sequential)] -internal struct _CorsairProtocolDetails -{ - /// - /// CUE-SDK: null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found - /// - internal IntPtr sdkVersion; - - /// - /// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found. - /// - internal IntPtr serverVersion; - - /// - /// CUE-SDK: integer number that specifies version of protocol that is implemented by current SDK. - /// Numbering starts from 1. Always contains valid value even if there was no CUE found - /// - internal int sdkProtocolVersion; - - /// - /// CUE-SDK: integer number that specifies version of protocol that is implemented by CUE. - /// Numbering starts from 1. If CUE was not found then this value will be 0 - /// - internal int serverProtocolVersion; - - /// - /// CUE-SDK: boolean value that specifies if there were breaking changes between version of protocol implemented by server and client - /// - internal byte breakingChanges; -}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs b/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs new file mode 100644 index 0000000..392a30b --- /dev/null +++ b/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs @@ -0,0 +1,32 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles +// ReSharper disable NotAccessedField.Global + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.Corsair.Native; + +// ReSharper disable once InconsistentNaming +/// +/// iCUE-SDK: contains information about SDK and iCUE versions +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairSessionDetails +{ + /// + /// iCUE-SDK: version of SDK client (like {4,0,1}). Always contains valid value even if there was no iCUE found. Must comply with the semantic versioning rules. + /// + internal _CorsairVersion clientVersion = new(); + + /// + /// iCUE-SDK: version of SDK server (like {4,0,1}) or empty struct ({0,0,0}) if the iCUE was not found. Must comply with the semantic versioning rules. + /// + internal _CorsairVersion serverVersion = new(); + + /// + /// iCUE-SDK: version of iCUE (like {3,33,100}) or empty struct ({0,0,0}) if the iCUE was not found. + /// + internal _CorsairVersion serverHostVersion = new(); +}; diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs b/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs new file mode 100644 index 0000000..99aa8fd --- /dev/null +++ b/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs @@ -0,0 +1,27 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles +// ReSharper disable NotAccessedField.Global + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.Corsair.Native; + +// ReSharper disable once InconsistentNaming +/// +/// iCUE-SDK: contains information about session state and client/server versions +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairSessionStateChanged +{ + /// + /// iCUE-SDK: new session state which SDK client has been transitioned to + /// + internal CorsairSessionState state; + + /// + /// iCUE-SDK: information about client/server versions + /// + internal _CorsairSessionDetails details = new(); +}; diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs b/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs new file mode 100644 index 0000000..790226e --- /dev/null +++ b/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs @@ -0,0 +1,31 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles +// ReSharper disable NotAccessedField.Global + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.Corsair.Native; + +// ReSharper disable once InconsistentNaming +/// +/// iCUE-SDK: contains information about version that consists of three components +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairVersion +{ + #region Properties & Fields + + internal int major; + internal int minor; + internal int patch; + + #endregion + + #region Methods + + public override string ToString() => $"{major}.{minor}.{patch}"; + + #endregion +}; diff --git a/RGB.NET.Devices.Corsair/README.md b/RGB.NET.Devices.Corsair/README.md index dd30377..c6c1803 100644 --- a/RGB.NET.Devices.Corsair/README.md +++ b/RGB.NET.Devices.Corsair/README.md @@ -11,14 +11,16 @@ surface.Load(CorsairDeviceProvider.Instance); This providers requires native SDK-dlls. You can get them directly from Corsair at [https://github.com/CorsairOfficial/cue-sdk/releases](https://github.com/CorsairOfficial/cue-sdk/releases) +(Developed and tested with iCUE SDK v4.0.48) + Since the SDK-dlls are native it's important to use the correct architecture you're building your application for. (If in doubt you can always include both.) ### x64 -`redist\x64\CUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `\x64\CUESDK.x64_2019.dll` (or simply named `CUESDK.dll`) +`redist\x64\iCUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `\x64\iCUESDK.x64_2019.dll` (or simply named `iCUESDK.dll`) You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX64NativePaths`. ### x86 -`redist\i386\CUESDK_2019.dll` from the SDK-zip needs to be distributed as `\x86\CUESDK_2019.dll` (or simply named `CUESDK.dll`) +`redist\i386\iCUESDK_2019.dll` from the SDK-zip needs to be distributed as `\x86\iCUESDK_2019.dll` (or simply named `iCUESDK.dll`) You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX86NativePaths`. diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings index eeca971..16defe6 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings @@ -1,8 +1,12 @@  + True + True True True True True + True + True True True True @@ -19,4 +23,5 @@ True True True + True \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs index 092e84c..d704343 100644 --- a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using RGB.NET.Core; +using System.Collections.Generic; namespace RGB.NET.Devices.Corsair; @@ -9,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair touchbar. /// -public class CorsairTouchbarRGBDevice : CorsairRGBDevice, IDRAM +public class CorsairTouchbarRGBDevice : CorsairRGBDevice, ILedStripe { #region Constructors @@ -20,8 +21,14 @@ public class CorsairTouchbarRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the touchbar. /// The queue used to update this device. internal CorsairTouchbarRGBDevice(CorsairTouchbarRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, LedMappings.Keyboard, updateQueue) //TODO DarthAffe 17.07.2022: Find someone with such a device and check which LedIds are actually used + : base(info, updateQueue) { } #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateLedStripMapping(ids); + + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs index 9ee690c..68ea4f0 100644 --- a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs @@ -15,13 +15,8 @@ public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo #region Constructors /// - /// - /// Internal constructor of managed . - /// - /// The index of the . - /// The native -struct - internal CorsairTouchbarRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, RGBDeviceType.Keypad, nativeInfo) + internal CorsairTouchbarRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.LedStripe, nativeInfo, ledCount, ledOffset) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs new file mode 100644 index 0000000..d860336 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs @@ -0,0 +1,34 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using System.Collections.Generic; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a unknown corsair device. +/// +public class CorsairUnknownRGBDevice : CorsairRGBDevice, IUnknownDevice +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the unknown device. + /// The queue used to update this device. + internal CorsairUnknownRGBDevice(CorsairUnknownRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { } + + #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateUnknownMapping(ids); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs new file mode 100644 index 0000000..e9b6da5 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs @@ -0,0 +1,23 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + internal CorsairUnknownRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.Unknown, nativeInfo, ledCount, ledOffset) + { } + + #endregion +} \ No newline at end of file From d6aed5c5a20f31bc327d9ba306ecee54dc02b874 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 10 Feb 2023 19:23:48 +0100 Subject: [PATCH 06/96] Fixed some code issues (dispose finalizers) --- RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs | 6 +----- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 3 +++ RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs | 8 +++++++- .../CoolerMasterDeviceProvider.cs | 2 ++ .../Generic/CoolerMasterRGBDevice.cs | 2 ++ RGB.NET.Devices.Debug/DebugDeviceProvider.cs | 2 ++ RGB.NET.Devices.Msi/MsiDeviceProvider.cs | 2 ++ RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj | 1 + RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs | 2 ++ RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs | 4 +++- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 2 ++ .../SteelSeriesDeviceProvider.cs | 2 ++ RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs | 10 ++++++++-- .../NodeMCU/NodeMCUWS2812USBUpdateQueue.cs | 2 ++ RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs | 2 ++ .../Keyboard/WootingKeyboardRGBDevice.cs | 5 ++++- RGB.NET.Devices.Wooting/WootingDeviceProvider.cs | 2 ++ 17 files changed, 47 insertions(+), 10 deletions(-) diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index baa3515..c1859c2 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -22,11 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public bool Equals(in Color color, object? obj) - { - if (obj is not Color color2) return false; - return Equals(color, color2); - } + public bool Equals(in Color color, object? obj) => obj is Color color2 && Equals(color, color2); /// /// Tests whether the specified object is a and is equivalent to this . diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 1457e0a..ca6a5b2 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -160,6 +161,8 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index 5d357b6..db22aa4 100644 --- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -1,5 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global +using System; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -178,7 +179,12 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger } /// - public override void Dispose() => Stop(); + public override void Dispose() + { + Stop(); + + GC.SuppressFinalize(this); + } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 280e520..e51ed8a 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -100,6 +100,8 @@ public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider try { _CoolerMasterSDK.Reload(); } catch { /* Unlucky.. */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs index b44a90c..f5d2fad 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs @@ -33,6 +33,8 @@ public abstract class CoolerMasterRGBDevice : AbstractRGBDevice + diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index 5480370..b64c72a 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -49,6 +49,8 @@ public abstract class NovationRGBDevice : AbstractRGBDevice - /// Defines which device types will be separated by zones. Defaults to | . + /// Defines which device types will be separated by zones. Defaults to | | . /// public RGBDeviceType PerZoneDeviceFlag { get; } = RGBDeviceType.LedStripe | RGBDeviceType.Mainboard | RGBDeviceType.Speaker; @@ -141,6 +141,8 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider _clients.Clear(); DeviceDefinitions.Clear(); Devices = Enumerable.Empty(); + + GC.SuppressFinalize(this); } #endregion } diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 09f1a27..77c5bd2 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -301,6 +301,8 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit //try { _RazerSDK.UnloadRazerSDK(); } //catch { /* at least we tried */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index 7144da6..ee15533 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -137,6 +137,8 @@ public class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider try { SteelSeriesSDK.Dispose(); } catch { /* shit happens */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs index 7d4ea4d..f581e3f 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs @@ -1,4 +1,5 @@ -using System.IO.Ports; +using System; +using System.IO.Ports; namespace RGB.NET.Devices.WS281X; @@ -61,7 +62,12 @@ public class SerialPortConnection : ISerialConnection public void WriteLine(string line) => SerialPort.WriteLine(line); /// - public void Dispose() => SerialPort.Dispose(); + public void Dispose() + { + SerialPort.Dispose(); + + GC.SuppressFinalize(this); + } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index 0e7a9b7..a3619e2 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -171,6 +171,8 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue ResetDevice(); _httpClient.Dispose(); } + + GC.SuppressFinalize(this); } private string GetUrl(string path) => $"http://{_hostname}/{path}"; diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index e2adc45..6a5c49d 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -75,6 +75,8 @@ public class WS281XDeviceProvider : AbstractRGBDeviceProvider base.Dispose(); DeviceDefinitions.Clear(); + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index 502927a..eb0cc75 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Generic; using RGB.NET.Devices.Wooting.Native; @@ -55,6 +56,8 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice Date: Fri, 10 Feb 2023 19:25:18 +0100 Subject: [PATCH 07/96] Removed editorconfig --- RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 5e3c535..c565c94 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -53,7 +53,6 @@ - From 8431a8cb5e24243ed58223538fa959b64b4efcf8 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 11 Feb 2023 22:36:59 +0100 Subject: [PATCH 08/96] (MAJOR) Optimized surface-updating to reduce the amount of allocations --- RGB.NET.Core/Events/UpdatingEventArgs.cs | 4 +- RGB.NET.Core/Groups/AbstractLedGroup.cs | 4 ++ RGB.NET.Core/Groups/ILedGroup.cs | 6 +++ RGB.NET.Core/Groups/ListLedGroup.cs | 9 +++- RGB.NET.Core/Positioning/Rectangle.cs | 33 ++++++++++-- RGB.NET.Core/RGBSurface.cs | 28 ++++++---- RGB.NET.Core/Update/CustomUpdateData.cs | 60 +++++++++++++++++++-- RGB.NET.Presets/Groups/RectangleLedGroup.cs | 9 +++- 8 files changed, 129 insertions(+), 24 deletions(-) diff --git a/RGB.NET.Core/Events/UpdatingEventArgs.cs b/RGB.NET.Core/Events/UpdatingEventArgs.cs index 47df4af..d39ea74 100644 --- a/RGB.NET.Core/Events/UpdatingEventArgs.cs +++ b/RGB.NET.Core/Events/UpdatingEventArgs.cs @@ -26,7 +26,7 @@ public class UpdatingEventArgs : EventArgs /// /// Gets the custom-data provided by the trigger for this update. /// - public CustomUpdateData CustomData { get; } + public ICustomUpdateData CustomData { get; } #endregion @@ -39,7 +39,7 @@ public class UpdatingEventArgs : EventArgs /// The elapsed time (in seconds) since the last update. /// The trigger causing this update. /// The custom-data provided by the trigger for this update. - public UpdatingEventArgs(double deltaTime, IUpdateTrigger? trigger, CustomUpdateData customData) + public UpdatingEventArgs(double deltaTime, IUpdateTrigger? trigger, ICustomUpdateData customData) { this.DeltaTime = deltaTime; this.Trigger = trigger; diff --git a/RGB.NET.Core/Groups/AbstractLedGroup.cs b/RGB.NET.Core/Groups/AbstractLedGroup.cs index 6569dac..86659af 100644 --- a/RGB.NET.Core/Groups/AbstractLedGroup.cs +++ b/RGB.NET.Core/Groups/AbstractLedGroup.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; namespace RGB.NET.Core; @@ -51,6 +52,9 @@ public abstract class AbstractLedGroup : AbstractDecoratable /// public virtual void OnDetach() { } + /// + public virtual IList ToList() => GetLeds().ToList(); + /// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs index 88b5b97..97ed8b2 100644 --- a/RGB.NET.Core/Groups/ILedGroup.cs +++ b/RGB.NET.Core/Groups/ILedGroup.cs @@ -39,4 +39,10 @@ public interface ILedGroup : IDecoratable, IEnumerable /// Called when the is detached from the . /// void OnDetach(); + + /// + /// Returns a list containing all in this group. + /// + /// A list containing all in this group. + IList ToList(); } \ No newline at end of file diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index a33fc56..9c51906 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -122,7 +122,14 @@ public class ListLedGroup : AbstractLedGroup /// Gets a list containing the from this group. /// /// The list containing the . - protected override IEnumerable GetLeds() + protected override IEnumerable GetLeds() => ToList(); + + /// + /// + /// Gets a list containing the from this group. + /// + /// The list containing the . + public override IList ToList() { lock (GroupLeds) return new List(GroupLeds); diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index 456a568..095a210 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -57,7 +57,8 @@ public readonly struct Rectangle : IEquatable /// Initializes a new instance of the class using the (0,0) and the specified . /// /// The size of of this . - public Rectangle(Size size) : this(new Point(), size) + public Rectangle(Size size) + : this(new Point(), size) { } /// @@ -120,15 +121,13 @@ public readonly struct Rectangle : IEquatable public Rectangle(params Point[] points) : this(points.AsEnumerable()) { } - - /// + /// /// Initializes a new instance of the class using the specified list of . /// The and is calculated to contain all points provided as parameters. /// /// The list of used to calculate the and . public Rectangle(IEnumerable points) - : this() { bool hasPoint = false; float posX = float.MaxValue; @@ -145,13 +144,37 @@ public readonly struct Rectangle : IEquatable posY2 = Math.Max(posY2, point.Y); } - (Point location, Size size) = hasPoint ? InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)) : InitializeFromPoints(new Point(0, 0), new Point(0, 0)); + (Point location, Size size) = hasPoint ? InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)) + : InitializeFromPoints(new Point(0, 0), new Point(0, 0)); Location = location; Size = size; Center = new Point(Location.X + (Size.Width / 2.0f), Location.Y + (Size.Height / 2.0f)); } + internal Rectangle(IList leds) + { + float posX = float.MaxValue; + float posY = float.MaxValue; + float posX2 = float.MinValue; + float posY2 = float.MinValue; + + // ReSharper disable once ForCanBeConvertedToForeach + for (int i = 0; i < leds.Count; i++) + { + Rectangle rectangle = leds[i].AbsoluteBoundary; + posX = Math.Min(posX, rectangle.Location.X); + posY = Math.Min(posY, rectangle.Location.Y); + posX2 = Math.Max(posX2, rectangle.Location.X + rectangle.Size.Width); + posY2 = Math.Max(posY2, rectangle.Location.Y + rectangle.Size.Height); + } + + (Point location, Size size) = leds.Count > 0 ? InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)) : InitializeFromPoints(new Point(0, 0), new Point(0, 0)); + Location = location; + Size = size; + Center = new Point(Location.X + (Size.Width / 2.0f), Location.Y + (Size.Height / 2.0f)); + } + #endregion #region Methods diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index f8ec437..fc8003f 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -132,11 +132,12 @@ public sealed class RGBSurface : AbstractBindable, IDisposable /// Perform a full update for all devices. Updates only dirty by default, or all , if flushLeds is set to true. /// /// Specifies whether all , (including clean ones) should be updated. - public void Update(bool flushLeds = false) => Update(null, new CustomUpdateData((CustomUpdateDataIndex.FLUSH_LEDS, flushLeds))); + //public void Update(bool flushLeds = false) => Update(null, new CustomUpdateData((CustomUpdateDataIndex.FLUSH_LEDS, flushLeds))); + public void Update(bool flushLeds = false) => Update(null, flushLeds ? DefaultCustomUpdateData.FLUSH : DefaultCustomUpdateData.NO_FLUSH); - private void Update(object? updateTrigger, CustomUpdateData customData) => Update(updateTrigger as IUpdateTrigger, customData); + private void Update(object? updateTrigger, ICustomUpdateData customData) => Update(updateTrigger as IUpdateTrigger, customData); - private void Update(IUpdateTrigger? updateTrigger, CustomUpdateData customData) + private void Update(IUpdateTrigger? updateTrigger, ICustomUpdateData customData) { try { @@ -149,19 +150,25 @@ public sealed class RGBSurface : AbstractBindable, IDisposable { OnUpdating(updateTrigger, customData); + // ReSharper disable ForCanBeConvertedToForeach - 'for' has a performance benefit (no enumerator allocation) here and since 'Update' is considered a hot path it's optimized if (render) lock (_ledGroups) { // Render brushes - foreach (ILedGroup ledGroup in _ledGroups) - try { Render(ledGroup); } + for (int i = 0; i < _ledGroups.Count; i++) + { + try { Render(_ledGroups[i]); } catch (Exception ex) { OnException(ex); } + } } if (updateDevices) - foreach (IRGBDevice device in _devices) - try { device.Update(flushLeds); } + for (int i = 0; i < _devices.Count; i++) + { + try { _devices[i].Update(flushLeds); } catch (Exception ex) { OnException(ex); } + } + // ReSharper restore ForCanBeConvertedToForeach OnUpdated(); } @@ -197,16 +204,17 @@ public sealed class RGBSurface : AbstractBindable, IDisposable /// Thrown if the of the Brush is not valid. private void Render(ILedGroup ledGroup) { - IList leds = ledGroup.ToList(); IBrush? brush = ledGroup.Brush; if ((brush == null) || !brush.IsEnabled) return; + IList leds = ledGroup.ToList(); + IEnumerable<(RenderTarget renderTarget, Color color)> render; switch (brush.CalculationMode) { case RenderMode.Relative: - Rectangle brushRectangle = new(leds.Select(led => led.AbsoluteBoundary)); + Rectangle brushRectangle = new(leds); Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y); brushRectangle = brushRectangle.SetLocation(new Point(0, 0)); render = brush.Render(brushRectangle, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary.Translate(offset)))); @@ -358,7 +366,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable /// /// Handles the needed event-calls before updating. /// - private void OnUpdating(IUpdateTrigger? trigger, CustomUpdateData customData) + private void OnUpdating(IUpdateTrigger? trigger, ICustomUpdateData customData) { try { diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index 88f734a..a657e96 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace RGB.NET.Core; @@ -34,11 +35,24 @@ public static class CustomUpdateDataIndex /// /// Represents a set of custom data, each indexed by a string-key. /// -public class CustomUpdateData +public interface ICustomUpdateData +{ + /// + /// Gets the value for a specific key. + /// + /// The key of the value. + /// The value represented by the specified key. + object? this[string key] { get; } +} + +/// +/// Represents a set of custom data, each indexed by a string-key. +/// +public class CustomUpdateData : ICustomUpdateData { #region Properties & Fields - private Dictionary _data = new(); + private readonly Dictionary _data = new(); #endregion @@ -51,8 +65,8 @@ public class CustomUpdateData /// The value represented by the specified key. public object? this[string key] { - get => _data.TryGetValue(key.ToUpperInvariant(), out object? data) ? data : default; - set => _data[key.ToUpperInvariant()] = value; + get => _data.TryGetValue(key, out object? data) ? data : default; + set => _data[key] = value; } #endregion @@ -77,3 +91,39 @@ public class CustomUpdateData #endregion } + +internal class DefaultCustomUpdateData : ICustomUpdateData +{ + #region Constants + + public static readonly DefaultCustomUpdateData FLUSH = new(true); + public static readonly DefaultCustomUpdateData NO_FLUSH = new(false); + + #endregion + + #region Properties & Fields + + private readonly bool _flushLeds; + + public object? this[string key] + { + get + { + if (string.Equals(key, CustomUpdateDataIndex.FLUSH_LEDS, StringComparison.Ordinal)) + return _flushLeds; + + return null; + } + } + + #endregion + + #region Constructors + + public DefaultCustomUpdateData(bool flushLeds) + { + this._flushLeds = flushLeds; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Presets/Groups/RectangleLedGroup.cs b/RGB.NET.Presets/Groups/RectangleLedGroup.cs index 9547476..d6cb650 100644 --- a/RGB.NET.Presets/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Presets/Groups/RectangleLedGroup.cs @@ -114,7 +114,14 @@ public class RectangleLedGroup : AbstractLedGroup /// Gets a list containing all of this . /// /// The list containing all of this . - protected override IEnumerable GetLeds() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List()); + protected override IEnumerable GetLeds() => ToList(); + + /// + /// + /// Gets a list containing all of this . + /// + /// The list containing all of this . + public override IList ToList() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List()); private void InvalidateCache() => _ledCache = null; From 38840ef6f4b1af296cd40612da959176e53e9851 Mon Sep 17 00:00:00 2001 From: Danielle Date: Sun, 12 Feb 2023 11:41:18 +1100 Subject: [PATCH 09/96] Asus dev --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 42 +++++++++++++++++++++ RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs | 3 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 2e09b52..a9413a7 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -3,6 +3,9 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Reflection.Metadata; using AuraServiceLib; using RGB.NET.Core; @@ -52,6 +55,7 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider } /// + protected override IEnumerable LoadDevices() { if (_sdk == null) yield break; @@ -75,6 +79,44 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider }; } } + /* + protected override IEnumerable LoadDevices() + { + if (_sdk == null) { + throw new InvalidOperationException($"Asus Library not yet loaded."); + yield break; + } + + var enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; + var filePath = $"{enviroment}/ASUSDEBUG.txt"; + var content = ""; + + _devices = _sdk.Enumerate(0); + for (int i = 0; i < _devices.Count; i++) + { + IAuraSyncDevice device = _devices[i]; + + content += $"Name: {device.Name} Type: {device.Type} Type Hex: {device.Type:X} LEDs: {device.Lights.Count} \n\n"; + + yield return (AsusDeviceType)device.Type switch + { + AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()), + AsusDeviceType.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()), + AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()), + AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()), + AsusDeviceType.DRAM_RGB => new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device), GetUpdateTrigger()), + AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), + AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), + AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()), + AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()), + AsusDeviceType.TERMINAL_RGB => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedController, device), LedId.Custom1, GetUpdateTrigger()), + _ => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1, GetUpdateTrigger()) + }; + } + + System.IO.File.WriteAllText(filePath, content); + } + */ /// public override void Dispose() diff --git a/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs b/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs index ad529ed..bb5f16f 100644 --- a/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs +++ b/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs @@ -20,5 +20,6 @@ internal enum AsusDeviceType : uint NB_KB_4ZONE_RGB = 0x81001, MOUSE_RGB = 0x90000, CHASSIS_RGB = 0xB0000, - PROJECTOR_RGB = 0xC0000 + PROJECTOR_RGB = 0xC0000, + TERMINAL_RGB = 0xE0000 } \ No newline at end of file From df2f5620eefe08d111cd5414dd9cd7c91f33fe15 Mon Sep 17 00:00:00 2001 From: Danielle Date: Sun, 12 Feb 2023 12:44:39 +1100 Subject: [PATCH 10/96] Update AsusDeviceProvider.cs --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 40 ++-------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index a9413a7..494adc0 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Reflection.Metadata; using AuraServiceLib; using RGB.NET.Core; @@ -58,46 +55,16 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider protected override IEnumerable LoadDevices() { - if (_sdk == null) yield break; - - _devices = _sdk.Enumerate(0); - for (int i = 0; i < _devices.Count; i++) - { - IAuraSyncDevice device = _devices[i]; - yield return (AsusDeviceType)device.Type switch - { - AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()), - AsusDeviceType.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()), - AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()), - AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()), - AsusDeviceType.DRAM_RGB => new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device), GetUpdateTrigger()), - AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), - AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), - AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()), - AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()), - _ => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1, GetUpdateTrigger()) - }; - } - } - /* - protected override IEnumerable LoadDevices() - { - if (_sdk == null) { - throw new InvalidOperationException($"Asus Library not yet loaded."); + if (_sdk == null) { yield break; } - var enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; - var filePath = $"{enviroment}/ASUSDEBUG.txt"; - var content = ""; _devices = _sdk.Enumerate(0); for (int i = 0; i < _devices.Count; i++) { IAuraSyncDevice device = _devices[i]; - content += $"Name: {device.Name} Type: {device.Type} Type Hex: {device.Type:X} LEDs: {device.Lights.Count} \n\n"; - yield return (AsusDeviceType)device.Type switch { AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()), @@ -110,13 +77,10 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()), AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()), AsusDeviceType.TERMINAL_RGB => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedController, device), LedId.Custom1, GetUpdateTrigger()), - _ => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1, GetUpdateTrigger()) + _ => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Unknown1, GetUpdateTrigger()) }; } - - System.IO.File.WriteAllText(filePath, content); } - */ /// public override void Dispose() From 914bd8c0a1c591ddd20943bec09a2b40c182567b Mon Sep 17 00:00:00 2001 From: Danielle Date: Sun, 12 Feb 2023 12:45:30 +1100 Subject: [PATCH 11/96] Update AsusDeviceProvider.cs Code cleanup --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 494adc0..0dfddb7 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -55,10 +55,7 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider protected override IEnumerable LoadDevices() { - if (_sdk == null) { - yield break; - } - + if (_sdk == null) yield break; _devices = _sdk.Enumerate(0); for (int i = 0; i < _devices.Count; i++) From b67294eb3c4d8d0588fe25d25ecf6c790edcefc9 Mon Sep 17 00:00:00 2001 From: Markus Mohoritsch Date: Sun, 12 Feb 2023 10:06:38 +0100 Subject: [PATCH 12/96] Added missing G915 TKL PID --- RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 1180ff5..4ebd163 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -73,6 +73,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider { { 0x407C, RGBDeviceType.Keyboard, "G915", LedMappings.PerKey, 0 }, { 0x408E, RGBDeviceType.Keyboard, "G915 TKL", LedMappings.PerKey, 0 }, + { 0xC232, RGBDeviceType.Keyboard, "G915 TKL", LedMappings.PerKey, 0 }, }; /// From db2f16d371780bf6b911d0b2515494ab08bbaa4a Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sun, 12 Feb 2023 13:48:01 +0100 Subject: [PATCH 13/96] Update RGB.NET.Devices.Asus/AsusDeviceProvider.cs --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 0dfddb7..f9af5b3 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -52,7 +52,6 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider } /// - protected override IEnumerable LoadDevices() { if (_sdk == null) yield break; From cc652a08a61c4acb54755677cba9e2b1dded61b0 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 12 Feb 2023 16:19:00 +0100 Subject: [PATCH 14/96] Added corsair session details --- .../CorsairDeviceProvider.cs | 12 +++++- .../Generic/CorsairProtocolDetails.cs | 37 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 7a1abe0..d4cd116 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -45,6 +45,11 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider /// public static bool ExclusiveAccess { get; set; } = false; + /// + /// Gets the details for the current SDK-session. + /// + public CorsairSessionDetails SessionDetails { get; private set; } = new(); + #endregion #region Constructors @@ -81,12 +86,17 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider _CUESDK.SessionStateChanged += OnSessionStateChanged; CorsairError errorCode = _CUESDK.CorsairConnect(); - if (errorCode != CorsairError.Success) Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (ErrorCode: {errorCode})")); if (!waitEvent.Wait(ConnectionTimeout)) Throw(new RGBDeviceException($"Failed to initialized Corsair-SDK. (Timeout - Current connection state: {_CUESDK.SesionState})")); + + _CUESDK.CorsairGetSessionDetails(out _CorsairSessionDetails? details); + if (errorCode != CorsairError.Success) + Throw(new RGBDeviceException($"Failed to get session details. (ErrorCode: {errorCode})")); + + SessionDetails = new CorsairSessionDetails(details!); } finally { diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs new file mode 100644 index 0000000..7069776 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs @@ -0,0 +1,37 @@ +// ReSharper disable MemberCanBePrivate.Global + +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// Represents version information for the Corsair-SDK +/// +public class CorsairSessionDetails +{ + #region Properties & Fields + + public string ClientVersion { get; } + public string ServerVersion { get; } + public string ServerHostVersion { get; } + + #endregion + + #region Constructors + + internal CorsairSessionDetails() + { + ClientVersion = string.Empty; + ServerVersion = string.Empty; + ServerHostVersion = string.Empty; + } + + internal CorsairSessionDetails(_CorsairSessionDetails nativeDetails) + { + this.ClientVersion = nativeDetails.clientVersion.ToString(); + this.ServerVersion = nativeDetails.serverVersion.ToString(); + this.ServerHostVersion = nativeDetails.serverHostVersion.ToString(); + } + + #endregion +} \ No newline at end of file From bb3b74b9195a68d91396d66b0fb96d8d114cda17 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 12 Feb 2023 16:23:27 +0100 Subject: [PATCH 15/96] Removed debug output --- RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index d4cd116..08f692a 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -129,8 +129,7 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider Throw(new RGBDeviceException($"Failed to take control of device '{device.id}'. (ErrorCode: {error})")); CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), device); - - Console.WriteLine("Loading " + device.model); + int channelLedCount = 0; for (int i = 0; i < device.channelCount; i++) { From 37e495458346c2294754f23cdc827eb6e7a6edec Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 5 Mar 2023 16:34:01 +0100 Subject: [PATCH 16/96] Added exception-handling to all UpdateQueues --- .../Devices/AbstractRGBDeviceProvider.cs | 2 +- RGB.NET.Core/Devices/IRGBDeviceProvider.cs | 4 +++ .../Generic/AsusUpdateQueue.cs | 5 ++-- .../Generic/CoolerMasterUpdateQueue.cs | 17 +++++++---- .../CorsairDeviceProvider.cs | 29 +++++++++++++++++-- .../Generic/CorsairDeviceUpdateQueue.cs | 25 ++++++++++------ RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs | 23 ++++++++++----- .../PerDevice/LogitechPerDeviceUpdateQueue.cs | 17 +++++++---- .../PerKey/LogitechPerKeyUpdateQueue.cs | 25 ++++++++++------ .../Generic/MsiDeviceUpdateQueue.cs | 11 +++++-- .../Generic/MidiUpdateQueue.cs | 11 +++++-- .../Generic/OpenRGBUpdateQueue.cs | 13 +++++++-- .../PicoPi/PicoPiBulkUpdateQueue.cs | 29 ++++++++++++------- .../PicoPi/PicoPiHIDUpdateQueue.cs | 29 ++++++++++++------- .../Generic/RazerUpdateQueue.cs | 26 ++++++++++------- .../Generic/SteelSeriesDeviceUpdateQueue.cs | 15 +++++++--- .../Generic/SerialPortUpdateQueue.cs | 13 +++++++-- .../Generic/WootingUpdateQueue.cs | 25 ++++++++++------ 18 files changed, 222 insertions(+), 97 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs index ae66ca0..d61fcbb 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs @@ -178,7 +178,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// /// The exception to throw. /// Indicates if the exception is critical for device provider to work correctly. - protected virtual void Throw(Exception ex, bool isCritical = false) + public virtual void Throw(Exception ex, bool isCritical = false) { ExceptionEventArgs args = new(ex, isCritical, ThrowsExceptions); try { OnException(args); } catch { /* we don't want to throw due to bad event handlers */ } diff --git a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs index 48edc4d..86f41e1 100644 --- a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs @@ -20,6 +20,10 @@ public interface IRGBDeviceProvider : IDisposable /// /// Indicates if exceptions in the device provider are thrown or silently ignored. /// + /// + /// This should only be set to true for debugging/development purposes. + /// Production code should use the -Event to handle exceptions. + /// bool ThrowsExceptions { get; } /// diff --git a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs index 6de33fa..27f4f5b 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs @@ -89,8 +89,9 @@ public class AsusUpdateQueue : UpdateQueue Device.Apply(); } - catch - { /* "The server threw an exception." seems to be a thing here ... */ + catch (Exception ex) + { + AsusDeviceProvider.Instance.Throw(ex, true); } } diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs index 6631eb1..07df7cc 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs @@ -39,13 +39,20 @@ public class CoolerMasterUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach ((object key, Color color) in dataSet) + try { - (int row, int column) = ((int, int))key; - _deviceMatrix.KeyColor[row, column] = new _CoolerMasterKeyColor(color.GetR(), color.GetG(), color.GetB()); - } + foreach ((object key, Color color) in dataSet) + { + (int row, int column) = ((int, int))key; + _deviceMatrix.KeyColor[row, column] = new _CoolerMasterKeyColor(color.GetR(), color.GetG(), color.GetB()); + } - _CoolerMasterSDK.SetAllLedColor(_deviceMatrix, _deviceIndex); + _CoolerMasterSDK.SetAllLedColor(_deviceMatrix, _deviceIndex); + } + catch (Exception ex) + { + CoolerMasterDeviceProvider.Instance.Throw(ex, true); + } } #endregion diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 08f692a..ac363b9 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -50,6 +50,26 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider /// public CorsairSessionDetails SessionDetails { get; private set; } = new(); + private CorsairSessionState _sessionState = CorsairSessionState.Invalid; + public CorsairSessionState SessionState + { + get => _sessionState; + private set + { + _sessionState = value; + + try { SessionStateChanged?.Invoke(this, SessionState); } + catch { /* catch faulty event-handlers*/ } + } + } + + #endregion + + #region Events + + // ReSharper disable once UnassignedField.Global + public EventHandler? SessionStateChanged; + #endregion #region Constructors @@ -74,7 +94,7 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider using ManualResetEventSlim waitEvent = new(false); - void OnSessionStateChanged(object? sender, CorsairSessionState state) + void OnInitializeSessionStateChanged(object? sender, CorsairSessionState state) { if (state == CorsairSessionState.Connected) // ReSharper disable once AccessToDisposedClosure @@ -84,6 +104,7 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider try { _CUESDK.SessionStateChanged += OnSessionStateChanged; + _CUESDK.SessionStateChanged += OnInitializeSessionStateChanged; CorsairError errorCode = _CUESDK.CorsairConnect(); if (errorCode != CorsairError.Success) @@ -100,10 +121,12 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider } finally { - _CUESDK.SessionStateChanged -= OnSessionStateChanged; + _CUESDK.SessionStateChanged -= OnInitializeSessionStateChanged; } } + private void OnSessionStateChanged(object? sender, CorsairSessionState state) => SessionState = state; + /// protected override IEnumerable LoadDevices() { @@ -129,7 +152,7 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider Throw(new RGBDeviceException($"Failed to take control of device '{device.id}'. (ErrorCode: {error})")); CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), device); - + int channelLedCount = 0; for (int i = 0; i < device.channelCount; i++) { diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index 1d42dc2..2cc6b88 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -40,17 +40,24 @@ public class CorsairDeviceUpdateQueue : UpdateQueue /// protected override unsafe void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length); - for (int i = 0; i < colors.Length; i++) + try { - (object id, Color color) = dataSet[i]; - (byte a, byte r, byte g, byte b) = color.GetRGBBytes(); - colors[i] = new _CorsairLedColor((CorsairLedId)id, r, g, b, a); - } + Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length); + for (int i = 0; i < colors.Length; i++) + { + (object id, Color color) = dataSet[i]; + (byte a, byte r, byte g, byte b) = color.GetRGBBytes(); + colors[i] = new _CorsairLedColor((CorsairLedId)id, r, g, b, a); + } - CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr); - if (error != CorsairError.Success) - throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})"); + CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr); + if (error != CorsairError.Success) + throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})"); + } + catch (Exception ex) + { + CorsairDeviceProvider.Instance.Throw(ex, true); + } } /// diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index b1bffdb..4fc62e9 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -61,16 +61,23 @@ public class E131UpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - DataPacket.SetSequenceNumber(GetNextSequenceNumber()); - - foreach ((object key, Color color) in dataSet) + try { - LedChannelMapping mapping = (LedChannelMapping)key; - foreach ((int channel, Func getValue) in mapping) - DataPacket.SetChannel(channel, getValue(color)); - } + DataPacket.SetSequenceNumber(GetNextSequenceNumber()); - _socket.Send(DataPacket, DataPacket.Length); + foreach ((object key, Color color) in dataSet) + { + LedChannelMapping mapping = (LedChannelMapping)key; + foreach ((int channel, Func getValue) in mapping) + DataPacket.SetChannel(channel, getValue(color)); + } + + _socket.Send(DataPacket, DataPacket.Length); + } + catch (Exception ex) + { + DMXDeviceProvider.Instance.Throw(ex, true); + } } /// diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs index a3e8801..eede537 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs @@ -27,12 +27,19 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - Color color = dataSet[0].color; + try + { + Color color = dataSet[0].color; - _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB); - _LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100), - (int)Math.Round(color.G * 100), - (int)Math.Round(color.B * 100)); + _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB); + _LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100), + (int)Math.Round(color.G * 100), + (int)Math.Round(color.B * 100)); + } + catch (Exception ex) + { + LogitechDeviceProvider.Instance.Throw(ex, true); + } } #endregion diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index 3b75a3b..5c4efbb 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -27,16 +27,23 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB); - - foreach ((object key, Color color) in dataSet) + try { - // These will be LogitechLedId but the SDK expects an int and doesn't care about invalid values - int keyName = (int)key; - _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyName, - (int)MathF.Round(color.R * 100), - (int)MathF.Round(color.G * 100), - (int)MathF.Round(color.B * 100)); + _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB); + + foreach ((object key, Color color) in dataSet) + { + // These will be LogitechLedId but the SDK expects an int and doesn't care about invalid values + int keyName = (int)key; + _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyName, + (int)MathF.Round(color.R * 100), + (int)MathF.Round(color.G * 100), + (int)MathF.Round(color.B * 100)); + } + } + catch (Exception ex) + { + LogitechDeviceProvider.Instance.Throw(ex, true); } } diff --git a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs index d503148..4a9acd5 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs @@ -36,8 +36,15 @@ public class MsiDeviceUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach ((object key, Color color) in dataSet) - _MsiSDK.SetLedColor(_deviceType, (int)key, color.GetR(), color.GetG(), color.GetB()); + try + { + foreach ((object key, Color color) in dataSet) + _MsiSDK.SetLedColor(_deviceType, (int)key, color.GetR(), color.GetG(), color.GetB()); + } + catch (Exception ex) + { + MsiDeviceProvider.Instance.Throw(ex, true); + } } #endregion diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index dc21766..9a1af35 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -37,8 +37,15 @@ public abstract class MidiUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach ((object key, Color color) in dataSet) - SendMessage(CreateMessage(key, color)); + try + { + foreach ((object key, Color color) in dataSet) + SendMessage(CreateMessage(key, color)); + } + catch (Exception ex) + { + NovationDeviceProvider.Instance.Throw(ex, true); + } } /// diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs index aab78d4..b6c91b8 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs @@ -51,10 +51,17 @@ public class OpenRGBUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach ((object key, Color color) in dataSet) - _colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB()); + try + { + foreach ((object key, Color color) in dataSet) + _colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB()); - _openRGB.UpdateLeds(_deviceid, _colors); + _openRGB.UpdateLeds(_deviceid, _colors); + } + catch (Exception ex) + { + OpenRGBDeviceProvider.Instance.Throw(ex, true); + } } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs index fa32893..4e0a096 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs @@ -46,20 +46,27 @@ public class PicoPiBulkUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - Span buffer = _dataBuffer; - foreach ((object key, Color color) in dataSet) + try { - int index = key as int? ?? -1; - if (index < 0) continue; + Span buffer = _dataBuffer; + foreach ((object key, Color color) in dataSet) + { + int index = key as int? ?? -1; + if (index < 0) continue; - (byte _, byte r, byte g, byte b) = color.GetRGBBytes(); - int offset = index * 3; - buffer[offset] = r; - buffer[offset + 1] = g; - buffer[offset + 2] = b; + (byte _, byte r, byte g, byte b) = color.GetRGBBytes(); + int offset = index * 3; + buffer[offset] = r; + buffer[offset + 1] = g; + buffer[offset + 2] = b; + } + + _sdk.SendBulkUpdate(buffer, _channel); + } + catch (Exception ex) + { + PicoPiDeviceProvider.Instance.Throw(ex, true); } - - _sdk.SendBulkUpdate(buffer, _channel); } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs index 8ee06a2..381d382 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs @@ -43,20 +43,27 @@ public class PicoPiHIDUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - Span buffer = _dataBuffer; - foreach ((object key, Color color) in dataSet) + try { - int index = key as int? ?? -1; - if (index < 0) continue; + Span buffer = _dataBuffer; + foreach ((object key, Color color) in dataSet) + { + int index = key as int? ?? -1; + if (index < 0) continue; - (byte _, byte r, byte g, byte b) = color.GetRGBBytes(); - int offset = index * 3; - buffer[offset] = r; - buffer[offset + 1] = g; - buffer[offset + 2] = b; + (byte _, byte r, byte g, byte b) = color.GetRGBBytes(); + int offset = index * 3; + buffer[offset] = r; + buffer[offset + 1] = g; + buffer[offset + 2] = b; + } + + _sdk.SendHidUpdate(buffer, _channel); + } + catch (Exception ex) + { + PicoPiDeviceProvider.Instance.Throw(ex, true); } - - _sdk.SendHidUpdate(buffer, _channel); } #endregion diff --git a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs index cc8fedc..33f8d32 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; public abstract class RazerUpdateQueue : UpdateQueue { #region Properties & Fields - + private Guid? _lastEffect; #endregion @@ -23,8 +23,7 @@ public abstract class RazerUpdateQueue : UpdateQueue /// The update trigger used to update this queue. protected RazerUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) - { - } + { } #endregion @@ -33,16 +32,23 @@ public abstract class RazerUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - IntPtr effectParams = CreateEffectParams(dataSet); - Guid effectId = Guid.NewGuid(); - CreateEffect(effectParams, ref effectId); + try + { + IntPtr effectParams = CreateEffectParams(dataSet); + Guid effectId = Guid.NewGuid(); + CreateEffect(effectParams, ref effectId); - _RazerSDK.SetEffect(effectId); + _RazerSDK.SetEffect(effectId); - if (_lastEffect.HasValue) - _RazerSDK.DeleteEffect(_lastEffect.Value); + if (_lastEffect.HasValue) + _RazerSDK.DeleteEffect(_lastEffect.Value); - _lastEffect = effectId; + _lastEffect = effectId; + } + catch (Exception ex) + { + RazerDeviceProvider.Instance.Throw(ex, true); + } } /// diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs index 67c39a4..d5b0c2a 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs @@ -37,10 +37,17 @@ internal class SteelSeriesDeviceUpdateQueue : UpdateQueue protected override void OnUpdate(object? sender, CustomUpdateData customData) { - if (customData[CustomUpdateDataIndex.HEARTBEAT] as bool? ?? false) - SteelSeriesSDK.SendHeartbeat(); - else - base.OnUpdate(sender, customData); + try + { + if (customData[CustomUpdateDataIndex.HEARTBEAT] as bool? ?? false) + SteelSeriesSDK.SendHeartbeat(); + else + base.OnUpdate(sender, customData); + } + catch (Exception ex) + { + SteelSeriesDeviceProvider.Instance.Throw(ex, true); + } } /// diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs index cdd1075..78dab04 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs @@ -58,10 +58,17 @@ public abstract class SerialConnectionUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach (TData command in GetCommands(dataSet.ToArray())) + try { - SerialConnection.ReadTo(Prompt); - SendCommand(command); + foreach (TData command in GetCommands(dataSet.ToArray())) + { + SerialConnection.ReadTo(Prompt); + SendCommand(command); + } + } + catch (Exception ex) + { + WS281XDeviceProvider.Instance.Throw(ex, true); } } diff --git a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs index a9d6f54..7e6ae67 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs @@ -13,7 +13,7 @@ public class WootingUpdateQueue : UpdateQueue #region Properties & Fields private readonly byte _deviceid; #endregion - + #region Constructors /// @@ -33,17 +33,24 @@ public class WootingUpdateQueue : UpdateQueue /// protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - lock (_WootingSDK.SdkLock) + try { - _WootingSDK.SelectDevice(_deviceid); - - foreach ((object key, Color color) in dataSet) + lock (_WootingSDK.SdkLock) { - (int row, int column) = ((int, int))key; - _WootingSDK.ArraySetSingle((byte)row, (byte)column, color.GetR(), color.GetG(), color.GetB()); - } + _WootingSDK.SelectDevice(_deviceid); - _WootingSDK.ArrayUpdateKeyboard(); + foreach ((object key, Color color) in dataSet) + { + (int row, int column) = ((int, int))key; + _WootingSDK.ArraySetSingle((byte)row, (byte)column, color.GetR(), color.GetG(), color.GetB()); + } + + _WootingSDK.ArrayUpdateKeyboard(); + } + } + catch (Exception ex) + { + WootingDeviceProvider.Instance.Throw(ex, true); } } From 30ccfdcd85c35f02b6ad845fb264cbac8fb61006 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 5 Mar 2023 18:04:50 +0100 Subject: [PATCH 17/96] (MAJOR) Added success-indication to device updates and forced flushes after nonsuccessful ones. Added exception handling the last missing queues. --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 2 +- RGB.NET.Core/Update/Devices/IUpdateQueue.cs | 5 ++++ RGB.NET.Core/Update/Devices/UpdateQueue.cs | 6 ++-- .../Generic/AsusUpdateQueue.cs | 12 +++++--- .../Generic/CoolerMasterUpdateQueue.cs | 8 +++-- .../Generic/CorsairDeviceUpdateQueue.cs | 10 +++++-- RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs | 8 +++-- .../DebugDeviceUpdateQueue.cs | 2 +- .../PerDevice/LogitechPerDeviceUpdateQueue.cs | 8 +++-- .../PerKey/LogitechPerKeyUpdateQueue.cs | 8 +++-- .../Zone/LogitechZoneUpdateQueue.cs | 29 +++++++++++++------ .../Generic/MsiDeviceUpdateQueue.cs | 8 +++-- .../Generic/MidiUpdateQueue.cs | 8 +++-- .../Generic/OpenRGBUpdateQueue.cs | 8 +++-- .../PicoPi/PicoPiBulkUpdateQueue.cs | 8 +++-- .../PicoPi/PicoPiHIDUpdateQueue.cs | 8 +++-- .../Generic/RazerUpdateQueue.cs | 8 +++-- .../Generic/SteelSeriesDeviceUpdateQueue.cs | 19 ++++++++++-- .../Generic/SerialPortUpdateQueue.cs | 8 +++-- .../NodeMCU/NodeMCUWS2812USBUpdateQueue.cs | 20 ++++++++++--- .../Generic/WootingUpdateQueue.cs | 8 +++-- 21 files changed, 151 insertions(+), 50 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index ca6a5b2..6ac90da 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -111,7 +111,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice /// Forces all LEDs to be treated as dirty. /// The collection LEDs to update. - protected virtual IEnumerable GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).Where(led => led.RequestedColor?.A > 0); + protected virtual IEnumerable GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds || UpdateQueue.RequiresFlush) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).Where(led => led.RequestedColor?.A > 0); /// /// Gets an enumerable of a custom data and color tuple for the specified leds. diff --git a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs index 3a0f63a..348c16e 100644 --- a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs @@ -11,6 +11,11 @@ namespace RGB.NET.Core; public interface IUpdateQueue : IDisposable where TIdentifier : notnull { + /// + /// Gets a bool indicating if the queue requires a flush of all data due to an internal error. + /// + bool RequiresFlush { get; } + /// /// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available. /// diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index 4c169b7..239b689 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -19,6 +19,8 @@ public abstract class UpdateQueue : IUpdateQueue _currentDataSet = new(); + public bool RequiresFlush { get; private set; } + #endregion #region Constructors @@ -62,7 +64,7 @@ public abstract class UpdateQueue : IUpdateQueue.Shared.Return(dataSet); } @@ -78,7 +80,7 @@ public abstract class UpdateQueue : IUpdateQueue /// The set of data that needs to be updated. - protected abstract void Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet); + protected abstract bool Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet); /// /// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available. diff --git a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs index 27f4f5b..012ed7e 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs @@ -43,14 +43,14 @@ public class AsusUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB)) { if (Device is not IAuraSyncKeyboard keyboard) - return; + return true; foreach ((object customData, Color value) in dataSet) { @@ -88,12 +88,16 @@ public class AsusUpdateQueue : UpdateQueue } Device.Apply(); + + return true; } catch (Exception ex) { - AsusDeviceProvider.Instance.Throw(ex, true); + AsusDeviceProvider.Instance.Throw(ex); } - } + return false; + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs index 07df7cc..4121c4f 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs @@ -37,7 +37,7 @@ public class CoolerMasterUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -48,11 +48,15 @@ public class CoolerMasterUpdateQueue : UpdateQueue } _CoolerMasterSDK.SetAllLedColor(_deviceMatrix, _deviceIndex); + + return true; } catch (Exception ex) { - CoolerMasterDeviceProvider.Instance.Throw(ex, true); + CoolerMasterDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index 2cc6b88..fa743e8 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -38,10 +38,12 @@ public class CorsairDeviceUpdateQueue : UpdateQueue #region Methods /// - protected override unsafe void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override unsafe bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { + if (!_CUESDK.IsConnected) return false; + Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length); for (int i = 0; i < colors.Length; i++) { @@ -53,11 +55,15 @@ public class CorsairDeviceUpdateQueue : UpdateQueue CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr); if (error != CorsairError.Success) throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})"); + + return true; } catch (Exception ex) { - CorsairDeviceProvider.Instance.Throw(ex, true); + CorsairDeviceProvider.Instance.Throw(ex); } + + return false; } /// diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index 4fc62e9..57159e9 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -59,7 +59,7 @@ public class E131UpdateQueue : UpdateQueue } /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -73,11 +73,15 @@ public class E131UpdateQueue : UpdateQueue } _socket.Send(DataPacket, DataPacket.Length); + + return true; } catch (Exception ex) { - DMXDeviceProvider.Instance.Throw(ex, true); + DMXDeviceProvider.Instance.Throw(ex); } + + return false; } /// diff --git a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs index ccd0344..1e00c42 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs @@ -15,7 +15,7 @@ internal class DebugDeviceUpdateQueue : UpdateQueue #region Methods - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { } + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) => true; #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs index eede537..c32f87d 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs @@ -25,7 +25,7 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -35,11 +35,15 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue _LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100), (int)Math.Round(color.G * 100), (int)Math.Round(color.B * 100)); + + return true; } catch (Exception ex) { - LogitechDeviceProvider.Instance.Throw(ex, true); + LogitechDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index 5c4efbb..b0bdaf4 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -25,7 +25,7 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -40,11 +40,15 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue (int)MathF.Round(color.G * 100), (int)MathF.Round(color.B * 100)); } + + return true; } catch (Exception ex) { - LogitechDeviceProvider.Instance.Throw(ex, true); + LogitechDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs index a76d5c5..eba7a2d 100644 --- a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs @@ -33,18 +33,29 @@ public class LogitechZoneUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All); - - foreach ((object key, Color color) in dataSet) + try { - int zone = (int)key; - _LogitechGSDK.LogiLedSetLightingForTargetZone(_deviceType, zone, - (int)MathF.Round(color.R * 100), - (int)MathF.Round(color.G * 100), - (int)MathF.Round(color.B * 100)); + _LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All); + + foreach ((object key, Color color) in dataSet) + { + int zone = (int)key; + _LogitechGSDK.LogiLedSetLightingForTargetZone(_deviceType, zone, + (int)MathF.Round(color.R * 100), + (int)MathF.Round(color.G * 100), + (int)MathF.Round(color.B * 100)); + } + + return true; } + catch (Exception ex) + { + LogitechDeviceProvider.Instance.Throw(ex); + } + + return false; } #endregion diff --git a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs index 4a9acd5..8db204f 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs @@ -34,17 +34,21 @@ public class MsiDeviceUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { foreach ((object key, Color color) in dataSet) _MsiSDK.SetLedColor(_deviceType, (int)key, color.GetR(), color.GetG(), color.GetB()); + + return true; } catch (Exception ex) { - MsiDeviceProvider.Instance.Throw(ex, true); + MsiDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index 9a1af35..945c4ff 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -35,17 +35,21 @@ public abstract class MidiUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { foreach ((object key, Color color) in dataSet) SendMessage(CreateMessage(key, color)); + + return true; } catch (Exception ex) { - NovationDeviceProvider.Instance.Throw(ex, true); + NovationDeviceProvider.Instance.Throw(ex); } + + return false; } /// diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs index b6c91b8..fa79e6e 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs @@ -49,7 +49,7 @@ public class OpenRGBUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -57,11 +57,15 @@ public class OpenRGBUpdateQueue : UpdateQueue _colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB()); _openRGB.UpdateLeds(_deviceid, _colors); + + return true; } catch (Exception ex) { - OpenRGBDeviceProvider.Instance.Throw(ex, true); + OpenRGBDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs index 4e0a096..8cd251d 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs @@ -44,7 +44,7 @@ public class PicoPiBulkUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -62,11 +62,15 @@ public class PicoPiBulkUpdateQueue : UpdateQueue } _sdk.SendBulkUpdate(buffer, _channel); + + return true; } catch (Exception ex) { - PicoPiDeviceProvider.Instance.Throw(ex, true); + PicoPiDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs index 381d382..b3ff956 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs @@ -41,7 +41,7 @@ public class PicoPiHIDUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -59,11 +59,15 @@ public class PicoPiHIDUpdateQueue : UpdateQueue } _sdk.SendHidUpdate(buffer, _channel); + + return true; } catch (Exception ex) { - PicoPiDeviceProvider.Instance.Throw(ex, true); + PicoPiDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion diff --git a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs index 33f8d32..105fee9 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs @@ -30,7 +30,7 @@ public abstract class RazerUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -44,11 +44,15 @@ public abstract class RazerUpdateQueue : UpdateQueue _RazerSDK.DeleteEffect(_lastEffect.Value); _lastEffect = effectId; + + return true; } catch (Exception ex) { - RazerDeviceProvider.Instance.Throw(ex, true); + RazerDeviceProvider.Instance.Throw(ex); } + + return false; } /// diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs index d5b0c2a..26d744d 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs @@ -46,13 +46,26 @@ internal class SteelSeriesDeviceUpdateQueue : UpdateQueue } catch (Exception ex) { - SteelSeriesDeviceProvider.Instance.Throw(ex, true); + SteelSeriesDeviceProvider.Instance.Throw(ex); } } /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) - => SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToArray().Select(x => (((SteelSeriesLedId)x.key).GetAPIName(), x.color.ToIntArray())).Where(x => x.Item1 != null).ToList()!); + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + { + try + { + SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToArray().Select(x => (((SteelSeriesLedId)x.key).GetAPIName(), x.color.ToIntArray())).Where(x => x.Item1 != null).ToList()!); + + return true; + } + catch (Exception ex) + { + SteelSeriesDeviceProvider.Instance.Throw(ex); + } + + return false; + } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs index 78dab04..f1aa16c 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortUpdateQueue.cs @@ -56,7 +56,7 @@ public abstract class SerialConnectionUpdateQueue : UpdateQueue } /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -65,11 +65,15 @@ public abstract class SerialConnectionUpdateQueue : UpdateQueue SerialConnection.ReadTo(Prompt); SendCommand(command); } + + return true; } catch (Exception ex) { - WS281XDeviceProvider.Instance.Throw(ex, true); + WS281XDeviceProvider.Instance.Throw(ex); } + + return false; } /// diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index a3619e2..9e6d30e 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -77,13 +77,25 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue } /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { - foreach (IGrouping channelData in dataSet.ToArray().Select(x => (((int channel, int key))x.key, x.color)).GroupBy(x => x.Item1.channel)) + try { - byte[] buffer = GetBuffer(channelData); - _sendDataAction(buffer); + foreach (IGrouping channelData in dataSet.ToArray() + .Select(x => (((int channel, int key))x.key, x.color)).GroupBy(x => x.Item1.channel)) + { + byte[] buffer = GetBuffer(channelData); + _sendDataAction(buffer); + } + + return true; } + catch (Exception ex) + { + WS281XDeviceProvider.Instance.Throw(ex); + } + + return false; } private void SendHttp(byte[] buffer) diff --git a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs index 7e6ae67..3791ba0 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs @@ -31,7 +31,7 @@ public class WootingUpdateQueue : UpdateQueue #region Methods /// - protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) { try { @@ -47,11 +47,15 @@ public class WootingUpdateQueue : UpdateQueue _WootingSDK.ArrayUpdateKeyboard(); } + + return true; } catch (Exception ex) { - WootingDeviceProvider.Instance.Throw(ex, true); + WootingDeviceProvider.Instance.Throw(ex); } + + return false; } #endregion From 4a9bbb64dc5a029d44c5a6bf1fbf4b0f3ea3c508 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 5 Mar 2023 18:06:08 +0100 Subject: [PATCH 18/96] Added missing doc comment --- RGB.NET.Core/Update/Devices/UpdateQueue.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index 239b689..1cc5eca 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -19,6 +19,7 @@ public abstract class UpdateQueue : IUpdateQueue _currentDataSet = new(); + /// public bool RequiresFlush { get; private set; } #endregion From b6342ea57563746712c5e9c245e961c5a2e40cdd Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Thu, 9 Mar 2023 14:43:23 +0000 Subject: [PATCH 19/96] Wooting - Add macOS dylib --- .../Generic/WootingRGBDevice.cs | 1 - RGB.NET.Devices.Wooting/Native/_WootingSDK.cs | 6 ++++-- .../WootingDeviceProvider.cs | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs index fc28728..8697eb1 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs @@ -20,7 +20,6 @@ public abstract class WootingRGBDevice : AbstractRGBDevice possibleLibraryPaths; if (OperatingSystem.IsWindows()) - possibleLibraryPaths = Environment.Is64BitProcess ? WootingDeviceProvider.PossibleX64NativePaths : WootingDeviceProvider.PossibleX86NativePaths; + possibleLibraryPaths = Environment.Is64BitProcess ? WootingDeviceProvider.PossibleX64NativePathsWindows : WootingDeviceProvider.PossibleX86NativePathsWindows; else if (OperatingSystem.IsLinux()) - possibleLibraryPaths = Environment.Is64BitProcess ? WootingDeviceProvider.PossibleX64NativePathsLinux : WootingDeviceProvider.PossibleX86NativePathsLinux; + possibleLibraryPaths = WootingDeviceProvider.PossibleNativePathsLinux; + else if (OperatingSystem.IsMacOS()) + possibleLibraryPaths = WootingDeviceProvider.PossibleNativePathsMacOS; else possibleLibraryPaths = Enumerable.Empty(); diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 57d99c1..c920ebb 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -26,25 +26,25 @@ public class WootingDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/wooting-rgb-sdk.dll" }; - - /// - /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 linux applications. - /// The first match will be used. - /// - public static List PossibleX86NativePathsLinux { get; } = new() { "x86/wooting-rgb-sdk.so" }; + public static List PossibleX86NativePathsWindows { get; } = new() { "x86/wooting-rgb-sdk.dll" }; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 windows applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/wooting-rgb-sdk64.dll" }; + public static List PossibleX64NativePathsWindows { get; } = new() { "x64/wooting-rgb-sdk64.dll" }; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 linux applications. /// The first match will be used. /// - public static List PossibleX64NativePathsLinux { get; } = new() { "x64/wooting-rgb-sdk64.so" }; + public static List PossibleNativePathsLinux { get; } = new() { "x64/libwooting-rgb-sdk.so" }; + + /// + /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 MacOS applications. + /// The first match will be used. + /// + public static List PossibleNativePathsMacOS { get; } = new() { "x64/libwooting-rgb-sdk.dylib" }; #endregion From 1793d26166fa98e5295ce74ce4f1a1179320556e Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Thu, 9 Mar 2023 15:33:37 +0000 Subject: [PATCH 20/96] OpenRgb - added segments --- .../Abstract/OpenRGBDeviceInfo.cs | 2 +- .../Generic/OpenRGBGenericDevice.cs | 12 ++-- .../Generic/OpenRGBUpdateQueue.cs | 21 ++++--- RGB.NET.Devices.OpenRGB/Helper.cs | 4 +- .../OpenRGBDeviceProvider.cs | 55 +++++++++++++------ .../PerZone/OpenRGBZoneDevice.cs | 11 ++-- .../RGB.NET.Devices.OpenRGB.csproj | 2 +- .../Segment/OpenRGBSegmentDevice.cs | 55 +++++++++++++++++++ 8 files changed, 118 insertions(+), 44 deletions(-) create mode 100644 RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs diff --git a/RGB.NET.Devices.OpenRGB/Abstract/OpenRGBDeviceInfo.cs b/RGB.NET.Devices.OpenRGB/Abstract/OpenRGBDeviceInfo.cs index 05afff3..5d3cc1b 100644 --- a/RGB.NET.Devices.OpenRGB/Abstract/OpenRGBDeviceInfo.cs +++ b/RGB.NET.Devices.OpenRGB/Abstract/OpenRGBDeviceInfo.cs @@ -1,5 +1,5 @@ using RGB.NET.Core; -using OpenRGBDevice = OpenRGB.NET.Models.Device; +using OpenRGBDevice = OpenRGB.NET.Device; namespace RGB.NET.Devices.OpenRGB; diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs index 8f19c5a..618c310 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs @@ -1,4 +1,4 @@ -using OpenRGB.NET.Enums; +using OpenRGB.NET; using RGB.NET.Core; namespace RGB.NET.Devices.OpenRGB; @@ -34,15 +34,15 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice int zoneLedIndex = 0; const int LED_SPACING = 20; - foreach (global::OpenRGB.NET.Models.Zone? zone in DeviceInfo.OpenRGBDevice.Zones) + foreach (Zone? zone in DeviceInfo.OpenRGBDevice.Zones) { if (zone.Type == ZoneType.Matrix) { - for (int row = 0; row < zone.MatrixMap.Height; row++) + for (int row = 0; row < zone.MatrixMap!.Height; row++) { - for (int column = 0; column < zone.MatrixMap.Width; column++) + for (int column = 0; column < zone.MatrixMap!.Width; column++) { - uint index = zone.MatrixMap.Matrix[row, column]; + uint index = zone.MatrixMap!.Matrix[row, column]; //will be max value if the position does not have an associated key if (index == uint.MaxValue) @@ -59,7 +59,7 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice ledId = initial++; } } - y += (int)(zone.MatrixMap.Height * LED_SPACING); + y += (int)(zone.MatrixMap!.Height * LED_SPACING); } else { diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs index fa79e6e..ff4daa5 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs @@ -2,8 +2,9 @@ using RGB.NET.Core; using System; using System.Linq; -using OpenRGBColor = OpenRGB.NET.Models.Color; -using OpenRGBDevice = OpenRGB.NET.Models.Device; +using Color = RGB.NET.Core.Color; +using OpenRGBColor = OpenRGB.NET.Color; +using OpenRGBDevice = OpenRGB.NET.Device; namespace RGB.NET.Devices.OpenRGB; @@ -15,10 +16,9 @@ public class OpenRGBUpdateQueue : UpdateQueue { #region Properties & Fields - private readonly int _deviceid; + private readonly int _deviceId; - private readonly OpenRGBClient _openRGB; - private readonly OpenRGBDevice _device; + private readonly OpenRgbClient _openRGB; private readonly OpenRGBColor[] _colors; #endregion @@ -29,17 +29,16 @@ public class OpenRGBUpdateQueue : UpdateQueue /// Initializes a new instance of the class. /// /// The update trigger used by this queue. - /// The index used to identify the device. + /// The index used to identify the device. /// The OpenRGB client used to send updates to the OpenRGB server. /// The OpenRGB Device containing device-specific information. - public OpenRGBUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceid, OpenRGBClient client, OpenRGBDevice device) + public OpenRGBUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId, OpenRgbClient client, OpenRGBDevice device) : base(updateTrigger) { - this._deviceid = deviceid; + this._deviceId = deviceId; this._openRGB = client; - this._device = device; - _colors = Enumerable.Range(0, _device.Colors.Length) + _colors = Enumerable.Range(0, device.Colors.Length) .Select(_ => new OpenRGBColor()) .ToArray(); } @@ -56,7 +55,7 @@ public class OpenRGBUpdateQueue : UpdateQueue foreach ((object key, Color color) in dataSet) _colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB()); - _openRGB.UpdateLeds(_deviceid, _colors); + _openRGB.UpdateLeds(_deviceId, _colors); return true; } diff --git a/RGB.NET.Devices.OpenRGB/Helper.cs b/RGB.NET.Devices.OpenRGB/Helper.cs index 639730e..a79afff 100644 --- a/RGB.NET.Devices.OpenRGB/Helper.cs +++ b/RGB.NET.Devices.OpenRGB/Helper.cs @@ -1,6 +1,6 @@ -using OpenRGB.NET.Enums; +using OpenRGB.NET; using RGB.NET.Core; -using OpenRGBDevice = OpenRGB.NET.Models.Device; +using OpenRGBDevice = OpenRGB.NET.Device; namespace RGB.NET.Devices.OpenRGB; diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 0f2b44b..ccf41a3 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -1,5 +1,4 @@ using OpenRGB.NET; -using OpenRGB.NET.Models; using RGB.NET.Core; using System; using System.Collections.Generic; @@ -15,7 +14,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields - private readonly List _clients = new(); + private readonly List _clients = new(); private static OpenRGBDeviceProvider? _instance; @@ -71,7 +70,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider { try { - OpenRGBClient openRgb = new(ip: deviceDefinition.Ip, port: deviceDefinition.Port, name: deviceDefinition.ClientName, autoconnect: true); + OpenRgbClient openRgb = new(ip: deviceDefinition.Ip, port: deviceDefinition.Port, name: deviceDefinition.ClientName, autoConnect: true); _clients.Add(openRgb); deviceDefinition.Connected = true; } @@ -87,7 +86,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider /// protected override IEnumerable LoadDevices() { - foreach (OpenRGBClient? openRgb in _clients) + foreach (OpenRgbClient? openRgb in _clients) { int deviceCount = openRgb.GetControllerCount(); @@ -99,7 +98,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider if (directModeIndex != -1) { //set the device to direct mode if it has it - openRgb.SetMode(i, directModeIndex); + openRgb.UpdateMode(i, directModeIndex); } else if (!ForceAddAllDevices) { @@ -108,21 +107,43 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider continue; } + if (device.Zones.Length == 0) + continue; + if (device.Zones.All(z => z.LedCount == 0)) + continue; + OpenRGBUpdateQueue? updateQueue = new(GetUpdateTrigger(), i, openRgb, device); + + bool anyZoneHasSegments = device.Zones.Any(z => z.Segments.Length > 0); + bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type)); - if (PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type))) + if (!splitDeviceByZones) { - int totalLedCount = 0; - - foreach (Zone zone in device.Zones) - if (zone.LedCount > 0) - { - yield return new OpenRGBZoneDevice(new OpenRGBDeviceInfo(device), totalLedCount, zone, updateQueue); - totalLedCount += (int)zone.LedCount; - } - } - else yield return new OpenRGBGenericDevice(new OpenRGBDeviceInfo(device), updateQueue); + continue; + } + + int totalLedCount = 0; + + foreach (Zone zone in device.Zones) + { + if (zone.LedCount <= 0) + continue; + + if (zone.Segments.Length <= 0) + { + yield return new OpenRGBZoneDevice(new OpenRGBDeviceInfo(device), totalLedCount, zone, updateQueue); + totalLedCount += (int)zone.LedCount; + } + else + { + foreach (Segment segment in zone.Segments) + { + yield return new OpenRGBSegmentDevice(new OpenRGBDeviceInfo(device), totalLedCount, segment, updateQueue); + totalLedCount += (int)segment.LedCount; + } + } + } } } } @@ -132,7 +153,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider { base.Dispose(); - foreach (OpenRGBClient client in _clients) + foreach (OpenRgbClient client in _clients) { try { client.Dispose(); } catch { /* at least we tried */ } diff --git a/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs b/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs index 42ab433..6def092 100644 --- a/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs +++ b/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs @@ -1,5 +1,4 @@ -using OpenRGB.NET.Enums; -using OpenRGB.NET.Models; +using OpenRGB.NET; using RGB.NET.Core; namespace RGB.NET.Devices.OpenRGB; @@ -40,15 +39,15 @@ public class OpenRGBZoneDevice : AbstractOpenRGBDevice { Size ledSize = new(19); const int LED_SPACING = 20; - LedId initialId = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType) + _initialLed; + LedId initialId = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType); if (_zone.Type == ZoneType.Matrix) { - for (int row = 0; row < _zone.MatrixMap.Height; row++) + for (int row = 0; row < _zone.MatrixMap!.Height; row++) { - for (int column = 0; column < _zone.MatrixMap.Width; column++) + for (int column = 0; column < _zone.MatrixMap!.Width; column++) { - uint index = _zone.MatrixMap.Matrix[row, column]; + uint index = _zone.MatrixMap!.Matrix[row, column]; //will be max value if the position does not have an associated key if (index == uint.MaxValue) diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 9fd3eec..9d4c0e8 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -57,7 +57,7 @@ - + diff --git a/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs b/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs new file mode 100644 index 0000000..9d8c633 --- /dev/null +++ b/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs @@ -0,0 +1,55 @@ +using OpenRGB.NET; +using RGB.NET.Core; + +namespace RGB.NET.Devices.OpenRGB; + +/// +public class OpenRGBSegmentDevice : AbstractOpenRGBDevice +{ + #region Properties & Fields + + private readonly int _initialLed; + private readonly Segment _segment; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The information provided by OpenRGB + /// The ledId of the first led in the device that belongs to this zone. + /// The Segment information provided by OpenRGB. + /// The queue used to update this zone. + public OpenRGBSegmentDevice(OpenRGBDeviceInfo info, int initialLed, Segment segment, IUpdateQueue updateQueue) + : base(info, updateQueue) + { + _initialLed = initialLed; + _segment = segment; + + InitializeLayout(); + } + + #endregion + + #region Methods + + private void InitializeLayout() + { + Size ledSize = new(19); + const int LED_SPACING = 20; + LedId initialId = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType); + + for (int i = 0; i < _segment.LedCount; i++) + { + LedId ledId = initialId++; + + // ReSharper disable once HeapView.BoxingAllocation + while (AddLed(ledId, new Point(LED_SPACING * i, 0), ledSize, _initialLed + i) == null) + ledId = initialId++; + } + } + + #endregion +} \ No newline at end of file From 5eb39b1a07d98175eb431ce54c3e66784730a371 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 14 Mar 2023 20:27:59 +0100 Subject: [PATCH 21/96] Added Pid for Razer BlackWidow V4 Fixes #305 --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index d967b36..f31174e 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -107,6 +107,7 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x025E, RGBDeviceType.Keyboard, "Cynosa V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0266, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice { 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse }, From d054d16c100f5d099c38f79ce11f300edd37f26c Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 8 Apr 2023 00:53:15 +0200 Subject: [PATCH 22/96] Added reference counting to update queues to prevent premature disposes when used in multiple devices --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 9 +++- .../Extensions/ReferenceCountingExtension.cs | 6 +++ .../Misc/AbstractReferenceCounting.cs | 41 +++++++++++++++++++ RGB.NET.Core/Misc/IReferenceCounting.cs | 21 ++++++++++ RGB.NET.Core/RGB.NET.Core.csproj.DotSettings | 1 + RGB.NET.Core/Update/Devices/IUpdateQueue.cs | 2 +- RGB.NET.Core/Update/Devices/UpdateQueue.cs | 8 +++- 7 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 RGB.NET.Core/Extensions/ReferenceCountingExtension.cs create mode 100644 RGB.NET.Core/Misc/AbstractReferenceCounting.cs create mode 100644 RGB.NET.Core/Misc/IReferenceCounting.cs diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 6ac90da..faaf147 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -85,6 +85,8 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice : Placeable, IRGBDevice public virtual void Dispose() { - try { UpdateQueue.Dispose(); } catch { /* :( */ } + try + { + UpdateQueue.RemoveReferencingObject(this); + UpdateQueue.Dispose(); + } + catch { /* :( */ } try { LedMapping.Clear(); } catch { /* this really shouldn't happen */ } IdGenerator.ResetCounter(GetType().Assembly); diff --git a/RGB.NET.Core/Extensions/ReferenceCountingExtension.cs b/RGB.NET.Core/Extensions/ReferenceCountingExtension.cs new file mode 100644 index 0000000..58039eb --- /dev/null +++ b/RGB.NET.Core/Extensions/ReferenceCountingExtension.cs @@ -0,0 +1,6 @@ +namespace RGB.NET.Core; + +public static class ReferenceCountingExtension +{ + public static bool HasActiveReferences(this IReferenceCounting target) => target.ActiveReferenceCount > 0; +} \ No newline at end of file diff --git a/RGB.NET.Core/Misc/AbstractReferenceCounting.cs b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs new file mode 100644 index 0000000..070138a --- /dev/null +++ b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; + +namespace RGB.NET.Core; + +public abstract class AbstractReferenceCounting : IReferenceCounting +{ + #region Properties & Fields + + private readonly HashSet _referencingObjects = new(); + + /// + public int ActiveReferenceCount + { + get + { + lock (_referencingObjects) + return _referencingObjects.Count; + } + } + + #endregion + + #region Methods + + /// + public void AddReferencingObject(object obj) + { + lock (_referencingObjects) + if (!_referencingObjects.Contains(obj)) + _referencingObjects.Add(obj); + } + + /// + public void RemoveReferencingObject(object obj) + { + lock (_referencingObjects) + _referencingObjects.Remove(obj); + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Core/Misc/IReferenceCounting.cs b/RGB.NET.Core/Misc/IReferenceCounting.cs new file mode 100644 index 0000000..d8bcb28 --- /dev/null +++ b/RGB.NET.Core/Misc/IReferenceCounting.cs @@ -0,0 +1,21 @@ +namespace RGB.NET.Core; + +public interface IReferenceCounting +{ + /// + /// Gets the amount of currently registered referencing objects. + /// + public int ActiveReferenceCount { get; } + + /// + /// Adds the given object to the list of referencing objects. + /// + /// The object to add. + public void AddReferencingObject(object obj); + + /// + /// Removes the given object from the list of referencing objects. + /// + /// The object to remove. + public void RemoveReferencingObject(object obj); +} \ No newline at end of file diff --git a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings index bf7655f..7f9a6e2 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings +++ b/RGB.NET.Core/RGB.NET.Core.csproj.DotSettings @@ -16,6 +16,7 @@ True True True + True True True True diff --git a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs index 348c16e..bf4011c 100644 --- a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Core; /// /// The identifier used to identify the data processed by this queue. /// The type of the data processed by this queue. -public interface IUpdateQueue : IDisposable +public interface IUpdateQueue : IReferenceCounting, IDisposable where TIdentifier : notnull { /// diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index 1cc5eca..bdd0868 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Core; /// /// The type of the key used to identify some data. /// The type of the data. -public abstract class UpdateQueue : IUpdateQueue +public abstract class UpdateQueue : AbstractReferenceCounting, IUpdateQueue where TIdentifier : notnull { #region Properties & Fields @@ -112,8 +112,14 @@ public abstract class UpdateQueue : IUpdateQueue + /// + /// Disposes this queue. + /// Checks if any referencing objects are registered and if so, will return without disposing! + /// public virtual void Dispose() { + if (this.HasActiveReferences()) return; + _updateTrigger.Starting -= OnStartup; _updateTrigger.Update -= OnUpdate; From 5b514ff9629d756c36c769bfa1055cbac0f8c079 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 8 Apr 2023 14:42:56 +0200 Subject: [PATCH 23/96] Moved reference check for UpdateQueue disposal to the caller to prevent issues with Dispose-overrides --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 3 ++- RGB.NET.Core/Update/Devices/UpdateQueue.cs | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index faaf147..596625c 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -162,7 +162,8 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice : AbstractReferenceCountin } /// - /// - /// Disposes this queue. - /// Checks if any referencing objects are registered and if so, will return without disposing! - /// public virtual void Dispose() { - if (this.HasActiveReferences()) return; - _updateTrigger.Starting -= OnStartup; _updateTrigger.Update -= OnUpdate; From 818678fdf228a8dc08d9fc03092557ef189ddc09 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 8 Apr 2023 21:10:12 +0200 Subject: [PATCH 24/96] Added PID for Razer Ornata V3 fixes #309 --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index f31174e..04edecc 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -108,6 +108,7 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0266, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice { 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse }, From 10183fb27014792062c0dfb10ffb9cc7b96064be Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 9 Apr 2023 16:36:27 +0200 Subject: [PATCH 25/96] Added dispose-check to corsairs update queue --- RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index fa743e8..8bea2eb 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -13,6 +13,8 @@ public class CorsairDeviceUpdateQueue : UpdateQueue { #region Properties & Fields + private bool _isDisposed = false; + private readonly _CorsairDeviceInfo _device; private readonly nint _colorPtr; @@ -42,6 +44,7 @@ public class CorsairDeviceUpdateQueue : UpdateQueue { try { + if (_isDisposed) throw new ObjectDisposedException(nameof(CorsairDeviceUpdateQueue)); if (!_CUESDK.IsConnected) return false; Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length); @@ -71,6 +74,7 @@ public class CorsairDeviceUpdateQueue : UpdateQueue { base.Dispose(); + _isDisposed = true; Marshal.FreeHGlobal(_colorPtr); GC.SuppressFinalize(this); From aaabbc6a8df897e6df43544d1ee4b21fe332c8b9 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 11 Apr 2023 00:06:17 +0200 Subject: [PATCH 26/96] (MAJOR): Removed support for .NET 5; Updated nugets; Removed the not even working distribution of the Asus-SDK from the project; Fixed a warning in the OpenRGBServerDefinition --- RGB.NET.Core/RGB.NET.Core.csproj | 2 +- .../RGB.NET.Devices.Asus.csproj | 18 ++---------------- .../RGB.NET.Devices.CoolerMaster.csproj | 2 +- .../RGB.NET.Devices.Corsair.csproj | 2 +- RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj | 2 +- .../RGB.NET.Devices.Debug.csproj | 2 +- .../RGB.NET.Devices.Logitech.csproj | 2 +- RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj | 2 +- .../RGB.NET.Devices.Novation.csproj | 2 +- .../OpenRGBServerDefinition.cs | 4 ++-- .../RGB.NET.Devices.OpenRGB.csproj | 2 +- .../RGB.NET.Devices.PicoPi.csproj | 2 +- .../RGB.NET.Devices.Razer.csproj | 2 +- .../RGB.NET.Devices.SteelSeries.csproj | 2 +- .../RGB.NET.Devices.WS281X.csproj | 4 ++-- .../RGB.NET.Devices.Wooting.csproj | 2 +- RGB.NET.HID/RGB.NET.HID.csproj | 2 +- RGB.NET.Layout/RGB.NET.Layout.csproj | 2 +- RGB.NET.Presets/RGB.NET.Presets.csproj | 2 +- .../RGB.NET.Core.Tests.csproj | 6 +++--- .../RGB.NET.Presets.Tests.csproj | 6 +++--- 21 files changed, 28 insertions(+), 42 deletions(-) diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 6357388..ee87698 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index b4ac280..f7a9c4b 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable @@ -57,21 +57,7 @@ - - - - - <_PackageFiles Include="$(OutputPath)\net6.0\Interop.AuraServiceLib.dll"> - None - lib\net6.0\ - - - - - <_PackageFiles Include="$(OutputPath)\net5.0\Interop.AuraServiceLib.dll"> - None - lib\net5.0\ - + diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index d4812ed..fad9d75 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index 302d93d..13b8ead 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj index d291aa0..6ddf0ea 100644 --- a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj index f4edaae..b2d5367 100644 --- a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj +++ b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 7ee22dd..7b57ee4 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index c565c94..0d9a647 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index 12a7919..19a1464 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs b/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs index 860b6bc..9de9246 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs @@ -8,12 +8,12 @@ public class OpenRGBServerDefinition /// /// The name of the client that will appear in the OpenRGB interface. /// - public string? ClientName { get; set; } = "RGB.NET"; + public string ClientName { get; set; } = "RGB.NET"; /// /// The ip address of the server. /// - public string? Ip { get; set; } = "127.0.0.1"; + public string Ip { get; set; } = "127.0.0.1"; /// /// The port of the server. diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 9d4c0e8..6474494 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj index db64c4a..d75e479 100644 --- a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj +++ b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 32fcbe0..886ad44 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index d8b2ab6..487711b 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj index 0e0e08f..82435e5 100644 --- a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj +++ b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable @@ -57,7 +57,7 @@ - + diff --git a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj index ac158f0..532c590 100644 --- a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj +++ b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.HID/RGB.NET.HID.csproj b/RGB.NET.HID/RGB.NET.HID.csproj index 5469438..2021184 100644 --- a/RGB.NET.HID/RGB.NET.HID.csproj +++ b/RGB.NET.HID/RGB.NET.HID.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Layout/RGB.NET.Layout.csproj b/RGB.NET.Layout/RGB.NET.Layout.csproj index f6330ed..582fb71 100644 --- a/RGB.NET.Layout/RGB.NET.Layout.csproj +++ b/RGB.NET.Layout/RGB.NET.Layout.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/RGB.NET.Presets/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index fc2d052..f4da69c 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0;net5.0 + net7.0;net6.0 latest enable diff --git a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj index 0279d53..7e98ef5 100644 --- a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj +++ b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj index 5777739..ca57230 100644 --- a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj +++ b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj @@ -7,9 +7,9 @@ - - - + + + From 02235a3f7f3a10dd5be277ce085f971ea134e3cf Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 11 Apr 2023 00:15:27 +0200 Subject: [PATCH 27/96] Fixed some code-issues --- RGB.NET.Core/RGB.NET.Core.csproj | 4 ++-- RGB.NET.Devices.Asus/Helper/WMIHelper.cs | 6 +++--- .../RGB.NET.Devices.CoolerMaster.csproj | 4 ++-- RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs | 4 +++- RGB.NET.Devices.Corsair/Generic/LedMappings.cs | 1 + RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj | 4 ++-- RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj | 4 ++-- RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj | 4 ++-- RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj | 4 ++-- RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj | 4 ++-- RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj | 4 ++-- RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs | 4 ++-- RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj | 4 ++-- .../RGB.NET.Devices.OpenRGB.csproj.DotSettings | 3 ++- RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj | 4 ++-- RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj | 4 ++-- .../RGB.NET.Devices.SteelSeries.csproj | 4 ++-- RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj | 4 ++-- RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj | 4 ++-- RGB.NET.Devices.Wooting/WootingDeviceProvider.cs | 1 + RGB.NET.HID/RGB.NET.HID.csproj | 4 ++-- RGB.NET.Layout/RGB.NET.Layout.csproj | 4 ++-- RGB.NET.Presets/RGB.NET.Presets.csproj | 4 ++-- 23 files changed, 46 insertions(+), 41 deletions(-) diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index ee87698..8499b1e 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs b/RGB.NET.Devices.Asus/Helper/WMIHelper.cs index 5aa49c7..482f3a3 100644 --- a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs +++ b/RGB.NET.Devices.Asus/Helper/WMIHelper.cs @@ -43,7 +43,7 @@ internal static class WMIHelper if ((_systemModelInfo == null) && (_systemModelSearcher != null)) foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get()) { - _systemModelInfo = managementBaseObject["Model"]?.ToString(); + _systemModelInfo = managementBaseObject["Model"].ToString(); break; } @@ -57,7 +57,7 @@ internal static class WMIHelper if (!_mainboardInfo.HasValue && (_mainboardSearcher != null)) foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get()) { - _mainboardInfo = (managementBaseObject["Manufacturer"]?.ToString() ?? string.Empty, managementBaseObject["Product"]?.ToString() ?? string.Empty); + _mainboardInfo = (managementBaseObject["Manufacturer"].ToString() ?? string.Empty, managementBaseObject["Product"].ToString() ?? string.Empty); break; } @@ -71,7 +71,7 @@ internal static class WMIHelper if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null)) foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get()) { - _graphicsCardInfo = managementBaseObject["Name"]?.ToString(); + _graphicsCardInfo = managementBaseObject["Name"].ToString(); break; } diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index fad9d75..2adfaa5 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs index 7281323..3ec299d 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs @@ -1,4 +1,6 @@ -namespace RGB.NET.Devices.Corsair; +// ReSharper disable InconsistentNaming + +namespace RGB.NET.Devices.Corsair; /// /// iCUE-SDK: contains a list of led groups. Led group is used as a part of led identifier diff --git a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs index 8166070..ffbfa0f 100644 --- a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs @@ -11,6 +11,7 @@ internal static class LedMappings { #region Constants + // ReSharper disable once InconsistentNaming private static LedMapping KEYBOARD_MAPPING => new() { { LedId.Invalid, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Invalid) }, diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index 13b8ead..ccb143e 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj index 6ddf0ea..e6e876e 100644 --- a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj index b2d5367..980153c 100644 --- a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj +++ b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 7b57ee4..fd412e7 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 0d9a647..7d604a6 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index 19a1464..cda9c5e 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index ccf41a3..c9d3cbc 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -92,7 +92,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider for (int i = 0; i < deviceCount; i++) { - Device? device = openRgb.GetControllerData(i); + Device device = openRgb.GetControllerData(i); int directModeIndex = Array.FindIndex(device.Modes, d => d.Name == "Direct"); if (directModeIndex != -1) @@ -112,7 +112,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider if (device.Zones.All(z => z.LedCount == 0)) continue; - OpenRGBUpdateQueue? updateQueue = new(GetUpdateTrigger(), i, openRgb, device); + OpenRGBUpdateQueue updateQueue = new(GetUpdateTrigger(), i, openRgb, device); bool anyZoneHasSegments = device.Zones.Any(z => z.Segments.Length > 0); bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type)); diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 6474494..94ce604 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj.DotSettings b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj.DotSettings index f79e29d..7e8e95f 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj.DotSettings +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj.DotSettings @@ -1,4 +1,5 @@  True True - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj index d75e479..6cf8a2c 100644 --- a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj +++ b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 886ad44..27f7261 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index 487711b..f75e2d8 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj index 82435e5..5487a8e 100644 --- a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj +++ b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj index 532c590..8a34dcd 100644 --- a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj +++ b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index c920ebb..aebe9c0 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -44,6 +44,7 @@ public class WootingDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 MacOS applications. /// The first match will be used. /// + // ReSharper disable once InconsistentNaming public static List PossibleNativePathsMacOS { get; } = new() { "x64/libwooting-rgb-sdk.dylib" }; #endregion diff --git a/RGB.NET.HID/RGB.NET.HID.csproj b/RGB.NET.HID/RGB.NET.HID.csproj index 2021184..7bf502b 100644 --- a/RGB.NET.HID/RGB.NET.HID.csproj +++ b/RGB.NET.HID/RGB.NET.HID.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Layout/RGB.NET.Layout.csproj b/RGB.NET.Layout/RGB.NET.Layout.csproj index 582fb71..3c90185 100644 --- a/RGB.NET.Layout/RGB.NET.Layout.csproj +++ b/RGB.NET.Layout/RGB.NET.Layout.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Presets/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index f4da69c..048087a 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -41,7 +41,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -49,7 +49,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE From 82050b8d5a85feaca675cc67837a386cbaa9ca78 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 11 Apr 2023 00:26:46 +0200 Subject: [PATCH 28/96] Fixed some code issues --- RGB.NET.Core/Ids/IdGenerator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RGB.NET.Core/Ids/IdGenerator.cs b/RGB.NET.Core/Ids/IdGenerator.cs index 99beaa6..c6270e7 100644 --- a/RGB.NET.Core/Ids/IdGenerator.cs +++ b/RGB.NET.Core/Ids/IdGenerator.cs @@ -50,8 +50,7 @@ public static class IdGenerator idMapping.Add(id, mappedId); } - if (!counterMapping.ContainsKey(mappedId)) - counterMapping.Add(mappedId, 0); + counterMapping.TryAdd(mappedId, 0); int counter = ++counterMapping[mappedId]; return counter <= 1 ? mappedId : $"{mappedId} ({counter})"; From 4216dacf4fb37f912278c0afa8ce16a311eeae4f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 11 Apr 2023 00:29:01 +0200 Subject: [PATCH 29/96] Removed unnecessary contains check in AbstractReferenceCounting --- RGB.NET.Core/Misc/AbstractReferenceCounting.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RGB.NET.Core/Misc/AbstractReferenceCounting.cs b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs index 070138a..09d64ef 100644 --- a/RGB.NET.Core/Misc/AbstractReferenceCounting.cs +++ b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs @@ -26,8 +26,7 @@ public abstract class AbstractReferenceCounting : IReferenceCounting public void AddReferencingObject(object obj) { lock (_referencingObjects) - if (!_referencingObjects.Contains(obj)) - _referencingObjects.Add(obj); + _referencingObjects.Add(obj); } /// From 764fcd1b1dc309a3ef9accfb613177912bec8137 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 12 Apr 2023 22:25:24 +0200 Subject: [PATCH 30/96] (MAJOR) Improved update performance of devices --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 55 +++++++++---------- RGB.NET.Core/Update/Devices/IUpdateQueue.cs | 3 +- RGB.NET.Core/Update/Devices/UpdateQueue.cs | 6 +- .../PerDevice/LogitechPerDeviceRGBDevice.cs | 7 +-- .../PerKey/LogitechPerKeyRGBDevice.cs | 8 +-- .../Zone/LogitechZoneRGBDevice.cs | 6 +- .../Generic/NovationRGBDevice.cs | 4 -- .../Generic/RazerRGBDevice.cs | 6 +- .../Generic/SteelSeriesRGBDevice.cs | 6 +- .../Arduino/ArduinoWS2812USBDevice.cs | 5 +- .../Bitwizard/BitwizardWS2812USBDevice.cs | 6 +- .../NodeMCU/NodeMCUWS2812USBDevice.cs | 5 +- .../Keyboard/WootingKeyboardRGBDevice.cs | 3 - 13 files changed, 38 insertions(+), 82 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 596625c..fc18794 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -3,6 +3,7 @@ // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global using System; +using System.Buffers; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -100,12 +101,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice ledsToUpdate = GetLedsToUpdate(flushLeds).ToList(); - - foreach (Led led in ledsToUpdate) - led.Update(); - - UpdateLeds(ledsToUpdate); + UpdateLeds(GetLedsToUpdate(flushLeds)); } /// @@ -124,37 +120,38 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice /// The enumerable of leds to convert. /// The enumerable of custom data and color tuples for the specified leds. - protected virtual IEnumerable<(object key, Color color)> GetUpdateData(IEnumerable leds) + protected (object key, Color color) GetUpdateData(Led led) { - if (ColorCorrections.Count > 0) - { - foreach (Led led in leds) - { - Color color = led.Color; - object key = led.CustomData ?? led.Id; + Color color = led.Color; + object key = led.CustomData ?? led.Id; - foreach (IColorCorrection colorCorrection in ColorCorrections) - colorCorrection.ApplyTo(ref color); + // ReSharper disable once ForCanBeConvertedToForeach - This causes an allocation that's not really needed here + for (int i = 0; i < ColorCorrections.Count; i++) + ColorCorrections[i].ApplyTo(ref color); - yield return (key, color); - } - } - else - { - foreach (Led led in leds) - { - Color color = led.Color; - object key = led.CustomData ?? led.Id; - - yield return (key, color); - } - } + return (key, color); } /// /// Sends all the updated to the device. /// - protected virtual void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); + protected virtual void UpdateLeds(IEnumerable ledsToUpdate) + { + (object key, Color color)[] buffer = ArrayPool<(object, Color)>.Shared.Rent(LedMapping.Count); + + int counter = 0; + foreach (Led led in ledsToUpdate) + { + led.Update(); + + buffer[counter] = GetUpdateData(led); + ++counter; + } + + UpdateQueue.SetData(new ReadOnlySpan<(object, Color)>(buffer)[..counter]); + + ArrayPool<(object, Color)>.Shared.Return(buffer); + } /// public virtual void Dispose() diff --git a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs index bf4011c..2943379 100644 --- a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace RGB.NET.Core; @@ -21,7 +20,7 @@ public interface IUpdateQueue : IReferenceCounting, IDisposa /// /// The set of data. // ReSharper disable once MemberCanBeProtected.Global - void SetData(IEnumerable<(TIdentifier, TData)> dataSet); + void SetData(ReadOnlySpan<(TIdentifier, TData)> dataSet); /// /// Resets the current data set. diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index 72cec7e..c17e3a9 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.Collections.Generic; -using System.Linq; namespace RGB.NET.Core; @@ -88,10 +87,9 @@ public abstract class UpdateQueue : AbstractReferenceCountin /// /// The set of data. // ReSharper disable once MemberCanBeProtected.Global - public virtual void SetData(IEnumerable<(TIdentifier, TData)> dataSet) + public virtual void SetData(ReadOnlySpan<(TIdentifier, TData)> data) { - IList<(TIdentifier, TData)> data = dataSet.ToList(); - if (data.Count == 0) return; + if (data.Length == 0) return; lock (_dataLock) { diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs index 9fdbc79..7727006 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using RGB.NET.Core; +using RGB.NET.Core; namespace RGB.NET.Devices.Logitech; @@ -42,8 +40,5 @@ public class LogitechPerDeviceRGBDevice : LogitechRGBDevice protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId]; - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate.Take(1))); - #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs index 933603f..715079e 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using RGB.NET.Core; +using RGB.NET.Core; namespace RGB.NET.Devices.Logitech; @@ -33,9 +32,6 @@ public class LogitechPerKeyRGBDevice : LogitechRGBDevice, /// protected override object GetLedCustomData(LedId ledId) => _ledMapping.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : -1; - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs b/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs index 8820834..4909dcc 100644 --- a/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using RGB.NET.Core; +using RGB.NET.Core; namespace RGB.NET.Devices.Logitech; @@ -41,8 +40,5 @@ public class LogitechZoneRGBDevice : LogitechRGBDevice, I /// protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId]; - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index b64c72a..7a8f2eb 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.Novation; @@ -34,9 +33,6 @@ public abstract class NovationRGBDevice : AbstractRGBDevice throw new ArgumentOutOfRangeException() }; - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - /// /// Resets the back to default. /// diff --git a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs index 1a36595..c468948 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.Razer; @@ -27,10 +26,7 @@ public abstract class RazerRGBDevice : AbstractRGBDevice, IR #endregion #region Methods - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - + /// public override void Dispose() { diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs index debe441..f85213b 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using RGB.NET.Core; +using RGB.NET.Core; namespace RGB.NET.Devices.SteelSeries; @@ -43,8 +42,5 @@ public class SteelSeriesRGBDevice : AbstractRGBDevice, /// protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId]; - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs index 8d3d290..4f2bf09 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs @@ -53,9 +53,6 @@ public class ArduinoWS2812USBDevice : AbstractRGBDevice protected override IEnumerable GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : Enumerable.Empty(); - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs index a102126..1dc38cd 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs @@ -1,7 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global -using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.WS281X.Bitwizard; @@ -47,9 +46,6 @@ public class BitwizardWS2812USBDevice : AbstractRGBDevice protected override object GetLedCustomData(LedId ledId) => _ledOffset + ((int)ledId - (int)LedId.LedStripe1); - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs index d1a5b98..8c55f6b 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs @@ -55,9 +55,6 @@ public class NodeMCUWS2812USBDevice : AbstractRGBDevice protected override IEnumerable GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : Enumerable.Empty(); - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index eb0cc75..0f5882c 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -47,9 +47,6 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice protected override object GetLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.WootingDeviceType][ledId]; - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); - public override void Dispose() { _WootingSDK.SelectDevice(DeviceInfo.WootingDeviceIndex); From 0cf4f39ccf8e4d46a2b1aa09c87ece8495919c57 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 13 Apr 2023 00:21:20 +0200 Subject: [PATCH 31/96] Reduced allocations when a ListLedGroup is used --- RGB.NET.Core/Groups/AbstractLedGroup.cs | 12 +++++++- RGB.NET.Core/Groups/ILedGroup.cs | 3 ++ RGB.NET.Core/Groups/ListLedGroup.cs | 9 ++++++ RGB.NET.Core/Misc/ActionDisposable.cs | 27 ++++++++++++++++++ RGB.NET.Core/RGBSurface.cs | 38 +++++++++++++------------ 5 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 RGB.NET.Core/Misc/ActionDisposable.cs diff --git a/RGB.NET.Core/Groups/AbstractLedGroup.cs b/RGB.NET.Core/Groups/AbstractLedGroup.cs index 86659af..7135a21 100644 --- a/RGB.NET.Core/Groups/AbstractLedGroup.cs +++ b/RGB.NET.Core/Groups/AbstractLedGroup.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using System.Linq; @@ -61,5 +62,14 @@ public abstract class AbstractLedGroup : AbstractDecoratable /// public IEnumerator GetEnumerator() => GetLeds().GetEnumerator(); + /// + IDisposable? ILedGroup.ToListUnsafe(out IList leds) => ToListUnsafe(out leds); + + protected virtual IDisposable? ToListUnsafe(out IList leds) + { + leds = ToList(); + return null; + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs index 97ed8b2..1970afc 100644 --- a/RGB.NET.Core/Groups/ILedGroup.cs +++ b/RGB.NET.Core/Groups/ILedGroup.cs @@ -1,6 +1,7 @@ // ReSharper disable UnusedMemberInSuper.Global // ReSharper disable UnusedMember.Global +using System; using System.Collections.Generic; namespace RGB.NET.Core; @@ -45,4 +46,6 @@ public interface ILedGroup : IDecoratable, IEnumerable /// /// A list containing all in this group. IList ToList(); + + internal IDisposable? ToListUnsafe(out IList leds); } \ No newline at end of file diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index 9c51906..c6f7d54 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -1,7 +1,9 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global +using System; using System.Collections.Generic; +using System.Threading; namespace RGB.NET.Core; @@ -135,5 +137,12 @@ public class ListLedGroup : AbstractLedGroup return new List(GroupLeds); } + protected override IDisposable ToListUnsafe(out IList leds) + { + Monitor.Enter(GroupLeds); + leds = GroupLeds; + return new ActionDisposable(() => Monitor.Exit(GroupLeds)); + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Misc/ActionDisposable.cs b/RGB.NET.Core/Misc/ActionDisposable.cs new file mode 100644 index 0000000..843605e --- /dev/null +++ b/RGB.NET.Core/Misc/ActionDisposable.cs @@ -0,0 +1,27 @@ +using System; + +namespace RGB.NET.Core; + +public sealed class ActionDisposable : IDisposable +{ + #region Properties & Fields + + private readonly Action _onDispose; + + #endregion + + #region Constructors + + public ActionDisposable(Action onDispose) + { + this._onDispose = onDispose; + } + + #endregion + + #region Methods + + public void Dispose() => _onDispose(); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index fc8003f..5e022ed 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -208,26 +208,28 @@ public sealed class RGBSurface : AbstractBindable, IDisposable if ((brush == null) || !brush.IsEnabled) return; - IList leds = ledGroup.ToList(); - - IEnumerable<(RenderTarget renderTarget, Color color)> render; - switch (brush.CalculationMode) + using (ledGroup.ToListUnsafe(out IList leds)) { - case RenderMode.Relative: - Rectangle brushRectangle = new(leds); - Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y); - brushRectangle = brushRectangle.SetLocation(new Point(0, 0)); - render = brush.Render(brushRectangle, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary.Translate(offset)))); - break; - case RenderMode.Absolute: - render = brush.Render(Boundary, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary))); - break; - default: - throw new ArgumentException($"The CalculationMode '{brush.CalculationMode}' is not valid."); - } + IEnumerable<(RenderTarget renderTarget, Color color)> render; + switch (brush.CalculationMode) + { + case RenderMode.Relative: + Rectangle brushRectangle = new(leds); + Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y); + brushRectangle = brushRectangle.SetLocation(new Point(0, 0)); + render = brush.Render(brushRectangle, + leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary.Translate(offset)))); + break; + case RenderMode.Absolute: + render = brush.Render(Boundary, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary))); + break; + default: + throw new ArgumentException($"The CalculationMode '{brush.CalculationMode}' is not valid."); + } - foreach ((RenderTarget renderTarget, Color c) in render) - renderTarget.Led.Color = c; + foreach ((RenderTarget renderTarget, Color c) in render) + renderTarget.Led.Color = c; + } } /// From 70ccc4d5754ec86989e8cb3b83905f302f5740b2 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 13 Apr 2023 00:49:29 +0200 Subject: [PATCH 32/96] Reduced some more allocations --- RGB.NET.Core/Groups/ListLedGroup.cs | 14 ++++++++++++-- RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs | 4 +++- RGB.NET.Core/Update/ManualUpdateTrigger.cs | 6 +++--- RGB.NET.Core/Update/TimerUpdateTrigger.cs | 5 +++-- RGB.NET.Presets/Groups/RectangleLedGroup.cs | 3 ++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index c6f7d54..a97b6ec 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -15,6 +15,8 @@ public class ListLedGroup : AbstractLedGroup { #region Properties & Fields + private readonly ActionDisposable _unlockDisposable; + /// /// Gets the list containing the of this . /// @@ -31,7 +33,9 @@ public class ListLedGroup : AbstractLedGroup /// Specifies the surface to attach this group to or null if the group should not be attached on creation. public ListLedGroup(RGBSurface? surface) : base(surface) - { } + { + _unlockDisposable = new ActionDisposable(Unlock); + } /// /// @@ -42,6 +46,8 @@ public class ListLedGroup : AbstractLedGroup public ListLedGroup(RGBSurface? surface, IEnumerable leds) : base(surface) { + _unlockDisposable = new ActionDisposable(Unlock); + AddLeds(leds); } @@ -54,6 +60,8 @@ public class ListLedGroup : AbstractLedGroup public ListLedGroup(RGBSurface? surface, params Led[] leds) : base(surface) { + _unlockDisposable = new ActionDisposable(Unlock); + AddLeds(leds); } @@ -141,8 +149,10 @@ public class ListLedGroup : AbstractLedGroup { Monitor.Enter(GroupLeds); leds = GroupLeds; - return new ActionDisposable(() => Monitor.Exit(GroupLeds)); + return _unlockDisposable; } + private void Unlock() => Monitor.Exit(GroupLeds); + #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index db22aa4..00abcc7 100644 --- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -157,11 +157,13 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger using (TimerHelper.RequestHighResolutionTimer()) while (!UpdateToken.IsCancellationRequested) if (HasDataEvent.WaitOne(Timeout)) - LastUpdateTime = TimerHelper.Execute(() => OnUpdate(), UpdateFrequency * 1000); + LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000); else if ((HeartbeatTimer > 0) && (LastUpdateTimestamp > 0) && (TimerHelper.GetElapsedTime(LastUpdateTimestamp) > HeartbeatTimer)) OnUpdate(new CustomUpdateData().Heartbeat()); } + private void TimerExecute() => OnUpdate(); + protected override void OnUpdate(CustomUpdateData? updateData = null) { base.OnUpdate(updateData); diff --git a/RGB.NET.Core/Update/ManualUpdateTrigger.cs b/RGB.NET.Core/Update/ManualUpdateTrigger.cs index 67e8ca4..5cd4235 100644 --- a/RGB.NET.Core/Update/ManualUpdateTrigger.cs +++ b/RGB.NET.Core/Update/ManualUpdateTrigger.cs @@ -83,12 +83,12 @@ public sealed class ManualUpdateTrigger : AbstractUpdateTrigger OnStartup(); while (!UpdateToken.IsCancellationRequested) - { if (_mutex.WaitOne(100)) - LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData)); - } + LastUpdateTime = TimerHelper.Execute(TimerExecute); } + private void TimerExecute() => OnUpdate(_customUpdateData); + /// public override void Dispose() => Stop(); diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs index 14a7e9f..9f2b2b6 100644 --- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -131,10 +131,11 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger using (TimerHelper.RequestHighResolutionTimer()) while (!UpdateToken.IsCancellationRequested) - LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData), UpdateFrequency * 1000); - + LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000); } + private void TimerExecute() => OnUpdate(_customUpdateData); + /// public override void Dispose() { diff --git a/RGB.NET.Presets/Groups/RectangleLedGroup.cs b/RGB.NET.Presets/Groups/RectangleLedGroup.cs index d6cb650..cf66848 100644 --- a/RGB.NET.Presets/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Presets/Groups/RectangleLedGroup.cs @@ -2,6 +2,7 @@ // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable UnusedMember.Global +using System; using System.Collections.Generic; using System.Linq; using RGB.NET.Core; @@ -121,7 +122,7 @@ public class RectangleLedGroup : AbstractLedGroup /// Gets a list containing all of this . /// /// The list containing all of this . - public override IList ToList() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List()); + public override IList ToList() => _ledCache ??= ((IList?)Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? Array.Empty()); private void InvalidateCache() => _ledCache = null; From 4ee55c6725367e2c754b76df61aa0cfc8faeeb30 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 13 Apr 2023 01:24:53 +0200 Subject: [PATCH 33/96] Small fixes --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 2 ++ RGB.NET.Core/RGBSurface.cs | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index fc18794..a03bfa2 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -7,6 +7,7 @@ using System.Buffers; using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; namespace RGB.NET.Core; @@ -120,6 +121,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice /// The enumerable of leds to convert. /// The enumerable of custom data and color tuples for the specified leds. + [MethodImpl(MethodImplOptions.AggressiveInlining)] protected (object key, Color color) GetUpdateData(Led led) { Color color = led.Color; diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 5e022ed..8219191 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -217,8 +217,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable Rectangle brushRectangle = new(leds); Point offset = new(-brushRectangle.Location.X, -brushRectangle.Location.Y); brushRectangle = brushRectangle.SetLocation(new Point(0, 0)); - render = brush.Render(brushRectangle, - leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary.Translate(offset)))); + render = brush.Render(brushRectangle, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary.Translate(offset)))); break; case RenderMode.Absolute: render = brush.Render(Boundary, leds.Select(led => new RenderTarget(led, led.AbsoluteBoundary))); From 260a820b80379f172fbaedf4d0d61a408da7ab0a Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 13 Apr 2023 02:03:13 +0200 Subject: [PATCH 34/96] Added SkipLocalsInitAttribute to Sample-Methods --- RGB.NET.Core/Rendering/Textures/PixelTexture.cs | 1 + RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs | 2 ++ RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 3672e2c..4ea5f06 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -76,6 +76,7 @@ public abstract class PixelTexture : ITexture /// The with of the region. /// The height of the region. /// The sampled color. + [SkipLocalsInit] public virtual Color this[int x, int y, int width, int height] { get diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index 8d5b8b6..0486c5a 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -1,5 +1,6 @@ using System; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -19,6 +20,7 @@ public class AverageByteSampler : ISampler #region Methods /// + [SkipLocalsInit] public unsafe void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index 50e9563..b047773 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -1,5 +1,6 @@ using System; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -13,6 +14,7 @@ public class AverageFloatSampler : ISampler #region Methods /// + [SkipLocalsInit] public unsafe void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; From ad757076458eb5fc9bcfc818bd13d0ccc248098b Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 13 Apr 2023 11:29:22 +0200 Subject: [PATCH 35/96] Removed SkipLocalInit-Attributes - they're causing issues and are not worth the effort for now --- RGB.NET.Core/Rendering/Textures/PixelTexture.cs | 1 - RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs | 2 -- RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs | 2 -- 3 files changed, 5 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 4ea5f06..3672e2c 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -76,7 +76,6 @@ public abstract class PixelTexture : ITexture /// The with of the region. /// The height of the region. /// The sampled color. - [SkipLocalsInit] public virtual Color this[int x, int y, int width, int height] { get diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index 0486c5a..8d5b8b6 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -20,7 +19,6 @@ public class AverageByteSampler : ISampler #region Methods /// - [SkipLocalsInit] public unsafe void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index b047773..50e9563 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -14,7 +13,6 @@ public class AverageFloatSampler : ISampler #region Methods /// - [SkipLocalsInit] public unsafe void Sample(in SamplerInfo info, in Span pixelData) { int count = info.Width * info.Height; From d9c244a044f2bd576f2670348352b843392975a7 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 19 Apr 2023 20:11:30 +0200 Subject: [PATCH 36/96] Small fixes --- RGB.NET.Core/MVVM/IBindable.cs | 3 +-- RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj | 4 ++-- RGB.NET.Devices.Corsair/Native/_CUESDK.cs | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/RGB.NET.Core/MVVM/IBindable.cs b/RGB.NET.Core/MVVM/IBindable.cs index 34a861d..24d1fa5 100644 --- a/RGB.NET.Core/MVVM/IBindable.cs +++ b/RGB.NET.Core/MVVM/IBindable.cs @@ -6,5 +6,4 @@ namespace RGB.NET.Core; /// Represents a basic bindable class which notifies when a property value changes. /// public interface IBindable : INotifyPropertyChanged -{ -} \ No newline at end of file +{ } \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index f7a9c4b..dc67689 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -40,7 +40,7 @@ - $(DefineConstants);TRACE;DEBUG + TRACE;DEBUG true false @@ -48,7 +48,7 @@ true $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE + RELEASE diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index d3593ee..00d9f92 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -91,11 +91,7 @@ internal static unsafe class _CUESDK if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); if (!NativeLibrary.TryLoad(dllPath, out _handle)) -#if NET6_0_OR_GREATER throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}"); -#else - throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}"); -#endif _corsairConnectPtr = (delegate* unmanaged[Cdecl])LoadFunction("CorsairConnect"); _corsairGetSessionDetails = (delegate* unmanaged[Cdecl])LoadFunction("CorsairGetSessionDetails"); From 20209922499fa885cd7d6c66b75784081f1bbc69 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 19 Apr 2023 21:19:05 +0200 Subject: [PATCH 37/96] Sealed a lot of classes that are not meant to be inherited --- RGB.NET.Core/Groups/ListLedGroup.cs | 32 ++++----- RGB.NET.Core/Leds/Led.cs | 2 +- RGB.NET.Core/Leds/LedMapping.cs | 2 +- .../Rendering/Brushes/SolidColorBrush.cs | 2 +- .../Rendering/Brushes/TextureBrush.cs | 2 +- .../Rendering/Textures/EmptyTexture.cs | 2 +- RGB.NET.Core/Update/CustomUpdateData.cs | 6 +- RGB.NET.Core/Update/TimerUpdateTrigger.cs | 33 +++++---- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 4 +- .../Generic/AsusUnspecifiedRGBDevice.cs | 2 +- .../Generic/AsusUpdateQueue.cs | 12 ++-- .../GraphicsCard/AsusGraphicsCardRGBDevice.cs | 2 +- .../Headset/AsusHeadsetRGBDevice.cs | 2 +- .../Keyboard/AsusKeyboardRGBDevice.cs | 2 +- .../Keyboard/AsusKeyboardRGBDeviceInfo.cs | 2 +- .../Mainboard/AsusMainboardRGBDevice.cs | 2 +- .../Mouse/AsusMouseRGBDevice.cs | 2 +- .../Attributes/DeviceTypeAttribute.cs | 2 +- .../CoolerMasterDeviceProvider.cs | 4 +- .../Enum/CoolerMasterDevicesIndexes.cs | 2 - .../Enum/CoolerMasterEffects.cs | 40 ----------- .../Generic/CoolerMasterUpdateQueue.cs | 2 +- .../Keyboard/CoolerMasterKeyboardRGBDevice.cs | 2 +- .../CoolerMasterKeyboardRGBDeviceInfo.cs | 2 +- .../Mouse/CoolerMasterMouseRGBDevice.cs | 2 +- .../Mouse/CoolerMasterMouseRGBDeviceInfo.cs | 2 +- .../Cooler/CorsairCoolerRGBDevice.cs | 2 +- .../Cooler/CorsairCoolerRGBDeviceInfo.cs | 2 +- .../CorsairDeviceProvider.cs | 4 +- .../Exceptions/CUEException.cs | 2 +- .../Fan/CorsairFanRGBDevice.cs | 2 +- .../Fan/CorsairFanRGBDeviceInfo.cs | 2 +- .../Generic/CorsairDeviceUpdateQueue.cs | 4 +- .../Generic/CorsairProtocolDetails.cs | 2 +- .../CorsairGraphicsCardRGBDevice.cs | 2 +- .../CorsairGraphicsCardRGBDeviceInfo.cs | 2 +- .../Headset/CorsairHeadsetRGBDevice.cs | 2 +- .../Headset/CorsairHeadsetRGBDeviceInfo.cs | 2 +- .../CorsairHeadsetStandRGBDevice.cs | 2 +- .../CorsairHeadsetStandRGBDeviceInfo.cs | 2 +- .../Keyboard/CorsairKeyboardRGBDevice.cs | 2 +- .../Keyboard/CorsairKeyboardRGBDeviceInfo.cs | 2 +- .../LedStrip/CorsairLedStripGBDevice.cs | 2 +- .../LedStrip/CorsairLedStripRGBDeviceInfo.cs | 2 +- .../Mainboard/CorsairMainboardRGBDevice.cs | 2 +- .../CorsairMainboardRGBDeviceInfo.cs | 2 +- .../Memory/CorsairMemoryRGBDevice.cs | 2 +- .../Memory/CorsairMemoryRGBDeviceInfo.cs | 2 +- .../Mouse/CorsairMouseRGBDevice.cs | 2 +- .../Mouse/CorsairMouseRGBDeviceInfo.cs | 2 +- .../Mousepad/CorsairMousepadRGBDevice.cs | 2 +- .../Mousepad/CorsairMousepadRGBDeviceInfo.cs | 2 +- .../Native/_CorsairDeviceFilter.cs | 2 +- .../Native/_CorsairDeviceInfo.cs | 2 +- .../Native/_CorsairLedPosition.cs | 2 +- .../Native/_CorsairSessionDetails.cs | 2 +- .../Native/_CorsairSessionStateChanged.cs | 2 +- .../Native/_CorsairVersion.cs | 2 +- .../Touchbar/CorsairTouchbarRGBDevice.cs | 2 +- .../Touchbar/CorsairTouchbarRGBDeviceInfo.cs | 2 +- .../Unknown/CorsairUnknownRGBDevice.cs | 2 +- .../Unknown/CorsairUnknownRGBDeviceInfo.cs | 2 +- RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 2 +- .../E131/E131DMXDeviceDefinition.cs | 2 +- RGB.NET.Devices.DMX/E131/E131Device.cs | 2 +- RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs | 2 +- RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs | 2 +- .../Generic/LedChannelMapping.cs | 2 +- RGB.NET.Devices.Debug/DebugDeviceProvider.cs | 4 +- .../DebugDeviceUpdateQueue.cs | 2 +- RGB.NET.Devices.Debug/DebugRGBDevice.cs | 2 +- RGB.NET.Devices.Debug/DebugRGBDeviceInfo.cs | 2 +- .../HID/LightspeedHidLoader.cs | 2 +- .../PerDevice/LogitechPerDeviceRGBDevice.cs | 2 +- .../PerDevice/LogitechPerDeviceUpdateQueue.cs | 2 +- .../PerKey/LogitechPerKeyRGBDevice.cs | 2 +- .../PerKey/LogitechPerKeyUpdateQueue.cs | 5 +- .../Zone/LogitechZoneRGBDevice.cs | 2 +- .../Zone/LogitechZoneUpdateQueue.cs | 2 +- .../Exceptions/MysticLightException.cs | 2 +- .../Generic/MsiDeviceUpdateQueue.cs | 2 +- .../GraphicsCard/MsiGraphicsCardRGBDevice.cs | 2 +- .../Mainboard/MsiMainboardRGBDevice.cs | 2 +- .../Mouse/MsiMouseRGBDevice.cs | 2 +- .../Attributes/ColorCapabilityAttribute.cs | 2 +- .../Attributes/DeviceIdAttribute.cs | 2 +- .../Attributes/LedIdMappingAttribute.cs | 2 +- .../Generic/LimitedColorUpdateQueue.cs | 4 +- .../Generic/RGBColorUpdateQueue.cs | 4 +- .../Launchpad/NovationLaunchpadRGBDevice.cs | 4 +- .../NovationLaunchpadRGBDeviceInfo.cs | 2 +- .../NovationDeviceProvider.cs | 2 +- .../Generic/OpenRGBGenericDevice.cs | 2 +- .../Generic/OpenRGBUpdateQueue.cs | 2 +- .../OpenRGBDeviceProvider.cs | 4 +- .../OpenRGBServerDefinition.cs | 2 +- .../PerZone/OpenRGBZoneDevice.cs | 2 +- .../Segment/OpenRGBSegmentDevice.cs | 2 +- .../PicoPi/PicoPiBulkUpdateQueue.cs | 2 +- .../PicoPi/PicoPiHIDUpdateQueue.cs | 2 +- .../PicoPi/PicoPiRGBDevice.cs | 2 +- .../PicoPi/PicoPiRGBDeviceInfo.cs | 2 +- RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs | 4 +- .../PicoPiDeviceProvider.cs | 2 +- .../ChromaLink/RazerChromaLinkRGBDevice.cs | 2 +- .../ChromaLink/RazerChromaLinkUpdateQueue.cs | 2 +- .../Exceptions/RazerException.cs | 2 +- RGB.NET.Devices.Razer/Generic/Devices.cs | 70 ------------------- .../Headset/RazerHeadsetRGBDevice.cs | 2 +- .../Headset/RazerHeadsetUpdateQueue.cs | 2 +- .../Keyboard/RazerKeyboardRGBDevice.cs | 2 +- .../Keyboard/RazerKeyboardRGBDeviceInfo.cs | 2 +- .../Keyboard/RazerKeyboardUpdateQueue.cs | 2 +- .../Keypad/RazerKeypadRGBDevice.cs | 2 +- .../Keypad/RazerKeypadUpdateQueue.cs | 2 +- .../Mouse/RazerMouseRGBDevice.cs | 2 +- .../Mouse/RazerMouseUpdateQueue.cs | 2 +- .../Mousepad/RazerMousepadRGBDevice.cs | 2 +- .../Mousepad/RazerMousepadUpdateQueue.cs | 2 +- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 4 +- .../API/Model/CoreProps.cs | 2 +- .../API/Model/Event.cs | 2 +- RGB.NET.Devices.SteelSeries/API/Model/Game.cs | 2 +- .../API/Model/GoLispHandler.cs | 2 +- .../Attribute/APIName.cs | 2 +- .../Generic/SteelSeriesDeviceUpdateQueue.cs | 2 +- .../Generic/SteelSeriesRGBDevice.cs | 2 +- .../Generic/SteelSeriesRGBDeviceInfo.cs | 2 +- .../SteelSeriesDeviceProvider.cs | 6 +- .../Arduino/ArduinoWS2812USBDevice.cs | 2 +- .../Arduino/ArduinoWS2812USBDeviceInfo.cs | 2 +- .../Arduino/ArduinoWS2812USBUpdateQueue.cs | 2 +- .../Arduino/ArduinoWS281XDeviceDefinition.cs | 2 +- .../Bitwizard/BitwizardWS2812USBDevice.cs | 2 +- .../Bitwizard/BitwizardWS2812USBDeviceInfo.cs | 2 +- .../BitwizardWS2812USBUpdateQueue.cs | 2 +- .../BitwizardWS281XDeviceDefinition.cs | 2 +- .../Generic/SerialPortConnection.cs | 7 +- .../NodeMCU/NodeMCUWS2812USBDevice.cs | 2 +- .../NodeMCU/NodeMCUWS2812USBDeviceInfo.cs | 2 +- .../NodeMCU/NodeMCUWS2812USBUpdateQueue.cs | 4 +- .../NodeMCU/NodeMCUWS281XDeviceDefinition.cs | 2 +- .../WS281XDeviceProvider.cs | 4 +- .../Generic/WootingUpdateQueue.cs | 4 +- .../Keyboard/WootingKeyboardRGBDevice.cs | 7 +- .../Keyboard/WootingKeyboardRGBDeviceInfo.cs | 2 +- .../WootingDeviceProvider.cs | 4 +- RGB.NET.HID/HIDLoader.cs | 2 +- RGB.NET.Presets/Decorators/FlashDecorator.cs | 2 +- RGB.NET.Presets/Groups/RectangleLedGroup.cs | 2 +- .../Textures/Gradients/GradientStop.cs | 2 +- .../Textures/Gradients/LinearGradient.cs | 11 +-- .../Textures/Gradients/RainbowGradient.cs | 4 +- .../Textures/Sampler/AverageByteSampler.cs | 2 +- .../Textures/Sampler/AverageFloatSampler.cs | 2 +- 155 files changed, 205 insertions(+), 344 deletions(-) delete mode 100644 RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterEffects.cs delete mode 100644 RGB.NET.Devices.Razer/Generic/Devices.cs diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index a97b6ec..4bca2fb 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -11,7 +11,7 @@ namespace RGB.NET.Core; /// /// Represents a ledgroup containing arbitrary . /// -public class ListLedGroup : AbstractLedGroup +public sealed class ListLedGroup : AbstractLedGroup { #region Properties & Fields @@ -20,7 +20,7 @@ public class ListLedGroup : AbstractLedGroup /// /// Gets the list containing the of this . /// - protected IList GroupLeds { get; } = new List(); + private readonly IList _groupLeds = new List(); #endregion @@ -81,10 +81,10 @@ public class ListLedGroup : AbstractLedGroup /// The to add. public void AddLeds(IEnumerable leds) { - lock (GroupLeds) + lock (_groupLeds) foreach (Led led in leds) if (!ContainsLed(led)) - GroupLeds.Add(led); + _groupLeds.Add(led); } /// @@ -99,9 +99,9 @@ public class ListLedGroup : AbstractLedGroup /// The to remove. public void RemoveLeds(IEnumerable leds) { - lock (GroupLeds) + lock (_groupLeds) foreach (Led led in leds) - GroupLeds.Remove(led); + _groupLeds.Remove(led); } /// @@ -111,8 +111,8 @@ public class ListLedGroup : AbstractLedGroup /// true if the LED is contained by this ledgroup; otherwise, false. public bool ContainsLed(Led led) { - lock (GroupLeds) - return GroupLeds.Contains(led); + lock (_groupLeds) + return _groupLeds.Contains(led); } /// @@ -121,10 +121,10 @@ public class ListLedGroup : AbstractLedGroup /// The ledgroup to merge. public void MergeLeds(ILedGroup groupToMerge) { - lock (GroupLeds) + lock (_groupLeds) foreach (Led led in groupToMerge) - if (!GroupLeds.Contains(led)) - GroupLeds.Add(led); + if (!_groupLeds.Contains(led)) + _groupLeds.Add(led); } /// @@ -141,18 +141,18 @@ public class ListLedGroup : AbstractLedGroup /// The list containing the . public override IList ToList() { - lock (GroupLeds) - return new List(GroupLeds); + lock (_groupLeds) + return new List(_groupLeds); } protected override IDisposable ToListUnsafe(out IList leds) { - Monitor.Enter(GroupLeds); - leds = GroupLeds; + Monitor.Enter(_groupLeds); + leds = _groupLeds; return _unlockDisposable; } - private void Unlock() => Monitor.Exit(GroupLeds); + private void Unlock() => Monitor.Exit(_groupLeds); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index ad2e3f9..2fb05ea 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Core; /// Represents a single LED of a RGB-device. /// [DebuggerDisplay("{Id} {Color}")] -public class Led : Placeable +public sealed class Led : Placeable { #region Properties & Fields diff --git a/RGB.NET.Core/Leds/LedMapping.cs b/RGB.NET.Core/Leds/LedMapping.cs index 05a10ec..0aab16d 100644 --- a/RGB.NET.Core/Leds/LedMapping.cs +++ b/RGB.NET.Core/Leds/LedMapping.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Core; /// Represents a mapping from to a custom identifier. /// /// The identifier the is mapped to. -public class LedMapping : IEnumerable<(LedId ledId, T mapping)> +public sealed class LedMapping : IEnumerable<(LedId ledId, T mapping)> where T : notnull { #region Constants diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs index 4175db1..158705c 100644 --- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Core; /// /// Represents a brush drawing only a single color. /// -public class SolidColorBrush : AbstractBrush +public sealed class SolidColorBrush : AbstractBrush { #region Properties & Fields diff --git a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs index 4a2de6e..41280cd 100644 --- a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs @@ -4,7 +4,7 @@ /// /// Represents a brush drawing a texture. /// -public class TextureBrush : AbstractBrush +public sealed class TextureBrush : AbstractBrush { #region Properties & Fields diff --git a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs index 588b62b..7aca9b7 100644 --- a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs @@ -1,6 +1,6 @@ namespace RGB.NET.Core; -internal class EmptyTexture : ITexture +internal sealed class EmptyTexture : ITexture { #region Properties & Fields diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index a657e96..4888cd1 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -48,7 +48,7 @@ public interface ICustomUpdateData /// /// Represents a set of custom data, each indexed by a string-key. /// -public class CustomUpdateData : ICustomUpdateData +public sealed class CustomUpdateData : ICustomUpdateData { #region Properties & Fields @@ -92,7 +92,7 @@ public class CustomUpdateData : ICustomUpdateData #endregion } -internal class DefaultCustomUpdateData : ICustomUpdateData +internal sealed class DefaultCustomUpdateData : ICustomUpdateData { #region Constants @@ -120,7 +120,7 @@ internal class DefaultCustomUpdateData : ICustomUpdateData #region Constructors - public DefaultCustomUpdateData(bool flushLeds) + private DefaultCustomUpdateData(bool flushLeds) { this._flushLeds = flushLeds; } diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs index 9f2b2b6..6b94b3f 100644 --- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Core; /// /// Represents an update trigger that triggers in a set interval. /// -public class TimerUpdateTrigger : AbstractUpdateTrigger +public sealed class TimerUpdateTrigger : AbstractUpdateTrigger { #region Properties & Fields @@ -21,17 +21,17 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger /// /// Gets or sets the update loop of this trigger. /// - protected Task? UpdateTask { get; set; } + private Task? _updateTask; /// - /// Gets or sets the cancellation token source used to create the cancellation token checked by the . + /// Gets or sets the cancellation token source used to create the cancellation token checked by the . /// - protected CancellationTokenSource? UpdateTokenSource { get; set; } + private CancellationTokenSource? _updateTokenSource; /// - /// Gets or sets the cancellation token checked by the . + /// Gets or sets the cancellation token checked by the . /// - protected CancellationToken UpdateToken { get; set; } + private CancellationToken _updateToken; private double _updateFrequency = 1.0 / 30.0; /// @@ -88,11 +88,11 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger { lock (_lock) { - if (UpdateTask == null) + if (_updateTask == null) { - UpdateTokenSource?.Dispose(); - UpdateTokenSource = new CancellationTokenSource(); - UpdateTask = Task.Factory.StartNew(UpdateLoop, (UpdateToken = UpdateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default); + _updateTokenSource?.Dispose(); + _updateTokenSource = new CancellationTokenSource(); + _updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default); } } } @@ -104,13 +104,13 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger { lock (_lock) { - if (UpdateTask != null) + if (_updateTask != null) { - UpdateTokenSource?.Cancel(); + _updateTokenSource?.Cancel(); try { // ReSharper disable once MethodSupportsCancellation - UpdateTask.Wait(); + _updateTask.Wait(); } catch (AggregateException) { @@ -118,8 +118,8 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger } finally { - UpdateTask.Dispose(); - UpdateTask = null; + _updateTask.Dispose(); + _updateTask = null; } } } @@ -130,7 +130,7 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger OnStartup(); using (TimerHelper.RequestHighResolutionTimer()) - while (!UpdateToken.IsCancellationRequested) + while (!_updateToken.IsCancellationRequested) LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000); } @@ -140,7 +140,6 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger public override void Dispose() { Stop(); - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index f9af5b3..318850e 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a device provider responsible for Cooler Master devices. /// -public class AsusDeviceProvider : AbstractRGBDeviceProvider +public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -88,8 +88,6 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider _devices = null; _sdk = null; - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs index bb40578..fe3c238 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a Asus headset. /// -public class AsusUnspecifiedRGBDevice : AsusRGBDevice, IUnknownDevice +public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice, IUnknownDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs index 012ed7e..2f40ec6 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents the update-queue performing updates for asus devices. /// -public class AsusUpdateQueue : UpdateQueue +public sealed class AsusUpdateQueue : UpdateQueue { #region Properties & Fields @@ -17,7 +17,7 @@ public class AsusUpdateQueue : UpdateQueue /// /// The device to be updated. /// - protected IAuraSyncDevice Device { get; } + private readonly IAuraSyncDevice _device; #endregion @@ -31,7 +31,7 @@ public class AsusUpdateQueue : UpdateQueue public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger, IAuraSyncDevice device) : base(updateTrigger) { - this.Device = device; + this._device = device; this._lights = new IAuraRgbLight[device.Lights.Count]; for (int i = 0; i < device.Lights.Count; i++) @@ -47,9 +47,9 @@ public class AsusUpdateQueue : UpdateQueue { try { - if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB)) + if ((_device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (_device.Type == (uint)AsusDeviceType.NB_KB_RGB)) { - if (Device is not IAuraSyncKeyboard keyboard) + if (_device is not IAuraSyncKeyboard keyboard) return true; foreach ((object customData, Color value) in dataSet) @@ -87,7 +87,7 @@ public class AsusUpdateQueue : UpdateQueue } } - Device.Apply(); + _device.Apply(); return true; } diff --git a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs index 15c2383..1debf59 100644 --- a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a Asus graphicsCard. /// -public class AsusGraphicsCardRGBDevice : AsusRGBDevice, IGraphicsCard +public sealed class AsusGraphicsCardRGBDevice : AsusRGBDevice, IGraphicsCard { #region Constructors diff --git a/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs b/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs index 71f9e10..516dab6 100644 --- a/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a Asus headset. /// -public class AsusHeadsetRGBDevice : AsusRGBDevice, IHeadset +public sealed class AsusHeadsetRGBDevice : AsusRGBDevice, IHeadset { #region Constructors diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 86f64aa..30b429c 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -20,7 +20,7 @@ public record AsusKeyboardExtraMapping(Regex Regex, LedMapping LedMapping); /// /// Represents a Asus keyboard. /// -public class AsusKeyboardRGBDevice : AsusRGBDevice, IKeyboard +public sealed class AsusKeyboardRGBDevice : AsusRGBDevice, IKeyboard { #region Properties & Fields diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index 4173271..b40ec59 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a generic information for a . /// -public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo +public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs index 2f92bb6..137ae90 100644 --- a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a Asus mainboard. /// -public class AsusMainboardRGBDevice : AsusRGBDevice, IMainboard +public sealed class AsusMainboardRGBDevice : AsusRGBDevice, IMainboard { #region Constructors diff --git a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs index 3db166a..e4ae049 100644 --- a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a Asus mouse. /// -public class AsusMouseRGBDevice : AsusRGBDevice, IMouse +public sealed class AsusMouseRGBDevice : AsusRGBDevice, IMouse { #region Constructors diff --git a/RGB.NET.Devices.CoolerMaster/Attributes/DeviceTypeAttribute.cs b/RGB.NET.Devices.CoolerMaster/Attributes/DeviceTypeAttribute.cs index 8aad300..07245cb 100644 --- a/RGB.NET.Devices.CoolerMaster/Attributes/DeviceTypeAttribute.cs +++ b/RGB.NET.Devices.CoolerMaster/Attributes/DeviceTypeAttribute.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// Specifies the of a field. /// [AttributeUsage(AttributeTargets.Field)] -public class DeviceTypeAttribute : Attribute +public sealed class DeviceTypeAttribute : Attribute { #region Properties & Fields diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index e51ed8a..ab16a45 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a device provider responsible for Cooler Master devices. /// -public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider +public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -100,8 +100,6 @@ public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider try { _CoolerMasterSDK.Reload(); } catch { /* Unlucky.. */ } - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs index f528ccf..66eb53b 100644 --- a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs +++ b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs @@ -4,8 +4,6 @@ using System.ComponentModel; using RGB.NET.Core; -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - namespace RGB.NET.Devices.CoolerMaster; /// diff --git a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterEffects.cs b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterEffects.cs deleted file mode 100644 index b9fcaa1..0000000 --- a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterEffects.cs +++ /dev/null @@ -1,40 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.CoolerMaster; - -/// -/// Contains a list of available effects. -/// -public enum CoolerMasterEffects -{ - FullOn = 0, - Breath = 1, - BreathCycle = 2, - Single = 3, - Wave = 4, - Ripple = 5, - Cross = 6, - Rain = 7, - Star = 8, - Snake = 9, - Rec = 10, - - Spectrum = 11, - RapidFire = 12, - Indicator = 13, //mouse Effect - FireBall = 14, - WaterRipple = 15, - ReactivePunch = 16, - Snowing = 17, - HeartBeat = 18, - ReactiveTornade = 19, - - Multi1 = 0xE0, - Multi2 = 0xE1, - Multi3 = 0xE2, - Multi4 = 0xE3, - Off = 0xFE -} \ No newline at end of file diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs index 4121c4f..99e1428 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents the update-queue performing updates for cooler master devices. /// -public class CoolerMasterUpdateQueue : UpdateQueue +public sealed class CoolerMasterUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs index 29b1e3c..1d03191 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a CoolerMaster keyboard. /// -public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice, IKeyboard +public sealed class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice, IKeyboard { #region Properties & Fields diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs index df9fec9..591a62f 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs @@ -5,7 +5,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a generic information for a . /// -public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo +public sealed class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs index 16ba91c..53e4522 100644 --- a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a CoolerMaster mouse. /// -public class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice, IMouse +public sealed class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice, IMouse { #region Constructors diff --git a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDeviceInfo.cs b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDeviceInfo.cs index 14f6b0e..2698216 100644 --- a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDeviceInfo.cs +++ b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDeviceInfo.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a generic information for a . /// -public class CoolerMasterMouseRGBDeviceInfo : CoolerMasterRGBDeviceInfo +public sealed class CoolerMasterMouseRGBDeviceInfo : CoolerMasterRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs index fd5b89b..e92a731 100644 --- a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair cooler. /// -public class CorsairCoolerRGBDevice : CorsairRGBDevice, ICooler +public sealed class CorsairCoolerRGBDevice : CorsairRGBDevice, ICooler { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs index 958f129..96333b4 100644 --- a/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Cooler/CorsairCoolerRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index ac363b9..87ab725 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a device provider responsible for corsair (CUE) devices. /// -public class CorsairDeviceProvider : AbstractRGBDeviceProvider +public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -306,8 +306,6 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ } try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ } - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Corsair/Exceptions/CUEException.cs b/RGB.NET.Devices.Corsair/Exceptions/CUEException.cs index aca2994..902860f 100644 --- a/RGB.NET.Devices.Corsair/Exceptions/CUEException.cs +++ b/RGB.NET.Devices.Corsair/Exceptions/CUEException.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents an exception thrown by the CUE. /// -public class CUEException : ApplicationException +public sealed class CUEException : ApplicationException { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs index 6520081..eb91492 100644 --- a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair fan. /// -public class CorsairFanRGBDevice : CorsairRGBDevice, IFan +public sealed class CorsairFanRGBDevice : CorsairRGBDevice, IFan { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs index f4973c5..35124d0 100644 --- a/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Fan/CorsairFanRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs index 8bea2eb..be3a3bf 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairDeviceUpdateQueue.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents the update-queue performing updates for corsair devices. /// -public class CorsairDeviceUpdateQueue : UpdateQueue +public sealed class CorsairDeviceUpdateQueue : UpdateQueue { #region Properties & Fields @@ -76,8 +76,6 @@ public class CorsairDeviceUpdateQueue : UpdateQueue _isDisposed = true; Marshal.FreeHGlobal(_colorPtr); - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs index 7069776..afca46b 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairProtocolDetails.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents version information for the Corsair-SDK /// -public class CorsairSessionDetails +public sealed class CorsairSessionDetails { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs index ce7fb8c..51aa88a 100644 --- a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair graphics card. /// -public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice, IGraphicsCard +public sealed class CorsairGraphicsCardRGBDevice : CorsairRGBDevice, IGraphicsCard { #region Constructors diff --git a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs index ec5b436..7c57ff0 100644 --- a/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index c2336d6..1cbd113 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair headset. /// -public class CorsairHeadsetRGBDevice : CorsairRGBDevice, IHeadset +public sealed class CorsairHeadsetRGBDevice : CorsairRGBDevice, IHeadset { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs index 5bac705..c7de7f9 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs index 7103b76..5d79725 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair headset stand. /// -public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice, IHeadsetStand +public sealed class CorsairHeadsetStandRGBDevice : CorsairRGBDevice, IHeadsetStand { #region Constructors diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs index cc6b274..48b2049 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index d1fa931..5133619 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair keyboard. /// -public class CorsairKeyboardRGBDevice : CorsairRGBDevice, IKeyboard +public sealed class CorsairKeyboardRGBDevice : CorsairRGBDevice, IKeyboard { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs index dcab088..8f5774c 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo +public sealed class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs index 53eb5b0..9f46411 100644 --- a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs +++ b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair ledStrip. /// -public class CorsairLedStripRGBDevice : CorsairRGBDevice, ILedStripe +public sealed class CorsairLedStripRGBDevice : CorsairRGBDevice, ILedStripe { #region Constructors diff --git a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs index 35006b8..a6497ac 100644 --- a/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/LedStrip/CorsairLedStripRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs index 55ab92c..98c02e1 100644 --- a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair memory. /// -public class CorsairMainboardRGBDevice : CorsairRGBDevice, IMainboard +public sealed class CorsairMainboardRGBDevice : CorsairRGBDevice, IMainboard { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs index 4058d10..761f951 100644 --- a/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mainboard/CorsairMainboardRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs index 48b2eb3..ec35a34 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair memory. /// -public class CorsairMemoryRGBDevice : CorsairRGBDevice, IDRAM +public sealed class CorsairMemoryRGBDevice : CorsairRGBDevice, IDRAM { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs index 8d779f7..326bd80 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index 89f25c4..4f66d31 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair mouse. /// -public class CorsairMouseRGBDevice : CorsairRGBDevice, IMouse +public sealed class CorsairMouseRGBDevice : CorsairRGBDevice, IMouse { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs index 422b18a..b5ab17d 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index ac7a9b3..7c005ea 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair mousepad. /// -public class CorsairMousepadRGBDevice : CorsairRGBDevice, IMousepad +public sealed class CorsairMousepadRGBDevice : CorsairRGBDevice, IMousepad { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs index 6b469c0..901f54f 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs index 76f179d..f598d27 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains device search filter /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairDeviceFilter +internal sealed class _CorsairDeviceFilter { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs index f122879..b4c8813 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceInfo.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains information about device /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairDeviceInfo +internal sealed class _CorsairDeviceInfo { /// /// iCUE-SDK: enum describing device type diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs index b2ff0fe..af2bad1 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains led id and position of led /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairLedPosition +internal sealed class _CorsairLedPosition { /// /// iCUE-SDK: unique identifier of led diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs b/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs index 392a30b..2fbf755 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairSessionDetails.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains information about SDK and iCUE versions /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairSessionDetails +internal sealed class _CorsairSessionDetails { /// /// iCUE-SDK: version of SDK client (like {4,0,1}). Always contains valid value even if there was no iCUE found. Must comply with the semantic versioning rules. diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs b/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs index 99aa8fd..07b1a38 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairSessionStateChanged.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains information about session state and client/server versions /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairSessionStateChanged +internal sealed class _CorsairSessionStateChanged { /// /// iCUE-SDK: new session state which SDK client has been transitioned to diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs b/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs index 790226e..d786b0f 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairVersion.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native; /// iCUE-SDK: contains information about version that consists of three components /// [StructLayout(LayoutKind.Sequential)] -internal class _CorsairVersion +internal sealed class _CorsairVersion { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs index d704343..d5f9248 100644 --- a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a corsair touchbar. /// -public class CorsairTouchbarRGBDevice : CorsairRGBDevice, ILedStripe +public sealed class CorsairTouchbarRGBDevice : CorsairRGBDevice, ILedStripe { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs index 68ea4f0..04f400d 100644 --- a/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Touchbar/CorsairTouchbarRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs index d860336..655bafc 100644 --- a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a unknown corsair device. /// -public class CorsairUnknownRGBDevice : CorsairRGBDevice, IUnknownDevice +public sealed class CorsairUnknownRGBDevice : CorsairRGBDevice, IUnknownDevice { #region Constructors diff --git a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs index e9b6da5..770f65b 100644 --- a/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Unknown/CorsairUnknownRGBDeviceInfo.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair; /// /// Represents a generic information for a . /// -public class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo +public sealed class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo { #region Constructors diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index 55e8e3f..2d85a44 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.DMX; /// /// Represents a device provider responsible for DMX devices. /// -public class DMXDeviceProvider : AbstractRGBDeviceProvider +public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields diff --git a/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs index 37db5ea..8e0934b 100644 --- a/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs +++ b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.DMX.E131; /// /// Represents the data used to create a E1.31 DMX-device. /// -public class E131DMXDeviceDefinition : IDMXDeviceDefinition +public sealed class E131DMXDeviceDefinition : IDMXDeviceDefinition { #region Properties & Fields diff --git a/RGB.NET.Devices.DMX/E131/E131Device.cs b/RGB.NET.Devices.DMX/E131/E131Device.cs index a7d3473..5955ddb 100644 --- a/RGB.NET.Devices.DMX/E131/E131Device.cs +++ b/RGB.NET.Devices.DMX/E131/E131Device.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.DMX.E131; /// /// Represents a E1.31-DXM-device. /// -public class E131Device : AbstractRGBDevice, IUnknownDevice +public sealed class E131Device : AbstractRGBDevice, IUnknownDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs index 330a740..db805f7 100644 --- a/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs +++ b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.DMX.E131; /// /// Represents device information for a />. /// -public class E131DeviceInfo : IRGBDeviceInfo +public sealed class E131DeviceInfo : IRGBDeviceInfo { #region Constants diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index 57159e9..7ebdab8 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.DMX.E131; /// /// Represents the update-queue performing updates for E131-DMX devices. /// -public class E131UpdateQueue : UpdateQueue +public sealed class E131UpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs index 2f999e3..aa1aa29 100644 --- a/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs +++ b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs @@ -5,7 +5,7 @@ using RGB.NET.Core; namespace RGB.NET.Devices.DMX; -internal class LedChannelMapping : IEnumerable<(int channel, Func getValue)> +internal sealed class LedChannelMapping : IEnumerable<(int channel, Func getValue)> { #region Properties & Fields diff --git a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs index d396bc0..f88ad50 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Debug; /// /// Represents a device provider responsible for debug devices. /// -public class DebugDeviceProvider : AbstractRGBDeviceProvider +public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -71,8 +71,6 @@ public class DebugDeviceProvider : AbstractRGBDeviceProvider base.Dispose(); _fakeDeviceDefinitions.Clear(); - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs index 1e00c42..2789821 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs @@ -3,7 +3,7 @@ using RGB.NET.Core; namespace RGB.NET.Devices.Debug; -internal class DebugDeviceUpdateQueue : UpdateQueue +internal sealed class DebugDeviceUpdateQueue : UpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Debug/DebugRGBDevice.cs b/RGB.NET.Devices.Debug/DebugRGBDevice.cs index 35d1765..61296ab 100644 --- a/RGB.NET.Devices.Debug/DebugRGBDevice.cs +++ b/RGB.NET.Devices.Debug/DebugRGBDevice.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Debug; /// /// Represents a debug device. /// -public class DebugRGBDevice : AbstractRGBDevice, IUnknownDevice +public sealed class DebugRGBDevice : AbstractRGBDevice, IUnknownDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.Debug/DebugRGBDeviceInfo.cs b/RGB.NET.Devices.Debug/DebugRGBDeviceInfo.cs index d724e36..43e3c64 100644 --- a/RGB.NET.Devices.Debug/DebugRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Debug/DebugRGBDeviceInfo.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Debug; /// /// Represents device information for a />. /// -public class DebugRGBDeviceInfo : IRGBDeviceInfo +public sealed class DebugRGBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs index 69cdce1..355e457 100644 --- a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs +++ b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs @@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Logitech.HID; /// /// The type of the identifier leds are mapped to. /// The type of the custom data added to the HID-device. -public class LightspeedHIDLoader : IEnumerable> +public sealed class LightspeedHIDLoader : IEnumerable> where TLed : notnull { #region Constants diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs index 7727006..6a31dad 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents a logitech per-device-lightable device. /// -public class LogitechPerDeviceRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated +public sealed class LogitechPerDeviceRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated { #region Properties & Fields diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs index c32f87d..b780a28 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents the update-queue performing updates for logitech per-device devices. /// -public class LogitechPerDeviceUpdateQueue : UpdateQueue +public sealed class LogitechPerDeviceUpdateQueue : UpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs index 715079e..edd3d95 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents a logitech per-key-lightable device. /// -public class LogitechPerKeyRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated +public sealed class LogitechPerKeyRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated { #region Properties & Fields diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs index b0bdaf4..7f1917f 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyUpdateQueue.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents the update-queue performing updates for logitech per-key devices. /// -public class LogitechPerKeyUpdateQueue : UpdateQueue +public sealed class LogitechPerKeyUpdateQueue : UpdateQueue { #region Constructors @@ -17,8 +17,7 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue /// The update trigger used by this queue. public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger) : base(updateTrigger) - { - } + { } #endregion diff --git a/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs b/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs index 4909dcc..d1050fd 100644 --- a/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Zone/LogitechZoneRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents a logitech zone-lightable device. /// -public class LogitechZoneRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated +public sealed class LogitechZoneRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated { #region Properties & Fields diff --git a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs index eba7a2d..c9a83a5 100644 --- a/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs +++ b/RGB.NET.Devices.Logitech/Zone/LogitechZoneUpdateQueue.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents the update-queue performing updates for logitech zone devices. /// -public class LogitechZoneUpdateQueue : UpdateQueue +public sealed class LogitechZoneUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs b/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs index cf688e1..57044fb 100644 --- a/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs +++ b/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Msi.Exceptions; /// /// Represents an exception thrown by the MysticLight-SDK. /// -public class MysticLightException : ApplicationException +public sealed class MysticLightException : ApplicationException { #region Properties & Fields diff --git a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs index 8db204f..0367029 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Msi; /// /// Represents the update-queue performing updates for MSI devices. /// -public class MsiDeviceUpdateQueue : UpdateQueue +public sealed class MsiDeviceUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs index a4d72f1..efb72f6 100644 --- a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Msi; /// /// Represents MSI VGA adapters. /// -public class MsiGraphicsCardRGBDevice : MsiRGBDevice, IGraphicsCard +public sealed class MsiGraphicsCardRGBDevice : MsiRGBDevice, IGraphicsCard { #region Constructors diff --git a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs index 113d364..2367678 100644 --- a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Msi; /// /// Represents a MSI mainboard. /// -public class MsiMainboardRGBDevice : MsiRGBDevice, IMainboard +public sealed class MsiMainboardRGBDevice : MsiRGBDevice, IMainboard { #region Constructors diff --git a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs index fc9adc8..5ebc73c 100644 --- a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Msi; /// /// Represents a MSI mouse. /// -public class MsiMouseRGBDevice : MsiRGBDevice +public sealed class MsiMouseRGBDevice : MsiRGBDevice { #region Constructors diff --git a/RGB.NET.Devices.Novation/Attributes/ColorCapabilityAttribute.cs b/RGB.NET.Devices.Novation/Attributes/ColorCapabilityAttribute.cs index d2c0a00..9d2131b 100644 --- a/RGB.NET.Devices.Novation/Attributes/ColorCapabilityAttribute.cs +++ b/RGB.NET.Devices.Novation/Attributes/ColorCapabilityAttribute.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Novation.Attributes; /// Specifies the color-capability of a field. /// [AttributeUsage(AttributeTargets.Field)] -public class ColorCapabilityAttribute : Attribute +public sealed class ColorCapabilityAttribute : Attribute { #region Properties & Fields diff --git a/RGB.NET.Devices.Novation/Attributes/DeviceIdAttribute.cs b/RGB.NET.Devices.Novation/Attributes/DeviceIdAttribute.cs index 34c8b2e..ee25485 100644 --- a/RGB.NET.Devices.Novation/Attributes/DeviceIdAttribute.cs +++ b/RGB.NET.Devices.Novation/Attributes/DeviceIdAttribute.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Novation.Attributes; /// Specifies the device-id of a field. /// [AttributeUsage(AttributeTargets.Field)] -public class DeviceIdAttribute : Attribute +public sealed class DeviceIdAttribute : Attribute { #region Properties & Fields diff --git a/RGB.NET.Devices.Novation/Attributes/LedIdMappingAttribute.cs b/RGB.NET.Devices.Novation/Attributes/LedIdMappingAttribute.cs index 1e5ac21..14e22e1 100644 --- a/RGB.NET.Devices.Novation/Attributes/LedIdMappingAttribute.cs +++ b/RGB.NET.Devices.Novation/Attributes/LedIdMappingAttribute.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Novation.Attributes; /// Specifies the led id mapping of a field. /// [AttributeUsage(AttributeTargets.Field)] -internal class LedIdMappingAttribute : Attribute +internal sealed class LedIdMappingAttribute : Attribute { #region Properties & Fields diff --git a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs index 9bb0bbe..987b691 100644 --- a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Novation; /// /// Represents the update-queue performing updates for a limited-color novation device. /// -public class LimitedColorUpdateQueue : MidiUpdateQueue +public sealed class LimitedColorUpdateQueue : MidiUpdateQueue { #region Constructors @@ -37,7 +37,7 @@ public class LimitedColorUpdateQueue : MidiUpdateQueue /// /// The to convert. /// The novation-representation of the . - protected virtual int ConvertColor(in Color color) + private static int ConvertColor(in Color color) { (double hue, double _, double value) = color.GetHSV(); diff --git a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs index 5a3367a..6279593 100644 --- a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Novation; /// /// Represents the update-queue performing updates for a RGB-color novation device. /// -public class RGBColorUpdateQueue : MidiUpdateQueue +public sealed class RGBColorUpdateQueue : MidiUpdateQueue { #region Properties & Fields @@ -165,7 +165,7 @@ public class RGBColorUpdateQueue : MidiUpdateQueue /// /// The to convert. /// The novation-representation of the . - protected virtual int ConvertColor(in Color color) + private static int ConvertColor(in Color color) { int bestVelocity = 0; double bestMatchDistance = double.MaxValue; diff --git a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs index 81e5dce..0a5b6e1 100644 --- a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Novation; /// /// Represents a Novation launchpad. /// -public class NovationLaunchpadRGBDevice : NovationRGBDevice, ILedMatrix +public sealed class NovationLaunchpadRGBDevice : NovationRGBDevice, ILedMatrix { #region Constructors @@ -50,7 +50,7 @@ public class NovationLaunchpadRGBDevice : NovationRGBDevice /// The mapping of the device. /// Thrown if the value of is not known. - protected virtual Dictionary GetDeviceMapping() + private Dictionary GetDeviceMapping() => DeviceInfo.LedMapping switch { LedIdMappings.Current => LaunchpadIdMapping.CURRENT, diff --git a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDeviceInfo.cs b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDeviceInfo.cs index 06296b9..2805da9 100644 --- a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDeviceInfo.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Novation; /// /// Represents a generic information for a . /// -public class NovationLaunchpadRGBDeviceInfo : NovationRGBDeviceInfo +public sealed class NovationLaunchpadRGBDeviceInfo : NovationRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index 9d2d8d2..837a82c 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Novation; /// /// Represents a device provider responsible for Novation devices. /// -public class NovationDeviceProvider : AbstractRGBDeviceProvider +public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs index 618c310..7f51c81 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBGenericDevice.cs @@ -4,7 +4,7 @@ using RGB.NET.Core; namespace RGB.NET.Devices.OpenRGB; /// -public class OpenRGBGenericDevice : AbstractOpenRGBDevice +public sealed class OpenRGBGenericDevice : AbstractOpenRGBDevice { #region Constructors /// diff --git a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs index ff4daa5..0537d11 100644 --- a/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs +++ b/RGB.NET.Devices.OpenRGB/Generic/OpenRGBUpdateQueue.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.OpenRGB; /// /// Represents the update-queue performing updates for OpenRGB devices. /// -public class OpenRGBUpdateQueue : UpdateQueue +public sealed class OpenRGBUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index c9d3cbc..6c83a68 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.OpenRGB; /// /// Represents a device provider responsible for OpenRGB devices. /// -public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider +public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -162,8 +162,6 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider _clients.Clear(); DeviceDefinitions.Clear(); Devices = Enumerable.Empty(); - - GC.SuppressFinalize(this); } #endregion } diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs b/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs index 9de9246..7943775 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBServerDefinition.cs @@ -3,7 +3,7 @@ /// /// Represents a definition of an OpenRGB server. /// -public class OpenRGBServerDefinition +public sealed class OpenRGBServerDefinition { /// /// The name of the client that will appear in the OpenRGB interface. diff --git a/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs b/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs index 6def092..1e3c4ff 100644 --- a/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs +++ b/RGB.NET.Devices.OpenRGB/PerZone/OpenRGBZoneDevice.cs @@ -4,7 +4,7 @@ using RGB.NET.Core; namespace RGB.NET.Devices.OpenRGB; /// -public class OpenRGBZoneDevice : AbstractOpenRGBDevice +public sealed class OpenRGBZoneDevice : AbstractOpenRGBDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs b/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs index 9d8c633..bc8e85e 100644 --- a/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs +++ b/RGB.NET.Devices.OpenRGB/Segment/OpenRGBSegmentDevice.cs @@ -4,7 +4,7 @@ using RGB.NET.Core; namespace RGB.NET.Devices.OpenRGB; /// -public class OpenRGBSegmentDevice : AbstractOpenRGBDevice +public sealed class OpenRGBSegmentDevice : AbstractOpenRGBDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs index 8cd251d..edd290b 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiBulkUpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.PicoPi; /// /// Using this requires the libusb driver to be installed! /// -public class PicoPiBulkUpdateQueue : UpdateQueue +public sealed class PicoPiBulkUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs index b3ff956..652ba80 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiHIDUpdateQueue.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.PicoPi; /// /// Represents the update-queue performing updates for Pico-Pi HID-devices. /// -public class PicoPiHIDUpdateQueue : UpdateQueue +public sealed class PicoPiHIDUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDevice.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDevice.cs index 486842d..b50be7b 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDevice.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.PicoPi; /// /// Represents a device based on an Raspberry Pi Pico. /// -public class PicoPiRGBDevice : AbstractRGBDevice +public sealed class PicoPiRGBDevice : AbstractRGBDevice { #region Properties & Fields diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDeviceInfo.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDeviceInfo.cs index ffe8e71..52e3d79 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDeviceInfo.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiRGBDeviceInfo.cs @@ -5,7 +5,7 @@ namespace RGB.NET.Devices.PicoPi; /// /// Represents a generic information for a . /// -public class PicoPiRGBDeviceInfo : IRGBDeviceInfo +public sealed class PicoPiRGBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs index a47916c..2dcd6de 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/PicoPiSDK.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.PicoPi; /// /// Represents a SDK to access devices based on a Raspberry Pi Pico. /// -public class PicoPiSDK : IDisposable +public sealed class PicoPiSDK : IDisposable { #region Constants @@ -303,8 +303,6 @@ public class PicoPiSDK : IDisposable _hidStream.Dispose(); _bulkDevice?.Dispose(); _usbContext?.Dispose(); - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs index bce7e9c..f18116f 100644 --- a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs +++ b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs @@ -15,7 +15,7 @@ namespace RGB.NET.Devices.PicoPi; /// Represents a device provider responsible for PicoPi-devices. /// // ReSharper disable once InconsistentNaming -public class PicoPiDeviceProvider : AbstractRGBDeviceProvider +public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider { #region Constants diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs index 1dd5c70..adc08f7 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer chroma link. /// -public class RazerChromaLinkRGBDevice : RazerRGBDevice, IUnknownDevice +public sealed class RazerChromaLinkRGBDevice : RazerRGBDevice, IUnknownDevice { #region Constructors diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs index 42755b9..3d63bf0 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer chroma-link devices. /// -public class RazerChromaLinkUpdateQueue : RazerUpdateQueue +public sealed class RazerChromaLinkUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/Exceptions/RazerException.cs b/RGB.NET.Devices.Razer/Exceptions/RazerException.cs index 3350c81..ae9ad23 100644 --- a/RGB.NET.Devices.Razer/Exceptions/RazerException.cs +++ b/RGB.NET.Devices.Razer/Exceptions/RazerException.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents an exception thrown by the Razer-SDK. /// -public class RazerException : ApplicationException +public sealed class RazerException : ApplicationException { #region Properties & Fields diff --git a/RGB.NET.Devices.Razer/Generic/Devices.cs b/RGB.NET.Devices.Razer/Generic/Devices.cs deleted file mode 100644 index fb47055..0000000 --- a/RGB.NET.Devices.Razer/Generic/Devices.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace RGB.NET.Devices.Razer; - -internal class Devices -{ - public static readonly List<(Guid guid, string model)> KEYBOARDS = new() - { - (new Guid("2EA1BB63-CA28-428D-9F06-196B88330BBB"), "Blackwidow Chroma"), - (new Guid("ED1C1B82-BFBE-418F-B49D-D03F05B149DF"), "Razer Blackwidow Chroma Tournament Edition"), - (new Guid("18C5AD9B-4326-4828-92C4-2669A66D2283"), "Razer Deathstalker "), - (new Guid("872AB2A9-7959-4478-9FED-15F6186E72E4"), "Overwatch Keyboard"), - (new Guid("5AF60076-ADE9-43D4-B574-52599293B554"), "Razer Blackwidow X Chroma"), - (new Guid("2D84DD51-3290-4AAC-9A89-D8AFDE38B57C"), "Razer Blackwidow X TE Chroma"), - (new Guid("803378C1-CC48-4970-8539-D828CC1D420A"), "Razer Omata Chroma"), - (new Guid("C83BDFE8-E7FC-40E0-99DB-872E23F19891"), "Razer Blade Stealth"), - (new Guid("F2BEDFAF-A0FE-4651-9D41-B6CE603A3DDD"), "Razer Blade"), - (new Guid("A73AC338-F0E5-4BF7-91AE-DD1F7E1737A5"), "Razer Blade Pro"), - (new Guid("608E743F-B402-44BD-A7A6-7AA9F574ECF4"), "Razer Blackwidow Chroma v2"), - (new Guid("F85E7473-8F03-45B6-A16E-CE26CB8D2441"), "Razer Huntsman"), - (new Guid("16BB5ABD-C1CD-4CB3-BDF7-62438748BD98"), "Razer Blackwidow Elite") - }; - - public static readonly List<(Guid guid, string model)> MICE = new() - { - (new Guid("7EC00450-E0EE-4289-89D5-0D879C19061A"), "Razer Mamba Chroma Tournament Edition"), - (new Guid("AEC50D91-B1F1-452F-8E16-7B73F376FDF3"), "Razer Deathadder Chroma "), - (new Guid("FF8A5929-4512-4257-8D59-C647BF9935D0"), "Razer Diamondback"), - (new Guid("D527CBDC-EB0A-483A-9E89-66D50463EC6C"), "Razer Mamba"), - (new Guid("D714C50B-7158-4368-B99C-601ACB985E98"), "Razer Naga Epic"), - (new Guid("F1876328-6CA4-46AE-BE04-BE812B414433"), "Razer Naga"), - (new Guid("52C15681-4ECE-4DD9-8A52-A1418459EB34"), "Razer Orochi Chroma"), - (new Guid("195D70F5-F285-4CFF-99F2-B8C0E9658DB4"), "Razer Naga Hex Chroma"), - (new Guid("77834867-3237-4A9F-AD77-4A46C4183003"), "Razer DeathAdder Elite Chroma") - }; - - public static readonly List<(Guid guid, string model)> HEADSETS = new() - { - (new Guid("DF3164D7-5408-4A0E-8A7F-A7412F26BEBF"), "Razer ManO'War"), - (new Guid("CD1E09A5-D5E6-4A6C-A93B-E6D9BF1D2092"), "Razer Kraken 7.1 Chroma"), - (new Guid("7FB8A36E-9E74-4BB3-8C86-CAC7F7891EBD"), "Razer Kraken 7.1 Chroma Refresh"), - (new Guid("FB357780-4617-43A7-960F-D1190ED54806"), "Razer Kraken Kitty") - }; - - public static readonly List<(Guid guid, string model)> MOUSEMATS = new() - { - (new Guid("80F95A94-73D2-48CA-AE9A-0986789A9AF2"), "Razer Firefly") - }; - - public static readonly List<(Guid guid, string model)> KEYPADS = new() - { - (new Guid("9D24B0AB-0162-466C-9640-7A924AA4D9FD"), "Razer Orbweaver"), - (new Guid("00F0545C-E180-4AD1-8E8A-419061CE505E"), "Razer Tartarus") - }; - - public static readonly List<(Guid guid, string model)> CHROMALINKS = new() - { - (new Guid("0201203B-62F3-4C50-83DD-598BABD208E0"), "Core Chroma"), - (new Guid("35F6F18D-1AE5-436C-A575-AB44A127903A"), "Lenovo Y900"), - (new Guid("47DB1FA7-6B9B-4EE6-B6F4-4071A3B2053B"), "Lenovo Y27"), - (new Guid("BB2E9C9B-B0D2-461A-BA52-230B5D6C3609"), "Chroma Box") - }; - - public static readonly List<(Guid guid, string model)> SPEAKERS = new() - { - (new Guid("45B308F2-CD44-4594-8375-4D5945AD880E"), "Nommo Chroma"), - (new Guid("3017280B-D7F9-4D7B-930E-7B47181B46B5"), "Nommo Chroma Pro") - }; -} \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs index cec7f08..2b61b35 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer headset. /// -public class RazerHeadsetRGBDevice : RazerRGBDevice, IHeadset +public sealed class RazerHeadsetRGBDevice : RazerRGBDevice, IHeadset { #region Constructors diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs index 9cb3eaf..24cc57b 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer headset devices. /// -public class RazerHeadsetUpdateQueue : RazerUpdateQueue +public sealed class RazerHeadsetUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs index 3a4c5f2..1a5cbfb 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer keyboard. /// -public class RazerKeyboardRGBDevice : RazerRGBDevice, IKeyboard +public sealed class RazerKeyboardRGBDevice : RazerRGBDevice, IKeyboard { #region Properties & Fields diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs index 983d030..2a369f3 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a generic information for a . /// -public class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo, IKeyboardDeviceInfo +public sealed class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs index 09b8c2d..b351d5f 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer keyboard devices. /// -public class RazerKeyboardUpdateQueue : RazerUpdateQueue +public sealed class RazerKeyboardUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs index f620388..6c1c244 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer keypad. /// -public class RazerKeypadRGBDevice : RazerRGBDevice, IKeypad +public sealed class RazerKeypadRGBDevice : RazerRGBDevice, IKeypad { #region Constructors diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs index 2b6dcc6..9b6908a 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer keypad devices. /// -public class RazerKeypadUpdateQueue : RazerUpdateQueue +public sealed class RazerKeypadUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs index 1433449..fe00b6c 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer mouse. /// -public class RazerMouseRGBDevice : RazerRGBDevice, IMouse +public sealed class RazerMouseRGBDevice : RazerRGBDevice, IMouse { #region Properties & Fields diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs index 5a50911..22295d0 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer mouse devices. /// -public class RazerMouseUpdateQueue : RazerUpdateQueue +public sealed class RazerMouseUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs index af47df3..33932c4 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer mousepad. /// -public class RazerMousepadRGBDevice : RazerRGBDevice, IMousepad +public sealed class RazerMousepadRGBDevice : RazerRGBDevice, IMousepad { #region Constructors diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs index 3b01b67..57d912a 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents the update-queue performing updates for razer mousepad devices. /// -public class RazerMousepadUpdateQueue : RazerUpdateQueue +public sealed class RazerMousepadUpdateQueue : RazerUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 04edecc..313ef08 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a device provider responsible for razer devices. /// -public class RazerDeviceProvider : AbstractRGBDeviceProvider +public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -308,8 +308,6 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit //try { _RazerSDK.UnloadRazerSDK(); } //catch { /* at least we tried */ } - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs b/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs index c5cc970..8e74d0e 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs @@ -2,7 +2,7 @@ namespace RGB.NET.Devices.SteelSeries.API.Model; -internal class CoreProps +internal sealed class CoreProps { [JsonPropertyName("address")] public string? Address { get; set; } diff --git a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs index 4aa335e..2862e94 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace RGB.NET.Devices.SteelSeries.API.Model; -internal class Event +internal sealed class Event { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/API/Model/Game.cs b/RGB.NET.Devices.SteelSeries/API/Model/Game.cs index b22cb1f..081d3dd 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/Game.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/Game.cs @@ -2,7 +2,7 @@ namespace RGB.NET.Devices.SteelSeries.API.Model; -internal class Game +internal sealed class Game { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs b/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs index 3cd2ec4..1c6dba1 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs @@ -2,7 +2,7 @@ namespace RGB.NET.Devices.SteelSeries.API.Model; -internal class GoLispHandler +internal sealed class GoLispHandler { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs b/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs index dbf9931..d500a53 100644 --- a/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs +++ b/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs @@ -1,6 +1,6 @@ namespace RGB.NET.Devices.SteelSeries; -internal class APIName : System.Attribute +internal sealed class APIName : System.Attribute { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs index 26d744d..c85f394 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesDeviceUpdateQueue.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.SteelSeries; /// /// Represents the update-queue performing updates for steelseries devices. /// -internal class SteelSeriesDeviceUpdateQueue : UpdateQueue +internal sealed class SteelSeriesDeviceUpdateQueue : UpdateQueue { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs index f85213b..86b1bdf 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.SteelSeries; /// /// Represents a SteelSeries-device. (keyboard, mouse, headset, mousepad). /// -public class SteelSeriesRGBDevice : AbstractRGBDevice, ISteelSeriesRGBDevice, IUnknownDevice//TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated +public sealed class SteelSeriesRGBDevice : AbstractRGBDevice, ISteelSeriesRGBDevice, IUnknownDevice//TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDeviceInfo.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDeviceInfo.cs index fe1f747..0ceebba 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDeviceInfo.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDeviceInfo.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.SteelSeries; /// /// Represents a generic information for a SteelSeries-. /// -public class SteelSeriesRGBDeviceInfo : IRGBDeviceInfo +public sealed class SteelSeriesRGBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index ee15533..417a448 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -10,11 +10,11 @@ namespace RGB.NET.Devices.SteelSeries; /// /// Represents a device provider responsible for SteelSeries-devices. /// -public class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider +public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider { #region Constants - private static readonly int HEARTBEAT_TIMER = 5000; // flush the device every 5 seconds to prevent timeouts + private const int HEARTBEAT_TIMER = 5000; // flush the device every 5 seconds to prevent timeouts #endregion @@ -137,8 +137,6 @@ public class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider try { SteelSeriesSDK.Dispose(); } catch { /* shit happens */ } - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs index 4f2bf09..a22502e 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDevice.cs @@ -11,7 +11,7 @@ namespace RGB.NET.Devices.WS281X.Arduino; /// /// Represents an arduino WS2812 device. /// -public class ArduinoWS2812USBDevice : AbstractRGBDevice, ILedStripe +public sealed class ArduinoWS2812USBDevice : AbstractRGBDevice, ILedStripe { #region Properties & Fields /// diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDeviceInfo.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDeviceInfo.cs index fede95c..a03fdf0 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDeviceInfo.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.WS281X.Arduino; /// /// Represents a generic information for a . /// -public class ArduinoWS2812USBDeviceInfo : IRGBDeviceInfo +public sealed class ArduinoWS2812USBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs index 603b6f5..2d035ff 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs @@ -9,7 +9,7 @@ namespace RGB.NET.Devices.WS281X.Arduino; /// /// Represents the update-queue performing updates for arduino WS2812 devices. /// -public class ArduinoWS2812USBUpdateQueue : SerialConnectionUpdateQueue +public sealed class ArduinoWS2812USBUpdateQueue : SerialConnectionUpdateQueue { #region Constants diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS281XDeviceDefinition.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS281XDeviceDefinition.cs index 612596d..e3d2545 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS281XDeviceDefinition.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS281XDeviceDefinition.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.WS281X.Arduino; /// /// Represents a definition of an arduino WS2812 devices. /// -public class ArduinoWS281XDeviceDefinition : IWS281XDeviceDefinition +public sealed class ArduinoWS281XDeviceDefinition : IWS281XDeviceDefinition { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs index 1dc38cd..94d7479 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDevice.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard; /// /// Represents an bitwizard WS2812 USB device. /// -public class BitwizardWS2812USBDevice : AbstractRGBDevice, ILedStripe +public sealed class BitwizardWS2812USBDevice : AbstractRGBDevice, ILedStripe { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDeviceInfo.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDeviceInfo.cs index 65f0054..3e911b7 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDeviceInfo.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard; /// /// Represents a generic information for a . /// -public class BitwizardWS2812USBDeviceInfo : IRGBDeviceInfo +public sealed class BitwizardWS2812USBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBUpdateQueue.cs index cb0ef7b..b970b54 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS2812USBUpdateQueue.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard; /// /// Represents the update-queue performing updates for a bitwizard WS2812 device. /// -public class BitwizardWS2812USBUpdateQueue : SerialConnectionUpdateQueue +public sealed class BitwizardWS2812USBUpdateQueue : SerialConnectionUpdateQueue { #region Constructors diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs index 3da2203..131a879 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard; /// /// Represents a definition of an bitwizard WS2812 devices. /// -public class BitwizardWS281XDeviceDefinition : IWS281XDeviceDefinition +public sealed class BitwizardWS281XDeviceDefinition : IWS281XDeviceDefinition { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs index f581e3f..7004a30 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs @@ -1,5 +1,4 @@ -using System; -using System.IO.Ports; +using System.IO.Ports; namespace RGB.NET.Devices.WS281X; @@ -7,7 +6,7 @@ namespace RGB.NET.Devices.WS281X; /// /// Represents a serial-connection using the default microsoft serial-port implementation. /// -public class SerialPortConnection : ISerialConnection +public sealed class SerialPortConnection : ISerialConnection { #region Properties & Fields @@ -65,8 +64,6 @@ public class SerialPortConnection : ISerialConnection public void Dispose() { SerialPort.Dispose(); - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs index 8c55f6b..f297a60 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDevice.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU; /// /// Represents an NodeMCU WS2812 device. /// -public class NodeMCUWS2812USBDevice : AbstractRGBDevice, ILedStripe +public sealed class NodeMCUWS2812USBDevice : AbstractRGBDevice, ILedStripe { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDeviceInfo.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDeviceInfo.cs index 0caf3b6..d36813f 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDeviceInfo.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBDeviceInfo.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU; /// /// Represents a generic information for a . /// -public class NodeMCUWS2812USBDeviceInfo : IRGBDeviceInfo +public sealed class NodeMCUWS2812USBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index 9e6d30e..a78343c 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -14,7 +14,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU; /// /// Represents the update-queue performing updates for NodeMCU WS2812 devices. /// -public class NodeMCUWS2812USBUpdateQueue : UpdateQueue +public sealed class NodeMCUWS2812USBUpdateQueue : UpdateQueue { #region Properties & Fields @@ -183,8 +183,6 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue ResetDevice(); _httpClient.Dispose(); } - - GC.SuppressFinalize(this); } private string GetUrl(string path) => $"http://{_hostname}/{path}"; diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS281XDeviceDefinition.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS281XDeviceDefinition.cs index 0f68f2b..a345119 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS281XDeviceDefinition.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS281XDeviceDefinition.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU; /// /// Represents a definition of an NodeMCU WS2812 devices. /// -public class NodeMCUWS281XDeviceDefinition : IWS281XDeviceDefinition +public sealed class NodeMCUWS281XDeviceDefinition : IWS281XDeviceDefinition { #region Properties & Fields diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index 6a5c49d..4d2e047 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.WS281X; /// // ReSharper disable once InconsistentNaming // ReSharper disable once UnusedType.Global -public class WS281XDeviceProvider : AbstractRGBDeviceProvider +public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -75,8 +75,6 @@ public class WS281XDeviceProvider : AbstractRGBDeviceProvider base.Dispose(); DeviceDefinitions.Clear(); - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs index 3791ba0..8a3012e 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs @@ -8,10 +8,12 @@ namespace RGB.NET.Devices.Wooting.Generic; /// /// Represents the update-queue performing updates for cooler master devices. /// -public class WootingUpdateQueue : UpdateQueue +public sealed class WootingUpdateQueue : UpdateQueue { #region Properties & Fields + private readonly byte _deviceid; + #endregion #region Constructors diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index 0f5882c..79e1baf 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Generic; using RGB.NET.Devices.Wooting.Native; @@ -10,7 +9,7 @@ namespace RGB.NET.Devices.Wooting.Keyboard; /// /// Represents a Wooting keyboard. /// -public class WootingKeyboardRGBDevice : WootingRGBDevice, IKeyboard +public sealed class WootingKeyboardRGBDevice : WootingRGBDevice, IKeyboard { #region Properties & Fields @@ -53,8 +52,6 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice /// Represents a generic information for a . /// -public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo, IKeyboardDeviceInfo +public sealed class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index aebe9c0..484bbaf 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Wooting; /// /// Represents a device provider responsible for Wooting devices. /// -public class WootingDeviceProvider : AbstractRGBDeviceProvider +public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields @@ -103,8 +103,6 @@ public class WootingDeviceProvider : AbstractRGBDeviceProvider try { _WootingSDK.UnloadWootingSDK(); } catch { /* at least we tried */ } } - - GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.HID/HIDLoader.cs b/RGB.NET.HID/HIDLoader.cs index b0ecfe7..b39df67 100644 --- a/RGB.NET.HID/HIDLoader.cs +++ b/RGB.NET.HID/HIDLoader.cs @@ -19,7 +19,7 @@ public record HIDDeviceDefinition(int ProductId, RGBDeviceType Devi /// /// The type of the identifier leds are mapped to. /// The type of the custom data added to the HID-device. -public class HIDLoader : IEnumerable> +public sealed class HIDLoader : IEnumerable> where TLed : notnull { #region Properties & Fields diff --git a/RGB.NET.Presets/Decorators/FlashDecorator.cs b/RGB.NET.Presets/Decorators/FlashDecorator.cs index 64794b5..e30a5f2 100644 --- a/RGB.NET.Presets/Decorators/FlashDecorator.cs +++ b/RGB.NET.Presets/Decorators/FlashDecorator.cs @@ -12,7 +12,7 @@ namespace RGB.NET.Presets.Decorators; /// /// Represents a decorator which allows to flash a brush by modifying his opacity. /// -public class FlashDecorator : AbstractUpdateAwareDecorator, IBrushDecorator +public sealed class FlashDecorator : AbstractUpdateAwareDecorator, IBrushDecorator { #region Properties & Fields diff --git a/RGB.NET.Presets/Groups/RectangleLedGroup.cs b/RGB.NET.Presets/Groups/RectangleLedGroup.cs index cf66848..62a59ac 100644 --- a/RGB.NET.Presets/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Presets/Groups/RectangleLedGroup.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Presets.Groups; /// /// Represents a containing which physically lay inside a . /// -public class RectangleLedGroup : AbstractLedGroup +public sealed class RectangleLedGroup : AbstractLedGroup { #region Properties & Fields diff --git a/RGB.NET.Presets/Textures/Gradients/GradientStop.cs b/RGB.NET.Presets/Textures/Gradients/GradientStop.cs index d7aa536..75b9842 100644 --- a/RGB.NET.Presets/Textures/Gradients/GradientStop.cs +++ b/RGB.NET.Presets/Textures/Gradients/GradientStop.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Presets.Textures.Gradients; /// /// Represents a stop on a gradient. /// -public class GradientStop : AbstractBindable +public sealed class GradientStop : AbstractBindable { #region Properties & Fields diff --git a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs index 29a732a..18fa252 100644 --- a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs @@ -11,12 +11,12 @@ namespace RGB.NET.Presets.Textures.Gradients; /// /// Represents a linear interpolated gradient with n stops. /// -public class LinearGradient : AbstractGradient +public sealed class LinearGradient : AbstractGradient { #region Properties & Fields private bool _isOrderedGradientListDirty = true; - private LinkedList _orderedGradientStops = new(); + private readonly List _orderedGradientStops = new(); #endregion @@ -89,7 +89,10 @@ public class LinearGradient : AbstractGradient if (GradientStops.Count == 1) return GradientStops[0].Color; if (_isOrderedGradientListDirty) - _orderedGradientStops = new LinkedList(GradientStops.OrderBy(x => x.Offset)); + { + _orderedGradientStops.Clear(); + _orderedGradientStops.AddRange(GradientStops.OrderBy(x => x.Offset)); + } (GradientStop gsBefore, GradientStop gsAfter) = GetEnclosingGradientStops(offset, _orderedGradientStops, WrapGradient); @@ -112,7 +115,7 @@ public class LinearGradient : AbstractGradient /// The ordered list of to choose from. /// Bool indicating if the gradient should be wrapped or not. /// The two s encapsulating the specified offset. - protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(float offset, LinkedList orderedStops, bool wrap) + private (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(float offset, IEnumerable orderedStops, bool wrap) { LinkedList gradientStops = new(orderedStops); diff --git a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs index 46c1e5b..177997a 100644 --- a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Presets.Textures.Gradients; /// Represents a rainbow gradient which circles through all colors of the HUE-color-space.
/// See as reference. /// -public class RainbowGradient : AbstractDecoratable, IGradient +public sealed class RainbowGradient : AbstractDecoratable, IGradient { #region Properties & Fields @@ -102,7 +102,7 @@ public class RainbowGradient : AbstractDecoratable, IGradien /// /// Should be called to indicate that the gradient was changed. /// - protected void OnGradientChanged() => GradientChanged?.Invoke(this, EventArgs.Empty); + private void OnGradientChanged() => GradientChanged?.Invoke(this, EventArgs.Empty); #endregion } \ No newline at end of file diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index 8d5b8b6..349afd7 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Presets.Textures.Sampler; /// /// Represents a sampled that averages multiple byte-data entries. /// -public class AverageByteSampler : ISampler +public sealed class AverageByteSampler : ISampler { #region Constants diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index 50e9563..d53ad5d 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -8,7 +8,7 @@ namespace RGB.NET.Presets.Textures.Sampler; /// /// Represents a sampled that averages multiple float-data entries. /// -public class AverageFloatSampler : ISampler +public sealed class AverageFloatSampler : ISampler { #region Methods From e8f168f64ab9b112996028e85fcbb981ff0b9c11 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 19 Apr 2023 22:15:27 +0200 Subject: [PATCH 38/96] Removed .NET 5 artifacts from build --- .github/workflows/ci.yml | 6 ------ .github/workflows/release.yml | 6 ------ 2 files changed, 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd005ce..36bab7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,6 @@ jobs: run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.versioning.outputs.version }} - name: Test run: dotnet test --no-build --verbosity normal --configuration Release - - name: Upload a Build Artifact NET5 - uses: actions/upload-artifact@v2.2.4 - with: - name: RGB.NET-NET5 - path: bin/net5.0/RGB.NET.*.dll - if-no-files-found: error - name: Upload a Build Artifact NET6 uses: actions/upload-artifact@v2.2.4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5e9cce..121fb30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,12 +32,6 @@ jobs: run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.versioning.outputs.version }} - name: Test run: dotnet test --no-build --verbosity normal --configuration Release - - name: Upload a Build Artifact NET5 - uses: actions/upload-artifact@v2.2.4 - with: - name: RGB.NET-NET5 - path: bin/net5.0/RGB.NET.*.dll - if-no-files-found: error - name: Upload a Build Artifact NET6 uses: actions/upload-artifact@v2.2.4 with: From af3989aa7317857773015a169a970c0a63ba6b71 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Apr 2023 12:16:38 +0200 Subject: [PATCH 39/96] Added Test for the PixelTexture --- .../RGB.NET.Core.Tests/Helper/SimplexNoise.cs | 354 ++++++++++++++++++ .../Texture/PixelTextureTest.cs | 61 +++ 2 files changed, 415 insertions(+) create mode 100644 Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs create mode 100644 Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs diff --git a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs new file mode 100644 index 0000000..aa756d6 --- /dev/null +++ b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs @@ -0,0 +1,354 @@ +using System; + +namespace RGB.NET.Core.Tests.Helper; + +// Simplex Noise for C# +// Copyright © Benjamin Ward 2019 +// See LICENSE +// Simplex Noise implementation offering 1D, 2D, and 3D forms w/ values in the range of 0 to 255. +// Based on work by Heikki Törmälä (2012) and Stefan Gustavson (2006). + +/// +/// Implementation of the Perlin simplex noise, an improved Perlin noise algorithm. +/// Based loosely on SimplexNoise1234 by Stefan Gustavson: http://staffwww.itn.liu.se/~stegu/aqsis/aqsis-newnoise/ +/// +public static class SimplexNoise +{ + public static float[] Calc1D(int width, float scale) + { + float[] values = new float[width]; + for (int i = 0; i < width; i++) + values[i] = Generate(i * scale); + return values; + } + + public static float[,] Calc2D(int width, int height, float scale) + { + float[,] values = new float[width, height]; + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) + values[i, j] = Generate(i * scale, j * scale); + return values; + } + + public static float[,,] Calc3D(int width, int height, int length, float scale) + { + float[,,] values = new float[width, height, length]; + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) + for (int k = 0; k < length; k++) + values[i, j, k] = Generate(i * scale, j * scale, k * scale); + return values; + } + + public static float CalcPixel1D(int x, float scale) => Generate(x * scale); + public static float CalcPixel2D(int x, int y, float scale) => Generate(x * scale, y * scale); + public static float CalcPixel3D(int x, int y, int z, float scale) => Generate(x * scale, y * scale, z * scale); + + static SimplexNoise() + { + _perm = new byte[PermOriginal.Length]; + PermOriginal.CopyTo(_perm, 0); + } + + public static int Seed + { + get => _seed; + set + { + if (value == 0) + { + _perm = new byte[PermOriginal.Length]; + PermOriginal.CopyTo(_perm, 0); + } + else + { + _perm = new byte[512]; + Random random = new Random(value); + random.NextBytes(_perm); + } + + _seed = value; + } + } + + private static int _seed; + + /// + /// 1D simplex noise + /// + /// + /// + private static float Generate(float x) + { + int i0 = FastFloor(x); + int i1 = i0 + 1; + float x0 = x - i0; + float x1 = x0 - 1.0f; + + float t0 = 1.0f - (x0 * x0); + t0 *= t0; + float n0 = t0 * t0 * Grad(_perm[i0 & 0xff], x0); + + float t1 = 1.0f - (x1 * x1); + t1 *= t1; + float n1 = t1 * t1 * Grad(_perm[i1 & 0xff], x1); + // The maximum value of this noise is 8*(3/4)^4 = 2.53125 + // A factor of 0.395 scales to fit exactly within [-1,1] + return 0.395f * (n0 + n1); + } + + /// + /// 2D simplex noise + /// + /// + /// + /// + private static float Generate(float x, float y) + { + const float F2 = 0.366025403f; // F2 = 0.5*(sqrt(3.0)-1.0) + const float G2 = 0.211324865f; // G2 = (3.0-Math.sqrt(3.0))/6.0 + + float n0, n1, n2; // Noise contributions from the three corners + + // Skew the input space to determine which simplex cell we're in + float s = (x + y) * F2; // Hairy factor for 2D + float xs = x + s; + float ys = y + s; + int i = FastFloor(xs); + int j = FastFloor(ys); + + float t = (i + j) * G2; + float X0 = i - t; // Unskew the cell origin back to (x,y) space + float Y0 = j - t; + float x0 = x - X0; // The x,y distances from the cell origin + float y0 = y - Y0; + + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if (x0 > y0) { i1 = 1; j1 = 0; } // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else { i1 = 0; j1 = 1; } // upper triangle, YX order: (0,0)->(0,1)->(1,1) + + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + + float x1 = (x0 - i1) + G2; // Offsets for middle corner in (x,y) unskewed coords + float y1 = (y0 - j1) + G2; + float x2 = (x0 - 1.0f) + (2.0f * G2); // Offsets for last corner in (x,y) unskewed coords + float y2 = (y0 - 1.0f) + (2.0f * G2); + + // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds + int ii = Mod(i, 256); + int jj = Mod(j, 256); + + // Calculate the contribution from the three corners + float t0 = 0.5f - (x0 * x0) - (y0 * y0); + if (t0 < 0.0f) n0 = 0.0f; + else + { + t0 *= t0; + n0 = t0 * t0 * Grad(_perm[ii + _perm[jj]], x0, y0); + } + + float t1 = 0.5f - (x1 * x1) - (y1 * y1); + if (t1 < 0.0f) n1 = 0.0f; + else + { + t1 *= t1; + n1 = t1 * t1 * Grad(_perm[ii + i1 + _perm[jj + j1]], x1, y1); + } + + float t2 = 0.5f - (x2 * x2) - (y2 * y2); + if (t2 < 0.0f) n2 = 0.0f; + else + { + t2 *= t2; + n2 = t2 * t2 * Grad(_perm[ii + 1 + _perm[jj + 1]], x2, y2); + } + + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 40.0f * (n0 + n1 + n2); // TODO: The scale factor is preliminary! + } + + + private static float Generate(float x, float y, float z) + { + // Simple skewing factors for the 3D case + const float F3 = 0.333333333f; + const float G3 = 0.166666667f; + + float n0, n1, n2, n3; // Noise contributions from the four corners + + // Skew the input space to determine which simplex cell we're in + float s = (x + y + z) * F3; // Very nice and simple skew factor for 3D + float xs = x + s; + float ys = y + s; + float zs = z + s; + int i = FastFloor(xs); + int j = FastFloor(ys); + int k = FastFloor(zs); + + float t = (i + j + k) * G3; + float X0 = i - t; // Unskew the cell origin back to (x,y,z) space + float Y0 = j - t; + float Z0 = k - t; + float x0 = x - X0; // The x,y,z distances from the cell origin + float y0 = y - Y0; + float z0 = z - Z0; + + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + + /* This code would benefit from a backport from the GLSL version! */ + if (x0 >= y0) + { + if (y0 >= z0) + { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // X Y Z order + else if (x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; } // X Z Y order + else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // Z X Y order + } + else + { // x0 0) ? ((int)x) : (((int)x) - 1); + } + + private static int Mod(int x, int m) + { + int a = x % m; + return a < 0 ? a + m : a; + } + + private static float Grad(int hash, float x) + { + int h = hash & 15; + float grad = 1.0f + (h & 7); // Gradient value 1.0, 2.0, ..., 8.0 + if ((h & 8) != 0) grad = -grad; // Set a random sign for the gradient + return (grad * x); // Multiply the gradient with the distance + } + + private static float Grad(int hash, float x, float y) + { + int h = hash & 7; // Convert low 3 bits of hash code + float u = h < 4 ? x : y; // into 8 simple gradient directions, + float v = h < 4 ? y : x; // and compute the dot product with (x,y). + return ((h & 1) != 0 ? -u : u) + ((h & 2) != 0 ? -2.0f * v : 2.0f * v); + } + + private static float Grad(int hash, float x, float y, float z) + { + int h = hash & 15; // Convert low 4 bits of hash code into 12 simple + float u = h < 8 ? x : y; // gradient directions, and compute dot product. + float v = h < 4 ? y : (h == 12) || (h == 14) ? x : z; // Fix repeats at h = 12 to 15 + return ((h & 1) != 0 ? -u : u) + ((h & 2) != 0 ? -v : v); + } + + private static float Grad(int hash, float x, float y, float z, float t) + { + int h = hash & 31; // Convert low 5 bits of hash code into 32 simple + float u = h < 24 ? x : y; // gradient directions, and compute dot product. + float v = h < 16 ? y : z; + float w = h < 8 ? z : t; + return ((h & 1) != 0 ? -u : u) + ((h & 2) != 0 ? -v : v) + ((h & 4) != 0 ? -w : w); + } +} diff --git a/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs b/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs new file mode 100644 index 0000000..bfeeccc --- /dev/null +++ b/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using RGB.NET.Core.Tests.Helper; + +namespace RGB.NET.Core.Tests.Texture; + +[TestClass] +public class PixelTextureTest +{ + #region Methods + + [TestMethod] + public void SampleRegionsTest() + { + const int SIZE = 1024; + + Dictionary testData = new() + { + [new Rectangle(0, 0, 1, 1)] = new Core.Color(255, 106, 159, 118), + [new Rectangle(0.09765625f, 0.486328125f, 0.427734375f, 0.2890625f)] = new Core.Color(255, 86, 115, 175), + [new Rectangle(0.5859375f, 0.111328125f, 0.271484375f, 0.826171875f)] = new Core.Color(255, 85, 183, 123), + [new Rectangle(0.279296875f, 0.439453125f, 0.583984375f, 0.499609375f)] = new Core.Color(255, 96, 144, 145), + [new Rectangle(0.603515625f, 0.646484375f, 0.365234375f, 0.306640625f)] = new Core.Color(255, 92, 151, 141), + [new Rectangle(0.583984375f, 0.11328125f, 0.314453125f, 0.662109375f)] = new Core.Color(255, 75, 201, 115), + [new Rectangle(0.166015625f, 0.740234375f, 0.76171875f, 0.166015625f)] = new Core.Color(255, 90, 150, 142), + [new Rectangle(0.384765625f, 0.017578125f, 0.576171875f, 0.82421875f)] = new Core.Color(255, 94, 164, 128), + [new Rectangle(0.216796875f, 0.5390625f, 0.669921875f, 0.2890625f)] = new Core.Color(255, 76, 135, 169), + [new Rectangle(0.08203125f, 0.060546875f, 0.857421875f, 0.8671875f)] = new Core.Color(255, 98, 167, 117), + [new Rectangle(0.345703125f, 0.431640625f, 0.560546875f, 0.25421875f)] = new Core.Color(255, 106, 167, 116), + [new Rectangle(0.54296875f, 0.12890625f, 0.40234375f, 0.8515625f)] = new Core.Color(255, 89, 183, 115), + [new Rectangle(0.00390625f, 0.462890625f, 0.953125f, 0.052734375f)] = new Core.Color(255, 138, 173, 96), + [new Rectangle(0.322265625f, 0.572265625f, 0.361328125f, 0.40234375f)] = new Core.Color(255, 123, 127, 128), + [new Rectangle(0.56640625f, 0.388671875f, 0.28125f, 0.423828125f)] = new Core.Color(255, 112, 161, 118), + [new Rectangle(0.119140625f, 0.28125f, 0.828125f, 0.501953125f)] = new Core.Color(255, 105, 170, 108), + [new Rectangle(0.173828125f, 0.8359375f, 0.7421875f, 0.119140625f)] = new Core.Color(255, 126, 151, 106), + [new Rectangle(0.109375f, 0.283203125f, 0.748046875f, 0.583984375f)] = new Core.Color(255, 102, 158, 122), + [new Rectangle(0.0546875f, 0.474609375f, 0.87109375f, 0.2734375f)] = new Core.Color(255, 101, 143, 140), + [new Rectangle(0.34765625f, 0.30859375f, 0.39453125f, 0.39453125f)] = new Core.Color(255, 99, 143, 136), + [new Rectangle(0.240234375f, 0.6796875f, 0.515625f, 0.248046875f)] = new Core.Color(255, 114, 135, 132), + }; + + Core.Color[] data = new Core.Color[SIZE * SIZE]; + SimplexNoise.Seed = 1872; + Random random = new(1872); + for (int y = 0; y < SIZE; y++) + for (int x = 0; x < SIZE; x++) + data[(y * SIZE) + x] = HSVColor.Create(SimplexNoise.CalcPixel2D(x, y, 1f / SIZE) * 360, 1, 1); + + PixelTexture texture = new(SIZE, SIZE, data); + foreach ((Rectangle rect, Core.Color color) in testData) + { + // DarthAffe 23.04.2023: To check it "correctly" the test-data would need to be setup with floating point colors, but i don't really bother for now - that should be good enough to detect breaking changes + (byte, byte, byte, byte) sampled = texture[rect].GetRGBBytes(); + (byte, byte, byte, byte) refColor = color.GetRGBBytes(); + Assert.AreEqual(refColor, sampled); + } + } + + #endregion +} \ No newline at end of file From 586734b44a491784bf531217bdf55f37add455f6 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Apr 2023 17:19:51 +0200 Subject: [PATCH 40/96] (MAJOR) Improvied sampling performance by removing the need to copy region data to a buffer first --- .../Rendering/Textures/PixelTexture.cs | 57 ++--------------- .../Textures/Sampler/AverageColorSampler.cs | 56 +++++++++-------- .../Rendering/Textures/Sampler/SamplerInfo.cs | 27 ++++++-- RGB.NET.Presets/Textures/BytePixelTexture.cs | 2 + RGB.NET.Presets/Textures/FloatPixelTexture.cs | 2 + .../Textures/Sampler/AverageByteSampler.cs | 62 ++++++++++--------- .../Textures/Sampler/AverageFloatSampler.cs | 50 ++++++++------- .../RGB.NET.Core.Tests/Helper/SimplexNoise.cs | 13 +--- .../Sampler/AverageColorSamplerTest.cs | 16 ++--- .../Texture/PixelTextureTest.cs | 4 +- .../Sampler/AverageByteSamplerTest.cs | 28 ++++++--- .../Sampler/AverageFloatSamplerTest.cs | 28 ++++++--- 12 files changed, 176 insertions(+), 169 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 3672e2c..c8a61cc 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -1,5 +1,4 @@ using System; -using System.Buffers; using System.Runtime.CompilerServices; namespace RGB.NET.Core; @@ -12,12 +11,6 @@ namespace RGB.NET.Core; public abstract class PixelTexture : ITexture where T : unmanaged { - #region Constants - - private const int STACK_ALLOC_LIMIT = 1024; - - #endregion - #region Properties & Fields private readonly int _dataPerPixel; @@ -85,31 +78,12 @@ public abstract class PixelTexture : ITexture if ((width == 0) || (height == 0)) return Color.Transparent; if ((width == 1) && (height == 1)) return GetColor(GetPixelData(x, y)); - int bufferSize = width * height * _dataPerPixel; - if (bufferSize <= STACK_ALLOC_LIMIT) - { - Span buffer = stackalloc T[bufferSize]; - GetRegionData(x, y, width, height, buffer); + SamplerInfo samplerInfo = new(x, y, width, height, _stride, _dataPerPixel, Data); - Span pixelData = stackalloc T[_dataPerPixel]; - Sampler.Sample(new SamplerInfo(width, height, buffer), pixelData); + Span pixelData = stackalloc T[_dataPerPixel]; + Sampler.Sample(samplerInfo, pixelData); - return GetColor(pixelData); - } - else - { - T[] rent = ArrayPool.Shared.Rent(bufferSize); - - Span buffer = new Span(rent)[..bufferSize]; - GetRegionData(x, y, width, height, buffer); - - Span pixelData = stackalloc T[_dataPerPixel]; - Sampler.Sample(new SamplerInfo(width, height, buffer), pixelData); - - ArrayPool.Shared.Return(rent); - - return GetColor(pixelData); - } + return GetColor(pixelData); } } @@ -152,27 +126,7 @@ public abstract class PixelTexture : ITexture /// The y-location. /// The pixel-data on the specified location. [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected virtual ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * _stride) + x, _dataPerPixel); - - /// - /// Writes the pixel-data of the specified region to the passed buffer. - /// - /// The x-location of the region to get the data for. - /// The y-location of the region to get the data for. - /// The width of the region to get the data for. - /// The height of the region to get the data for. - /// The buffer to write the data to. - protected virtual void GetRegionData(int x, int y, int width, int height, in Span buffer) - { - int dataWidth = width * _dataPerPixel; - ReadOnlySpan data = Data; - for (int i = 0; i < height; i++) - { - ReadOnlySpan dataSlice = data.Slice((((y + i) * _stride) + x) * _dataPerPixel, dataWidth); - Span destination = buffer.Slice(i * dataWidth, dataWidth); - dataSlice.CopyTo(destination); - } - } + private ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * _stride) + x, _dataPerPixel); #endregion } @@ -225,6 +179,7 @@ public sealed class PixelTexture : PixelTexture #region Methods /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override Color GetColor(in ReadOnlySpan pixel) => pixel[0]; #endregion diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index d8fd006..a9a7b86 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -30,20 +30,35 @@ public sealed class AverageColorSampler : ISampler float a = 0, r = 0, g = 0, b = 0; - if (Vector.IsHardwareAccelerated && (info.Data.Length >= Vector.Count)) + if (Vector.IsHardwareAccelerated && (info.Height > 1) && (info.Width >= ELEMENTS_PER_VECTOR)) { - int chunks = info.Data.Length / ELEMENTS_PER_VECTOR; - int missingElements = info.Data.Length - (chunks * ELEMENTS_PER_VECTOR); + int chunks = info.Width / ELEMENTS_PER_VECTOR; + int missingElements = info.Width - (chunks * ELEMENTS_PER_VECTOR); Vector sum = Vector.Zero; - fixed (Color* colorPtr = &MemoryMarshal.GetReference(info.Data)) + for (int y = 0; y < info.Height; y++) { - Color* current = colorPtr; - for (int i = 0; i < chunks; i++) + ReadOnlySpan data = info[y]; + + fixed (Color* colorPtr = &MemoryMarshal.GetReference(data)) { - sum = Vector.Add(sum, *(Vector*)current); - current += ELEMENTS_PER_VECTOR; + Color* current = colorPtr; + for (int i = 0; i < chunks; i++) + { + sum = Vector.Add(sum, *(Vector*)current); + current += ELEMENTS_PER_VECTOR; + } + } + + for (int i = 0; i < missingElements; i++) + { + Color color = data[^(i + 1)]; + + a += color.A; + r += color.R; + g += color.G; + b += color.B; } } @@ -54,26 +69,17 @@ public sealed class AverageColorSampler : ISampler g += sum[i + 2]; b += sum[i + 3]; } - - for (int i = 0; i < missingElements; i++) - { - Color color = info.Data[^(i + 1)]; - - a += color.A; - r += color.R; - g += color.G; - b += color.B; - } } else { - foreach (Color color in info.Data) - { - a += color.A; - r += color.R; - g += color.G; - b += color.B; - } + for (int y = 0; y < info.Height; y++) + foreach (Color color in info[y]) + { + a += color.A; + r += color.R; + g += color.G; + b += color.B; + } } pixelData[0] = new Color(a / count, r / count, g / count, b / count); diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs index ab7a0a1..bf59c93 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/SamplerInfo.cs @@ -10,20 +10,29 @@ public readonly ref struct SamplerInfo { #region Properties & Fields + private readonly ReadOnlySpan _data; + private readonly int _x; + private readonly int _y; + private readonly int _stride; + private readonly int _dataPerPixel; + private readonly int _dataWidth; + /// /// Gets the width of the region the data comes from. /// - public int Width { get; } + public readonly int Width; /// /// Gets the height of region the data comes from. /// - public int Height { get; } + public readonly int Height; /// - /// Gets the data to sample. + /// Gets the data for the requested row. /// - public ReadOnlySpan Data { get; } + /// The row to get the data for. + /// A readonly span containing the data of the row. + public ReadOnlySpan this[int row] => _data.Slice((((_y + row) * _stride) + _x) * _dataPerPixel, _dataWidth); #endregion @@ -35,11 +44,17 @@ public readonly ref struct SamplerInfo /// The width of the region the data comes from. /// The height of region the data comes from. /// The data to sample. - public SamplerInfo(int width, int height, ReadOnlySpan data) + public SamplerInfo(int x, int y, int width, int height, int stride, int dataPerPixel, in ReadOnlySpan data) { + this._x = x; + this._y = y; + this._data = data; + this._stride = stride; + this._dataPerPixel = dataPerPixel; this.Width = width; this.Height = height; - this.Data = data; + + _dataWidth = width * dataPerPixel; } #endregion diff --git a/RGB.NET.Presets/Textures/BytePixelTexture.cs b/RGB.NET.Presets/Textures/BytePixelTexture.cs index eb6cd1c..103b2ae 100644 --- a/RGB.NET.Presets/Textures/BytePixelTexture.cs +++ b/RGB.NET.Presets/Textures/BytePixelTexture.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using RGB.NET.Core; using RGB.NET.Presets.Textures.Sampler; @@ -59,6 +60,7 @@ public sealed class BytePixelTexture : PixelTexture #region Methods /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override Color GetColor(in ReadOnlySpan pixel) { return ColorFormat switch diff --git a/RGB.NET.Presets/Textures/FloatPixelTexture.cs b/RGB.NET.Presets/Textures/FloatPixelTexture.cs index 55d15fc..f60b177 100644 --- a/RGB.NET.Presets/Textures/FloatPixelTexture.cs +++ b/RGB.NET.Presets/Textures/FloatPixelTexture.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using RGB.NET.Core; using RGB.NET.Presets.Textures.Sampler; @@ -59,6 +60,7 @@ public sealed class FloatPixelTexture : PixelTexture #region Methods /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override Color GetColor(in ReadOnlySpan pixel) { return ColorFormat switch diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index 349afd7..1cfbdf8 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -24,41 +24,48 @@ public sealed class AverageByteSampler : ISampler int count = info.Width * info.Height; if (count == 0) return; - ReadOnlySpan data = info.Data; - int dataLength = pixelData.Length; Span sums = stackalloc uint[dataLength]; - if (Vector.IsHardwareAccelerated && (data.Length >= Vector.Count) && (dataLength <= Vector.Count)) + int elementsPerVector = Vector.Count / dataLength; + int valuesPerVector = elementsPerVector * dataLength; + if (Vector.IsHardwareAccelerated && (info.Height > 1) && (info.Width >= valuesPerVector) && (dataLength <= Vector.Count)) { - int elementsPerVector = Vector.Count / dataLength; - int valuesPerVector = elementsPerVector * dataLength; - - int chunks = data.Length / valuesPerVector; - int missingElements = data.Length - (chunks * valuesPerVector); + int chunks = info.Width / elementsPerVector; Vector sum1 = Vector.Zero; Vector sum2 = Vector.Zero; Vector sum3 = Vector.Zero; Vector sum4 = Vector.Zero; - fixed (byte* colorPtr = &MemoryMarshal.GetReference(data)) + for (int y = 0; y < info.Height; y++) { - byte* current = colorPtr; - for (int i = 0; i < chunks; i++) + ReadOnlySpan data = info[y]; + + fixed (byte* colorPtr = &MemoryMarshal.GetReference(data)) { - Vector bytes = *(Vector*)current; - Vector.Widen(bytes, out Vector short1, out Vector short2); - Vector.Widen(short1, out Vector int1, out Vector int2); - Vector.Widen(short2, out Vector int3, out Vector int4); + byte* current = colorPtr; + for (int i = 0; i < chunks; i++) + { + Vector bytes = *(Vector*)current; + Vector.Widen(bytes, out Vector short1, out Vector short2); + Vector.Widen(short1, out Vector int1, out Vector int2); + Vector.Widen(short2, out Vector int3, out Vector int4); - sum1 = Vector.Add(sum1, int1); - sum2 = Vector.Add(sum2, int2); - sum3 = Vector.Add(sum3, int3); - sum4 = Vector.Add(sum4, int4); + sum1 = Vector.Add(sum1, int1); + sum2 = Vector.Add(sum2, int2); + sum3 = Vector.Add(sum3, int3); + sum4 = Vector.Add(sum4, int4); - current += valuesPerVector; + current += valuesPerVector; + } } + + int missingElements = data.Length - (chunks * valuesPerVector); + int offset = chunks * valuesPerVector; + for (int i = 0; i < missingElements; i += dataLength) + for (int j = 0; j < sums.Length; j++) + sums[j] += data[offset + i + j]; } int value = 0; @@ -102,17 +109,16 @@ public sealed class AverageByteSampler : ISampler if (sumIndex >= dataLength) sumIndex = 0; } - - int offset = chunks * valuesPerVector; - for (int i = 0; i < missingElements; i += dataLength) - for (int j = 0; j < sums.Length; j++) - sums[j] += data[offset + i + j]; } else { - for (int i = 0; i < data.Length; i += dataLength) - for (int j = 0; j < sums.Length; j++) - sums[j] += data[i + j]; + for (int y = 0; y < info.Height; y++) + { + ReadOnlySpan data = info[y]; + for (int i = 0; i < data.Length; i += dataLength) + for (int j = 0; j < sums.Length; j++) + sums[j] += data[i + j]; + } } float divisor = count * byte.MaxValue; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index d53ad5d..dfa3f17 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -18,45 +18,51 @@ public sealed class AverageFloatSampler : ISampler int count = info.Width * info.Height; if (count == 0) return; - ReadOnlySpan data = info.Data; - int dataLength = pixelData.Length; Span sums = stackalloc float[dataLength]; - - if (Vector.IsHardwareAccelerated && (data.Length >= Vector.Count) && (dataLength <= Vector.Count)) - { - int elementsPerVector = Vector.Count / dataLength; - int valuesPerVector = elementsPerVector * dataLength; - int chunks = data.Length / valuesPerVector; - int missingElements = data.Length - (chunks * valuesPerVector); + int elementsPerVector = Vector.Count / dataLength; + int valuesPerVector = elementsPerVector * dataLength; + if (Vector.IsHardwareAccelerated && (info.Height > 1) && (info.Width >= valuesPerVector) && (dataLength <= Vector.Count)) + { + int chunks = info.Width / elementsPerVector; Vector sum = Vector.Zero; - fixed (float* colorPtr = &MemoryMarshal.GetReference(data)) + for (int y = 0; y < info.Height; y++) { - float* current = colorPtr; - for (int i = 0; i < chunks; i++) + ReadOnlySpan data = info[y]; + + fixed (float* colorPtr = &MemoryMarshal.GetReference(data)) { - sum = Vector.Add(sum, *(Vector*)current); - current += valuesPerVector; + float* current = colorPtr; + for (int i = 0; i < chunks; i++) + { + sum = Vector.Add(sum, *(Vector*)current); + current += valuesPerVector; + } } + + int missingElements = data.Length - (chunks * valuesPerVector); + int offset = chunks * valuesPerVector; + for (int i = 0; i < missingElements; i += dataLength) + for (int j = 0; j < sums.Length; j++) + sums[j] += data[offset + i + j]; } for (int i = 0; i < valuesPerVector; i += dataLength) for (int j = 0; j < sums.Length; j++) sums[j] += sum[i + j]; - - int offset = chunks * valuesPerVector; - for (int i = 0; i < missingElements; i += dataLength) - for (int j = 0; j < sums.Length; j++) - sums[j] += data[offset + i + j]; } else { - for (int i = 0; i < data.Length; i += dataLength) - for (int j = 0; j < sums.Length; j++) - sums[j] += data[i + j]; + for (int y = 0; y < info.Height; y++) + { + ReadOnlySpan data = info[y]; + for (int i = 0; i < data.Length; i += dataLength) + for (int j = 0; j < sums.Length; j++) + sums[j] += data[i + j]; + } } for (int i = 0; i < pixelData.Length; i++) diff --git a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs index aa756d6..f28dd16 100644 --- a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs +++ b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs @@ -1,4 +1,6 @@ -using System; +// ReSharper disable InconsistentNaming + +using System; namespace RGB.NET.Core.Tests.Helper; @@ -342,13 +344,4 @@ public static class SimplexNoise float v = h < 4 ? y : (h == 12) || (h == 14) ? x : z; // Fix repeats at h = 12 to 15 return ((h & 1) != 0 ? -u : u) + ((h & 2) != 0 ? -v : v); } - - private static float Grad(int hash, float x, float y, float z, float t) - { - int h = hash & 31; // Convert low 5 bits of hash code into 32 simple - float u = h < 24 ? x : y; // gradient directions, and compute dot product. - float v = h < 16 ? y : z; - float w = h < 8 ? z : t; - return ((h & 1) != 0 ? -u : u) + ((h & 2) != 0 ? -v : v) + ((h & 4) != 0 ? -w : w); - } } diff --git a/Tests/RGB.NET.Core.Tests/Sampler/AverageColorSamplerTest.cs b/Tests/RGB.NET.Core.Tests/Sampler/AverageColorSamplerTest.cs index 99398ec..49c1485 100644 --- a/Tests/RGB.NET.Core.Tests/Sampler/AverageColorSamplerTest.cs +++ b/Tests/RGB.NET.Core.Tests/Sampler/AverageColorSamplerTest.cs @@ -15,11 +15,11 @@ public class AverageColorSamplerTest data.Fill(new Core.Color(1f, 1f, 1f, 1f)); Core.Color[] result = new Core.Color[1]; - SamplerInfo info = new(2, 3, data[..6]); + SamplerInfo info = new(0, 0, 2, 3, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 1f, 1f, 1f), result[0]); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 1f, 1f, 1f), result[0]); } @@ -31,11 +31,11 @@ public class AverageColorSamplerTest data.Fill(new Core.Color(1f, 0f, 0f, 0f)); Core.Color[] result = new Core.Color[1]; - SamplerInfo info = new(2, 3, data[..6]); + SamplerInfo info = new(0, 0, 2, 3, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 0f, 0f, 0f), result[0]); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 0f, 0f, 0f), result[0]); } @@ -48,11 +48,11 @@ public class AverageColorSamplerTest data[i] = (i % 2) == 0 ? new Core.Color(1f, 0f, 0f, 0f) : new Core.Color(1f, 1f, 1f, 1f); Core.Color[] result = new Core.Color[1]; - SamplerInfo info = new(2, 3, data[..6]); + SamplerInfo info = new(0, 0, 2, 3, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 0.5f, 0.5f, 0.5f), result[0]); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(1f, 0.5f, 0.5f, 0.5f), result[0]); } @@ -72,11 +72,11 @@ public class AverageColorSamplerTest }; Core.Color[] result = new Core.Color[1]; - SamplerInfo info = new(2, 3, data[..6]); + SamplerInfo info = new(0, 0, 2, 3, 2, 1, data[..6]); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(0.5833333f, 0.5f, 0.291666657f, 0.25f), result[0]); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 1, data); new AverageColorSampler().Sample(info, result); Assert.AreEqual(new Core.Color(0.5019531f, 0.40234375f, 0.3486328f, 0.298828125f), result[0]); } diff --git a/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs b/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs index bfeeccc..52c2f83 100644 --- a/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs +++ b/Tests/RGB.NET.Core.Tests/Texture/PixelTextureTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using RGB.NET.Core.Tests.Helper; @@ -42,7 +41,6 @@ public class PixelTextureTest Core.Color[] data = new Core.Color[SIZE * SIZE]; SimplexNoise.Seed = 1872; - Random random = new(1872); for (int y = 0; y < SIZE; y++) for (int x = 0; x < SIZE; x++) data[(y * SIZE) + x] = HSVColor.Create(SimplexNoise.CalcPixel2D(x, y, 1f / SIZE) * 360, 1, 1); diff --git a/Tests/RGB.NET.Presets.Tests/Sampler/AverageByteSamplerTest.cs b/Tests/RGB.NET.Presets.Tests/Sampler/AverageByteSamplerTest.cs index 34a1e34..0ceb9e7 100644 --- a/Tests/RGB.NET.Presets.Tests/Sampler/AverageByteSamplerTest.cs +++ b/Tests/RGB.NET.Presets.Tests/Sampler/AverageByteSamplerTest.cs @@ -27,11 +27,15 @@ public class AverageByteSamplerTest data[index++] = colorData[i].GetB(); } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageByteSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); } @@ -53,11 +57,15 @@ public class AverageByteSamplerTest data[index++] = colorData[i].GetB(); } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageByteSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); } @@ -80,11 +88,15 @@ public class AverageByteSamplerTest data[index++] = colorData[i].GetB(); } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0.5f, 0.5f, 0.5f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageByteSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, (6f / 13f).GetByteValueFromPercentage(), (6f / 13f).GetByteValueFromPercentage(), (6f / 13f).GetByteValueFromPercentage()), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0.5f, 0.5f, 0.5f), new Color(result[0], result[1], result[2], result[3])); } @@ -114,11 +126,11 @@ public class AverageByteSamplerTest data[index++] = colorData[i].GetB(); } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 2, 4, data[..(6 * 4)]); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(149, 128, 74, 64), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageByteSampler().Sample(info, result); Assert.AreEqual(new Color(128, 103, 89, 76), new Color(result[0], result[1], result[2], result[3])); } diff --git a/Tests/RGB.NET.Presets.Tests/Sampler/AverageFloatSamplerTest.cs b/Tests/RGB.NET.Presets.Tests/Sampler/AverageFloatSamplerTest.cs index 6795f2c..a9ef8a4 100644 --- a/Tests/RGB.NET.Presets.Tests/Sampler/AverageFloatSamplerTest.cs +++ b/Tests/RGB.NET.Presets.Tests/Sampler/AverageFloatSamplerTest.cs @@ -27,11 +27,15 @@ public class AverageFloatSamplerTest data[index++] = colorData[i].B; } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageFloatSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 1f, 1f, 1f), new Color(result[0], result[1], result[2], result[3])); } @@ -53,11 +57,15 @@ public class AverageFloatSamplerTest data[index++] = colorData[i].B; } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageFloatSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0f, 0f, 0f), new Color(result[0], result[1], result[2], result[3])); } @@ -80,11 +88,15 @@ public class AverageFloatSamplerTest data[index++] = colorData[i].B; } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0.5f, 0.5f, 0.5f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 13, 13, 16, 4, data); + new AverageFloatSampler().Sample(info, result); + Assert.AreEqual(new Color(1f, 6f / 13f, 6f / 13f, 6f / 13f), new Color(result[0], result[1], result[2], result[3])); + + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(1f, 0.5f, 0.5f, 0.5f), new Color(result[0], result[1], result[2], result[3])); } @@ -114,11 +126,11 @@ public class AverageFloatSamplerTest data[index++] = colorData[i].B; } - SamplerInfo info = new(2, 3, data[..(6 * 4)]); + SamplerInfo info = new(0, 0, 2, 3, 2, 4, data[..(6 * 4)]); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(0.5833333f, 0.5f, 0.291666657f, 0.25f), new Color(result[0], result[1], result[2], result[3])); - info = new SamplerInfo(16, 16, data); + info = new SamplerInfo(0, 0, 16, 16, 16, 4, data); new AverageFloatSampler().Sample(info, result); Assert.AreEqual(new Color(0.5019531f, 0.40234375f, 0.3486328f, 0.298828125f), new Color(result[0], result[1], result[2], result[3])); } From 928d5c2ef95160afcb6c32d0b44a066a00fbaa62 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Apr 2023 17:36:22 +0200 Subject: [PATCH 41/96] Added license link to SimplexNoise --- Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs index f28dd16..322eb5c 100644 --- a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs +++ b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Core.Tests.Helper; // Simplex Noise for C# // Copyright © Benjamin Ward 2019 -// See LICENSE +// See LICENSE (https://github.com/WardBenjamin/SimplexNoise/blob/2afa9a63483562cc4c0a95bbfa6b183fc256a790/LICENSE.txt) // Simplex Noise implementation offering 1D, 2D, and 3D forms w/ values in the range of 0 to 255. // Based on work by Heikki Törmälä (2012) and Stefan Gustavson (2006). From 9f8e64fbcbe032b430f959e15ab8332287b34259 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Apr 2023 18:02:11 +0200 Subject: [PATCH 42/96] Changed DataPerPixel and Stride to be protected in PixelTexture --- .../Rendering/Textures/PixelTexture.cs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index c8a61cc..8fd1da6 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -1,4 +1,6 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global + +using System; using System.Runtime.CompilerServices; namespace RGB.NET.Core; @@ -12,9 +14,21 @@ public abstract class PixelTexture : ITexture where T : unmanaged { #region Properties & Fields + + /// + /// Gets the underlying pixel data. + /// + protected abstract ReadOnlySpan Data { get; } - private readonly int _dataPerPixel; - private readonly int _stride; + /// + /// Gets the amount of data-entries per pixel. + /// + protected readonly int DataPerPixel; + + /// + /// Gets the stride of the data. + /// + protected readonly int Stride; /// /// Gets or sets the sampler used to get the color of a region. @@ -24,11 +38,6 @@ public abstract class PixelTexture : ITexture /// public Size Size { get; } - /// - /// Gets the underlying pixel data. - /// - protected abstract ReadOnlySpan Data { get; } - /// public virtual Color this[in Point point] { @@ -78,9 +87,9 @@ public abstract class PixelTexture : ITexture if ((width == 0) || (height == 0)) return Color.Transparent; if ((width == 1) && (height == 1)) return GetColor(GetPixelData(x, y)); - SamplerInfo samplerInfo = new(x, y, width, height, _stride, _dataPerPixel, Data); + SamplerInfo samplerInfo = new(x, y, width, height, Stride, DataPerPixel, Data); - Span pixelData = stackalloc T[_dataPerPixel]; + Span pixelData = stackalloc T[DataPerPixel]; Sampler.Sample(samplerInfo, pixelData); return GetColor(pixelData); @@ -101,8 +110,8 @@ public abstract class PixelTexture : ITexture /// The stride of the data or -1 if the width should be used. public PixelTexture(int with, int height, int dataPerPixel, ISampler sampler, int stride = -1) { - this._stride = stride == -1 ? with : stride; - this._dataPerPixel = dataPerPixel; + this.Stride = stride == -1 ? with : stride; + this.DataPerPixel = dataPerPixel; this.Sampler = sampler; Size = new Size(with, height); @@ -126,7 +135,7 @@ public abstract class PixelTexture : ITexture /// The y-location. /// The pixel-data on the specified location. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * _stride) + x, _dataPerPixel); + private ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * Stride) + x, DataPerPixel); #endregion } From a2194849b66f51e3a9e17e8fc485b616d52a5dff Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Apr 2023 18:05:24 +0200 Subject: [PATCH 43/96] Changed stride and DataPerPixel in the PixelTexture to be a property for consistency --- RGB.NET.Core/Rendering/Textures/PixelTexture.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 8fd1da6..170d2d5 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -14,7 +14,7 @@ public abstract class PixelTexture : ITexture where T : unmanaged { #region Properties & Fields - + /// /// Gets the underlying pixel data. /// @@ -23,12 +23,12 @@ public abstract class PixelTexture : ITexture /// /// Gets the amount of data-entries per pixel. /// - protected readonly int DataPerPixel; + protected int DataPerPixel { get; } /// /// Gets the stride of the data. /// - protected readonly int Stride; + protected int Stride { get; } /// /// Gets or sets the sampler used to get the color of a region. From 93cd8055a28caa1fcd9c46e3853b65fff79d0891 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 24 Apr 2023 23:13:12 +0200 Subject: [PATCH 44/96] Simplified span-fixes in Samplers --- RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs | 3 +-- RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs | 3 +-- RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index a9a7b86..9ba2cb0 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Runtime.InteropServices; namespace RGB.NET.Core; @@ -41,7 +40,7 @@ public sealed class AverageColorSampler : ISampler { ReadOnlySpan data = info[y]; - fixed (Color* colorPtr = &MemoryMarshal.GetReference(data)) + fixed (Color* colorPtr = data) { Color* current = colorPtr; for (int i = 0; i < chunks; i++) diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index 1cfbdf8..bf5d7c6 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Runtime.InteropServices; using RGB.NET.Core; namespace RGB.NET.Presets.Textures.Sampler; @@ -42,7 +41,7 @@ public sealed class AverageByteSampler : ISampler { ReadOnlySpan data = info[y]; - fixed (byte* colorPtr = &MemoryMarshal.GetReference(data)) + fixed (byte* colorPtr = data) { byte* current = colorPtr; for (int i = 0; i < chunks; i++) diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index dfa3f17..cea8f45 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Runtime.InteropServices; using RGB.NET.Core; namespace RGB.NET.Presets.Textures.Sampler; @@ -33,7 +32,7 @@ public sealed class AverageFloatSampler : ISampler { ReadOnlySpan data = info[y]; - fixed (float* colorPtr = &MemoryMarshal.GetReference(data)) + fixed (float* colorPtr = data) { float* current = colorPtr; for (int i = 0; i < chunks; i++) From 0c8f48ea4406858bde5ef2733f3dc53f25a304ce Mon Sep 17 00:00:00 2001 From: David Ross Smith <5095074+DragRedSim@users.noreply.github.com> Date: Tue, 2 May 2023 21:50:47 +1000 Subject: [PATCH 45/96] Asus - Modify device type enum to add new items - USB keyboard with 5-zone lighting (also passed as a keyboard) - Watercooler (uses generic lighting) - Sourced from https://www.asus.com/microsite/aurareadydevportal/interface_aura_service_lib_1_1_i_aura_sdk.html --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 1 + RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 318850e..e3b093c 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -69,6 +69,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()), AsusDeviceType.DRAM_RGB => new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device), GetUpdateTrigger()), AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), + AsusDeviceType.KEYBOARD_5ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()), AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()), AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()), AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()), diff --git a/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs b/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs index bb5f16f..bb9a2be 100644 --- a/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs +++ b/RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs @@ -16,10 +16,12 @@ internal enum AsusDeviceType : uint EXTERNAL_BLUE_RAY_RGB = 0x61000, DRAM_RGB = 0x70000, KEYBOARD_RGB = 0x80000, + KEYBOARD_5ZONE_RGB = 0x80001, NB_KB_RGB = 0x81000, NB_KB_4ZONE_RGB = 0x81001, MOUSE_RGB = 0x90000, CHASSIS_RGB = 0xB0000, PROJECTOR_RGB = 0xC0000, + WATERCOOLER_RGB = 0xD1000, TERMINAL_RGB = 0xE0000 } \ No newline at end of file From e9cd657eac16b1606bf17b71a549d2719c8b05a3 Mon Sep 17 00:00:00 2001 From: David Ross Smith <5095074+DragRedSim@users.noreply.github.com> Date: Tue, 2 May 2023 21:51:32 +1000 Subject: [PATCH 46/96] Asus - Corrected unspecified device documentation - Previous info was copy/pasted from headset values --- RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs index fe3c238..6d20952 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusUnspecifiedRGBDevice.cs @@ -4,7 +4,7 @@ namespace RGB.NET.Devices.Asus; /// /// -/// Represents a Asus headset. +/// Represents a Asus device that is otherwise not handled by a more specific helper. /// public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice, IUnknownDevice { @@ -18,9 +18,9 @@ public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice, /// /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The specific information provided by Asus for the headset. + /// The specific information provided by Asus for the device. /// The ledId of the first led of this device. All other leds are created by incrementing this base-id by 1. /// The update trigger used to update this device. internal AsusUnspecifiedRGBDevice(AsusRGBDeviceInfo info, LedId baseLedId, IDeviceUpdateTrigger updateTrigger) From 184a5823e8f77117aef0fa39265eaa9f53a07aa2 Mon Sep 17 00:00:00 2001 From: David Ross Smith <5095074+DragRedSim@users.noreply.github.com> Date: Tue, 2 May 2023 21:55:36 +1000 Subject: [PATCH 47/96] Asus - added LED mapping for ROG Strix G15 (2021) - Device is a laptop with RGB in the keyboard, as well as an LED strip - LED mappings reuse those from the ROG Zephyrus Duo where appropriate --- .../Keyboard/AsusKeyboardLedMapping.cs | 45 +++++++++++++++++++ .../Keyboard/AsusKeyboardRGBDevice.cs | 5 ++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs index 9eb8d1f..298dd61 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs @@ -188,4 +188,49 @@ public static class LedMappings { LedId.Keyboard_Custom59, 131 }, { LedId.Keyboard_Custom60, 133 }, }; + + /// + /// A LED mapping containing extra lights for the ROG Strix G15 (2021) + /// + /// + /// + /// ASUS notebooks have extra lights under wide keys like space and backspace, these do not appear as keys on the device. + /// Instead they only appear in the Lights enumerable, this mapping maps the matching keys to the index of these lights. + /// There are also some keys which do not use the default key scan code mappings for LEDs, and instead rely on lights. + /// + /// You may add more of these by further populating . + /// + public static LedMapping ROGStrixG15 { get; } = new() + { + { LedId.Keyboard_Custom71, 4 }, //Mic Mute + { LedId.Keyboard_Custom72, 5 }, //Fan + { LedId.Keyboard_Custom73, 6 }, //ROG Logo + //{ LedId.Keyboard_Function, 127 }, //commented out because adding a mapping fails if a mapping already exists for a key, even if it is incorrect for this device + //use Keyboard_Custom36 in the default mapping to get the Fn key on this laptop + + { LedId.Keyboard_Custom52, 55 }, //backspace extra LEDs (x2) - these are named to match the appropriate LEDs in the previous ROG Zephyrus mapping + { LedId.Keyboard_Custom53, 57 }, + { LedId.Keyboard_Custom54, 97 }, //enter extra LEDs (x2) + { LedId.Keyboard_Custom55, 99 }, + { LedId.Keyboard_Custom56, 118 }, //right shift extra LEDs (x2) + { LedId.Keyboard_Custom57, 120 }, + { LedId.Keyboard_Custom58, 130 }, //space bar extra LEDs (x3) + { LedId.Keyboard_Custom59, 131 }, //this one specifically is also exposed as Custom7 (AsusLedID.KEY_NOCONVERT) in the main map + { LedId.Keyboard_Custom60, 133 }, + + { LedId.Keyboard_MediaVolumeDown, 2 }, + { LedId.Keyboard_MediaVolumeUp, 3 }, + { LedId.Keyboard_MediaPlay, 58 }, + { LedId.Keyboard_MediaStop, 79 }, + { LedId.Keyboard_MediaPreviousTrack, 100 }, + { LedId.Keyboard_MediaNextTrack, 121 }, + + { LedId.LedStripe1, 174 }, //front LED strip; yes, these are in reverse order, since the SDK exposes them from right to left + { LedId.LedStripe2, 173 }, + { LedId.LedStripe3, 172 }, + { LedId.LedStripe4, 171 }, + { LedId.LedStripe5, 170 }, + { LedId.LedStripe6, 169 }, + + }; } \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 30b429c..ee5f549 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -37,7 +37,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice ExtraLedMappings = new() { - new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15) + new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15), + new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15) }; #endregion @@ -65,7 +66,7 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice Date: Mon, 8 May 2023 20:47:47 +0200 Subject: [PATCH 48/96] Removed allocation when applying decorators --- RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs index 553e53b..bc39b5d 100644 --- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs @@ -74,9 +74,13 @@ public abstract class AbstractBrush : AbstractDecoratable, IBru if (Decorators.Count == 0) return; lock (Decorators) - foreach (IBrushDecorator decorator in Decorators) + // ReSharper disable once ForCanBeConvertedToForeach - Sadly this does not get optimized reliably and causes allocations if foreached + for (int i = 0; i < Decorators.Count; i++) + { + IBrushDecorator decorator = Decorators[i]; if (decorator.IsEnabled) decorator.ManipulateColor(rectangle, renderTarget, ref color); + } } /// From 7e72d3199beefca076fd12bbba2802b4ba2940e3 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 21:28:55 +0200 Subject: [PATCH 49/96] Added DevicesChanged-event to device providers --- .../Devices/AbstractRGBDeviceProvider.cs | 55 +++++++++++++++++-- RGB.NET.Core/Devices/IRGBDeviceProvider.cs | 7 ++- .../Events/DevicesChangedEventArgs.cs | 34 ++++++++++++ .../OpenRGBDeviceProvider.cs | 2 +- 4 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 RGB.NET.Core/Events/DevicesChangedEventArgs.cs diff --git a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs index d61fcbb..e76554e 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs @@ -20,8 +20,13 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// public bool ThrowsExceptions { get; protected set; } + /// + /// The list of devices managed by this device-provider. + /// + protected List InternalDevices { get; } = new(); + /// - public virtual IEnumerable Devices { get; protected set; } = Enumerable.Empty(); + public virtual IReadOnlyList Devices => new ReadOnlyCollection(InternalDevices); /// /// Gets the dictionary containing the registered update triggers. @@ -39,6 +44,9 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// public event EventHandler? Exception; + /// + public event EventHandler? DevicesChanged; + #endregion #region Constructors @@ -67,7 +75,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider InitializeSDK(); - Devices = new ReadOnlyCollection(GetLoadedDevices(loadFilter).ToList()); + foreach (IRGBDevice device in GetLoadedDevices(loadFilter)) + AddDevice(device); foreach (IDeviceUpdateTrigger updateTrigger in UpdateTriggerMapping.Values) updateTrigger.Start(); @@ -168,11 +177,43 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider foreach (IRGBDevice device in Devices) device.Dispose(); - Devices = Enumerable.Empty(); + List devices = new(InternalDevices); + foreach (IRGBDevice device in devices) + RemoveDevice(device); + UpdateTriggerMapping.Clear(); IsInitialized = false; } + /// + /// Adds the provided device to the list of managed devices. + /// + /// The device to add. + /// true if the device was added successfully; otherwise false. + protected virtual bool AddDevice(IRGBDevice device) + { + if (InternalDevices.Contains(device)) return false; + + InternalDevices.Add(device); + try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesAddedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ } + + return true; + } + + /// + /// Removes the provided device from the list of managed devices. + /// + /// The device to remove. + /// true if the device was removed successfully; otherwise false. + protected virtual bool RemoveDevice(IRGBDevice device) + { + if (!InternalDevices.Remove(device)) return false; + + try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesRemovedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ } + + return true; + } + /// /// Triggers the -event and throws the specified exception if is true and it is not overriden in the event. /// @@ -188,11 +229,17 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider } /// - /// Throws the event. + /// Throws the .event. /// /// The parameters passed to the event. protected virtual void OnException(ExceptionEventArgs args) => Exception?.Invoke(this, args); + /// + /// Throws the -event. + /// + /// The parameters passed to the event. + protected virtual void OnDevicesChanged(DevicesChangedEventArgs args) => DevicesChanged?.Invoke(this, args); + /// public virtual void Dispose() { diff --git a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs index 86f41e1..6e22d12 100644 --- a/RGB.NET.Core/Devices/IRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs @@ -29,7 +29,7 @@ public interface IRGBDeviceProvider : IDisposable /// /// Gets a collection of loaded by this . /// - IEnumerable Devices { get; } + IReadOnlyList Devices { get; } /// /// Gets a collection registered to this device provider. @@ -45,6 +45,11 @@ public interface IRGBDeviceProvider : IDisposable /// event EventHandler? Exception; + /// + /// Occures when the devices provided by this device provider changed. + /// + event EventHandler? DevicesChanged; + #endregion #region Methods diff --git a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs new file mode 100644 index 0000000..5b5012d --- /dev/null +++ b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +namespace RGB.NET.Core; + +public sealed class DevicesChangedEventArgs : EventArgs +{ + #region Properties & Fields + + public IList Added { get; } + public IList Removed { get; } + + #endregion + + #region Constructors + + private DevicesChangedEventArgs(IList added, IList removed) + { + this.Added = added; + this.Removed = removed; + } + + #endregion + + #region Methods + + public static DevicesChangedEventArgs CreateDevicesAddedArgs(params IRGBDevice[] addedDevices) => CreateDevicesAddedArgs((IEnumerable)addedDevices); + public static DevicesChangedEventArgs CreateDevicesAddedArgs(IEnumerable addedDevices) => new(new List(addedDevices), new List()); + + public static DevicesChangedEventArgs CreateDevicesRemovedArgs(params IRGBDevice[] removedDevices) => CreateDevicesRemovedArgs((IEnumerable)removedDevices); + public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IEnumerable removedDevices) => new(new List(), new List(removedDevices)); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 6c83a68..4d19484 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -161,7 +161,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider _clients.Clear(); DeviceDefinitions.Clear(); - Devices = Enumerable.Empty(); } + #endregion } From 67f3625993695d41e86e70aa85b0c1e55365e128 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 21:30:52 +0200 Subject: [PATCH 50/96] Changed device lists in the DevicesChanged-event to readonly --- RGB.NET.Core/Events/DevicesChangedEventArgs.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs index 5b5012d..53a5a97 100644 --- a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs +++ b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; namespace RGB.NET.Core; @@ -7,8 +8,8 @@ public sealed class DevicesChangedEventArgs : EventArgs { #region Properties & Fields - public IList Added { get; } - public IList Removed { get; } + public IReadOnlyList Added { get; } + public IReadOnlyList Removed { get; } #endregion @@ -16,8 +17,8 @@ public sealed class DevicesChangedEventArgs : EventArgs private DevicesChangedEventArgs(IList added, IList removed) { - this.Added = added; - this.Removed = removed; + this.Added = new ReadOnlyCollection(added); + this.Removed = new ReadOnlyCollection(removed); } #endregion From 4684e29610e68a610048f846b0e21b97d0650f76 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 21:47:51 +0200 Subject: [PATCH 51/96] Changed DevicesChanged-event to provide a single device instead of a list --- .../Events/DevicesChangedEventArgs.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs index 53a5a97..02706de 100644 --- a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs +++ b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; namespace RGB.NET.Core; @@ -8,28 +6,25 @@ public sealed class DevicesChangedEventArgs : EventArgs { #region Properties & Fields - public IReadOnlyList Added { get; } - public IReadOnlyList Removed { get; } + public IRGBDevice? Added { get; } + public IRGBDevice? Removed { get; } #endregion #region Constructors - private DevicesChangedEventArgs(IList added, IList removed) + private DevicesChangedEventArgs(IRGBDevice? added, IRGBDevice? removed) { - this.Added = new ReadOnlyCollection(added); - this.Removed = new ReadOnlyCollection(removed); + this.Added = added; + this.Removed = removed; } #endregion #region Methods - public static DevicesChangedEventArgs CreateDevicesAddedArgs(params IRGBDevice[] addedDevices) => CreateDevicesAddedArgs((IEnumerable)addedDevices); - public static DevicesChangedEventArgs CreateDevicesAddedArgs(IEnumerable addedDevices) => new(new List(addedDevices), new List()); - - public static DevicesChangedEventArgs CreateDevicesRemovedArgs(params IRGBDevice[] removedDevices) => CreateDevicesRemovedArgs((IEnumerable)removedDevices); - public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IEnumerable removedDevices) => new(new List(), new List(removedDevices)); + public static DevicesChangedEventArgs CreateDevicesAddedArgs(IRGBDevice addedDevice) => new(addedDevice, null); + public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IRGBDevice removedDevice) => new(null, removedDevice); #endregion } \ No newline at end of file From 124f76b382c064c568099893f90392f8626450f8 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 22:03:41 +0200 Subject: [PATCH 52/96] Fixed comment --- RGB.NET.Core/MVVM/AbstractBindable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Core/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs index b12f302..1cb7197 100644 --- a/RGB.NET.Core/MVVM/AbstractBindable.cs +++ b/RGB.NET.Core/MVVM/AbstractBindable.cs @@ -27,7 +27,7 @@ public abstract class AbstractBindable : IBindable /// Type of the property. /// Reference to the backing-filed. /// Value to apply. - /// true if the value needs to be updated; otherweise false. + /// true if the value needs to be updated; otherwise false. [MethodImpl(MethodImplOptions.AggressiveInlining)] protected virtual bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value); From 73b7f1f24fe17d4fc975c7e8bbab89c1c6e7ac4f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 22:04:36 +0200 Subject: [PATCH 53/96] Changed Bindable-Methods to not be virtual since there is not really a point in overriding them --- RGB.NET.Core/MVVM/AbstractBindable.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Core/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs index 1cb7197..26ac0b5 100644 --- a/RGB.NET.Core/MVVM/AbstractBindable.cs +++ b/RGB.NET.Core/MVVM/AbstractBindable.cs @@ -29,7 +29,7 @@ public abstract class AbstractBindable : IBindable /// Value to apply. /// true if the value needs to be updated; otherwise false. [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected virtual bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value); + protected bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value); /// /// Checks if the property already matches the desired value and updates it if not. @@ -40,7 +40,7 @@ public abstract class AbstractBindable : IBindable /// Name of the property used to notify listeners. This value is optional /// and can be provided automatically when invoked from compilers that support . /// true if the value was changed, false if the existing value matched the desired value. - protected virtual bool SetProperty(ref T storage, T value, [CallerMemberName] string? propertyName = null) + protected bool SetProperty(ref T storage, T value, [CallerMemberName] string? propertyName = null) { if (!RequiresUpdate(ref storage, value)) return false; @@ -55,7 +55,7 @@ public abstract class AbstractBindable : IBindable /// /// Name of the property used to notify listeners. This value is optional /// and can be provided automatically when invoked from compilers that support . - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); #endregion From a196d2a0a4a5832147f0d498631dcb74149c9377 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 8 May 2023 22:07:49 +0200 Subject: [PATCH 54/96] Changed the calculation mode of the SolidColor-brush to absolute for performance reasons --- RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs index 158705c..02f8e2d 100644 --- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs @@ -32,6 +32,8 @@ public sealed class SolidColorBrush : AbstractBrush public SolidColorBrush(Color color) { this.Color = color; + + CalculationMode = RenderMode.Absolute; } #endregion From d53801117b631b5549e3defb3260177a85270586 Mon Sep 17 00:00:00 2001 From: Danielle Date: Thu, 11 May 2023 19:44:37 +1000 Subject: [PATCH 55/96] Add more Razer Keyboard HIDs Added extra Razer Keyboard device HIDs, sourced from https://github.com/openrazer/openrazer. --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 313ef08..61e8968 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -109,6 +109,28 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wired + { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wireless + { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wired + { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wireless + { 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice { 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse }, From b90c47076a51d160c1bd6a23091fdc7cb8aa52fd Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 15 May 2023 22:45:28 +0200 Subject: [PATCH 56/96] Changed DevicesChangedEventArgs to only contain the device causing the change and an enum indicatin what happened --- .../Events/DevicesChangedEventArgs.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs index 02706de..a0d648b 100644 --- a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs +++ b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs @@ -6,25 +6,31 @@ public sealed class DevicesChangedEventArgs : EventArgs { #region Properties & Fields - public IRGBDevice? Added { get; } - public IRGBDevice? Removed { get; } + public IRGBDevice Device { get; } + public DevicesChangedAction Action { get; } #endregion #region Constructors - private DevicesChangedEventArgs(IRGBDevice? added, IRGBDevice? removed) + public DevicesChangedEventArgs(IRGBDevice device, DevicesChangedAction action) { - this.Added = added; - this.Removed = removed; + this.Device = device; + this.Action = action; } #endregion #region Methods - public static DevicesChangedEventArgs CreateDevicesAddedArgs(IRGBDevice addedDevice) => new(addedDevice, null); - public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IRGBDevice removedDevice) => new(null, removedDevice); + public static DevicesChangedEventArgs CreateDevicesAddedArgs(IRGBDevice addedDevice) => new(addedDevice, DevicesChangedAction.Added); + public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IRGBDevice removedDevice) => new(removedDevice, DevicesChangedAction.Removed); #endregion + + public enum DevicesChangedAction + { + Added, + Removed + } } \ No newline at end of file From 1532e31a33c7e070f15dd7e09fbf7c0117decb0d Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 15 May 2023 22:50:47 +0200 Subject: [PATCH 57/96] Improved Stop of DeviceUpdateTrigger --- RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index 00abcc7..a45ae6c 100644 --- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -133,7 +133,7 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger /// /// Stops the trigger. /// - public async void Stop() + public virtual async void Stop() { if (!IsRunning) return; @@ -141,7 +141,9 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger UpdateTokenSource?.Cancel(); if (UpdateTask != null) - await UpdateTask; + try { await UpdateTask.ConfigureAwait(false); } + catch (TaskCanceledException) { } + catch (OperationCanceledException) { } UpdateTask?.Dispose(); UpdateTask = null; From 0aca2d84b16868f35ded00d4f9c4db615bfb8345 Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sat, 20 May 2023 19:36:53 +0000 Subject: [PATCH 58/96] Apply suggestions from code review --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 61e8968..4513d3d 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -111,10 +111,10 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wired - { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wireless - { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wired - { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, #Wireless + { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired + { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless + { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired + { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, From 5dbcd9c81eb05564bd843ad91c2dfb7921ecbeaf Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 20 May 2023 22:34:29 +0200 Subject: [PATCH 59/96] Added SteelSeries Aerox 5 Wireless #323 --- RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index 417a448..61f3254 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -55,6 +55,8 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider { 0x1832, RGBDeviceType.Mouse, "Sensei Ten", LedMappings.MouseTwoZone, SteelSeriesDeviceType.TwoZone }, { 0x1838, RGBDeviceType.Mouse, "Aerox 3 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, { 0x183C, RGBDeviceType.Mouse, "Rival 5", LedMappings.MouseTenZone, SteelSeriesDeviceType.TenZone }, + { 0x1854, RGBDeviceType.Mouse, "Aerox 5 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, + { 0x1852, RGBDeviceType.Mouse, "Aerox 5 Wireless", LedMappings.MouseThreeZone, SteelSeriesDeviceType.ThreeZone }, //Keyboards { 0x161C, RGBDeviceType.Keyboard, "Apex 5", LedMappings.KeyboardMappingUk, SteelSeriesDeviceType.PerKey }, From e547bae2096bce5499c1c3b13745157f8c2b0ab0 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 23 May 2023 22:58:13 +0100 Subject: [PATCH 60/96] Update OpenRGB.NET nuget --- RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 94ce604..f3b3a81 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -57,7 +57,7 @@ - + From ca3c9fc5d382a017cc71b1a9f718c2e55a12ea6a Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Fri, 2 Jun 2023 22:14:12 +0100 Subject: [PATCH 61/96] WIP - Fixed corsair partial devices getting longer the first device has the correct size, all following ones are larger than intended. tested with corsaid lighting node core and sp120 --- .../Generic/CorsairRGBDevice.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index 94fd49c..e780de1 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; @@ -58,6 +58,18 @@ public abstract class CorsairRGBDevice : AbstractRGBDevice 0) + FixOffsetDeviceLayout(); + } + + protected virtual void FixOffsetDeviceLayout() + { + float minX = this.Min(x => x.Location.X); + float minY = this.Min(x => x.Location.Y); + + foreach (Led led in this) + led.Location = led.Location.Translate(-minX, -minY); } protected abstract LedMapping CreateMapping(IEnumerable ids); From d7fffb42136c9e46141821983be322bdd1d50b27 Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sat, 3 Jun 2023 19:28:15 +0000 Subject: [PATCH 62/96] Added comment to new corsai FixOffsetDeviceLayout-method --- RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index e780de1..9fcbca6 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -63,6 +63,9 @@ public abstract class CorsairRGBDevice : AbstractRGBDevice + /// Fixes the locations for devices split by offset by aligning them to the top left. + /// protected virtual void FixOffsetDeviceLayout() { float minX = this.Min(x => x.Location.X); From bf711325cfca92815347e3282e7ec95c954a7904 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 11 Jun 2023 10:19:27 +0200 Subject: [PATCH 63/96] Added more Razer keyboard and mouse PIDs --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 73 +++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 4513d3d..efa7daa 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -55,6 +55,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x010F, RGBDeviceType.Keyboard, "Anansi", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x011A, RGBDeviceType.Keyboard, "BlackWidow Ultimate 2013", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x011B, RGBDeviceType.Keyboard, "BlackWidow Stealth", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x011C, RGBDeviceType.Keyboard, "BlackWidow Tournament Edition 2014", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0202, RGBDeviceType.Keyboard, "DeathStalker Expert", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0203, RGBDeviceType.Keyboard, "BlackWidow Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0204, RGBDeviceType.Keyboard, "DeathStalker Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard }, @@ -77,6 +78,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0227, RGBDeviceType.Keyboard, "Huntsman", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0228, RGBDeviceType.Keyboard, "BlackWidow Elite", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x022A, RGBDeviceType.Keyboard, "Cynosa Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x022C, RGBDeviceType.Keyboard, "Cynosa Chroma Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x022D, RGBDeviceType.Keyboard, "Blade Stealth (Mid 2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, { 0x022F, RGBDeviceType.Keyboard, "Blade Pro FullHD (2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, { 0x0232, RGBDeviceType.Keyboard, "Blade Stealth (Late 2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, @@ -100,37 +102,40 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0252, RGBDeviceType.Keyboard, "Blade Stealth (Early 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, { 0x0253, RGBDeviceType.Keyboard, "Blade 15 Advanced (2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, { 0x0255, RGBDeviceType.Keyboard, "Blade 15 (Early 2020) Base", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, + { 0x0256, RGBDeviceType.Keyboard, "Blade Blade Pro (Early 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, + { 0x0257, RGBDeviceType.Keyboard, "Huntsman Mini", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0258, RGBDeviceType.Keyboard, "BlackWidow V3 Mini", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0259, RGBDeviceType.Keyboard, "Blade Stealth (Late 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard }, - { 0x25A, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The keyboard, only present when connected with cable - { 0x25C, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The dongle, may not be present when connected with cable + { 0x025A, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The keyboard, only present when connected with cable + { 0x025C, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The dongle, may not be present when connected with cable { 0x025D, RGBDeviceType.Keyboard, "Ornata Chroma V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x025E, RGBDeviceType.Keyboard, "Cynosa V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0266, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless + { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired + { 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless + { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired - { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless - { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired - { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless - { 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice { 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -138,6 +143,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0020, RGBDeviceType.Mouse, "Abyssus 1800", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0024, RGBDeviceType.Mouse, "Mamba 2012 (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0025, RGBDeviceType.Mouse, "Mamba 2012 (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0029, RGBDeviceType.Mouse, "DeathAdder V3 5G", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x002E, RGBDeviceType.Mouse, "Naga 2012", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x002F, RGBDeviceType.Mouse, "Imperator 2012", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0032, RGBDeviceType.Mouse, "Ouroboros 2012", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -167,6 +173,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0060, RGBDeviceType.Mouse, "Lancehead Tournament Edition", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0062, RGBDeviceType.Mouse, "Atheris (Receiver)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0064, RGBDeviceType.Mouse, "Basilisk", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0065, RGBDeviceType.Mouse, "Basilisk Essential", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0067, RGBDeviceType.Mouse, "Naga Trinity", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x006A, RGBDeviceType.Mouse, "Abyssus Elite (D.Va Edition)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x006B, RGBDeviceType.Mouse, "Abyssus Essential", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -177,24 +184,38 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0071, RGBDeviceType.Mouse, "DeathAdder Essential (White Edition)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0072, RGBDeviceType.Mouse, "Mamba Wireless (Receiver)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0073, RGBDeviceType.Mouse, "Mamba Wireless (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0077, RGBDeviceType.Mouse, "Pro Click (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0078, RGBDeviceType.Mouse, "Viper", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x007A, RGBDeviceType.Mouse, "Viper Ultimate (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x007B, RGBDeviceType.Mouse, "Viper Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x007C, RGBDeviceType.Mouse, "DeathAdder V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x007D, RGBDeviceType.Mouse, "DeathAdder V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0080, RGBDeviceType.Mouse, "Pro Click (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0083, RGBDeviceType.Mouse, "Basilisk X HyperSpeed", LedMappings.Mouse, RazerEndpointType.Mouse }, - { 0x0085, RGBDeviceType.Mouse, "Basilisk V2", LedMappings.Mouse, RazerEndpointType.Mouse }, - { 0x0088, RGBDeviceType.Mouse, "Basilisk Ultimate", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0084, RGBDeviceType.Mouse, "DeathAdder V2", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0085, RGBDeviceType.Mouse, "Basilisk V2", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0085, RGBDeviceType.Mouse, "Basilisk Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0088, RGBDeviceType.Mouse, "Basilisk Ultimate", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008A, RGBDeviceType.Mouse, "Viper Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x008C, RGBDeviceType.Mouse, "DeathAdder V2 Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008D, RGBDeviceType.Mouse, "Naga Left Handed Edition", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008F, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via usb connection { 0x0090, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via bluetooth connection { 0x0091, RGBDeviceType.Mouse, "Viper 8khz", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0094, RGBDeviceType.Mouse, "Orochi V2", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0096, RGBDeviceType.Mouse, "Naga X", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0099, RGBDeviceType.Mouse, "Basilisk v3", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x009A, RGBDeviceType.Mouse, "Pro Click Mini (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x009C, RGBDeviceType.Mouse, "DeathAdder V2 X Hyperspeed", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00A1, RGBDeviceType.Mouse, "DeathAdder V2 Lite", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00A5, RGBDeviceType.Mouse, "Viper V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00A6, RGBDeviceType.Mouse, "Viper V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A8, RGBDeviceType.Mouse, "Naga V2 Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, - + { 0x00AA, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00AB, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00B6, RGBDeviceType.Mouse, "DeathAdder V3 (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00B7, RGBDeviceType.Mouse, "DeathAdder V3 (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + // Mousepads { 0x0068, RGBDeviceType.Mousepad, "Firefly Hyperflux", LedMappings.Mousepad, RazerEndpointType.Mousepad }, { 0x0C00, RGBDeviceType.Mousepad, "Firefly", LedMappings.Mousepad, RazerEndpointType.Mousepad }, From 2b203b2308695f9c784d2d869c3ba6d6912a5677 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 12 Jun 2023 19:48:52 +0200 Subject: [PATCH 64/96] Fix duplicate --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index efa7daa..344f96e 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -194,7 +194,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0083, RGBDeviceType.Mouse, "Basilisk X HyperSpeed", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0084, RGBDeviceType.Mouse, "DeathAdder V2", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0085, RGBDeviceType.Mouse, "Basilisk V2", LedMappings.Mouse, RazerEndpointType.Mouse }, - { 0x0085, RGBDeviceType.Mouse, "Basilisk Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x0086, RGBDeviceType.Mouse, "Basilisk Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x0088, RGBDeviceType.Mouse, "Basilisk Ultimate", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008A, RGBDeviceType.Mouse, "Viper Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x008C, RGBDeviceType.Mouse, "DeathAdder V2 Mini", LedMappings.Mouse, RazerEndpointType.Mouse }, From fdc69fdac5e0273aaafcdb455e3297a752d71446 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 15 Jun 2023 23:03:24 +0200 Subject: [PATCH 65/96] Implemented recommended dispose pattern for DeviceProviders --- .../Devices/AbstractRGBDeviceProvider.cs | 34 +++++++++++++++++-- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 5 +-- .../CoolerMasterDeviceProvider.cs | 6 ++-- .../CorsairDeviceProvider.cs | 6 ++-- RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 8 +++++ RGB.NET.Devices.Debug/DebugDeviceProvider.cs | 6 ++-- .../LogitechDeviceProvider.cs | 6 ++-- RGB.NET.Devices.Msi/MsiDeviceProvider.cs | 8 ++--- .../NovationDeviceProvider.cs | 8 +++++ .../OpenRGBDeviceProvider.cs | 16 +++++---- .../PicoPiDeviceProvider.cs | 8 +++++ RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 6 ++-- .../SteelSeriesDeviceProvider.cs | 6 ++-- .../WS281XDeviceProvider.cs | 6 ++-- .../WootingDeviceProvider.cs | 6 ++-- 15 files changed, 103 insertions(+), 32 deletions(-) diff --git a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs index e76554e..2d1f2eb 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs @@ -12,6 +12,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider { #region Properties & Fields + private bool _isDisposed = false; + private readonly double _defaultUpdateRateHardLimit; /// @@ -60,6 +62,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider this._defaultUpdateRateHardLimit = defaultUpdateRateHardLimit; } + ~AbstractRGBDeviceProvider() => Dispose(false); + #endregion #region Methods @@ -67,6 +71,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + ThrowsExceptions = throwExceptions; try @@ -108,6 +114,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// The filtered collection of loaded devices. protected virtual IEnumerable GetLoadedDevices(RGBDeviceType loadFilter) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + List devices = new(); foreach (IRGBDevice device in LoadDevices()) { @@ -152,6 +160,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// The update trigger mapped to the specified id. protected virtual IDeviceUpdateTrigger GetUpdateTrigger(int id = -1, double? updateRateHardLimit = null) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + if (!UpdateTriggerMapping.TryGetValue(id, out IDeviceUpdateTrigger? updaeTrigger)) UpdateTriggerMapping[id] = (updaeTrigger = CreateUpdateTrigger(id, updateRateHardLimit ?? _defaultUpdateRateHardLimit)); @@ -171,6 +181,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// protected virtual void Reset() { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + foreach (IDeviceUpdateTrigger updateTrigger in UpdateTriggerMapping.Values) updateTrigger.Dispose(); @@ -192,6 +204,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// true if the device was added successfully; otherwise false. protected virtual bool AddDevice(IRGBDevice device) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + if (InternalDevices.Contains(device)) return false; InternalDevices.Add(device); @@ -207,6 +221,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// true if the device was removed successfully; otherwise false. protected virtual bool RemoveDevice(IRGBDevice device) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + if (!InternalDevices.Remove(device)) return false; try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesRemovedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ } @@ -241,12 +257,26 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider protected virtual void OnDevicesChanged(DevicesChangedEventArgs args) => DevicesChanged?.Invoke(this, args); /// - public virtual void Dispose() + public void Dispose() { - Reset(); + if (_isDisposed) return; + + try + { + Dispose(true); + } + catch { /* don't throw in dispose! */ } GC.SuppressFinalize(this); + + _isDisposed = true; } + /// + /// Disposes the object and frees all resources. + /// + /// true if explicitely called through the Dispose-Method, false if called by the destructor. + protected virtual void Dispose(bool disposing) => Reset(); + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index e3b093c..1558f6d 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -80,15 +80,16 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { _sdk?.ReleaseControl(0); } catch { /* at least we tried */ } _devices = null; _sdk = null; + _instance = null; } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index ab16a45..be075df 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -94,12 +94,14 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { _CoolerMasterSDK.Reload(); } catch { /* Unlucky.. */ } + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 87ab725..88f4509 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -300,12 +300,14 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ } try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ } + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index 2d85a44..0baad66 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -86,5 +86,13 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider return updateTrigger; } + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + _instance = null; + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs index f88ad50..f37e4e9 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs @@ -66,11 +66,13 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); _fakeDeviceDefinitions.Clear(); + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 4ebd163..f6a8862 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -254,9 +254,9 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { _LogitechGSDK.LogiLedRestoreLighting(); } catch { /* at least we tried */ } @@ -264,7 +264,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider try { _LogitechGSDK.UnloadLogitechGSDK(); } catch { /* at least we tried */ } - GC.SuppressFinalize(this); + _instance = null; } #endregion diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index fb18827..c45a2df 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -98,14 +98,14 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider private void ThrowMsiError(int errorCode, bool isCritical = false) => Throw(new MysticLightException(errorCode, _MsiSDK.GetErrorMessage(errorCode)), isCritical); /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { _MsiSDK.UnloadMsiSDK(); } catch { /* at least we tried */ } - - GC.SuppressFinalize(this); + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index 837a82c..9c9555b 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -67,5 +67,13 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider } } + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + _instance = null; + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 4d19484..50647a1 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -107,22 +107,22 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider continue; } - if (device.Zones.Length == 0) + if (device.Zones.Length == 0) continue; - if (device.Zones.All(z => z.LedCount == 0)) + if (device.Zones.All(z => z.LedCount == 0)) continue; OpenRGBUpdateQueue updateQueue = new(GetUpdateTrigger(), i, openRgb, device); - + bool anyZoneHasSegments = device.Zones.Any(z => z.Segments.Length > 0); - bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type)); + bool splitDeviceByZones = anyZoneHasSegments || PerZoneDeviceFlag.HasFlag(Helper.GetRgbNetDeviceType(device.Type)); if (!splitDeviceByZones) { yield return new OpenRGBGenericDevice(new OpenRGBDeviceInfo(device), updateQueue); continue; } - + int totalLedCount = 0; foreach (Zone zone in device.Zones) @@ -149,9 +149,9 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); foreach (OpenRgbClient client in _clients) { @@ -161,6 +161,8 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider _clients.Clear(); DeviceDefinitions.Clear(); + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs index f18116f..debdc39 100644 --- a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs +++ b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs @@ -126,5 +126,13 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider _sdks.Clear(); } + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + _instance = null; + } + #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 344f96e..05c18c1 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -342,15 +342,17 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); TryUnInit(); // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit //try { _RazerSDK.UnloadRazerSDK(); } //catch { /* at least we tried */ } + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index 61f3254..eeeff1c 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -133,12 +133,14 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider protected override IDeviceUpdateTrigger CreateUpdateTrigger(int id, double updateRateHardLimit) => new DeviceUpdateTrigger(updateRateHardLimit) { HeartbeatTimer = HEARTBEAT_TIMER }; /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); try { SteelSeriesSDK.Dispose(); } catch { /* shit happens */ } + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index 4d2e047..43077c8 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -70,11 +70,13 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); DeviceDefinitions.Clear(); + + _instance = null; } #endregion diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 484bbaf..079ffb1 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -94,15 +94,17 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + base.Dispose(disposing); lock (_WootingSDK.SdkLock) { try { _WootingSDK.UnloadWootingSDK(); } catch { /* at least we tried */ } } + + _instance = null; } #endregion From 0609e4957170531253b8ace965bbf04f5be70778 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 18 Jun 2023 19:54:57 +0200 Subject: [PATCH 66/96] Added locks around device provider instance usages --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 34 +++++++++++---- .../CoolerMasterDeviceProvider.cs | 30 +++++++++---- .../CorsairDeviceProvider.cs | 33 +++++++++++---- RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 26 +++++++++--- RGB.NET.Devices.Debug/DebugDeviceProvider.cs | 28 ++++++++++--- .../LogitechDeviceProvider.cs | 37 +++++++++++----- RGB.NET.Devices.Msi/MsiDeviceProvider.cs | 32 ++++++++++---- .../NovationDeviceProvider.cs | 26 +++++++++--- .../OpenRGBDeviceProvider.cs | 42 +++++++++++++------ .../PicoPiDeviceProvider.cs | 26 +++++++++--- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 36 +++++++++++----- .../SteelSeriesDeviceProvider.cs | 30 +++++++++---- .../WS281XDeviceProvider.cs | 28 ++++++++++--- .../WootingDeviceProvider.cs | 36 +++++++++++----- 14 files changed, 336 insertions(+), 108 deletions(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 1558f6d..805db68 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -16,11 +16,21 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static AsusDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static AsusDeviceProvider Instance => _instance ?? new AsusDeviceProvider(); + public static AsusDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new AsusDeviceProvider(); + } + } private IAuraSdk2? _sdk; private IAuraSyncDeviceCollection? _devices; //HACK DarthAffe 05.04.2021: Due to some researches this might fix the access violation in the asus-sdk @@ -35,8 +45,11 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public AsusDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}"); + _instance = this; + } } #endregion @@ -82,14 +95,17 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { _sdk?.ReleaseControl(0); } - catch { /* at least we tried */ } + try { _sdk?.ReleaseControl(0); } + catch { /* at least we tried */ } - _devices = null; - _sdk = null; - _instance = null; + _devices = null; + _sdk = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index be075df..8678e1a 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -17,11 +17,21 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static CoolerMasterDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static CoolerMasterDeviceProvider Instance => _instance ?? new CoolerMasterDeviceProvider(); + public static CoolerMasterDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new CoolerMasterDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -45,8 +55,11 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public CoolerMasterDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}"); + _instance = this; + } } #endregion @@ -96,12 +109,15 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { _CoolerMasterSDK.Reload(); } - catch { /* Unlucky.. */ } + try { _CoolerMasterSDK.Reload(); } + catch { /* Unlucky.. */ } - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 88f4509..89f4684 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -17,11 +17,21 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static CorsairDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static CorsairDeviceProvider Instance => _instance ?? new CorsairDeviceProvider(); + public static CorsairDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new CorsairDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -80,8 +90,11 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public CorsairDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}"); + _instance = this; + } } #endregion @@ -302,12 +315,18 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ } - try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ } + try { _CUESDK.CorsairDisconnect(); } + catch { /* at least we tried */ } - _instance = null; + try { _CUESDK.UnloadCUESDK(); } + catch { /* at least we tried */ } + + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index 0baad66..d5f2456 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -16,11 +16,21 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static DMXDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static DMXDeviceProvider Instance => _instance ?? new DMXDeviceProvider(); + public static DMXDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new DMXDeviceProvider(); + } + } /// /// Gets a list of all defined device-definitions. @@ -37,8 +47,11 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public DMXDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}"); + _instance = this; + } } #endregion @@ -89,9 +102,12 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs index f37e4e9..836c6db 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs @@ -16,11 +16,21 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static DebugDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static DebugDeviceProvider Instance => _instance ?? new DebugDeviceProvider(); + public static DebugDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new DebugDeviceProvider(); + } + } private List<(IDeviceLayout layout, Action>? updateLedsAction)> _fakeDeviceDefinitions = new(); @@ -34,8 +44,11 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public DebugDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DebugDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DebugDeviceProvider)}"); + _instance = this; + } } #endregion @@ -68,11 +81,14 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - _fakeDeviceDefinitions.Clear(); + _fakeDeviceDefinitions.Clear(); - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index f6a8862..4a12b39 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -20,11 +20,21 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static LogitechDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static LogitechDeviceProvider Instance => _instance ?? new LogitechDeviceProvider(); + public static LogitechDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new LogitechDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -112,7 +122,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider { 0x0A78, RGBDeviceType.Speaker, "G560", LedMappings.ZoneSpeaker, (LogitechDeviceType.Speaker, 4, 0) }, }; - + /// /// Gets the HID-definitions for wireless per-zone-devices. /// @@ -164,8 +174,12 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public LogitechDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) + throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}"); + _instance = this; + } } #endregion @@ -256,15 +270,18 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { _LogitechGSDK.LogiLedRestoreLighting(); } - catch { /* at least we tried */ } + try { _LogitechGSDK.LogiLedRestoreLighting(); } + catch { /* at least we tried */ } - try { _LogitechGSDK.UnloadLogitechGSDK(); } - catch { /* at least we tried */ } + try { _LogitechGSDK.UnloadLogitechGSDK(); } + catch { /* at least we tried */ } - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index c45a2df..1a305cc 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -17,11 +17,21 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static MsiDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static MsiDeviceProvider Instance => _instance ?? new MsiDeviceProvider(); + public static MsiDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new MsiDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -45,8 +55,11 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public MsiDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}"); + _instance = this; + } } #endregion @@ -100,12 +113,15 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { _MsiSDK.UnloadMsiSDK(); } - catch { /* at least we tried */ } - - _instance = null; + try { _MsiSDK.UnloadMsiSDK(); } + catch { /* at least we tried */ } + + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index 9c9555b..9a86f6f 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -17,11 +17,21 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static NovationDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static NovationDeviceProvider Instance => _instance ?? new NovationDeviceProvider(); + public static NovationDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new NovationDeviceProvider(); + } + } #endregion @@ -33,8 +43,11 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. private NovationDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}"); + _instance = this; + } } #endregion @@ -70,9 +83,12 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 50647a1..4ad82cc 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -14,6 +14,9 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private readonly List _clients = new(); private static OpenRGBDeviceProvider? _instance; @@ -21,7 +24,14 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider /// /// Gets the singleton instance. /// - public static OpenRGBDeviceProvider Instance => _instance ?? new OpenRGBDeviceProvider(); + public static OpenRGBDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new OpenRGBDeviceProvider(); + } + } /// /// Gets a list of all defined device-definitions. @@ -48,8 +58,11 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public OpenRGBDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(OpenRGBDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(OpenRGBDeviceProvider)}"); + _instance = this; + } } #endregion @@ -151,18 +164,21 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); - - foreach (OpenRgbClient client in _clients) + lock (_lock) { - try { client.Dispose(); } - catch { /* at least we tried */ } + base.Dispose(disposing); + + foreach (OpenRgbClient client in _clients) + { + try { client.Dispose(); } + catch { /* at least we tried */ } + } + + _clients.Clear(); + DeviceDefinitions.Clear(); + + _instance = null; } - - _clients.Clear(); - DeviceDefinitions.Clear(); - - _instance = null; } #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs index debdc39..c799460 100644 --- a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs +++ b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs @@ -25,11 +25,21 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static PicoPiDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static PicoPiDeviceProvider Instance => _instance ?? new PicoPiDeviceProvider(); + public static PicoPiDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new PicoPiDeviceProvider(); + } + } /// /// Gets the HID-definitions for PicoPi-devices. @@ -57,8 +67,11 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public PicoPiDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(PicoPiDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(PicoPiDeviceProvider)}"); + _instance = this; + } } #endregion @@ -129,9 +142,12 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 05c18c1..54cabf8 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -19,11 +19,21 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static RazerDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static RazerDeviceProvider Instance => _instance ?? new RazerDeviceProvider(); + public static RazerDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new RazerDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -254,7 +264,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0F13, RGBDeviceType.Unknown, "Lian Li O11", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F1D, RGBDeviceType.Unknown, "Mouse Bungee V3 Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F1F, RGBDeviceType.LedController, "Addressable RGB Controller", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, - + }; #endregion @@ -267,8 +277,11 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public RazerDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}"); + _instance = this; + } } #endregion @@ -344,15 +357,18 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - TryUnInit(); + TryUnInit(); - // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit - //try { _RazerSDK.UnloadRazerSDK(); } - //catch { /* at least we tried */ } + // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit + //try { _RazerSDK.UnloadRazerSDK(); } + //catch { /* at least we tried */ } - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index eeeff1c..0bf1958 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -20,11 +20,21 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static SteelSeriesDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static SteelSeriesDeviceProvider Instance => _instance ?? new SteelSeriesDeviceProvider(); + public static SteelSeriesDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new SteelSeriesDeviceProvider(); + } + } private const int VENDOR_ID = 0x1038; @@ -93,8 +103,11 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public SteelSeriesDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SteelSeriesDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SteelSeriesDeviceProvider)}"); + _instance = this; + } } #endregion @@ -135,12 +148,15 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - try { SteelSeriesSDK.Dispose(); } - catch { /* shit happens */ } + try { SteelSeriesSDK.Dispose(); } + catch { /* shit happens */ } - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index 43077c8..e150028 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -16,11 +16,21 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static WS281XDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static WS281XDeviceProvider Instance => _instance ?? new WS281XDeviceProvider(); + public static WS281XDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new WS281XDeviceProvider(); + } + } /// /// Gets a list of all defined device-definitions. @@ -39,8 +49,11 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public WS281XDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WS281XDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WS281XDeviceProvider)}"); + _instance = this; + } } #endregion @@ -72,11 +85,14 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); + lock (_lock) + { + base.Dispose(disposing); - DeviceDefinitions.Clear(); + DeviceDefinitions.Clear(); - _instance = null; + _instance = null; + } } #endregion diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 079ffb1..6d16b2f 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -16,11 +16,21 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static WootingDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static WootingDeviceProvider Instance => _instance ?? new WootingDeviceProvider(); + public static WootingDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new WootingDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications. @@ -57,8 +67,11 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public WootingDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}"); + _instance = this; + } } #endregion @@ -96,15 +109,18 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider /// protected override void Dispose(bool disposing) { - base.Dispose(disposing); - - lock (_WootingSDK.SdkLock) + lock (_lock) { - try { _WootingSDK.UnloadWootingSDK(); } - catch { /* at least we tried */ } - } + base.Dispose(disposing); - _instance = null; + lock (_WootingSDK.SdkLock) + { + try { _WootingSDK.UnloadWootingSDK(); } + catch { /* at least we tried */ } + } + + _instance = null; + } } #endregion From ba99ecfbdcabdee3a9eb5d952d449e6457fc8a57 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 9 Jul 2023 13:43:54 +0200 Subject: [PATCH 67/96] Layout - Allow loading directly from a stream --- RGB.NET.Layout/DeviceLayout.cs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs index bdddb99..24efd37 100644 --- a/RGB.NET.Layout/DeviceLayout.cs +++ b/RGB.NET.Layout/DeviceLayout.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -118,20 +118,16 @@ public class DeviceLayout : IDeviceLayout /// /// Creates a new from the specified xml. /// - /// The path to the xml file. + /// The stream that contains the layout to be loaded. /// The type of the custom data. /// The type of the custom data of the leds. /// The deserialized . - public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null) + public static DeviceLayout? Load(Stream stream, Type? customDeviceDataType = null, Type? customLedDataType = null) { - if (!File.Exists(path)) return null; - try { XmlSerializer serializer = new(typeof(DeviceLayout)); - using StreamReader reader = new(path); - - DeviceLayout? layout = serializer.Deserialize(reader) as DeviceLayout; + DeviceLayout? layout = serializer.Deserialize(stream) as DeviceLayout; if (layout != null) layout.CustomData = layout.GetCustomData(layout.InternalCustomData, customDeviceDataType); @@ -155,6 +151,21 @@ public class DeviceLayout : IDeviceLayout } } + /// + /// Creates a new from the specified xml. + /// + /// The path to the xml file. + /// The type of the custom data. + /// The type of the custom data of the leds. + /// The deserialized . + public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null) + { + if (!File.Exists(path)) return null; + + using Stream stream = File.OpenRead(path); + return Load(stream, customDeviceDataType, customLedDataType); + } + /// /// Gets the deserialized custom data. /// @@ -177,4 +188,4 @@ public class DeviceLayout : IDeviceLayout } #endregion -} \ No newline at end of file +} From 803acf2f994f6d54e1e23d2fd1cf44918fa672bd Mon Sep 17 00:00:00 2001 From: DELUUXE Date: Sat, 22 Jul 2023 23:39:23 +0200 Subject: [PATCH 68/96] Added Razer Blade 16 PID --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 344f96e..f2e6aed 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -127,6 +127,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x029F, RGBDeviceType.Keyboard, "Blade 16 (2023)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired From 6f91af903974ac745915fd41b9d45301c9e64a0b Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 23 Jul 2023 19:49:30 +0200 Subject: [PATCH 69/96] Readded support for older CUE-SDKs --- .../CorsairLegacyDeviceProvider.cs | 213 ++ .../Custom/CorsairCustomRGBDevice.cs | 74 + .../Custom/CorsairCustomRGBDeviceInfo.cs | 155 ++ .../Enum/CorsairAccessMode.cs | 14 + .../Enum/CorsairChannelDeviceType.cs | 25 + .../Enum/CorsairDeviceCaps.cs | 28 + .../Enum/CorsairDeviceType.cs | 27 + .../Enum/CorsairError.cs | 41 + .../Enum/CorsairLedId.cs | 1742 +++++++++++++++++ .../Enum/CorsairLogicalKeyboardLayout.cs | 30 + .../Enum/CorsairPhysicalKeyboardLayout.cs | 35 + .../Enum/CorsairPhysicalMouseLayout.cs | 107 + .../Exceptions/CUEException.cs | 36 + .../Generic/CorsairDeviceUpdateQueue.cs | 80 + .../Generic/CorsairProtocolDetails.cs | 65 + .../Generic/CorsairRGBDevice.cs | 76 + .../Generic/CorsairRGBDeviceInfo.cs | 95 + .../Generic/ICorsairRGBDevice.cs | 11 + .../Generic/LedMappings.cs | 302 +++ .../CorsairGraphicsCardRGBDevice.cs | 27 + .../CorsairGraphicsCardRGBDeviceInfo.cs | 28 + .../Headset/CorsairHeadsetRGBDevice.cs | 27 + .../Headset/CorsairHeadsetRGBDeviceInfo.cs | 25 + .../CorsairHeadsetStandRGBDevice.cs | 27 + .../CorsairHeadsetStandRGBDeviceInfo.cs | 25 + .../Helper/DictionaryExtension.cs | 12 + .../Helper/NativeExtensions.cs | 18 + .../Keyboard/CorsairKeyboardRGBDevice.cs | 33 + .../Keyboard/CorsairKeyboardRGBDeviceInfo.cs | 56 + .../Mainboard/CorsairMainboardRGBDevice.cs | 27 + .../CorsairMainboardRGBDeviceInfo.cs | 28 + .../Memory/CorsairMemoryRGBDevice.cs | 27 + .../Memory/CorsairMemoryRGBDeviceInfo.cs | 28 + .../Mouse/CorsairMouseRGBDevice.cs | 27 + .../Mouse/CorsairMouseRGBDeviceInfo.cs | 36 + .../Mousepad/CorsairMousepadRGBDevice.cs | 27 + .../Mousepad/CorsairMousepadRGBDeviceInfo.cs | 25 + .../Native/_CUESDK.cs | 193 ++ .../Native/_CorsairChannelDeviceInfo.cs | 27 + .../Native/_CorsairChannelInfo.cs | 33 + .../Native/_CorsairChannelsInfo.cs | 28 + .../Native/_CorsairDeviceInfo.cs | 58 + .../Native/_CorsairLedColor.cs | 37 + .../Native/_CorsairLedPosition.cs | 42 + .../Native/_CorsairLedPositions.cs | 26 + .../Native/_CorsairProtocolDetails.cs | 43 + RGB.NET.Devices.Corsair_Legacy/README.md | 24 + .../RGB.NET.Devices.Corsair_Legacy.csproj | 63 + ....Devices.Corsair_Legacy.csproj.DotSettings | 22 + .../Touchbar/CorsairTouchbarRGBDevice.cs | 27 + .../Touchbar/CorsairTouchbarRGBDeviceInfo.cs | 28 + RGB.NET.sln | 7 + 52 files changed, 4317 insertions(+) create mode 100644 RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairChannelDeviceType.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLogicalKeyboardLayout.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalKeyboardLayout.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalMouseLayout.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/README.md create mode 100644 RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj create mode 100644 RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj.DotSettings create mode 100644 RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDeviceInfo.cs diff --git a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs new file mode 100644 index 0000000..20a1b58 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs @@ -0,0 +1,213 @@ +// 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.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a device provider responsible for corsair (CUE) devices. +/// +public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider +{ + #region Properties & Fields + + private static CorsairLegacyDeviceProvider? _instance; + /// + /// Gets the singleton instance. + /// + public static CorsairLegacyDeviceProvider Instance => _instance ?? new CorsairLegacyDeviceProvider(); + + /// + /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. + /// The first match will be used. + /// + public static List PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" }; + + /// + /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. + /// The first match will be used. + /// + public static List PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" }; + + /// + /// Gets the protocol details for the current SDK-connection. + /// + public CorsairProtocolDetails? ProtocolDetails { get; private set; } + + /// + /// Gets the last error documented by CUE. + /// + public static CorsairError LastError => _CUESDK.CorsairGetLastError(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Thrown if this constructor is called even if there is already an instance of this class. + public CorsairLegacyDeviceProvider() + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}"); + _instance = this; + } + + #endregion + + #region Methods + + /// + protected override void InitializeSDK() + { + _CUESDK.Reload(); + + ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake()); + + CorsairError error = LastError; + if (error != CorsairError.Success) + Throw(new CUEException(error), true); + + if (ProtocolDetails.BreakingChanges) + Throw(new RGBDeviceException("The SDK currently used isn't compatible with the installed version of CUE.\r\n" + + $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n" + + $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})"), true); + + // DarthAffe 02.02.2021: 127 is iCUE + if (!_CUESDK.CorsairSetLayerPriority(128)) + Throw(new CUEException(LastError)); + } + + /// + protected override IEnumerable LoadDevices() + { + foreach (ICorsairRGBDevice corsairDevice in LoadCorsairDevices()) + { + corsairDevice.Initialize(); + yield return corsairDevice; + } + } + + private IEnumerable LoadCorsairDevices() + { + int deviceCount = _CUESDK.CorsairGetDeviceCount(); + for (int i = 0; i < deviceCount; i++) + { + _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo))!; + if (!((CorsairDeviceCaps)nativeDeviceInfo.capsMask).HasFlag(CorsairDeviceCaps.Lighting)) + continue; // Everything that doesn't support lighting control is useless + + CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i); + switch (nativeDeviceInfo.type) + { + case CorsairDeviceType.Keyboard: + yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Mouse: + yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Headset: + yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Mousepad: + yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.HeadsetStand: + yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.MemoryModule: + yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Mainboard: + yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.GraphicsCard: + yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Touchbar: + yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(i, nativeDeviceInfo), updateQueue); + break; + + case CorsairDeviceType.Cooler: + case CorsairDeviceType.CommanderPro: + case CorsairDeviceType.LightningNodePro: + List<_CorsairChannelInfo> channels = GetChannels(nativeDeviceInfo).ToList(); + int channelsLedCount = channels.Sum(x => x.totalLedsCount); + int deviceLedCount = nativeDeviceInfo.ledsCount - channelsLedCount; + + if (deviceLedCount > 0) + yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, deviceLedCount), updateQueue); + + int ledOffset = deviceLedCount; + foreach (_CorsairChannelInfo channelInfo in channels) + { + int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo)); + IntPtr channelDeviceInfoPtr = channelInfo.devices; + for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++) + { + _CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!; + + yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue); + + ledOffset += channelDeviceInfo.deviceLedCount; + channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize); + } + } + break; + + default: + Throw(new RGBDeviceException("Unknown Device-Type")); + break; + } + } + } + + private static IEnumerable<_CorsairChannelInfo> GetChannels(_CorsairDeviceInfo deviceInfo) + { + _CorsairChannelsInfo? channelsInfo = deviceInfo.channels; + if (channelsInfo == null) yield break; + + IntPtr channelInfoPtr = channelsInfo.channels; + for (int channel = 0; channel < channelsInfo.channelsCount; channel++) + { + yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!; + + int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo)); + channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize); + } + } + + /// + protected override void Reset() + { + ProtocolDetails = null; + + base.Reset(); + } + + /// + public override void Dispose() + { + base.Dispose(); + + try { _CUESDK.UnloadCUESDK(); } + catch { /* at least we tried */ } + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs new file mode 100644 index 0000000..4f5a301 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs @@ -0,0 +1,74 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair custom. +/// +public class CorsairCustomRGBDevice : CorsairRGBDevice, IUnknownDevice +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the custom-device. + /// The queue used to update this device. + internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, new LedMapping(), updateQueue) + { } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + Mapping.Clear(); + + _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); + if (nativeLedPositions == null) return; + + int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); + IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset)); + + LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType); + for (int i = 0; i < DeviceInfo.LedCount; i++) + { + LedId ledId = referenceLedId + i; + _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); + if (ledPosition == null) + { + ptr = new IntPtr(ptr.ToInt64() + structSize); + continue; + } + + Mapping.Add(ledId, ledPosition.LedId); + + Rectangle rectangle = ledPosition.ToRectangle(); + AddLed(ledId, rectangle.Location, rectangle.Size); + + ptr = new IntPtr(ptr.ToInt64() + structSize); + } + } + + private static LedId GetReferenceLed(RGBDeviceType deviceType) + => deviceType switch + { + RGBDeviceType.LedStripe => LedId.LedStripe1, + RGBDeviceType.Fan => LedId.Fan1, + RGBDeviceType.Cooler => LedId.Cooler1, + _ => LedId.Custom1 + }; + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs new file mode 100644 index 0000000..3664f0d --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs @@ -0,0 +1,155 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Properties & Fields + + /// + /// Gets the amount of LEDs this device contains. + /// + public int LedCount { get; } + + /// + /// Gets the offset used to access the LEDs of this device. + /// + internal int LedOffset { get; } + + #endregion + + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + /// The native representing this device. + /// The offset used to find the LEDs of this device. + 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.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 + + private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType) + => deviceType switch + { + CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown, + CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanML => RGBDeviceType.Fan, + CorsairChannelDeviceType.DAP => RGBDeviceType.Fan, + CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan, + CorsairChannelDeviceType.EightLedSeriesFan => RGBDeviceType.Fan, + CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe, + CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler, + CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler, + _ => 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) + { + case CorsairChannelDeviceType.Invalid: + return model; + + 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.FanQL: + return "QL Fan"; + + case CorsairChannelDeviceType.EightLedSeriesFan: + return "8-Led-Series Fan Fan"; + + case CorsairChannelDeviceType.Strip: + // LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single + if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138)) + return "LS100 LED Strip (dual monitor)"; + else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84)) + return "LS100 LED Strip (single monitor)"; + // Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long + else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15)) + return "LS100 LED Strip (short)"; + else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27)) + return "LS100 LED Strip (long)"; + // Device model is "Commander Pro" for regular LED strips + else + return "LED Strip"; + + case CorsairChannelDeviceType.DAP: + return "DAP Fan"; + + case CorsairChannelDeviceType.WaterBlock: + return "Water Block"; + + case CorsairChannelDeviceType.Pump: + return "Pump"; + + default: +#pragma warning disable CA2208 // Instantiate argument exceptions correctly + throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly + } + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs new file mode 100644 index 0000000..98885da --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs @@ -0,0 +1,14 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Represents an SDK access mode. +/// +public enum CorsairAccessMode +{ + ExclusiveLightingControl = 0 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairChannelDeviceType.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairChannelDeviceType.cs new file mode 100644 index 0000000..99c943f --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairChannelDeviceType.cs @@ -0,0 +1,25 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of available corsair channel device types. +/// +public enum CorsairChannelDeviceType +{ + Invalid = 0, + FanHD = 1, + FanSP = 2, + FanLL = 3, + FanML = 4, + Strip = 5, + DAP = 6, + Pump = 7, + FanQL = 8, + WaterBlock = 9, + EightLedSeriesFan = 10 // Previously called FanSPPRO +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs new file mode 100644 index 0000000..2e77521 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs @@ -0,0 +1,28 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +using System; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of corsair device capabilities. +/// +[Flags] +public enum CorsairDeviceCaps +{ + /// + /// For devices that do not support any SDK functions. + /// + None = 0, + + /// + /// For devices that has controlled lighting. + /// + Lighting = 1, + + /// + /// For devices that provide current state through set of properties. + /// + PropertyLookup = 2 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs new file mode 100644 index 0000000..339a72f --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs @@ -0,0 +1,27 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of available corsair device types. +/// +public enum CorsairDeviceType +{ + Unknown = 0, + Mouse = 1, + Keyboard = 2, + Headset = 3, + Mousepad = 4, + HeadsetStand = 5, + CommanderPro = 6, + LightningNodePro = 7, + MemoryModule = 8, + Cooler = 9, + Mainboard = 10, + GraphicsCard = 11, + Touchbar = 12 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs new file mode 100644 index 0000000..dfe8703 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs @@ -0,0 +1,41 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Shared list of all errors which could happen during calling of Corsair* functions. +/// +public enum CorsairError +{ + /// + /// If previously called function completed successfully. + /// + Success, + + /// + /// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error) + /// + ServerNotFound, + + /// + /// If some other client has or took over exclusive control. (runtime error) + /// + NoControl, + + /// + /// If developer did not perform protocol handshake. (developer error) + /// + ProtocolHandshakeMissing, + + /// + /// If developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old. + /// Check CorsairProtocolDetails for details). (developer error) + /// + IncompatibleProtocol, + + /// + /// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error) + /// + InvalidArguments +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs new file mode 100644 index 0000000..00ce18b --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs @@ -0,0 +1,1742 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global +#pragma warning disable 1591 + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of all LEDs available for all corsair devices. +/// +public enum CorsairLedId +{ + Invalid = 0, + Escape = 1, + F1 = 2, + F2 = 3, + F3 = 4, + F4 = 5, + F5 = 6, + F6 = 7, + F7 = 8, + F8 = 9, + F9 = 10, + F10 = 11, + F11 = 12, + GraveAccentAndTilde = 13, + D1 = 14, + D2 = 15, + D3 = 16, + D4 = 17, + D5 = 18, + D6 = 19, + D7 = 20, + D8 = 21, + D9 = 22, + D0 = 23, + MinusAndUnderscore = 24, + Tab = 25, + Q = 26, + W = 27, + E = 28, + R = 29, + T = 30, + Y = 31, + U = 32, + I = 33, + O = 34, + P = 35, + BracketLeft = 36, + CapsLock = 37, + A = 38, + S = 39, + D = 40, + F = 41, + G = 42, + H = 43, + J = 44, + K = 45, + L = 46, + SemicolonAndColon = 47, + ApostropheAndDoubleQuote = 48, + LeftShift = 49, + NonUsBackslash = 50, + Z = 51, + X = 52, + C = 53, + V = 54, + B = 55, + N = 56, + M = 57, + CommaAndLessThan = 58, + PeriodAndBiggerThan = 59, + SlashAndQuestionMark = 60, + LeftCtrl = 61, + LeftGui = 62, + LeftAlt = 63, + Lang2 = 64, + Space = 65, + Lang1 = 66, + International2 = 67, + RightAlt = 68, + RightGui = 69, + Application = 70, + LedProgramming = 71, + Brightness = 72, + F12 = 73, + PrintScreen = 74, + ScrollLock = 75, + PauseBreak = 76, + Insert = 77, + Home = 78, + PageUp = 79, + BracketRight = 80, + Backslash = 81, + NonUsTilde = 82, + Enter = 83, + International1 = 84, + EqualsAndPlus = 85, + International3 = 86, + Backspace = 87, + Delete = 88, + End = 89, + PageDown = 90, + RightShift = 91, + RightCtrl = 92, + UpArrow = 93, + LeftArrow = 94, + DownArrow = 95, + RightArrow = 96, + WinLock = 97, + Mute = 98, + Stop = 99, + ScanPreviousTrack = 100, + PlayPause = 101, + ScanNextTrack = 102, + NumLock = 103, + KeypadSlash = 104, + KeypadAsterisk = 105, + KeypadMinus = 106, + KeypadPlus = 107, + KeypadEnter = 108, + Keypad7 = 109, + Keypad8 = 110, + Keypad9 = 111, + KeypadComma = 112, + Keypad4 = 113, + Keypad5 = 114, + Keypad6 = 115, + Keypad1 = 116, + Keypad2 = 117, + Keypad3 = 118, + Keypad0 = 119, + KeypadPeriodAndDelete = 120, + G1 = 121, + G2 = 122, + G3 = 123, + G4 = 124, + G5 = 125, + G6 = 126, + G7 = 127, + G8 = 128, + G9 = 129, + G10 = 130, + VolumeUp = 131, + VolumeDown = 132, + MR = 133, + M1 = 134, + M2 = 135, + M3 = 136, + G11 = 137, + G12 = 138, + G13 = 139, + G14 = 140, + G15 = 141, + G16 = 142, + G17 = 143, + G18 = 144, + International5 = 145, + International4 = 146, + Fn = 147, + + B1 = 148, + B2 = 149, + B3 = 150, + B4 = 151, + + LeftLogo = 152, + RightLogo = 153, + + Logo = 154, + + Zone1 = 155, + Zone2 = 156, + Zone3 = 157, + Zone4 = 158, + Zone5 = 159, + Zone6 = 160, + Zone7 = 161, + Zone8 = 162, + Zone9 = 163, + Zone10 = 164, + Zone11 = 165, + Zone12 = 166, + Zone13 = 167, + Zone14 = 168, + Zone15 = 169, + + Lightbar1 = 170, + Lightbar2 = 171, + Lightbar3 = 172, + Lightbar4 = 173, + Lightbar5 = 174, + Lightbar6 = 175, + Lightbar7 = 176, + Lightbar8 = 177, + Lightbar9 = 178, + Lightbar10 = 179, + Lightbar11 = 180, + Lightbar12 = 181, + Lightbar13 = 182, + Lightbar14 = 183, + Lightbar15 = 184, + Lightbar16 = 185, + Lightbar17 = 186, + Lightbar18 = 187, + Lightbar19 = 188, + + B5 = 189, + B6 = 190, + + HeadsetStandZone1 = 191, + HeadsetStandZone2 = 192, + HeadsetStandZone3 = 193, + HeadsetStandZone4 = 194, + HeadsetStandZone5 = 195, + HeadsetStandZone6 = 196, + HeadsetStandZone7 = 197, + HeadsetStandZone8 = 198, + HeadsetStandZone9 = 199, + + CustomDeviceChannel1Led1 = 200, + CustomDeviceChannel1Led2 = 201, + CustomDeviceChannel1Led3 = 202, + CustomDeviceChannel1Led4 = 203, + CustomDeviceChannel1Led5 = 204, + CustomDeviceChannel1Led6 = 205, + CustomDeviceChannel1Led7 = 206, + CustomDeviceChannel1Led8 = 207, + CustomDeviceChannel1Led9 = 208, + CustomDeviceChannel1Led10 = 209, + CustomDeviceChannel1Led11 = 210, + CustomDeviceChannel1Led12 = 211, + CustomDeviceChannel1Led13 = 212, + CustomDeviceChannel1Led14 = 213, + CustomDeviceChannel1Led15 = 214, + CustomDeviceChannel1Led16 = 215, + CustomDeviceChannel1Led17 = 216, + CustomDeviceChannel1Led18 = 217, + CustomDeviceChannel1Led19 = 218, + CustomDeviceChannel1Led20 = 219, + CustomDeviceChannel1Led21 = 220, + CustomDeviceChannel1Led22 = 221, + CustomDeviceChannel1Led23 = 222, + CustomDeviceChannel1Led24 = 223, + CustomDeviceChannel1Led25 = 224, + CustomDeviceChannel1Led26 = 225, + CustomDeviceChannel1Led27 = 226, + CustomDeviceChannel1Led28 = 227, + CustomDeviceChannel1Led29 = 228, + CustomDeviceChannel1Led30 = 229, + CustomDeviceChannel1Led31 = 230, + CustomDeviceChannel1Led32 = 231, + CustomDeviceChannel1Led33 = 232, + CustomDeviceChannel1Led34 = 233, + CustomDeviceChannel1Led35 = 234, + CustomDeviceChannel1Led36 = 235, + CustomDeviceChannel1Led37 = 236, + CustomDeviceChannel1Led38 = 237, + CustomDeviceChannel1Led39 = 238, + CustomDeviceChannel1Led40 = 239, + CustomDeviceChannel1Led41 = 240, + CustomDeviceChannel1Led42 = 241, + CustomDeviceChannel1Led43 = 242, + CustomDeviceChannel1Led44 = 243, + CustomDeviceChannel1Led45 = 244, + CustomDeviceChannel1Led46 = 245, + CustomDeviceChannel1Led47 = 246, + CustomDeviceChannel1Led48 = 247, + CustomDeviceChannel1Led49 = 248, + CustomDeviceChannel1Led50 = 249, + CustomDeviceChannel1Led51 = 250, + CustomDeviceChannel1Led52 = 251, + CustomDeviceChannel1Led53 = 252, + CustomDeviceChannel1Led54 = 253, + CustomDeviceChannel1Led55 = 254, + CustomDeviceChannel1Led56 = 255, + CustomDeviceChannel1Led57 = 256, + CustomDeviceChannel1Led58 = 257, + CustomDeviceChannel1Led59 = 258, + CustomDeviceChannel1Led60 = 259, + CustomDeviceChannel1Led61 = 260, + CustomDeviceChannel1Led62 = 261, + CustomDeviceChannel1Led63 = 262, + CustomDeviceChannel1Led64 = 263, + CustomDeviceChannel1Led65 = 264, + CustomDeviceChannel1Led66 = 265, + CustomDeviceChannel1Led67 = 266, + CustomDeviceChannel1Led68 = 267, + CustomDeviceChannel1Led69 = 268, + CustomDeviceChannel1Led70 = 269, + CustomDeviceChannel1Led71 = 270, + CustomDeviceChannel1Led72 = 271, + CustomDeviceChannel1Led73 = 272, + CustomDeviceChannel1Led74 = 273, + CustomDeviceChannel1Led75 = 274, + CustomDeviceChannel1Led76 = 275, + CustomDeviceChannel1Led77 = 276, + CustomDeviceChannel1Led78 = 277, + CustomDeviceChannel1Led79 = 278, + CustomDeviceChannel1Led80 = 279, + CustomDeviceChannel1Led81 = 280, + CustomDeviceChannel1Led82 = 281, + CustomDeviceChannel1Led83 = 282, + CustomDeviceChannel1Led84 = 283, + CustomDeviceChannel1Led85 = 284, + CustomDeviceChannel1Led86 = 285, + CustomDeviceChannel1Led87 = 286, + CustomDeviceChannel1Led88 = 287, + CustomDeviceChannel1Led89 = 288, + CustomDeviceChannel1Led90 = 289, + CustomDeviceChannel1Led91 = 290, + CustomDeviceChannel1Led92 = 291, + CustomDeviceChannel1Led93 = 292, + CustomDeviceChannel1Led94 = 293, + CustomDeviceChannel1Led95 = 294, + CustomDeviceChannel1Led96 = 295, + CustomDeviceChannel1Led97 = 296, + CustomDeviceChannel1Led98 = 297, + CustomDeviceChannel1Led99 = 298, + CustomDeviceChannel1Led100 = 299, + CustomDeviceChannel1Led101 = 300, + CustomDeviceChannel1Led102 = 301, + CustomDeviceChannel1Led103 = 302, + CustomDeviceChannel1Led104 = 303, + CustomDeviceChannel1Led105 = 304, + CustomDeviceChannel1Led106 = 305, + CustomDeviceChannel1Led107 = 306, + CustomDeviceChannel1Led108 = 307, + CustomDeviceChannel1Led109 = 308, + CustomDeviceChannel1Led110 = 309, + CustomDeviceChannel1Led111 = 310, + CustomDeviceChannel1Led112 = 311, + CustomDeviceChannel1Led113 = 312, + CustomDeviceChannel1Led114 = 313, + CustomDeviceChannel1Led115 = 314, + CustomDeviceChannel1Led116 = 315, + CustomDeviceChannel1Led117 = 316, + CustomDeviceChannel1Led118 = 317, + CustomDeviceChannel1Led119 = 318, + CustomDeviceChannel1Led120 = 319, + CustomDeviceChannel1Led121 = 320, + CustomDeviceChannel1Led122 = 321, + CustomDeviceChannel1Led123 = 322, + CustomDeviceChannel1Led124 = 323, + CustomDeviceChannel1Led125 = 324, + CustomDeviceChannel1Led126 = 325, + CustomDeviceChannel1Led127 = 326, + CustomDeviceChannel1Led128 = 327, + CustomDeviceChannel1Led129 = 328, + CustomDeviceChannel1Led130 = 329, + CustomDeviceChannel1Led131 = 330, + CustomDeviceChannel1Led132 = 331, + CustomDeviceChannel1Led133 = 332, + CustomDeviceChannel1Led134 = 333, + CustomDeviceChannel1Led135 = 334, + CustomDeviceChannel1Led136 = 335, + CustomDeviceChannel1Led137 = 336, + CustomDeviceChannel1Led138 = 337, + CustomDeviceChannel1Led139 = 338, + CustomDeviceChannel1Led140 = 339, + CustomDeviceChannel1Led141 = 340, + CustomDeviceChannel1Led142 = 341, + CustomDeviceChannel1Led143 = 342, + CustomDeviceChannel1Led144 = 343, + CustomDeviceChannel1Led145 = 344, + CustomDeviceChannel1Led146 = 345, + CustomDeviceChannel1Led147 = 346, + CustomDeviceChannel1Led148 = 347, + CustomDeviceChannel1Led149 = 348, + CustomDeviceChannel1Led150 = 349, + + CustomDeviceChannel2Led1 = 350, + CustomDeviceChannel2Led2 = 351, + CustomDeviceChannel2Led3 = 352, + CustomDeviceChannel2Led4 = 353, + CustomDeviceChannel2Led5 = 354, + CustomDeviceChannel2Led6 = 355, + CustomDeviceChannel2Led7 = 356, + CustomDeviceChannel2Led8 = 357, + CustomDeviceChannel2Led9 = 358, + CustomDeviceChannel2Led10 = 359, + CustomDeviceChannel2Led11 = 360, + CustomDeviceChannel2Led12 = 361, + CustomDeviceChannel2Led13 = 362, + CustomDeviceChannel2Led14 = 363, + CustomDeviceChannel2Led15 = 364, + CustomDeviceChannel2Led16 = 365, + CustomDeviceChannel2Led17 = 366, + CustomDeviceChannel2Led18 = 367, + CustomDeviceChannel2Led19 = 368, + CustomDeviceChannel2Led20 = 369, + CustomDeviceChannel2Led21 = 370, + CustomDeviceChannel2Led22 = 371, + CustomDeviceChannel2Led23 = 372, + CustomDeviceChannel2Led24 = 373, + CustomDeviceChannel2Led25 = 374, + CustomDeviceChannel2Led26 = 375, + CustomDeviceChannel2Led27 = 376, + CustomDeviceChannel2Led28 = 377, + CustomDeviceChannel2Led29 = 378, + CustomDeviceChannel2Led30 = 379, + CustomDeviceChannel2Led31 = 380, + CustomDeviceChannel2Led32 = 381, + CustomDeviceChannel2Led33 = 382, + CustomDeviceChannel2Led34 = 383, + CustomDeviceChannel2Led35 = 384, + CustomDeviceChannel2Led36 = 385, + CustomDeviceChannel2Led37 = 386, + CustomDeviceChannel2Led38 = 387, + CustomDeviceChannel2Led39 = 388, + CustomDeviceChannel2Led40 = 389, + CustomDeviceChannel2Led41 = 390, + CustomDeviceChannel2Led42 = 391, + CustomDeviceChannel2Led43 = 392, + CustomDeviceChannel2Led44 = 393, + CustomDeviceChannel2Led45 = 394, + CustomDeviceChannel2Led46 = 395, + CustomDeviceChannel2Led47 = 396, + CustomDeviceChannel2Led48 = 397, + CustomDeviceChannel2Led49 = 398, + CustomDeviceChannel2Led50 = 399, + CustomDeviceChannel2Led51 = 400, + CustomDeviceChannel2Led52 = 401, + CustomDeviceChannel2Led53 = 402, + CustomDeviceChannel2Led54 = 403, + CustomDeviceChannel2Led55 = 404, + CustomDeviceChannel2Led56 = 405, + CustomDeviceChannel2Led57 = 406, + CustomDeviceChannel2Led58 = 407, + CustomDeviceChannel2Led59 = 408, + CustomDeviceChannel2Led60 = 409, + CustomDeviceChannel2Led61 = 410, + CustomDeviceChannel2Led62 = 411, + CustomDeviceChannel2Led63 = 412, + CustomDeviceChannel2Led64 = 413, + CustomDeviceChannel2Led65 = 414, + CustomDeviceChannel2Led66 = 415, + CustomDeviceChannel2Led67 = 416, + CustomDeviceChannel2Led68 = 417, + CustomDeviceChannel2Led69 = 418, + CustomDeviceChannel2Led70 = 419, + CustomDeviceChannel2Led71 = 420, + CustomDeviceChannel2Led72 = 421, + CustomDeviceChannel2Led73 = 422, + CustomDeviceChannel2Led74 = 423, + CustomDeviceChannel2Led75 = 424, + CustomDeviceChannel2Led76 = 425, + CustomDeviceChannel2Led77 = 426, + CustomDeviceChannel2Led78 = 427, + CustomDeviceChannel2Led79 = 428, + CustomDeviceChannel2Led80 = 429, + CustomDeviceChannel2Led81 = 430, + CustomDeviceChannel2Led82 = 431, + CustomDeviceChannel2Led83 = 432, + CustomDeviceChannel2Led84 = 433, + CustomDeviceChannel2Led85 = 434, + CustomDeviceChannel2Led86 = 435, + CustomDeviceChannel2Led87 = 436, + CustomDeviceChannel2Led88 = 437, + CustomDeviceChannel2Led89 = 438, + CustomDeviceChannel2Led90 = 439, + CustomDeviceChannel2Led91 = 440, + CustomDeviceChannel2Led92 = 441, + CustomDeviceChannel2Led93 = 442, + CustomDeviceChannel2Led94 = 443, + CustomDeviceChannel2Led95 = 444, + CustomDeviceChannel2Led96 = 445, + CustomDeviceChannel2Led97 = 446, + CustomDeviceChannel2Led98 = 447, + CustomDeviceChannel2Led99 = 448, + CustomDeviceChannel2Led100 = 449, + CustomDeviceChannel2Led101 = 450, + CustomDeviceChannel2Led102 = 451, + CustomDeviceChannel2Led103 = 452, + CustomDeviceChannel2Led104 = 453, + CustomDeviceChannel2Led105 = 454, + CustomDeviceChannel2Led106 = 455, + CustomDeviceChannel2Led107 = 456, + CustomDeviceChannel2Led108 = 457, + CustomDeviceChannel2Led109 = 458, + CustomDeviceChannel2Led110 = 459, + CustomDeviceChannel2Led111 = 460, + CustomDeviceChannel2Led112 = 461, + CustomDeviceChannel2Led113 = 462, + CustomDeviceChannel2Led114 = 463, + CustomDeviceChannel2Led115 = 464, + CustomDeviceChannel2Led116 = 465, + CustomDeviceChannel2Led117 = 466, + CustomDeviceChannel2Led118 = 467, + CustomDeviceChannel2Led119 = 468, + CustomDeviceChannel2Led120 = 469, + CustomDeviceChannel2Led121 = 470, + CustomDeviceChannel2Led122 = 471, + CustomDeviceChannel2Led123 = 472, + CustomDeviceChannel2Led124 = 473, + CustomDeviceChannel2Led125 = 474, + CustomDeviceChannel2Led126 = 475, + CustomDeviceChannel2Led127 = 476, + CustomDeviceChannel2Led128 = 477, + CustomDeviceChannel2Led129 = 478, + CustomDeviceChannel2Led130 = 479, + CustomDeviceChannel2Led131 = 480, + CustomDeviceChannel2Led132 = 481, + CustomDeviceChannel2Led133 = 482, + CustomDeviceChannel2Led134 = 483, + CustomDeviceChannel2Led135 = 484, + CustomDeviceChannel2Led136 = 485, + CustomDeviceChannel2Led137 = 486, + CustomDeviceChannel2Led138 = 487, + CustomDeviceChannel2Led139 = 488, + CustomDeviceChannel2Led140 = 489, + CustomDeviceChannel2Led141 = 490, + CustomDeviceChannel2Led142 = 491, + CustomDeviceChannel2Led143 = 492, + CustomDeviceChannel2Led144 = 493, + CustomDeviceChannel2Led145 = 494, + CustomDeviceChannel2Led146 = 495, + CustomDeviceChannel2Led147 = 496, + CustomDeviceChannel2Led148 = 497, + CustomDeviceChannel2Led149 = 498, + CustomDeviceChannel2Led150 = 499, + + OemLed1 = 500, + OemLed2 = 501, + OemLed3 = 502, + OemLed4 = 503, + OemLed5 = 504, + OemLed6 = 505, + OemLed7 = 506, + OemLed8 = 507, + OemLed9 = 508, + OemLed10 = 509, + OemLed11 = 510, + OemLed12 = 511, + OemLed13 = 512, + OemLed14 = 513, + OemLed15 = 514, + OemLed16 = 515, + OemLed17 = 516, + OemLed18 = 517, + OemLed19 = 518, + OemLed20 = 519, + OemLed21 = 520, + OemLed22 = 521, + OemLed23 = 522, + OemLed24 = 523, + OemLed25 = 524, + OemLed26 = 525, + OemLed27 = 526, + OemLed28 = 527, + OemLed29 = 528, + OemLed30 = 529, + OemLed31 = 530, + OemLed32 = 531, + OemLed33 = 532, + OemLed34 = 533, + OemLed35 = 534, + OemLed36 = 535, + OemLed37 = 536, + OemLed38 = 537, + OemLed39 = 538, + OemLed40 = 539, + OemLed41 = 540, + OemLed42 = 541, + OemLed43 = 542, + OemLed44 = 543, + OemLed45 = 544, + OemLed46 = 545, + OemLed47 = 546, + OemLed48 = 547, + OemLed49 = 548, + OemLed50 = 549, + OemLed51 = 550, + OemLed52 = 551, + OemLed53 = 552, + OemLed54 = 553, + OemLed55 = 554, + OemLed56 = 555, + OemLed57 = 556, + OemLed58 = 557, + OemLed59 = 558, + OemLed60 = 559, + OemLed61 = 560, + OemLed62 = 561, + OemLed63 = 562, + OemLed64 = 563, + OemLed65 = 564, + OemLed66 = 565, + OemLed67 = 566, + OemLed68 = 567, + OemLed69 = 568, + OemLed70 = 569, + OemLed71 = 570, + OemLed72 = 571, + OemLed73 = 572, + OemLed74 = 573, + OemLed75 = 574, + OemLed76 = 575, + OemLed77 = 576, + OemLed78 = 577, + OemLed79 = 578, + OemLed80 = 579, + OemLed81 = 580, + OemLed82 = 581, + OemLed83 = 582, + OemLed84 = 583, + OemLed85 = 584, + OemLed86 = 585, + OemLed87 = 586, + OemLed88 = 587, + OemLed89 = 588, + OemLed90 = 589, + OemLed91 = 590, + OemLed92 = 591, + OemLed93 = 592, + OemLed94 = 593, + OemLed95 = 594, + OemLed96 = 595, + OemLed97 = 596, + OemLed98 = 597, + OemLed99 = 598, + OemLed100 = 599, + + DRAM1 = 600, + DRAM2 = 601, + DRAM3 = 602, + DRAM4 = 603, + DRAM5 = 604, + DRAM6 = 605, + DRAM7 = 606, + DRAM8 = 607, + DRAM9 = 608, + DRAM10 = 609, + DRAM11 = 610, + DRAM12 = 611, + + CustomDeviceChannel3Led1 = 612, + CustomDeviceChannel3Led2 = 613, + CustomDeviceChannel3Led3 = 614, + CustomDeviceChannel3Led4 = 615, + CustomDeviceChannel3Led5 = 616, + CustomDeviceChannel3Led6 = 617, + CustomDeviceChannel3Led7 = 618, + CustomDeviceChannel3Led8 = 619, + CustomDeviceChannel3Led9 = 620, + CustomDeviceChannel3Led10 = 621, + CustomDeviceChannel3Led11 = 622, + CustomDeviceChannel3Led12 = 623, + CustomDeviceChannel3Led13 = 624, + CustomDeviceChannel3Led14 = 625, + CustomDeviceChannel3Led15 = 626, + CustomDeviceChannel3Led16 = 627, + CustomDeviceChannel3Led17 = 628, + CustomDeviceChannel3Led18 = 629, + CustomDeviceChannel3Led19 = 630, + CustomDeviceChannel3Led20 = 631, + CustomDeviceChannel3Led21 = 632, + CustomDeviceChannel3Led22 = 633, + CustomDeviceChannel3Led23 = 634, + CustomDeviceChannel3Led24 = 635, + CustomDeviceChannel3Led25 = 636, + CustomDeviceChannel3Led26 = 637, + CustomDeviceChannel3Led27 = 638, + CustomDeviceChannel3Led28 = 639, + CustomDeviceChannel3Led29 = 640, + CustomDeviceChannel3Led30 = 641, + CustomDeviceChannel3Led31 = 642, + CustomDeviceChannel3Led32 = 643, + CustomDeviceChannel3Led33 = 644, + CustomDeviceChannel3Led34 = 645, + CustomDeviceChannel3Led35 = 646, + CustomDeviceChannel3Led36 = 647, + CustomDeviceChannel3Led37 = 648, + CustomDeviceChannel3Led38 = 649, + CustomDeviceChannel3Led39 = 650, + CustomDeviceChannel3Led40 = 651, + CustomDeviceChannel3Led41 = 652, + CustomDeviceChannel3Led42 = 653, + CustomDeviceChannel3Led43 = 654, + CustomDeviceChannel3Led44 = 655, + CustomDeviceChannel3Led45 = 656, + CustomDeviceChannel3Led46 = 657, + CustomDeviceChannel3Led47 = 658, + CustomDeviceChannel3Led48 = 659, + CustomDeviceChannel3Led49 = 660, + CustomDeviceChannel3Led50 = 661, + CustomDeviceChannel3Led51 = 662, + CustomDeviceChannel3Led52 = 663, + CustomDeviceChannel3Led53 = 664, + CustomDeviceChannel3Led54 = 665, + CustomDeviceChannel3Led55 = 666, + CustomDeviceChannel3Led56 = 667, + CustomDeviceChannel3Led57 = 668, + CustomDeviceChannel3Led58 = 669, + CustomDeviceChannel3Led59 = 670, + CustomDeviceChannel3Led60 = 671, + CustomDeviceChannel3Led61 = 672, + CustomDeviceChannel3Led62 = 673, + CustomDeviceChannel3Led63 = 674, + CustomDeviceChannel3Led64 = 675, + CustomDeviceChannel3Led65 = 676, + CustomDeviceChannel3Led66 = 677, + CustomDeviceChannel3Led67 = 678, + CustomDeviceChannel3Led68 = 679, + CustomDeviceChannel3Led69 = 680, + CustomDeviceChannel3Led70 = 681, + CustomDeviceChannel3Led71 = 682, + CustomDeviceChannel3Led72 = 683, + CustomDeviceChannel3Led73 = 684, + CustomDeviceChannel3Led74 = 685, + CustomDeviceChannel3Led75 = 686, + CustomDeviceChannel3Led76 = 687, + CustomDeviceChannel3Led77 = 688, + CustomDeviceChannel3Led78 = 689, + CustomDeviceChannel3Led79 = 690, + CustomDeviceChannel3Led80 = 691, + CustomDeviceChannel3Led81 = 692, + CustomDeviceChannel3Led82 = 693, + CustomDeviceChannel3Led83 = 694, + CustomDeviceChannel3Led84 = 695, + CustomDeviceChannel3Led85 = 696, + CustomDeviceChannel3Led86 = 697, + CustomDeviceChannel3Led87 = 698, + CustomDeviceChannel3Led88 = 699, + CustomDeviceChannel3Led89 = 700, + CustomDeviceChannel3Led90 = 701, + CustomDeviceChannel3Led91 = 702, + CustomDeviceChannel3Led92 = 703, + CustomDeviceChannel3Led93 = 704, + CustomDeviceChannel3Led94 = 705, + CustomDeviceChannel3Led95 = 706, + CustomDeviceChannel3Led96 = 707, + CustomDeviceChannel3Led97 = 708, + CustomDeviceChannel3Led98 = 709, + CustomDeviceChannel3Led99 = 710, + CustomDeviceChannel3Led100 = 711, + CustomDeviceChannel3Led101 = 712, + CustomDeviceChannel3Led102 = 713, + CustomDeviceChannel3Led103 = 714, + CustomDeviceChannel3Led104 = 715, + CustomDeviceChannel3Led105 = 716, + CustomDeviceChannel3Led106 = 717, + CustomDeviceChannel3Led107 = 718, + CustomDeviceChannel3Led108 = 719, + CustomDeviceChannel3Led109 = 720, + CustomDeviceChannel3Led110 = 721, + CustomDeviceChannel3Led111 = 722, + CustomDeviceChannel3Led112 = 723, + CustomDeviceChannel3Led113 = 724, + CustomDeviceChannel3Led114 = 725, + CustomDeviceChannel3Led115 = 726, + CustomDeviceChannel3Led116 = 727, + CustomDeviceChannel3Led117 = 728, + CustomDeviceChannel3Led118 = 729, + CustomDeviceChannel3Led119 = 730, + CustomDeviceChannel3Led120 = 731, + CustomDeviceChannel3Led121 = 732, + CustomDeviceChannel3Led122 = 733, + CustomDeviceChannel3Led123 = 734, + CustomDeviceChannel3Led124 = 735, + CustomDeviceChannel3Led125 = 736, + CustomDeviceChannel3Led126 = 737, + CustomDeviceChannel3Led127 = 738, + CustomDeviceChannel3Led128 = 739, + CustomDeviceChannel3Led129 = 740, + CustomDeviceChannel3Led130 = 741, + CustomDeviceChannel3Led131 = 742, + CustomDeviceChannel3Led132 = 743, + CustomDeviceChannel3Led133 = 744, + CustomDeviceChannel3Led134 = 745, + CustomDeviceChannel3Led135 = 746, + CustomDeviceChannel3Led136 = 747, + CustomDeviceChannel3Led137 = 748, + CustomDeviceChannel3Led138 = 749, + CustomDeviceChannel3Led139 = 750, + CustomDeviceChannel3Led140 = 751, + CustomDeviceChannel3Led141 = 752, + CustomDeviceChannel3Led142 = 753, + CustomDeviceChannel3Led143 = 754, + CustomDeviceChannel3Led144 = 755, + CustomDeviceChannel3Led145 = 756, + CustomDeviceChannel3Led146 = 757, + CustomDeviceChannel3Led147 = 758, + CustomDeviceChannel3Led148 = 759, + CustomDeviceChannel3Led149 = 760, + CustomDeviceChannel3Led150 = 761, + + CustomLiquidCoolerChannel1Led1 = 762, + CustomLiquidCoolerChannel1Led2 = 763, + CustomLiquidCoolerChannel1Led3 = 764, + CustomLiquidCoolerChannel1Led4 = 765, + CustomLiquidCoolerChannel1Led5 = 766, + CustomLiquidCoolerChannel1Led6 = 767, + CustomLiquidCoolerChannel1Led7 = 768, + CustomLiquidCoolerChannel1Led8 = 769, + CustomLiquidCoolerChannel1Led9 = 770, + CustomLiquidCoolerChannel1Led10 = 771, + CustomLiquidCoolerChannel1Led11 = 772, + CustomLiquidCoolerChannel1Led12 = 773, + CustomLiquidCoolerChannel1Led13 = 774, + CustomLiquidCoolerChannel1Led14 = 775, + CustomLiquidCoolerChannel1Led15 = 776, + CustomLiquidCoolerChannel1Led16 = 777, + CustomLiquidCoolerChannel1Led17 = 778, + CustomLiquidCoolerChannel1Led18 = 779, + CustomLiquidCoolerChannel1Led19 = 780, + CustomLiquidCoolerChannel1Led20 = 781, + CustomLiquidCoolerChannel1Led21 = 782, + CustomLiquidCoolerChannel1Led22 = 783, + CustomLiquidCoolerChannel1Led23 = 784, + CustomLiquidCoolerChannel1Led24 = 785, + CustomLiquidCoolerChannel1Led25 = 786, + CustomLiquidCoolerChannel1Led26 = 787, + CustomLiquidCoolerChannel1Led27 = 788, + CustomLiquidCoolerChannel1Led28 = 789, + CustomLiquidCoolerChannel1Led29 = 790, + CustomLiquidCoolerChannel1Led30 = 791, + CustomLiquidCoolerChannel1Led31 = 792, + CustomLiquidCoolerChannel1Led32 = 793, + CustomLiquidCoolerChannel1Led33 = 794, + CustomLiquidCoolerChannel1Led34 = 795, + CustomLiquidCoolerChannel1Led35 = 796, + CustomLiquidCoolerChannel1Led36 = 797, + CustomLiquidCoolerChannel1Led37 = 798, + CustomLiquidCoolerChannel1Led38 = 799, + CustomLiquidCoolerChannel1Led39 = 800, + CustomLiquidCoolerChannel1Led40 = 801, + CustomLiquidCoolerChannel1Led41 = 802, + CustomLiquidCoolerChannel1Led42 = 803, + CustomLiquidCoolerChannel1Led43 = 804, + CustomLiquidCoolerChannel1Led44 = 805, + CustomLiquidCoolerChannel1Led45 = 806, + CustomLiquidCoolerChannel1Led46 = 807, + CustomLiquidCoolerChannel1Led47 = 808, + CustomLiquidCoolerChannel1Led48 = 809, + CustomLiquidCoolerChannel1Led49 = 810, + CustomLiquidCoolerChannel1Led50 = 811, + CustomLiquidCoolerChannel1Led51 = 812, + CustomLiquidCoolerChannel1Led52 = 813, + CustomLiquidCoolerChannel1Led53 = 814, + CustomLiquidCoolerChannel1Led54 = 815, + CustomLiquidCoolerChannel1Led55 = 816, + CustomLiquidCoolerChannel1Led56 = 817, + CustomLiquidCoolerChannel1Led57 = 818, + CustomLiquidCoolerChannel1Led58 = 819, + CustomLiquidCoolerChannel1Led59 = 820, + CustomLiquidCoolerChannel1Led60 = 821, + CustomLiquidCoolerChannel1Led61 = 822, + CustomLiquidCoolerChannel1Led62 = 823, + CustomLiquidCoolerChannel1Led63 = 824, + CustomLiquidCoolerChannel1Led64 = 825, + CustomLiquidCoolerChannel1Led65 = 826, + CustomLiquidCoolerChannel1Led66 = 827, + CustomLiquidCoolerChannel1Led67 = 828, + CustomLiquidCoolerChannel1Led68 = 829, + CustomLiquidCoolerChannel1Led69 = 830, + CustomLiquidCoolerChannel1Led70 = 831, + CustomLiquidCoolerChannel1Led71 = 832, + CustomLiquidCoolerChannel1Led72 = 833, + CustomLiquidCoolerChannel1Led73 = 834, + CustomLiquidCoolerChannel1Led74 = 835, + CustomLiquidCoolerChannel1Led75 = 836, + CustomLiquidCoolerChannel1Led76 = 837, + CustomLiquidCoolerChannel1Led77 = 838, + CustomLiquidCoolerChannel1Led78 = 839, + CustomLiquidCoolerChannel1Led79 = 840, + CustomLiquidCoolerChannel1Led80 = 841, + CustomLiquidCoolerChannel1Led81 = 842, + CustomLiquidCoolerChannel1Led82 = 843, + CustomLiquidCoolerChannel1Led83 = 844, + CustomLiquidCoolerChannel1Led84 = 845, + CustomLiquidCoolerChannel1Led85 = 846, + CustomLiquidCoolerChannel1Led86 = 847, + CustomLiquidCoolerChannel1Led87 = 848, + CustomLiquidCoolerChannel1Led88 = 849, + CustomLiquidCoolerChannel1Led89 = 850, + CustomLiquidCoolerChannel1Led90 = 851, + CustomLiquidCoolerChannel1Led91 = 852, + CustomLiquidCoolerChannel1Led92 = 853, + CustomLiquidCoolerChannel1Led93 = 854, + CustomLiquidCoolerChannel1Led94 = 855, + CustomLiquidCoolerChannel1Led95 = 856, + CustomLiquidCoolerChannel1Led96 = 857, + CustomLiquidCoolerChannel1Led97 = 858, + CustomLiquidCoolerChannel1Led98 = 859, + CustomLiquidCoolerChannel1Led99 = 860, + CustomLiquidCoolerChannel1Led100 = 861, + CustomLiquidCoolerChannel1Led101 = 862, + CustomLiquidCoolerChannel1Led102 = 863, + CustomLiquidCoolerChannel1Led103 = 864, + CustomLiquidCoolerChannel1Led104 = 865, + CustomLiquidCoolerChannel1Led105 = 866, + CustomLiquidCoolerChannel1Led106 = 867, + CustomLiquidCoolerChannel1Led107 = 868, + CustomLiquidCoolerChannel1Led108 = 869, + CustomLiquidCoolerChannel1Led109 = 870, + CustomLiquidCoolerChannel1Led110 = 871, + CustomLiquidCoolerChannel1Led111 = 872, + CustomLiquidCoolerChannel1Led112 = 873, + CustomLiquidCoolerChannel1Led113 = 874, + CustomLiquidCoolerChannel1Led114 = 875, + CustomLiquidCoolerChannel1Led115 = 876, + CustomLiquidCoolerChannel1Led116 = 877, + CustomLiquidCoolerChannel1Led117 = 878, + CustomLiquidCoolerChannel1Led118 = 879, + CustomLiquidCoolerChannel1Led119 = 880, + CustomLiquidCoolerChannel1Led120 = 881, + CustomLiquidCoolerChannel1Led121 = 882, + CustomLiquidCoolerChannel1Led122 = 883, + CustomLiquidCoolerChannel1Led123 = 884, + CustomLiquidCoolerChannel1Led124 = 885, + CustomLiquidCoolerChannel1Led125 = 886, + CustomLiquidCoolerChannel1Led126 = 887, + CustomLiquidCoolerChannel1Led127 = 888, + CustomLiquidCoolerChannel1Led128 = 889, + CustomLiquidCoolerChannel1Led129 = 890, + CustomLiquidCoolerChannel1Led130 = 891, + CustomLiquidCoolerChannel1Led131 = 892, + CustomLiquidCoolerChannel1Led132 = 893, + CustomLiquidCoolerChannel1Led133 = 894, + CustomLiquidCoolerChannel1Led134 = 895, + CustomLiquidCoolerChannel1Led135 = 896, + CustomLiquidCoolerChannel1Led136 = 897, + CustomLiquidCoolerChannel1Led137 = 898, + CustomLiquidCoolerChannel1Led138 = 899, + CustomLiquidCoolerChannel1Led139 = 900, + CustomLiquidCoolerChannel1Led140 = 901, + CustomLiquidCoolerChannel1Led141 = 902, + CustomLiquidCoolerChannel1Led142 = 903, + CustomLiquidCoolerChannel1Led143 = 904, + CustomLiquidCoolerChannel1Led144 = 905, + CustomLiquidCoolerChannel1Led145 = 906, + CustomLiquidCoolerChannel1Led146 = 907, + CustomLiquidCoolerChannel1Led147 = 908, + CustomLiquidCoolerChannel1Led148 = 909, + CustomLiquidCoolerChannel1Led149 = 910, + CustomLiquidCoolerChannel1Led150 = 911, + + CustomDeviceChannel1Led151 = 912, + CustomDeviceChannel1Led152 = 913, + CustomDeviceChannel1Led153 = 914, + CustomDeviceChannel1Led154 = 915, + CustomDeviceChannel1Led155 = 916, + CustomDeviceChannel1Led156 = 917, + CustomDeviceChannel1Led157 = 918, + CustomDeviceChannel1Led158 = 919, + CustomDeviceChannel1Led159 = 920, + CustomDeviceChannel1Led160 = 921, + CustomDeviceChannel1Led161 = 922, + CustomDeviceChannel1Led162 = 923, + CustomDeviceChannel1Led163 = 924, + CustomDeviceChannel1Led164 = 925, + CustomDeviceChannel1Led165 = 926, + CustomDeviceChannel1Led166 = 927, + CustomDeviceChannel1Led167 = 928, + CustomDeviceChannel1Led168 = 929, + CustomDeviceChannel1Led169 = 930, + CustomDeviceChannel1Led170 = 931, + CustomDeviceChannel1Led171 = 932, + CustomDeviceChannel1Led172 = 933, + CustomDeviceChannel1Led173 = 934, + CustomDeviceChannel1Led174 = 935, + CustomDeviceChannel1Led175 = 936, + CustomDeviceChannel1Led176 = 937, + CustomDeviceChannel1Led177 = 938, + CustomDeviceChannel1Led178 = 939, + CustomDeviceChannel1Led179 = 940, + CustomDeviceChannel1Led180 = 941, + CustomDeviceChannel1Led181 = 942, + CustomDeviceChannel1Led182 = 943, + CustomDeviceChannel1Led183 = 944, + CustomDeviceChannel1Led184 = 945, + CustomDeviceChannel1Led185 = 946, + CustomDeviceChannel1Led186 = 947, + CustomDeviceChannel1Led187 = 948, + CustomDeviceChannel1Led188 = 949, + CustomDeviceChannel1Led189 = 950, + CustomDeviceChannel1Led190 = 951, + CustomDeviceChannel1Led191 = 952, + CustomDeviceChannel1Led192 = 953, + CustomDeviceChannel1Led193 = 954, + CustomDeviceChannel1Led194 = 955, + CustomDeviceChannel1Led195 = 956, + CustomDeviceChannel1Led196 = 957, + CustomDeviceChannel1Led197 = 958, + CustomDeviceChannel1Led198 = 959, + CustomDeviceChannel1Led199 = 960, + CustomDeviceChannel1Led200 = 961, + CustomDeviceChannel1Led201 = 962, + CustomDeviceChannel1Led202 = 963, + CustomDeviceChannel1Led203 = 964, + CustomDeviceChannel1Led204 = 965, + CustomDeviceChannel1Led205 = 966, + CustomDeviceChannel1Led206 = 967, + CustomDeviceChannel1Led207 = 968, + CustomDeviceChannel1Led208 = 969, + CustomDeviceChannel1Led209 = 970, + CustomDeviceChannel1Led210 = 971, + CustomDeviceChannel1Led211 = 972, + CustomDeviceChannel1Led212 = 973, + CustomDeviceChannel1Led213 = 974, + CustomDeviceChannel1Led214 = 975, + CustomDeviceChannel1Led215 = 976, + CustomDeviceChannel1Led216 = 977, + CustomDeviceChannel1Led217 = 978, + CustomDeviceChannel1Led218 = 979, + CustomDeviceChannel1Led219 = 980, + CustomDeviceChannel1Led220 = 981, + CustomDeviceChannel1Led221 = 982, + CustomDeviceChannel1Led222 = 983, + CustomDeviceChannel1Led223 = 984, + CustomDeviceChannel1Led224 = 985, + CustomDeviceChannel1Led225 = 986, + CustomDeviceChannel1Led226 = 987, + CustomDeviceChannel1Led227 = 988, + CustomDeviceChannel1Led228 = 989, + CustomDeviceChannel1Led229 = 990, + CustomDeviceChannel1Led230 = 991, + CustomDeviceChannel1Led231 = 992, + CustomDeviceChannel1Led232 = 993, + CustomDeviceChannel1Led233 = 994, + CustomDeviceChannel1Led234 = 995, + CustomDeviceChannel1Led235 = 996, + CustomDeviceChannel1Led236 = 997, + CustomDeviceChannel1Led237 = 998, + CustomDeviceChannel1Led238 = 999, + CustomDeviceChannel1Led239 = 1000, + CustomDeviceChannel1Led240 = 1001, + CustomDeviceChannel1Led241 = 1002, + CustomDeviceChannel1Led242 = 1003, + CustomDeviceChannel1Led243 = 1004, + CustomDeviceChannel1Led244 = 1005, + CustomDeviceChannel1Led245 = 1006, + CustomDeviceChannel1Led246 = 1007, + CustomDeviceChannel1Led247 = 1008, + CustomDeviceChannel1Led248 = 1009, + CustomDeviceChannel1Led249 = 1010, + CustomDeviceChannel1Led250 = 1011, + CustomDeviceChannel1Led251 = 1012, + CustomDeviceChannel1Led252 = 1013, + CustomDeviceChannel1Led253 = 1014, + CustomDeviceChannel1Led254 = 1015, + CustomDeviceChannel1Led255 = 1016, + CustomDeviceChannel1Led256 = 1017, + CustomDeviceChannel1Led257 = 1018, + CustomDeviceChannel1Led258 = 1019, + CustomDeviceChannel1Led259 = 1020, + CustomDeviceChannel1Led260 = 1021, + CustomDeviceChannel1Led261 = 1022, + CustomDeviceChannel1Led262 = 1023, + CustomDeviceChannel1Led263 = 1024, + CustomDeviceChannel1Led264 = 1025, + CustomDeviceChannel1Led265 = 1026, + CustomDeviceChannel1Led266 = 1027, + CustomDeviceChannel1Led267 = 1028, + CustomDeviceChannel1Led268 = 1029, + CustomDeviceChannel1Led269 = 1030, + CustomDeviceChannel1Led270 = 1031, + CustomDeviceChannel1Led271 = 1032, + CustomDeviceChannel1Led272 = 1033, + CustomDeviceChannel1Led273 = 1034, + CustomDeviceChannel1Led274 = 1035, + CustomDeviceChannel1Led275 = 1036, + CustomDeviceChannel1Led276 = 1037, + CustomDeviceChannel1Led277 = 1038, + CustomDeviceChannel1Led278 = 1039, + CustomDeviceChannel1Led279 = 1040, + CustomDeviceChannel1Led280 = 1041, + CustomDeviceChannel1Led281 = 1042, + CustomDeviceChannel1Led282 = 1043, + CustomDeviceChannel1Led283 = 1044, + CustomDeviceChannel1Led284 = 1045, + CustomDeviceChannel1Led285 = 1046, + CustomDeviceChannel1Led286 = 1047, + CustomDeviceChannel1Led287 = 1048, + CustomDeviceChannel1Led288 = 1049, + CustomDeviceChannel1Led289 = 1050, + CustomDeviceChannel1Led290 = 1051, + CustomDeviceChannel1Led291 = 1052, + CustomDeviceChannel1Led292 = 1053, + CustomDeviceChannel1Led293 = 1054, + CustomDeviceChannel1Led294 = 1055, + CustomDeviceChannel1Led295 = 1056, + CustomDeviceChannel1Led296 = 1057, + CustomDeviceChannel1Led297 = 1058, + CustomDeviceChannel1Led298 = 1059, + CustomDeviceChannel1Led299 = 1060, + CustomDeviceChannel1Led300 = 1061, + + CustomDeviceChannel2Led151 = 1062, + CustomDeviceChannel2Led152 = 1063, + CustomDeviceChannel2Led153 = 1064, + CustomDeviceChannel2Led154 = 1065, + CustomDeviceChannel2Led155 = 1066, + CustomDeviceChannel2Led156 = 1067, + CustomDeviceChannel2Led157 = 1068, + CustomDeviceChannel2Led158 = 1069, + CustomDeviceChannel2Led159 = 1070, + CustomDeviceChannel2Led160 = 1071, + CustomDeviceChannel2Led161 = 1072, + CustomDeviceChannel2Led162 = 1073, + CustomDeviceChannel2Led163 = 1074, + CustomDeviceChannel2Led164 = 1075, + CustomDeviceChannel2Led165 = 1076, + CustomDeviceChannel2Led166 = 1077, + CustomDeviceChannel2Led167 = 1078, + CustomDeviceChannel2Led168 = 1079, + CustomDeviceChannel2Led169 = 1080, + CustomDeviceChannel2Led170 = 1081, + CustomDeviceChannel2Led171 = 1082, + CustomDeviceChannel2Led172 = 1083, + CustomDeviceChannel2Led173 = 1084, + CustomDeviceChannel2Led174 = 1085, + CustomDeviceChannel2Led175 = 1086, + CustomDeviceChannel2Led176 = 1087, + CustomDeviceChannel2Led177 = 1088, + CustomDeviceChannel2Led178 = 1089, + CustomDeviceChannel2Led179 = 1090, + CustomDeviceChannel2Led180 = 1091, + CustomDeviceChannel2Led181 = 1092, + CustomDeviceChannel2Led182 = 1093, + CustomDeviceChannel2Led183 = 1094, + CustomDeviceChannel2Led184 = 1095, + CustomDeviceChannel2Led185 = 1096, + CustomDeviceChannel2Led186 = 1097, + CustomDeviceChannel2Led187 = 1098, + CustomDeviceChannel2Led188 = 1099, + CustomDeviceChannel2Led189 = 1100, + CustomDeviceChannel2Led190 = 1101, + CustomDeviceChannel2Led191 = 1102, + CustomDeviceChannel2Led192 = 1103, + CustomDeviceChannel2Led193 = 1104, + CustomDeviceChannel2Led194 = 1105, + CustomDeviceChannel2Led195 = 1106, + CustomDeviceChannel2Led196 = 1107, + CustomDeviceChannel2Led197 = 1108, + CustomDeviceChannel2Led198 = 1109, + CustomDeviceChannel2Led199 = 1110, + CustomDeviceChannel2Led200 = 1111, + CustomDeviceChannel2Led201 = 1112, + CustomDeviceChannel2Led202 = 1113, + CustomDeviceChannel2Led203 = 1114, + CustomDeviceChannel2Led204 = 1115, + CustomDeviceChannel2Led205 = 1116, + CustomDeviceChannel2Led206 = 1117, + CustomDeviceChannel2Led207 = 1118, + CustomDeviceChannel2Led208 = 1119, + CustomDeviceChannel2Led209 = 1120, + CustomDeviceChannel2Led210 = 1121, + CustomDeviceChannel2Led211 = 1122, + CustomDeviceChannel2Led212 = 1123, + CustomDeviceChannel2Led213 = 1124, + CustomDeviceChannel2Led214 = 1125, + CustomDeviceChannel2Led215 = 1126, + CustomDeviceChannel2Led216 = 1127, + CustomDeviceChannel2Led217 = 1128, + CustomDeviceChannel2Led218 = 1129, + CustomDeviceChannel2Led219 = 1130, + CustomDeviceChannel2Led220 = 1131, + CustomDeviceChannel2Led221 = 1132, + CustomDeviceChannel2Led222 = 1133, + CustomDeviceChannel2Led223 = 1134, + CustomDeviceChannel2Led224 = 1135, + CustomDeviceChannel2Led225 = 1136, + CustomDeviceChannel2Led226 = 1137, + CustomDeviceChannel2Led227 = 1138, + CustomDeviceChannel2Led228 = 1139, + CustomDeviceChannel2Led229 = 1140, + CustomDeviceChannel2Led230 = 1141, + CustomDeviceChannel2Led231 = 1142, + CustomDeviceChannel2Led232 = 1143, + CustomDeviceChannel2Led233 = 1144, + CustomDeviceChannel2Led234 = 1145, + CustomDeviceChannel2Led235 = 1146, + CustomDeviceChannel2Led236 = 1147, + CustomDeviceChannel2Led237 = 1148, + CustomDeviceChannel2Led238 = 1149, + CustomDeviceChannel2Led239 = 1150, + CustomDeviceChannel2Led240 = 1151, + CustomDeviceChannel2Led241 = 1152, + CustomDeviceChannel2Led242 = 1153, + CustomDeviceChannel2Led243 = 1154, + CustomDeviceChannel2Led244 = 1155, + CustomDeviceChannel2Led245 = 1156, + CustomDeviceChannel2Led246 = 1157, + CustomDeviceChannel2Led247 = 1158, + CustomDeviceChannel2Led248 = 1159, + CustomDeviceChannel2Led249 = 1160, + CustomDeviceChannel2Led250 = 1161, + CustomDeviceChannel2Led251 = 1162, + CustomDeviceChannel2Led252 = 1163, + CustomDeviceChannel2Led253 = 1164, + CustomDeviceChannel2Led254 = 1165, + CustomDeviceChannel2Led255 = 1166, + CustomDeviceChannel2Led256 = 1167, + CustomDeviceChannel2Led257 = 1168, + CustomDeviceChannel2Led258 = 1169, + CustomDeviceChannel2Led259 = 1170, + CustomDeviceChannel2Led260 = 1171, + CustomDeviceChannel2Led261 = 1172, + CustomDeviceChannel2Led262 = 1173, + CustomDeviceChannel2Led263 = 1174, + CustomDeviceChannel2Led264 = 1175, + CustomDeviceChannel2Led265 = 1176, + CustomDeviceChannel2Led266 = 1177, + CustomDeviceChannel2Led267 = 1178, + CustomDeviceChannel2Led268 = 1179, + CustomDeviceChannel2Led269 = 1180, + CustomDeviceChannel2Led270 = 1181, + CustomDeviceChannel2Led271 = 1182, + CustomDeviceChannel2Led272 = 1183, + CustomDeviceChannel2Led273 = 1184, + CustomDeviceChannel2Led274 = 1185, + CustomDeviceChannel2Led275 = 1186, + CustomDeviceChannel2Led276 = 1187, + CustomDeviceChannel2Led277 = 1188, + CustomDeviceChannel2Led278 = 1189, + CustomDeviceChannel2Led279 = 1190, + CustomDeviceChannel2Led280 = 1191, + CustomDeviceChannel2Led281 = 1192, + CustomDeviceChannel2Led282 = 1193, + CustomDeviceChannel2Led283 = 1194, + CustomDeviceChannel2Led284 = 1195, + CustomDeviceChannel2Led285 = 1196, + CustomDeviceChannel2Led286 = 1197, + CustomDeviceChannel2Led287 = 1198, + CustomDeviceChannel2Led288 = 1199, + CustomDeviceChannel2Led289 = 1200, + CustomDeviceChannel2Led290 = 1201, + CustomDeviceChannel2Led291 = 1202, + CustomDeviceChannel2Led292 = 1203, + CustomDeviceChannel2Led293 = 1204, + CustomDeviceChannel2Led294 = 1205, + CustomDeviceChannel2Led295 = 1206, + CustomDeviceChannel2Led296 = 1207, + CustomDeviceChannel2Led297 = 1208, + CustomDeviceChannel2Led298 = 1209, + CustomDeviceChannel2Led299 = 1210, + CustomDeviceChannel2Led300 = 1211, + + CustomDeviceChannel3Led151 = 1212, + CustomDeviceChannel3Led152 = 1213, + CustomDeviceChannel3Led153 = 1214, + CustomDeviceChannel3Led154 = 1215, + CustomDeviceChannel3Led155 = 1216, + CustomDeviceChannel3Led156 = 1217, + CustomDeviceChannel3Led157 = 1218, + CustomDeviceChannel3Led158 = 1219, + CustomDeviceChannel3Led159 = 1220, + CustomDeviceChannel3Led160 = 1221, + CustomDeviceChannel3Led161 = 1222, + CustomDeviceChannel3Led162 = 1223, + CustomDeviceChannel3Led163 = 1224, + CustomDeviceChannel3Led164 = 1225, + CustomDeviceChannel3Led165 = 1226, + CustomDeviceChannel3Led166 = 1227, + CustomDeviceChannel3Led167 = 1228, + CustomDeviceChannel3Led168 = 1229, + CustomDeviceChannel3Led169 = 1230, + CustomDeviceChannel3Led170 = 1231, + CustomDeviceChannel3Led171 = 1232, + CustomDeviceChannel3Led172 = 1233, + CustomDeviceChannel3Led173 = 1234, + CustomDeviceChannel3Led174 = 1235, + CustomDeviceChannel3Led175 = 1236, + CustomDeviceChannel3Led176 = 1237, + CustomDeviceChannel3Led177 = 1238, + CustomDeviceChannel3Led178 = 1239, + CustomDeviceChannel3Led179 = 1240, + CustomDeviceChannel3Led180 = 1241, + CustomDeviceChannel3Led181 = 1242, + CustomDeviceChannel3Led182 = 1243, + CustomDeviceChannel3Led183 = 1244, + CustomDeviceChannel3Led184 = 1245, + CustomDeviceChannel3Led185 = 1246, + CustomDeviceChannel3Led186 = 1247, + CustomDeviceChannel3Led187 = 1248, + CustomDeviceChannel3Led188 = 1249, + CustomDeviceChannel3Led189 = 1250, + CustomDeviceChannel3Led190 = 1251, + CustomDeviceChannel3Led191 = 1252, + CustomDeviceChannel3Led192 = 1253, + CustomDeviceChannel3Led193 = 1254, + CustomDeviceChannel3Led194 = 1255, + CustomDeviceChannel3Led195 = 1256, + CustomDeviceChannel3Led196 = 1257, + CustomDeviceChannel3Led197 = 1258, + CustomDeviceChannel3Led198 = 1259, + CustomDeviceChannel3Led199 = 1260, + CustomDeviceChannel3Led200 = 1261, + CustomDeviceChannel3Led201 = 1262, + CustomDeviceChannel3Led202 = 1263, + CustomDeviceChannel3Led203 = 1264, + CustomDeviceChannel3Led204 = 1265, + CustomDeviceChannel3Led205 = 1266, + CustomDeviceChannel3Led206 = 1267, + CustomDeviceChannel3Led207 = 1268, + CustomDeviceChannel3Led208 = 1269, + CustomDeviceChannel3Led209 = 1270, + CustomDeviceChannel3Led210 = 1271, + CustomDeviceChannel3Led211 = 1272, + CustomDeviceChannel3Led212 = 1273, + CustomDeviceChannel3Led213 = 1274, + CustomDeviceChannel3Led214 = 1275, + CustomDeviceChannel3Led215 = 1276, + CustomDeviceChannel3Led216 = 1277, + CustomDeviceChannel3Led217 = 1278, + CustomDeviceChannel3Led218 = 1279, + CustomDeviceChannel3Led219 = 1280, + CustomDeviceChannel3Led220 = 1281, + CustomDeviceChannel3Led221 = 1282, + CustomDeviceChannel3Led222 = 1283, + CustomDeviceChannel3Led223 = 1284, + CustomDeviceChannel3Led224 = 1285, + CustomDeviceChannel3Led225 = 1286, + CustomDeviceChannel3Led226 = 1287, + CustomDeviceChannel3Led227 = 1288, + CustomDeviceChannel3Led228 = 1289, + CustomDeviceChannel3Led229 = 1290, + CustomDeviceChannel3Led230 = 1291, + CustomDeviceChannel3Led231 = 1292, + CustomDeviceChannel3Led232 = 1293, + CustomDeviceChannel3Led233 = 1294, + CustomDeviceChannel3Led234 = 1295, + CustomDeviceChannel3Led235 = 1296, + CustomDeviceChannel3Led236 = 1297, + CustomDeviceChannel3Led237 = 1298, + CustomDeviceChannel3Led238 = 1299, + CustomDeviceChannel3Led239 = 1300, + CustomDeviceChannel3Led240 = 1301, + CustomDeviceChannel3Led241 = 1302, + CustomDeviceChannel3Led242 = 1303, + CustomDeviceChannel3Led243 = 1304, + CustomDeviceChannel3Led244 = 1305, + CustomDeviceChannel3Led245 = 1306, + CustomDeviceChannel3Led246 = 1307, + CustomDeviceChannel3Led247 = 1308, + CustomDeviceChannel3Led248 = 1309, + CustomDeviceChannel3Led249 = 1310, + CustomDeviceChannel3Led250 = 1311, + CustomDeviceChannel3Led251 = 1312, + CustomDeviceChannel3Led252 = 1313, + CustomDeviceChannel3Led253 = 1314, + CustomDeviceChannel3Led254 = 1315, + CustomDeviceChannel3Led255 = 1316, + CustomDeviceChannel3Led256 = 1317, + CustomDeviceChannel3Led257 = 1318, + CustomDeviceChannel3Led258 = 1319, + CustomDeviceChannel3Led259 = 1320, + CustomDeviceChannel3Led260 = 1321, + CustomDeviceChannel3Led261 = 1322, + CustomDeviceChannel3Led262 = 1323, + CustomDeviceChannel3Led263 = 1324, + CustomDeviceChannel3Led264 = 1325, + CustomDeviceChannel3Led265 = 1326, + CustomDeviceChannel3Led266 = 1327, + CustomDeviceChannel3Led267 = 1328, + CustomDeviceChannel3Led268 = 1329, + CustomDeviceChannel3Led269 = 1330, + CustomDeviceChannel3Led270 = 1331, + CustomDeviceChannel3Led271 = 1332, + CustomDeviceChannel3Led272 = 1333, + CustomDeviceChannel3Led273 = 1334, + CustomDeviceChannel3Led274 = 1335, + CustomDeviceChannel3Led275 = 1336, + CustomDeviceChannel3Led276 = 1337, + CustomDeviceChannel3Led277 = 1338, + CustomDeviceChannel3Led278 = 1339, + CustomDeviceChannel3Led279 = 1340, + CustomDeviceChannel3Led280 = 1341, + CustomDeviceChannel3Led281 = 1342, + CustomDeviceChannel3Led282 = 1343, + CustomDeviceChannel3Led283 = 1344, + CustomDeviceChannel3Led284 = 1345, + CustomDeviceChannel3Led285 = 1346, + CustomDeviceChannel3Led286 = 1347, + CustomDeviceChannel3Led287 = 1348, + CustomDeviceChannel3Led288 = 1349, + CustomDeviceChannel3Led289 = 1350, + CustomDeviceChannel3Led290 = 1351, + CustomDeviceChannel3Led291 = 1352, + CustomDeviceChannel3Led292 = 1353, + CustomDeviceChannel3Led293 = 1354, + CustomDeviceChannel3Led294 = 1355, + CustomDeviceChannel3Led295 = 1356, + CustomDeviceChannel3Led296 = 1357, + CustomDeviceChannel3Led297 = 1358, + CustomDeviceChannel3Led298 = 1359, + CustomDeviceChannel3Led299 = 1360, + CustomDeviceChannel3Led300 = 1361, + + Mainboard1 = 1362, + Mainboard2 = 1363, + Mainboard3 = 1364, + Mainboard4 = 1365, + Mainboard5 = 1366, + Mainboard6 = 1367, + Mainboard7 = 1368, + Mainboard8 = 1369, + Mainboard9 = 1370, + Mainboard10 = 1371, + Mainboard11 = 1372, + Mainboard12 = 1373, + Mainboard13 = 1374, + Mainboard14 = 1375, + Mainboard15 = 1376, + Mainboard16 = 1377, + Mainboard17 = 1378, + Mainboard18 = 1379, + Mainboard19 = 1380, + Mainboard20 = 1381, + Mainboard21 = 1382, + Mainboard22 = 1383, + Mainboard23 = 1384, + Mainboard24 = 1385, + Mainboard25 = 1386, + Mainboard26 = 1387, + Mainboard27 = 1388, + Mainboard28 = 1389, + Mainboard29 = 1390, + Mainboard30 = 1391, + Mainboard31 = 1392, + Mainboard32 = 1393, + Mainboard33 = 1394, + Mainboard34 = 1395, + Mainboard35 = 1396, + Mainboard36 = 1397, + Mainboard37 = 1398, + Mainboard38 = 1399, + Mainboard39 = 1400, + Mainboard40 = 1401, + Mainboard41 = 1402, + Mainboard42 = 1403, + Mainboard43 = 1404, + Mainboard44 = 1405, + Mainboard45 = 1406, + Mainboard46 = 1407, + Mainboard47 = 1408, + Mainboard48 = 1409, + Mainboard49 = 1410, + Mainboard50 = 1411, + Mainboard51 = 1412, + Mainboard52 = 1413, + Mainboard53 = 1414, + Mainboard54 = 1415, + Mainboard55 = 1416, + Mainboard56 = 1417, + Mainboard57 = 1418, + Mainboard58 = 1419, + Mainboard59 = 1420, + Mainboard60 = 1421, + Mainboard61 = 1422, + Mainboard62 = 1423, + Mainboard63 = 1424, + Mainboard64 = 1425, + Mainboard65 = 1426, + Mainboard66 = 1427, + Mainboard67 = 1428, + Mainboard68 = 1429, + Mainboard69 = 1430, + Mainboard70 = 1431, + Mainboard71 = 1432, + Mainboard72 = 1433, + Mainboard73 = 1434, + Mainboard74 = 1435, + Mainboard75 = 1436, + Mainboard76 = 1437, + Mainboard77 = 1438, + Mainboard78 = 1439, + Mainboard79 = 1440, + Mainboard80 = 1441, + Mainboard81 = 1442, + Mainboard82 = 1443, + Mainboard83 = 1444, + Mainboard84 = 1445, + Mainboard85 = 1446, + Mainboard86 = 1447, + Mainboard87 = 1448, + Mainboard88 = 1449, + Mainboard89 = 1450, + Mainboard90 = 1451, + Mainboard91 = 1452, + Mainboard92 = 1453, + Mainboard93 = 1454, + Mainboard94 = 1455, + Mainboard95 = 1456, + Mainboard96 = 1457, + Mainboard97 = 1458, + Mainboard98 = 1459, + Mainboard99 = 1460, + Mainboard100 = 1461, + + GPU1 = 1462, + GPU2 = 1463, + GPU3 = 1464, + GPU4 = 1465, + GPU5 = 1466, + GPU6 = 1467, + GPU7 = 1468, + GPU8 = 1469, + GPU9 = 1470, + GPU10 = 1471, + GPU11 = 1472, + GPU12 = 1473, + GPU13 = 1474, + GPU14 = 1475, + GPU15 = 1476, + GPU16 = 1477, + GPU17 = 1478, + GPU18 = 1479, + GPU19 = 1480, + GPU20 = 1481, + GPU21 = 1482, + GPU22 = 1483, + GPU23 = 1484, + GPU24 = 1485, + GPU25 = 1486, + GPU26 = 1487, + GPU27 = 1488, + GPU28 = 1489, + GPU29 = 1490, + GPU30 = 1491, + GPU31 = 1492, + GPU32 = 1493, + GPU33 = 1494, + GPU34 = 1495, + GPU35 = 1496, + GPU36 = 1497, + GPU37 = 1498, + GPU38 = 1499, + GPU39 = 1500, + GPU40 = 1501, + GPU41 = 1502, + GPU42 = 1503, + GPU43 = 1504, + GPU44 = 1505, + GPU45 = 1506, + GPU46 = 1507, + GPU47 = 1508, + GPU48 = 1509, + GPU49 = 1510, + GPU50 = 1511, + + Lightbar20 = 1512, + Lightbar21 = 1513, + Lightbar22 = 1514, + Lightbar23 = 1515, + Lightbar24 = 1516, + Lightbar25 = 1517, + Lightbar26 = 1518, + Lightbar27 = 1519, + Lightbar28 = 1520, + Lightbar29 = 1521, + Lightbar30 = 1522, + Lightbar31 = 1523, + Lightbar32 = 1524, + Lightbar33 = 1525, + Lightbar34 = 1526, + Lightbar35 = 1527, + Lightbar36 = 1528, + Lightbar37 = 1529, + Lightbar38 = 1530, + Lightbar39 = 1531, + Lightbar40 = 1532, + Lightbar41 = 1533, + Lightbar42 = 1534, + Lightbar43 = 1535, + Lightbar44 = 1536, + Lightbar45 = 1537, + Lightbar46 = 1538, + Lightbar47 = 1539, + Lightbar48 = 1540, + Lightbar49 = 1541, + Lightbar50 = 1542, + + Profile = 1543, + + OemLed101 = 1544, + OemLed102 = 1545, + OemLed103 = 1546, + OemLed104 = 1547, + OemLed105 = 1548, + OemLed106 = 1549, + OemLed107 = 1550, + OemLed108 = 1551, + OemLed109 = 1552, + OemLed110 = 1553, + OemLed111 = 1554, + OemLed112 = 1555, + OemLed113 = 1556, + OemLed114 = 1557, + OemLed115 = 1558, + OemLed116 = 1559, + OemLed117 = 1560, + OemLed118 = 1561, + OemLed119 = 1562, + OemLed120 = 1563, + OemLed121 = 1564, + OemLed122 = 1565, + OemLed123 = 1566, + OemLed124 = 1567, + OemLed125 = 1568, + OemLed126 = 1569, + OemLed127 = 1570, + OemLed128 = 1571, + OemLed129 = 1572, + OemLed130 = 1573, + OemLed131 = 1574, + OemLed132 = 1575, + OemLed133 = 1576, + OemLed134 = 1577, + OemLed135 = 1578, + OemLed136 = 1579, + OemLed137 = 1580, + OemLed138 = 1581, + OemLed139 = 1582, + OemLed140 = 1583, + OemLed141 = 1584, + OemLed142 = 1585, + OemLed143 = 1586, + OemLed144 = 1587, + OemLed145 = 1588, + OemLed146 = 1589, + OemLed147 = 1590, + OemLed148 = 1591, + OemLed149 = 1592, + OemLed150 = 1593, + OemLed151 = 1594, + OemLed152 = 1595, + OemLed153 = 1596, + OemLed154 = 1597, + OemLed155 = 1598, + OemLed156 = 1599, + OemLed157 = 1600, + OemLed158 = 1601, + OemLed159 = 1602, + OemLed160 = 1603, + OemLed161 = 1604, + OemLed162 = 1605, + OemLed163 = 1606, + OemLed164 = 1607, + OemLed165 = 1608, + OemLed166 = 1609, + OemLed167 = 1610, + OemLed168 = 1611, + OemLed169 = 1612, + OemLed170 = 1613, + OemLed171 = 1614, + OemLed172 = 1615, + OemLed173 = 1616, + OemLed174 = 1617, + OemLed175 = 1618, + OemLed176 = 1619, + OemLed177 = 1620, + OemLed178 = 1621, + OemLed179 = 1622, + OemLed180 = 1623, + OemLed181 = 1624, + OemLed182 = 1625, + OemLed183 = 1626, + OemLed184 = 1627, + OemLed185 = 1628, + OemLed186 = 1629, + OemLed187 = 1630, + OemLed188 = 1631, + OemLed189 = 1632, + OemLed190 = 1633, + OemLed191 = 1634, + OemLed192 = 1635, + OemLed193 = 1636, + OemLed194 = 1637, + OemLed195 = 1638, + OemLed196 = 1639, + OemLed197 = 1640, + OemLed198 = 1641, + OemLed199 = 1642, + OemLed200 = 1643, + OemLed201 = 1644, + OemLed202 = 1645, + OemLed203 = 1646, + OemLed204 = 1647, + OemLed205 = 1648, + OemLed206 = 1649, + OemLed207 = 1650, + OemLed208 = 1651, + OemLed209 = 1652, + OemLed210 = 1653, + OemLed211 = 1654, + OemLed212 = 1655, + OemLed213 = 1656, + OemLed214 = 1657, + OemLed215 = 1658, + OemLed216 = 1659, + OemLed217 = 1660, + OemLed218 = 1661, + OemLed219 = 1662, + OemLed220 = 1663, + OemLed221 = 1664, + OemLed222 = 1665, + OemLed223 = 1666, + OemLed224 = 1667, + OemLed225 = 1668, + OemLed226 = 1669, + OemLed227 = 1670, + OemLed228 = 1671, + OemLed229 = 1672, + OemLed230 = 1673, + OemLed231 = 1674, + OemLed232 = 1675, + OemLed233 = 1676, + OemLed234 = 1677, + OemLed235 = 1678, + OemLed236 = 1679, + OemLed237 = 1680, + OemLed238 = 1681, + OemLed239 = 1682, + OemLed240 = 1683, + OemLed241 = 1684, + OemLed242 = 1685, + OemLed243 = 1686, + OemLed244 = 1687, + OemLed245 = 1688, + OemLed246 = 1689, + OemLed247 = 1690, + OemLed248 = 1691, + OemLed249 = 1692, + OemLed250 = 1693, + + B7 = 1694, + B8 = 1695, + B9 = 1696, + B10 = 1697, + B11 = 1698, + B12 = 1699, + B13 = 1700, + B14 = 1701, + B15 = 1702, + B16 = 1703, + B17 = 1704, + B18 = 1705, + B19 = 1706, + B20 = 1707, +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLogicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLogicalKeyboardLayout.cs new file mode 100644 index 0000000..48c8c21 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLogicalKeyboardLayout.cs @@ -0,0 +1,30 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global +#pragma warning disable 1591 + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of available logical layouts for corsair keyboards. +/// +public enum CorsairLogicalKeyboardLayout +{ + US_Int = 1, + NA = 2, + EU = 3, + UK = 4, + BE = 5, + BR = 6, + CH = 7, + CN = 8, + DE = 9, + ES = 10, + FR = 11, + IT = 12, + ND = 13, + RU = 14, + JP = 15, + KR = 16, + TW = 17, + MEX = 18 +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalKeyboardLayout.cs new file mode 100644 index 0000000..c917741 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalKeyboardLayout.cs @@ -0,0 +1,35 @@ +// ReSharper disable UnusedMember.Global +// ReSharper disable InconsistentNaming + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of available physical layouts for corsair keyboards. +/// +public enum CorsairPhysicalKeyboardLayout +{ + /// + /// US-Keyboard + /// + US = 1, + + /// + /// UK-Keyboard + /// + UK = 2, + + /// + /// BR-Keyboard + /// + BR = 3, + + /// + /// JP-Keyboard + /// + JP = 4, + + /// + /// KR-Keyboard + /// + KR = 5 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalMouseLayout.cs b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalMouseLayout.cs new file mode 100644 index 0000000..9be87b4 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Enum/CorsairPhysicalMouseLayout.cs @@ -0,0 +1,107 @@ +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains a list of available physical layouts for mice. +/// +public enum CorsairPhysicalMouseLayout +{ + /// + /// Zone1-Mouse + /// + Zones1 = 6, + + /// + /// Zone2-Mouse + /// + Zones2 = 7, + + /// + /// Zone3-Mouse + /// + Zones3 = 8, + + /// + /// Zone4-Mouse + /// + Zones4 = 9, + + /// + /// Zone5-Mouse + /// + Zones5 = 101, + + /// + /// Zone6-Mouse + /// + Zones6 = 11, + + /// + /// Zone7-Mouse + /// + Zones7 = 12, + + /// + /// Zone8-Mouse + /// + Zones8 = 13, + + /// + /// Zone9-Mouse + /// + Zones9 = 14, + + /// + /// Zone10-Mouse + /// + Zones10 = 15, + + /// + /// Zone11-Mouse + /// + Zones11 = 16, + + /// + /// Zone12-Mouse + /// + Zones12 = 17, + + /// + /// Zone13-Mouse + /// + Zones13 = 18, + + /// + /// Zone14-Mouse + /// + Zones14 = 19, + + /// + /// Zone15-Mouse + /// + Zones15 = 20, + + /// + /// Zone16-Mouse + /// + Zones16 = 21, + + /// + /// Zone17-Mouse + /// + Zones17 = 22, + + /// + /// Zone18-Mouse + /// + Zones18 = 23, + + /// + /// Zone19-Mouse + /// + Zones19 = 24, + + /// + /// Zone20-Mouse + /// + Zones20 = 25 +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs b/RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs new file mode 100644 index 0000000..1618afb --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs @@ -0,0 +1,36 @@ +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable MemberCanBePrivate.Global + +using System; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents an exception thrown by the CUE. +/// +public class CUEException : ApplicationException +{ + #region Properties & Fields + + /// + /// Gets the provided by CUE. + /// + public CorsairError Error { get; } + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The provided by CUE, which leads to this exception. + public CUEException(CorsairError error) + { + this.Error = error; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs new file mode 100644 index 0000000..6282932 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs @@ -0,0 +1,80 @@ +using System; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents the update-queue performing updates for corsair devices. +/// +public class CorsairDeviceUpdateQueue : UpdateQueue +{ + #region Properties & Fields + + private int _deviceIndex; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The update trigger used by this queue. + /// The index used to identify the device. + public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIndex) + : base(updateTrigger) + { + this._deviceIndex = deviceIndex; + } + + #endregion + + #region Methods + + /// + protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) + { + try + { + int structSize = Marshal.SizeOf(typeof(_CorsairLedColor)); + IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length); + IntPtr addPtr = new(ptr.ToInt64()); + try + { + foreach ((object key, Color color) in dataSet) + { + _CorsairLedColor corsairColor = new() + { + ledId = (int)key, + r = color.GetR(), + g = color.GetG(), + b = color.GetB() + }; + + Marshal.StructureToPtr(corsairColor, addPtr, false); + addPtr = new IntPtr(addPtr.ToInt64() + structSize); + } + + _CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr); + _CUESDK.CorsairSetLedsColorsFlushBuffer(); + } + finally + { + Marshal.FreeHGlobal(ptr); + } + + return true; + } + catch (Exception ex) + { + CorsairLegacyDeviceProvider.Instance.Throw(ex); + } + + return false; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs new file mode 100644 index 0000000..f2cd520 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs @@ -0,0 +1,65 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global + +using System; +using System.Runtime.InteropServices; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Managed wrapper for CorsairProtocolDetails. +/// +public class CorsairProtocolDetails +{ + #region Properties & Fields + + /// + /// String containing version of SDK(like "1.0.0.1"). + /// Always contains valid value even if there was no CUE found. + /// + public string? SdkVersion { get; } + + /// + /// String containing version of CUE(like "1.0.0.1") or NULL if CUE was not found. + /// + public string? ServerVersion { get; } + + /// + /// Integer that specifies version of protocol that is implemented by current SDK. + /// Numbering starts from 1. + /// Always contains valid value even if there was no CUE found. + /// + public int SdkProtocolVersion { get; } + + /// + /// Integer that specifies version of protocol that is implemented by CUE. + /// Numbering starts from 1. + /// If CUE was not found then this value will be 0. + /// + public int ServerProtocolVersion { get; } + + /// + /// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client. + /// + public bool BreakingChanges { get; } + + #endregion + + #region Constructors + + /// + /// Internal constructor of managed CorsairProtocolDetails. + /// + /// The native CorsairProtocolDetails-struct + internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails) + { + this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion); + this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion); + this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion; + this.ServerProtocolVersion = nativeDetails.serverProtocolVersion; + this.BreakingChanges = nativeDetails.breakingChanges != 0; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs new file mode 100644 index 0000000..fb9aa2e --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs @@ -0,0 +1,76 @@ +using System; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad). +/// +public abstract class CorsairRGBDevice : AbstractRGBDevice, ICorsairRGBDevice + where TDeviceInfo : CorsairRGBDeviceInfo +{ + #region Properties & Fields + + /// + /// Gets the mapping of to used to update the LEDs of this device. + /// + protected LedMapping Mapping { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The generic information provided by CUE for the device. + /// The mapping to used to update the LEDs of this device. + /// The queue used to update this device. + protected CorsairRGBDevice(TDeviceInfo info, LedMapping mapping, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { + this.Mapping = mapping; + } + + #endregion + + #region Methods + + void ICorsairRGBDevice.Initialize() => InitializeLayout(); + + /// + /// Initializes the LEDs of the device based on the data provided by the SDK. + /// + protected virtual void InitializeLayout() + { + _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); + if (nativeLedPositions == null) return; + + int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); + IntPtr ptr = nativeLedPositions.pLedPosition; + + for (int i = 0; i < nativeLedPositions.numberOfLed; i++) + { + _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); + if (ledPosition == null) + { + ptr = new IntPtr(ptr.ToInt64() + structSize); + continue; + } + + LedId ledId = Mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid; + Rectangle rectangle = ledPosition.ToRectangle(); + AddLed(ledId, rectangle.Location, rectangle.Size); + + ptr = new IntPtr(ptr.ToInt64() + structSize); + } + } + + /// + protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid; + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDeviceInfo.cs new file mode 100644 index 0000000..f35a65c --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDeviceInfo.cs @@ -0,0 +1,95 @@ +using System; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a Corsair-. +/// +public class CorsairRGBDeviceInfo : IRGBDeviceInfo +{ + #region Properties & Fields + + /// + /// Gets the corsair specific device type. + /// + public CorsairDeviceType CorsairDeviceType { get; } + + /// + /// Gets the index of the . + /// + public int CorsairDeviceIndex { get; } + + /// + public RGBDeviceType DeviceType { get; } + + /// + public string DeviceName { get; } + + /// + public string Manufacturer => "Corsair"; + + /// + public string Model { get; } + + /// + /// Returns the unique ID provided by the Corsair-SDK. + /// Returns string.Empty for Custom devices. + /// + public string DeviceId { get; } + + /// + public object? LayoutMetadata { get; set; } + + /// + /// Gets a flag that describes device capabilities. () + /// + public CorsairDeviceCaps CapsMask { get; } + + #endregion + + #region Constructors + + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The type of the . + /// The native -struct + internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo) + { + this.CorsairDeviceIndex = deviceIndex; + this.DeviceType = deviceType; + this.CorsairDeviceType = nativeInfo.type; + this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); + this.DeviceId = nativeInfo.deviceId ?? string.Empty; + this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; + + DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); + } + + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The type of the . + /// The native -struct + /// The name of the device-model (overwrites the one provided with the device info). + internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName) + { + this.CorsairDeviceIndex = deviceIndex; + this.DeviceType = deviceType; + this.CorsairDeviceType = nativeInfo.type; + this.Model = modelName; + this.DeviceId = nativeInfo.deviceId ?? string.Empty; + this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; + + DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs new file mode 100644 index 0000000..dbb031b --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs @@ -0,0 +1,11 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Represents a corsair RGB-device. +/// +public interface ICorsairRGBDevice : IRGBDevice +{ + internal void Initialize(); +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs new file mode 100644 index 0000000..ca2da70 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs @@ -0,0 +1,302 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Contains mappings for to . +/// +public static class LedMappings +{ + static LedMappings() + { + for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++) + GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i); + + for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++) + HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i); + + for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++) + Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i); + + for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++) + Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i); + + for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++) + Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i); + + for (int i = 0; i <= (CorsairLedId.OemLed100 - CorsairLedId.OemLed1); i++) + Keyboard.Add(LedId.Custom1 + i, CorsairLedId.OemLed1 + i); + + for (int i = 0; i <= (CorsairLedId.OemLed250 - CorsairLedId.OemLed101); i++) + Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i); + } + + /// + /// Gets the mapping for graphics cards. + /// + public static LedMapping GraphicsCard { get; } = new(); + + /// + /// Gets the mapping for headsets. + /// + public static LedMapping HeadsetStand { get; } = new(); + + /// + /// Gets the mapping for mainboards. + /// + public static LedMapping Mainboard { get; } = new(); + + /// + /// Gets the mapping for memory. + /// + public static LedMapping Memory { get; } = new(); + + /// + /// Gets the mapping for mousepads. + /// + public static LedMapping Mousepad { get; } = new(); + + /// + /// Gets the mapping for headsets. + /// + public static LedMapping Headset { get; } = new() + { + { LedId.Headset1, CorsairLedId.LeftLogo }, + { LedId.Headset2, CorsairLedId.RightLogo }, + }; + + /// + /// Gets the mapping for mice. + /// + public static LedMapping Mouse { get; } = new() + { + { LedId.Mouse1, CorsairLedId.B1 }, + { LedId.Mouse2, CorsairLedId.B2 }, + { LedId.Mouse3, CorsairLedId.B3 }, + { LedId.Mouse4, CorsairLedId.B4 }, + { LedId.Mouse5, CorsairLedId.B5 }, + { LedId.Mouse6, CorsairLedId.B6 }, + { LedId.Mouse7, CorsairLedId.B7 }, + { LedId.Mouse8, CorsairLedId.B8 }, + { LedId.Mouse9, CorsairLedId.B9 }, + { LedId.Mouse10, CorsairLedId.B10 }, + { LedId.Mouse11, CorsairLedId.B11 }, + { LedId.Mouse12, CorsairLedId.B12 }, + { LedId.Mouse13, CorsairLedId.B13 }, + { LedId.Mouse14, CorsairLedId.B14 }, + { LedId.Mouse15, CorsairLedId.B15 }, + { LedId.Mouse16, CorsairLedId.B16 }, + { LedId.Mouse17, CorsairLedId.B17 }, + { LedId.Mouse18, CorsairLedId.B18 }, + { LedId.Mouse19, CorsairLedId.B19 }, + { LedId.Mouse20, CorsairLedId.B20 }, + }; + + /// + /// Gets the mapping for keyboards. + /// + public static LedMapping Keyboard { get; } = new() + { + { LedId.Invalid, CorsairLedId.Invalid }, + { LedId.Logo, CorsairLedId.Logo }, + { LedId.Keyboard_Escape, CorsairLedId.Escape }, + { LedId.Keyboard_F1, CorsairLedId.F1 }, + { LedId.Keyboard_F2, CorsairLedId.F2 }, + { LedId.Keyboard_F3, CorsairLedId.F3 }, + { LedId.Keyboard_F4, CorsairLedId.F4 }, + { LedId.Keyboard_F5, CorsairLedId.F5 }, + { LedId.Keyboard_F6, CorsairLedId.F6 }, + { LedId.Keyboard_F7, CorsairLedId.F7 }, + { LedId.Keyboard_F8, CorsairLedId.F8 }, + { LedId.Keyboard_F9, CorsairLedId.F9 }, + { LedId.Keyboard_F10, CorsairLedId.F10 }, + { LedId.Keyboard_F11, CorsairLedId.F11 }, + { LedId.Keyboard_GraveAccentAndTilde, CorsairLedId.GraveAccentAndTilde }, + { LedId.Keyboard_1, CorsairLedId.D1 }, + { LedId.Keyboard_2, CorsairLedId.D2 }, + { LedId.Keyboard_3, CorsairLedId.D3 }, + { LedId.Keyboard_4, CorsairLedId.D4 }, + { LedId.Keyboard_5, CorsairLedId.D5 }, + { LedId.Keyboard_6, CorsairLedId.D6 }, + { LedId.Keyboard_7, CorsairLedId.D7 }, + { LedId.Keyboard_8, CorsairLedId.D8 }, + { LedId.Keyboard_9, CorsairLedId.D9 }, + { LedId.Keyboard_0, CorsairLedId.D0 }, + { LedId.Keyboard_MinusAndUnderscore, CorsairLedId.MinusAndUnderscore }, + { LedId.Keyboard_Tab, CorsairLedId.Tab }, + { LedId.Keyboard_Q, CorsairLedId.Q }, + { LedId.Keyboard_W, CorsairLedId.W }, + { LedId.Keyboard_E, CorsairLedId.E }, + { LedId.Keyboard_R, CorsairLedId.R }, + { LedId.Keyboard_T, CorsairLedId.T }, + { LedId.Keyboard_Y, CorsairLedId.Y }, + { LedId.Keyboard_U, CorsairLedId.U }, + { LedId.Keyboard_I, CorsairLedId.I }, + { LedId.Keyboard_O, CorsairLedId.O }, + { LedId.Keyboard_P, CorsairLedId.P }, + { LedId.Keyboard_BracketLeft, CorsairLedId.BracketLeft }, + { LedId.Keyboard_CapsLock, CorsairLedId.CapsLock }, + { LedId.Keyboard_A, CorsairLedId.A }, + { LedId.Keyboard_S, CorsairLedId.S }, + { LedId.Keyboard_D, CorsairLedId.D }, + { LedId.Keyboard_F, CorsairLedId.F }, + { LedId.Keyboard_G, CorsairLedId.G }, + { LedId.Keyboard_H, CorsairLedId.H }, + { LedId.Keyboard_J, CorsairLedId.J }, + { LedId.Keyboard_K, CorsairLedId.K }, + { LedId.Keyboard_L, CorsairLedId.L }, + { LedId.Keyboard_SemicolonAndColon, CorsairLedId.SemicolonAndColon }, + { LedId.Keyboard_ApostropheAndDoubleQuote, CorsairLedId.ApostropheAndDoubleQuote }, + { LedId.Keyboard_LeftShift, CorsairLedId.LeftShift }, + { LedId.Keyboard_NonUsBackslash, CorsairLedId.NonUsBackslash }, + { LedId.Keyboard_Z, CorsairLedId.Z }, + { LedId.Keyboard_X, CorsairLedId.X }, + { LedId.Keyboard_C, CorsairLedId.C }, + { LedId.Keyboard_V, CorsairLedId.V }, + { LedId.Keyboard_B, CorsairLedId.B }, + { LedId.Keyboard_N, CorsairLedId.N }, + { LedId.Keyboard_M, CorsairLedId.M }, + { LedId.Keyboard_CommaAndLessThan, CorsairLedId.CommaAndLessThan }, + { LedId.Keyboard_PeriodAndBiggerThan, CorsairLedId.PeriodAndBiggerThan }, + { LedId.Keyboard_SlashAndQuestionMark, CorsairLedId.SlashAndQuestionMark }, + { LedId.Keyboard_LeftCtrl, CorsairLedId.LeftCtrl }, + { LedId.Keyboard_LeftGui, CorsairLedId.LeftGui }, + { LedId.Keyboard_LeftAlt, CorsairLedId.LeftAlt }, + { LedId.Keyboard_Lang2, CorsairLedId.Lang2 }, + { LedId.Keyboard_Space, CorsairLedId.Space }, + { LedId.Keyboard_Lang1, CorsairLedId.Lang1 }, + { LedId.Keyboard_International2, CorsairLedId.International2 }, + { LedId.Keyboard_RightAlt, CorsairLedId.RightAlt }, + { LedId.Keyboard_RightGui, CorsairLedId.RightGui }, + { LedId.Keyboard_Application, CorsairLedId.Application }, + { LedId.Keyboard_Brightness, CorsairLedId.Brightness }, + { LedId.Keyboard_F12, CorsairLedId.F12 }, + { LedId.Keyboard_PrintScreen, CorsairLedId.PrintScreen }, + { LedId.Keyboard_ScrollLock, CorsairLedId.ScrollLock }, + { LedId.Keyboard_PauseBreak, CorsairLedId.PauseBreak }, + { LedId.Keyboard_Insert, CorsairLedId.Insert }, + { LedId.Keyboard_Home, CorsairLedId.Home }, + { LedId.Keyboard_PageUp, CorsairLedId.PageUp }, + { LedId.Keyboard_BracketRight, CorsairLedId.BracketRight }, + { LedId.Keyboard_Backslash, CorsairLedId.Backslash }, + { LedId.Keyboard_NonUsTilde, CorsairLedId.NonUsTilde }, + { LedId.Keyboard_Enter, CorsairLedId.Enter }, + { LedId.Keyboard_International1, CorsairLedId.International1 }, + { LedId.Keyboard_EqualsAndPlus, CorsairLedId.EqualsAndPlus }, + { LedId.Keyboard_International3, CorsairLedId.International3 }, + { LedId.Keyboard_Backspace, CorsairLedId.Backspace }, + { LedId.Keyboard_Delete, CorsairLedId.Delete }, + { LedId.Keyboard_End, CorsairLedId.End }, + { LedId.Keyboard_PageDown, CorsairLedId.PageDown }, + { LedId.Keyboard_RightShift, CorsairLedId.RightShift }, + { LedId.Keyboard_RightCtrl, CorsairLedId.RightCtrl }, + { LedId.Keyboard_ArrowUp, CorsairLedId.UpArrow }, + { LedId.Keyboard_ArrowLeft, CorsairLedId.LeftArrow }, + { LedId.Keyboard_ArrowDown, CorsairLedId.DownArrow }, + { LedId.Keyboard_ArrowRight, CorsairLedId.RightArrow }, + { LedId.Keyboard_WinLock, CorsairLedId.WinLock }, + { LedId.Keyboard_MediaMute, CorsairLedId.Mute }, + { LedId.Keyboard_MediaStop, CorsairLedId.Stop }, + { LedId.Keyboard_MediaPreviousTrack, CorsairLedId.ScanPreviousTrack }, + { LedId.Keyboard_MediaPlay, CorsairLedId.PlayPause }, + { LedId.Keyboard_MediaNextTrack, CorsairLedId.ScanNextTrack }, + { LedId.Keyboard_NumLock, CorsairLedId.NumLock }, + { LedId.Keyboard_NumSlash, CorsairLedId.KeypadSlash }, + { LedId.Keyboard_NumAsterisk, CorsairLedId.KeypadAsterisk }, + { LedId.Keyboard_NumMinus, CorsairLedId.KeypadMinus }, + { LedId.Keyboard_NumPlus, CorsairLedId.KeypadPlus }, + { LedId.Keyboard_NumEnter, CorsairLedId.KeypadEnter }, + { LedId.Keyboard_Num7, CorsairLedId.Keypad7 }, + { LedId.Keyboard_Num8, CorsairLedId.Keypad8 }, + { LedId.Keyboard_Num9, CorsairLedId.Keypad9 }, + { LedId.Keyboard_NumComma, CorsairLedId.KeypadComma }, + { LedId.Keyboard_Num4, CorsairLedId.Keypad4 }, + { LedId.Keyboard_Num5, CorsairLedId.Keypad5 }, + { LedId.Keyboard_Num6, CorsairLedId.Keypad6 }, + { LedId.Keyboard_Num1, CorsairLedId.Keypad1 }, + { LedId.Keyboard_Num2, CorsairLedId.Keypad2 }, + { LedId.Keyboard_Num3, CorsairLedId.Keypad3 }, + { LedId.Keyboard_Num0, CorsairLedId.Keypad0 }, + { LedId.Keyboard_NumPeriodAndDelete, CorsairLedId.KeypadPeriodAndDelete }, + { LedId.Keyboard_Programmable1, CorsairLedId.G1 }, + { LedId.Keyboard_Programmable2, CorsairLedId.G2 }, + { LedId.Keyboard_Programmable3, CorsairLedId.G3 }, + { LedId.Keyboard_Programmable4, CorsairLedId.G4 }, + { LedId.Keyboard_Programmable5, CorsairLedId.G5 }, + { LedId.Keyboard_Programmable6, CorsairLedId.G6 }, + { LedId.Keyboard_Programmable7, CorsairLedId.G7 }, + { LedId.Keyboard_Programmable8, CorsairLedId.G8 }, + { LedId.Keyboard_Programmable9, CorsairLedId.G9 }, + { LedId.Keyboard_Programmable10, CorsairLedId.G10 }, + { LedId.Keyboard_MediaVolumeUp, CorsairLedId.VolumeUp }, + { LedId.Keyboard_MediaVolumeDown, CorsairLedId.VolumeDown }, + { LedId.Keyboard_MacroRecording, CorsairLedId.MR }, + { LedId.Keyboard_Macro1, CorsairLedId.M1 }, + { LedId.Keyboard_Macro2, CorsairLedId.M2 }, + { LedId.Keyboard_Macro3, CorsairLedId.M3 }, + { LedId.Keyboard_Programmable11, CorsairLedId.G11 }, + { LedId.Keyboard_Programmable12, CorsairLedId.G12 }, + { LedId.Keyboard_Programmable13, CorsairLedId.G13 }, + { LedId.Keyboard_Programmable14, CorsairLedId.G14 }, + { LedId.Keyboard_Programmable15, CorsairLedId.G15 }, + { LedId.Keyboard_Programmable16, CorsairLedId.G16 }, + { LedId.Keyboard_Programmable17, CorsairLedId.G17 }, + { LedId.Keyboard_Programmable18, CorsairLedId.G18 }, + { LedId.Keyboard_International5, CorsairLedId.International5 }, + { LedId.Keyboard_International4, CorsairLedId.International4 }, + { LedId.Keyboard_Profile, CorsairLedId.Profile }, + { LedId.Keyboard_LedProgramming, CorsairLedId.LedProgramming }, + { LedId.Keyboard_Function, CorsairLedId.Fn }, + + { LedId.LedStripe1, CorsairLedId.Lightbar1 }, + { LedId.LedStripe2, CorsairLedId.Lightbar2 }, + { LedId.LedStripe3, CorsairLedId.Lightbar3 }, + { LedId.LedStripe4, CorsairLedId.Lightbar4 }, + { LedId.LedStripe5, CorsairLedId.Lightbar5 }, + { LedId.LedStripe6, CorsairLedId.Lightbar6 }, + { LedId.LedStripe7, CorsairLedId.Lightbar7 }, + { LedId.LedStripe8, CorsairLedId.Lightbar8 }, + { LedId.LedStripe9, CorsairLedId.Lightbar9 }, + { LedId.LedStripe10, CorsairLedId.Lightbar10 }, + { LedId.LedStripe11, CorsairLedId.Lightbar11 }, + { LedId.LedStripe12, CorsairLedId.Lightbar12 }, + { LedId.LedStripe13, CorsairLedId.Lightbar13 }, + { LedId.LedStripe14, CorsairLedId.Lightbar14 }, + { LedId.LedStripe15, CorsairLedId.Lightbar15 }, + { LedId.LedStripe16, CorsairLedId.Lightbar16 }, + { LedId.LedStripe17, CorsairLedId.Lightbar17 }, + { LedId.LedStripe18, CorsairLedId.Lightbar18 }, + { LedId.LedStripe19, CorsairLedId.Lightbar19 }, + { LedId.LedStripe20, CorsairLedId.Lightbar20 }, + { LedId.LedStripe21, CorsairLedId.Lightbar21 }, + { LedId.LedStripe22, CorsairLedId.Lightbar22 }, + { LedId.LedStripe23, CorsairLedId.Lightbar23 }, + { LedId.LedStripe24, CorsairLedId.Lightbar24 }, + { LedId.LedStripe25, CorsairLedId.Lightbar25 }, + { LedId.LedStripe26, CorsairLedId.Lightbar26 }, + { LedId.LedStripe27, CorsairLedId.Lightbar27 }, + { LedId.LedStripe28, CorsairLedId.Lightbar28 }, + { LedId.LedStripe29, CorsairLedId.Lightbar29 }, + { LedId.LedStripe30, CorsairLedId.Lightbar30 }, + { LedId.LedStripe31, CorsairLedId.Lightbar31 }, + { LedId.LedStripe32, CorsairLedId.Lightbar32 }, + { LedId.LedStripe33, CorsairLedId.Lightbar33 }, + { LedId.LedStripe34, CorsairLedId.Lightbar34 }, + { LedId.LedStripe35, CorsairLedId.Lightbar35 }, + { LedId.LedStripe36, CorsairLedId.Lightbar36 }, + { LedId.LedStripe37, CorsairLedId.Lightbar37 }, + { LedId.LedStripe38, CorsairLedId.Lightbar38 }, + { LedId.LedStripe39, CorsairLedId.Lightbar39 }, + { LedId.LedStripe40, CorsairLedId.Lightbar40 }, + { LedId.LedStripe41, CorsairLedId.Lightbar41 }, + { LedId.LedStripe42, CorsairLedId.Lightbar42 }, + { LedId.LedStripe43, CorsairLedId.Lightbar43 }, + { LedId.LedStripe44, CorsairLedId.Lightbar44 }, + { LedId.LedStripe45, CorsairLedId.Lightbar45 }, + { LedId.LedStripe46, CorsairLedId.Lightbar46 }, + { LedId.LedStripe47, CorsairLedId.Lightbar47 }, + { LedId.LedStripe48, CorsairLedId.Lightbar48 }, + { LedId.LedStripe49, CorsairLedId.Lightbar49 }, + { LedId.LedStripe50, CorsairLedId.Lightbar50 }, + }; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDevice.cs new file mode 100644 index 0000000..ece723e --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair graphics card. +/// +public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice, IGraphicsCard +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the graphics card. + /// The queue used to update this device. + internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.GraphicsCard, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs new file mode 100644 index 0000000..d1b38b6 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/GraphicsCard/CorsairGraphicsCardRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairGraphicsCardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.GraphicsCard, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDevice.cs new file mode 100644 index 0000000..1a6adfa --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair headset. +/// +public class CorsairHeadsetRGBDevice : CorsairRGBDevice, IHeadset +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the headset + /// The queue used to update this device. + internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Headset, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDeviceInfo.cs new file mode 100644 index 0000000..090760b --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Headset/CorsairHeadsetRGBDeviceInfo.cs @@ -0,0 +1,25 @@ +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Headset, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDevice.cs new file mode 100644 index 0000000..d696cff --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair headset stand. +/// +public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice, IHeadsetStand +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the headset stand + /// The queue used to update this device. + internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.HeadsetStand, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs new file mode 100644 index 0000000..61ab548 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/HeadsetStand/CorsairHeadsetStandRGBDeviceInfo.cs @@ -0,0 +1,25 @@ +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// 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) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs b/RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs new file mode 100644 index 0000000..f33fdea --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Linq; + +namespace RGB.NET.Devices.CorsairLegacy; + +internal static class DictionaryExtension +{ + public static Dictionary SwapKeyValue(this Dictionary dictionary) + where TKey : notnull + where TValue : notnull + => dictionary.ToDictionary(x => x.Value, x => x.Key); +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs b/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs new file mode 100644 index 0000000..e153e7a --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs @@ -0,0 +1,18 @@ +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +internal static class NativeExtensions +{ + internal static Rectangle ToRectangle(this _CorsairLedPosition position) + { + //HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0. + float width = position.width < 0.5f ? 10 : (float)position.width; + float height = position.height < 0.5f ? 10 : (float)position.height; + float posX = (float)position.left; + float posY = (float)position.top; + + return new Rectangle(posX, posY, width, height); + } +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDevice.cs new file mode 100644 index 0000000..5505c80 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDevice.cs @@ -0,0 +1,33 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair keyboard. +/// +public class CorsairKeyboardRGBDevice : CorsairRGBDevice, IKeyboard +{ + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the keyboard. + /// The queue used to update this device. + internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Keyboard, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDeviceInfo.cs new file mode 100644 index 0000000..c603b75 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Keyboard/CorsairKeyboardRGBDeviceInfo.cs @@ -0,0 +1,56 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// Represents a generic information for a . +/// +public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo +{ + #region Properties & Fields + + /// + public KeyboardLayoutType Layout { get; } + + /// + /// Gets the physical layout of the keyboard. + /// + public CorsairPhysicalKeyboardLayout PhysicalLayout { get; } + + /// + /// Gets the logical layout of the keyboard as set in CUE settings. + /// + public CorsairLogicalKeyboardLayout LogicalLayout { get; } + + #endregion + + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Keyboard, nativeInfo) + { + this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout; + this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout; + this.Layout = PhysicalLayout switch + { + CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI, + CorsairPhysicalKeyboardLayout.UK => KeyboardLayoutType.ISO, + CorsairPhysicalKeyboardLayout.BR => KeyboardLayoutType.ABNT, + CorsairPhysicalKeyboardLayout.JP => KeyboardLayoutType.JIS, + CorsairPhysicalKeyboardLayout.KR => KeyboardLayoutType.KS, + _ => KeyboardLayoutType.Unknown + }; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDevice.cs new file mode 100644 index 0000000..c7f238e --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair memory. +/// +public class CorsairMainboardRGBDevice : CorsairRGBDevice, IMainboard +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the memory. + /// The queue used to update this device. + internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Mainboard, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDeviceInfo.cs new file mode 100644 index 0000000..56fbb90 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mainboard/CorsairMainboardRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairMainboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Mainboard, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDevice.cs new file mode 100644 index 0000000..053ee81 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair memory. +/// +public class CorsairMemoryRGBDevice : CorsairRGBDevice, IDRAM +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the memory. + /// The queue used to update this device. + internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Memory, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDeviceInfo.cs new file mode 100644 index 0000000..9934135 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Memory/CorsairMemoryRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairMemoryRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.DRAM, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDevice.cs new file mode 100644 index 0000000..b9a84bf --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair mouse. +/// +public class CorsairMouseRGBDevice : CorsairRGBDevice, IMouse +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the mouse + /// The queue used to update this device. + internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Mouse, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDeviceInfo.cs new file mode 100644 index 0000000..89de824 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mouse/CorsairMouseRGBDeviceInfo.cs @@ -0,0 +1,36 @@ +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Properties & Fields + + /// + /// Gets the physical layout of the mouse. + /// + public CorsairPhysicalMouseLayout PhysicalLayout { get; } + + #endregion + + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Mouse, nativeInfo) + { + this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDevice.cs new file mode 100644 index 0000000..5d78d5d --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair mousepad. +/// +public class CorsairMousepadRGBDevice : CorsairRGBDevice, IMousepad +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the mousepad + /// The queue used to update this device. + internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Mousepad, updateQueue) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDeviceInfo.cs new file mode 100644 index 0000000..40f42b5 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Mousepad/CorsairMousepadRGBDeviceInfo.cs @@ -0,0 +1,25 @@ +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index if the . + /// The native -struct + internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs new file mode 100644 index 0000000..718f446 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs @@ -0,0 +1,193 @@ +#pragma warning disable IDE1006 // Naming Styles +// ReSharper disable UnusedMethodReturnValue.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +internal static class _CUESDK +{ + #region Libary Management + + private static IntPtr _handle = IntPtr.Zero; + + /// + /// Reloads the SDK. + /// + internal static void Reload() + { + UnloadCUESDK(); + LoadCUESDK(); + } + + private static void LoadCUESDK() + { + if (_handle != IntPtr.Zero) return; + + List possiblePathList = GetPossibleLibraryPaths().ToList(); + + string? dllPath = possiblePathList.FirstOrDefault(File.Exists); + if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); + + if (!NativeLibrary.TryLoad(dllPath, out _handle)) +#if NET6_0 + throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}"); +#else + throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}"); +#endif + + if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsBufferByDeviceIndex", out _corsairSetLedsColorsBufferByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsBufferByDeviceIndex'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsFlushBuffer", out _corsairSetLedsColorsFlushBufferPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsFlushBuffer'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedsColorsByDeviceIndex", out _corsairGetLedsColorsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedsColorsByDeviceIndex'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLayerPriority", out _corsairSetLayerPriorityPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLayerPriority'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceCount", out _corsairGetDeviceCountPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceCount'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceInfo", out _corsairGetDeviceInfoPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceInfo'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedIdForKeyName", out _corsairGetLedIdForKeyNamePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedIdForKeyName'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedPositionsByDeviceIndex", out _corsairGetLedPositionsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedPositionsByDeviceIndex'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairRequestControl", out _corsairRequestControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairRequestControl'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairReleaseControl", out _corsairReleaseControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairReleaseControl'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairPerformProtocolHandshake", out _corsairPerformProtocolHandshakePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairPerformProtocolHandshake'"); + if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLastError", out _corsairGetLastErrorPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLastError'"); + } + + private static IEnumerable GetPossibleLibraryPaths() + { + IEnumerable possibleLibraryPaths; + + if (OperatingSystem.IsWindows()) + possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths; + else + possibleLibraryPaths = Enumerable.Empty(); + + return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables); + } + + internal static void UnloadCUESDK() + { + if (_handle == IntPtr.Zero) return; + + _corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero; + _corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero; + _corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero; + _corsairSetLayerPriorityPointer = IntPtr.Zero; + _corsairGetDeviceCountPointer = IntPtr.Zero; + _corsairGetDeviceInfoPointer = IntPtr.Zero; + _corsairGetLedIdForKeyNamePointer = IntPtr.Zero; + _corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero; + _corsairRequestControlPointer = IntPtr.Zero; + _corsairReleaseControlPointer = IntPtr.Zero; + _corsairPerformProtocolHandshakePointer = IntPtr.Zero; + _corsairGetLastErrorPointer = IntPtr.Zero; + + NativeLibrary.Free(_handle); + _handle = IntPtr.Zero; + } + + #endregion + + #region SDK-METHODS + + #region Pointers + + private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer; + private static IntPtr _corsairSetLedsColorsFlushBufferPointer; + private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer; + private static IntPtr _corsairSetLayerPriorityPointer; + private static IntPtr _corsairGetDeviceCountPointer; + private static IntPtr _corsairGetDeviceInfoPointer; + private static IntPtr _corsairGetLedIdForKeyNamePointer; + private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer; + private static IntPtr _corsairRequestControlPointer; + private static IntPtr _corsairReleaseControlPointer; + private static IntPtr _corsairPerformProtocolHandshakePointer; + private static IntPtr _corsairGetLastErrorPointer; + + #endregion + + /// + /// CUE-SDK: set specified LEDs to some colors. + /// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync. + /// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device + /// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer. + /// This function does not take logical layout into account. + /// + internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors); + + /// + /// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function. + /// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync + /// + internal static unsafe bool CorsairSetLedsColorsFlushBuffer() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsFlushBufferPointer))(); + + /// + /// CUE-SDK: get current color for the list of requested LEDs. + /// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input. + /// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices. + /// + internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors); + + /// + /// CUE-SDK: set layer priority for this shared client. + /// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function. + /// Layers with higher priority value are shown on top of layers with lower priority. + /// + internal static unsafe bool CorsairSetLayerPriority(int priority) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLayerPriorityPointer))(priority); + + /// + /// CUE-SDK: returns number of connected Corsair devices that support lighting control. + /// + internal static unsafe int CorsairGetDeviceCount() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceCountPointer))(); + + /// + /// CUE-SDK: returns information about device at provided index. + /// + internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex); + + /// + /// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions. + /// + internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex); + + /// + /// CUE-SDK: retrieves led id for key name taking logical layout into account. + /// + internal static unsafe CorsairLedId CorsairGetLedIdForKeyName(char keyName) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedIdForKeyNamePointer))(keyName); + + /// + /// CUE-SDK: requestes control using specified access mode. + /// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control. + /// + internal static unsafe bool CorsairRequestControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairRequestControlPointer))(accessMode); + + /// + /// CUE-SDK: releases previously requested control for specified access mode. + /// + internal static unsafe bool CorsairReleaseControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairReleaseControlPointer))(accessMode); + + /// + /// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE. + /// + internal static unsafe _CorsairProtocolDetails CorsairPerformProtocolHandshake() => ((delegate* unmanaged[Cdecl]<_CorsairProtocolDetails>)ThrowIfZero(_corsairPerformProtocolHandshakePointer))(); + + /// + /// CUE-SDK: returns last error that occured while using any of Corsair* functions. + /// + internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLastErrorPointer))(); + + private static IntPtr ThrowIfZero(IntPtr ptr) + { + if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized."); + return ptr; + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelDeviceInfo.cs new file mode 100644 index 0000000..466e99d --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelDeviceInfo.cs @@ -0,0 +1,27 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device. +/// +[StructLayout(LayoutKind.Sequential)] + +internal class _CorsairChannelDeviceInfo +{ + /// + /// CUE-SDK: type of the LED-device + /// + internal CorsairChannelDeviceType type; + + /// + /// CUE-SDK: number of LEDs controlled by LED-device. + /// + internal int deviceLedCount; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs new file mode 100644 index 0000000..c30bfe6 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs @@ -0,0 +1,33 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about separate channel of the DIY-device. +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairChannelInfo +{ + /// + /// CUE-SDK: total number of LEDs connected to the channel; + /// + internal int totalLedsCount; + + /// + /// CUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device + /// + internal int devicesCount; + + /// + /// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device. + /// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device. + /// + internal IntPtr devices; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs new file mode 100644 index 0000000..61900b9 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs @@ -0,0 +1,28 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about channels of the DIY-devices. +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairChannelsInfo +{ + /// + /// CUE-SDK: number of channels controlled by the device + /// + internal int channelsCount; + + /// + /// CUE-SDK: array containing information about each separate channel of the DIY-device. + /// Index of the channel in the array is same as index of the channel on the DIY-device. + /// + internal IntPtr channels; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs new file mode 100644 index 0000000..af3c03e --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs @@ -0,0 +1,58 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about device +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairDeviceInfo +{ + /// + /// CUE-SDK: enum describing device type + /// + internal CorsairDeviceType type; + + /// + /// CUE-SDK: null - terminated device model(like “K95RGB”) + /// + internal IntPtr model; + + /// + /// CUE-SDK: enum describing physical layout of the keyboard or mouse + /// + internal int physicalLayout; + + /// + /// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings + /// + internal int logicalLayout; + + /// + /// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values + /// + internal int capsMask; + + /// + /// CUE-SDK: number of controllable LEDs on the device + /// + internal int ledsCount; + + /// + /// CUE-SDK: structure that describes channels of the DIY-devices + /// + internal _CorsairChannelsInfo? channels; + + /// + /// CUE-SDK: null-terminated string that contains unique device identifier that uniquely identifies device at least within session + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal string? deviceId; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs new file mode 100644 index 0000000..b170918 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs @@ -0,0 +1,37 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles +// ReSharper disable NotAccessedField.Global + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about led and its color +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairLedColor +{ + /// + /// CUE-SDK: identifier of LED to set + /// + internal int ledId; + + /// + /// CUE-SDK: red brightness[0..255] + /// + internal int r; + + /// + /// CUE-SDK: green brightness[0..255] + /// + internal int g; + + /// + /// CUE-SDK: blue brightness[0..255] + /// + internal int b; +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs new file mode 100644 index 0000000..baa959f --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs @@ -0,0 +1,42 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned +#pragma warning disable IDE1006 // Naming Styles + +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains led id and position of led rectangle.Most of the keys are rectangular. +/// In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairLedPosition +{ + /// + /// CUE-SDK: identifier of led + /// + internal CorsairLedId LedId; + + /// + /// CUE-SDK: values in mm + /// + internal double top; + + /// + /// CUE-SDK: values in mm + /// + internal double left; + + /// + /// CUE-SDK: values in mm + /// + internal double height; + + /// + /// CUE-SDK: values in mm + /// + internal double width; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs new file mode 100644 index 0000000..db3d41d --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs @@ -0,0 +1,26 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned + +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains number of leds and arrays with their positions +/// +[StructLayout(LayoutKind.Sequential)] +internal class _CorsairLedPositions +{ + /// + /// CUE-SDK: integer value.Number of elements in following array + /// + internal int numberOfLed; + + /// + /// CUE-SDK: array of led positions + /// + internal IntPtr pLedPosition; +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs new file mode 100644 index 0000000..23a5477 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs @@ -0,0 +1,43 @@ +#pragma warning disable 169 // Field 'x' is never used +#pragma warning disable 414 // Field 'x' is assigned but its value never used +#pragma warning disable 649 // Field 'x' is never assigned + +using System; +using System.Runtime.InteropServices; + +namespace RGB.NET.Devices.CorsairLegacy.Native; + +// ReSharper disable once InconsistentNaming +/// +/// CUE-SDK: contains information about SDK and CUE versions +/// +[StructLayout(LayoutKind.Sequential)] +internal struct _CorsairProtocolDetails +{ + /// + /// CUE-SDK: null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found + /// + internal IntPtr sdkVersion; + + /// + /// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found. + /// + internal IntPtr serverVersion; + + /// + /// CUE-SDK: integer number that specifies version of protocol that is implemented by current SDK. + /// Numbering starts from 1. Always contains valid value even if there was no CUE found + /// + internal int sdkProtocolVersion; + + /// + /// CUE-SDK: integer number that specifies version of protocol that is implemented by CUE. + /// Numbering starts from 1. If CUE was not found then this value will be 0 + /// + internal int serverProtocolVersion; + + /// + /// CUE-SDK: boolean value that specifies if there were breaking changes between version of protocol implemented by server and client + /// + internal byte breakingChanges; +}; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/README.md b/RGB.NET.Devices.Corsair_Legacy/README.md new file mode 100644 index 0000000..4448ae1 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/README.md @@ -0,0 +1,24 @@ +[RGB.NET](https://github.com/DarthAffe/RGB.NET) Device-Provider-Package for Corsair-Devices. + +## Usage +This provider follows the default pattern and does not require additional setup. + +```csharp +surface.Load(CorsairDeviceProvider.Instance); +``` + +# Required SDK +This providers requires native SDK-dlls. (version < 4.x) +You can get them directly from Corsair at [https://github.com/CorsairOfficial/cue-sdk/releases](https://github.com/CorsairOfficial/cue-sdk/releases) + +Since the SDK-dlls are native it's important to use the correct architecture you're building your application for. (If in doubt you can always include both.) + +### x64 +`redist\x64\CUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `\x64\CUESDK.x64_2019.dll` (or simply named `CUESDK.dll`) + +You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX64NativePaths`. + +### x86 +`redist\i386\CUESDK_2019.dll` from the SDK-zip needs to be distributed as `\x86\CUESDK_2019.dll` (or simply named `CUESDK.dll`) + +You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX86NativePaths`. diff --git a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj new file mode 100644 index 0000000..dff737c --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj @@ -0,0 +1,63 @@ + + + net7.0;net6.0 + latest + enable + + Darth Affe + Wyrez + en-US + en-US + RGB.NET.Devices.CorsairLegacy + RGB.NET.Devices.CorsairLegacy + RGB.NET.Devices.CorsairLegacy + RGB.NET.Devices.CorsairLegacy + RGB.NET.Devices.CorsairLegacy + Corsair-Device-Implementations of RGB.NET using the old SDK + Corsair-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals + Copyright © Darth Affe 2023 + Copyright © Darth Affe 2023 + icon.png + README.md + https://github.com/DarthAffe/RGB.NET + LGPL-2.1-only + Github + https://github.com/DarthAffe/RGB.NET + True + + + + 0.0.1 + 0.0.1 + 0.0.1 + + ..\bin\ + true + True + True + portable + snupkg + true + + + + TRACE;DEBUG + true + false + + + + true + $(NoWarn);CS1591;CS1572;CS1573 + RELEASE + + + + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj.DotSettings b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj.DotSettings new file mode 100644 index 0000000..eeca971 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj.DotSettings @@ -0,0 +1,22 @@ + + True + True + True + True + True + True + True + True + False + True + True + True + True + True + True + True + True + True + True + True + \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDevice.cs new file mode 100644 index 0000000..3b39611 --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDevice.cs @@ -0,0 +1,27 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a corsair touchbar. +/// +public class CorsairTouchbarRGBDevice : CorsairRGBDevice, IDRAM +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the touchbar. + /// The queue used to update this device. + internal CorsairTouchbarRGBDevice(CorsairTouchbarRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, LedMappings.Keyboard, updateQueue) //TODO DarthAffe 17.07.2022: Find someone with such a device and check which LedIds are actually used + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDeviceInfo.cs new file mode 100644 index 0000000..575294e --- /dev/null +++ b/RGB.NET.Devices.Corsair_Legacy/Touchbar/CorsairTouchbarRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using RGB.NET.Devices.CorsairLegacy.Native; + +namespace RGB.NET.Devices.CorsairLegacy; + +/// +/// +/// Represents a generic information for a . +/// +public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + internal CorsairTouchbarRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) + : base(deviceIndex, RGBDeviceType.Keypad, nativeInfo) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.sln b/RGB.NET.sln index afbcb67..2540669 100644 --- a/RGB.NET.sln +++ b/RGB.NET.sln @@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Presets.Tests", "Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.OpenRGB", "RGB.NET.Devices.OpenRGB\RGB.NET.Devices.OpenRGB.csproj", "{F29A96E5-CDD0-469F-A871-A35A7519BC49}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Corsair_Legacy", "..\..\..\..\DarthAffe\Source\Repos\RGB.NET\RGB.NET.Devices.Corsair_Legacy\RGB.NET.Devices.Corsair_Legacy.csproj", "{66AF690C-27A1-4097-AC53-57C0ED89E286}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -133,6 +135,10 @@ Global {F29A96E5-CDD0-469F-A871-A35A7519BC49}.Debug|Any CPU.Build.0 = Debug|Any CPU {F29A96E5-CDD0-469F-A871-A35A7519BC49}.Release|Any CPU.ActiveCfg = Release|Any CPU {F29A96E5-CDD0-469F-A871-A35A7519BC49}.Release|Any CPU.Build.0 = Release|Any CPU + {66AF690C-27A1-4097-AC53-57C0ED89E286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66AF690C-27A1-4097-AC53-57C0ED89E286}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66AF690C-27A1-4097-AC53-57C0ED89E286}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66AF690C-27A1-4097-AC53-57C0ED89E286}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -154,6 +160,7 @@ Global {7FC5C7A8-7B27-46E7-A8E8-DB80568F49C5} = {D13032C6-432E-4F43-8A32-071133C22B16} {EDBA49D6-AE96-4E96-9E6A-30154D93BD5F} = {92D7C263-D4C9-4D26-93E2-93C1F9C2CD16} {F29A96E5-CDD0-469F-A871-A35A7519BC49} = {D13032C6-432E-4F43-8A32-071133C22B16} + {66AF690C-27A1-4097-AC53-57C0ED89E286} = {D13032C6-432E-4F43-8A32-071133C22B16} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7F222AD4-1F9E-4AAB-9D69-D62372D4C1BA} From 8faedd1e26f3bd86a096d0c4f9eff3865ec46aab Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 24 Jul 2023 00:36:32 +0200 Subject: [PATCH 70/96] Fixed error in solution --- RGB.NET.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.sln b/RGB.NET.sln index 2540669..257bf65 100644 --- a/RGB.NET.sln +++ b/RGB.NET.sln @@ -47,7 +47,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Presets.Tests", "Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.OpenRGB", "RGB.NET.Devices.OpenRGB\RGB.NET.Devices.OpenRGB.csproj", "{F29A96E5-CDD0-469F-A871-A35A7519BC49}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Corsair_Legacy", "..\..\..\..\DarthAffe\Source\Repos\RGB.NET\RGB.NET.Devices.Corsair_Legacy\RGB.NET.Devices.Corsair_Legacy.csproj", "{66AF690C-27A1-4097-AC53-57C0ED89E286}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Corsair_Legacy", "RGB.NET.Devices.Corsair_Legacy\RGB.NET.Devices.Corsair_Legacy.csproj", "{66AF690C-27A1-4097-AC53-57C0ED89E286}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 5483a7581d2e1616aa6dd5f080755e85785fcf7b Mon Sep 17 00:00:00 2001 From: DELUUXE Date: Mon, 24 Jul 2023 22:08:39 +0200 Subject: [PATCH 71/96] Added custom led mapping for Razer Blade keyboards --- RGB.NET.Devices.Razer/Generic/LedMappings.cs | 131 +++++++++++++++++++ RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 2 +- 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Razer/Generic/LedMappings.cs b/RGB.NET.Devices.Razer/Generic/LedMappings.cs index c0e8b3a..373aae7 100644 --- a/RGB.NET.Devices.Razer/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Razer/Generic/LedMappings.cs @@ -160,6 +160,137 @@ public static class LedMappings //Row 7 is also empty }; + + /// + /// Gets the mapping for Blade keyboards. + /// + public static LedMapping Blade { get; } = new() + { + //Row 0 is empty + + #region Row 1 + + [LedId.Keyboard_Escape] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 2, + [LedId.Keyboard_F1] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 3, + [LedId.Keyboard_F2] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 4, + [LedId.Keyboard_F3] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 5, + [LedId.Keyboard_F4] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 6, + [LedId.Keyboard_F5] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 7, + [LedId.Keyboard_F6] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 8, + [LedId.Keyboard_F7] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 9, + [LedId.Keyboard_F8] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 10, + [LedId.Keyboard_F9] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 11, + [LedId.Keyboard_F10] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 12, + [LedId.Keyboard_F11] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 13, + [LedId.Keyboard_F12] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 14, + [LedId.Keyboard_PrintScreen] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 15, + [LedId.Keyboard_ScrollLock] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 16, + + #endregion + + #region Row 2 + + [LedId.Keyboard_GraveAccentAndTilde] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 2, + [LedId.Keyboard_1] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 3, + [LedId.Keyboard_2] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 4, + [LedId.Keyboard_3] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 5, + [LedId.Keyboard_4] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 6, + [LedId.Keyboard_5] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 7, + [LedId.Keyboard_6] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 8, + [LedId.Keyboard_7] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 9, + [LedId.Keyboard_8] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 10, + [LedId.Keyboard_9] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 11, + [LedId.Keyboard_0] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 12, + [LedId.Keyboard_MinusAndUnderscore] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 13, + [LedId.Keyboard_EqualsAndPlus] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 14, + [LedId.Keyboard_Backspace] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 16, + + #endregion + + #region Row 3 + + [LedId.Keyboard_Tab] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 2, + [LedId.Keyboard_Q] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 3, + [LedId.Keyboard_W] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 4, + [LedId.Keyboard_E] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 5, + [LedId.Keyboard_R] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 6, + [LedId.Keyboard_T] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 7, + [LedId.Keyboard_Y] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 8, + [LedId.Keyboard_U] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 9, + [LedId.Keyboard_I] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 10, + [LedId.Keyboard_O] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 11, + [LedId.Keyboard_P] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 12, + [LedId.Keyboard_BracketLeft] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 13, + [LedId.Keyboard_BracketRight] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 14, + [LedId.Keyboard_Backslash] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 16, + + #endregion + + #region Row 4 + + [LedId.Keyboard_CapsLock] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 2, + [LedId.Keyboard_A] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 3, + [LedId.Keyboard_S] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 4, + [LedId.Keyboard_D] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 5, + [LedId.Keyboard_F] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 6, + [LedId.Keyboard_G] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 7, + [LedId.Keyboard_H] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 8, + [LedId.Keyboard_J] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 9, + [LedId.Keyboard_K] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 10, + [LedId.Keyboard_L] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 11, + [LedId.Keyboard_SemicolonAndColon] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 12, + [LedId.Keyboard_ApostropheAndDoubleQuote] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 13, + [LedId.Keyboard_NonUsTilde] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 14, + [LedId.Keyboard_Enter] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 16, + + #endregion + + #region Row 5 + + [LedId.Keyboard_LeftShift] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 2, + [LedId.Keyboard_NonUsBackslash] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 3, + [LedId.Keyboard_Z] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 4, + [LedId.Keyboard_X] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 5, + [LedId.Keyboard_C] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 6, + [LedId.Keyboard_V] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 7, + [LedId.Keyboard_B] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 8, + [LedId.Keyboard_N] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 9, + [LedId.Keyboard_M] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 10, + [LedId.Keyboard_CommaAndLessThan] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 11, + [LedId.Keyboard_PeriodAndBiggerThan] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 12, + [LedId.Keyboard_SlashAndQuestionMark] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 13, + [LedId.Keyboard_RightShift] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 16, + + #endregion + + #region Row 6 + + [LedId.Keyboard_LeftCtrl] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 2, + // left gui lights left fn key + [LedId.Keyboard_LeftGui] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 3, + // left alt lights left gui key + [LedId.Keyboard_LeftAlt] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 4, + // space lights left alt key + [LedId.Keyboard_Space] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 6, + // see comment bellow + [LedId.Keyboard_RightAlt] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 10, + // right gui lights right fn key (this one (11) seems to light both right alt and right fn, but 8, 9 and 10 don't light anything) + [LedId.Keyboard_RightGui] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 11, + // application key lights right control to make room for up/down keys stacked in 1 key spot + [LedId.Keyboard_Application] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 12, + // right ctrl lights left arrow key + [LedId.Keyboard_RightCtrl] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 13, + // arrow left lights up arrow key + [LedId.Keyboard_ArrowLeft] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 14, + // these arrows appear to be flipped + [LedId.Keyboard_ArrowDown] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 16, + [LedId.Keyboard_ArrowRight] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 15, + + #endregion + + //Row 7 is also empty + }; + /// /// Gets the mapping for mice. /// diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index f2e6aed..15f2657 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -127,7 +127,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x029F, RGBDeviceType.Keyboard, "Blade 16 (2023)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x029F, RGBDeviceType.Keyboard, "Blade 16 (2023)", LedMappings.Blade, RazerEndpointType.Keyboard }, { 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired From 2a2053cc53dd2cd0542f18bcdddf967134b77a76 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 25 Jul 2023 20:11:58 +0200 Subject: [PATCH 72/96] Applied Led-Position-Fix from #331 to Corsair-Legacy-DeviceProvider --- .../Custom/CorsairCustomRGBDevice.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs index 4f5a301..4e15555 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using System; +using System.Linq; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.CorsairLegacy.Native; @@ -59,6 +60,21 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice 0) + FixOffsetDeviceLayout(); + } + + /// + /// Fixes the locations for devices split by offset by aligning them to the top left. + /// + protected virtual void FixOffsetDeviceLayout() + { + float minX = this.Min(x => x.Location.X); + float minY = this.Min(x => x.Location.Y); + + foreach (Led led in this) + led.Location = led.Location.Translate(-minX, -minY); } private static LedId GetReferenceLed(RGBDeviceType deviceType) From 2c8bc72dc96150ef016b3ae5a0f6513c3b557684 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 16 Aug 2023 21:47:54 +0200 Subject: [PATCH 73/96] Added missing provider-init-changes to CorsairLegacy --- .../CorsairLegacyDeviceProvider.cs | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs index 20a1b58..f82bec2 100644 --- a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs @@ -18,11 +18,21 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider { #region Properties & Fields + // ReSharper disable once InconsistentNaming + private static readonly object _lock = new(); + private static CorsairLegacyDeviceProvider? _instance; /// /// Gets the singleton instance. /// - public static CorsairLegacyDeviceProvider Instance => _instance ?? new CorsairLegacyDeviceProvider(); + public static CorsairLegacyDeviceProvider Instance + { + get + { + lock (_lock) + return _instance ?? new CorsairLegacyDeviceProvider(); + } + } /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. @@ -56,8 +66,11 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider /// Thrown if this constructor is called even if there is already an instance of this class. public CorsairLegacyDeviceProvider() { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}"); - _instance = this; + lock (_lock) + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}"); + _instance = this; + } } #endregion @@ -201,12 +214,17 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider } /// - public override void Dispose() + protected override void Dispose(bool disposing) { - base.Dispose(); + lock (_lock) + { + base.Dispose(disposing); - try { _CUESDK.UnloadCUESDK(); } - catch { /* at least we tried */ } + try { _CUESDK.UnloadCUESDK(); } + catch { /* at least we tried */ } + + _instance = null; + } } #endregion From 1f0b1b0774345160c2dce67e53ed33ca5b8616c6 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 17 Aug 2023 23:22:33 +0200 Subject: [PATCH 74/96] Fixed an exception when multiple invalid leds are present in custom corsair devices --- RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs index 4e15555..c285e5a 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs @@ -53,6 +53,8 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice Date: Wed, 23 Aug 2023 00:50:28 +0200 Subject: [PATCH 75/96] Fixed typo in Core readme --- RGB.NET.Core/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Core/README.md b/RGB.NET.Core/README.md index d31978b..b07d190 100644 --- a/RGB.NET.Core/README.md +++ b/RGB.NET.Core/README.md @@ -17,7 +17,7 @@ surface.AlignDevices(); surface.RegisterUpdateTrigger(new TimerUpdateTrigger()); ``` -## Basis Rendering +## Basic Rendering ```csharp // Create a led-group containing all leds on the surface ILedGroup allLeds = new ListLedGroup(surface, surface.Leds); From 5d3a3613e243dc33b11b3625aa74f3ef92dc6c6f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 23 Aug 2023 00:52:06 +0200 Subject: [PATCH 76/96] Added PID for Razer Black Widow V4 75% --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 8dfadc4..dc89201 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -146,6 +146,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02A5, RGBDeviceType.Keyboard, "Razer Bacl Widow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice From 3461674e17df9affc05572442b9b58e02720fb58 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 23 Aug 2023 00:53:14 +0200 Subject: [PATCH 77/96] Typo in Keyboard name --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index dc89201..7c13523 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -146,7 +146,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x02A5, RGBDeviceType.Keyboard, "Razer Bacl Widow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02A5, RGBDeviceType.Keyboard, "Razer Black Widow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice From 9d1188ab33115de79bdf032e83d17caacf46904c Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 23 Aug 2023 00:57:19 +0200 Subject: [PATCH 78/96] Fixed razer naming again --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 7c13523..7a8d50c 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -146,7 +146,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, - { 0x02A5, RGBDeviceType.Keyboard, "Razer Black Widow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x02A5, RGBDeviceType.Keyboard, "BlackWidow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Mice From c7abac5ecda7d9828780c3588b931c5b4ff96a9e Mon Sep 17 00:00:00 2001 From: Danielle Date: Wed, 23 Aug 2023 14:22:38 +1000 Subject: [PATCH 79/96] Update RazerDeviceProvider.cs Added additional Razer Blackwidow V4 PID. --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 7a8d50c..5f449e3 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -134,6 +134,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard }, + { 0x0287, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard }, From 72da2b6bdf14eae4f92c25324838603600d714e8 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 27 Aug 2023 21:40:01 +0200 Subject: [PATCH 80/96] Added LedIds for Indicator-LEDs (like NumLock) --- RGB.NET.Core/Leds/LedId.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Core/Leds/LedId.cs b/RGB.NET.Core/Leds/LedId.cs index dff98a5..18bb0b5 100644 --- a/RGB.NET.Core/Leds/LedId.cs +++ b/RGB.NET.Core/Leds/LedId.cs @@ -372,12 +372,20 @@ public enum LedId Keyboard_Custom127 = 0x0000707F, Keyboard_Custom128 = 0x00007080, + Keyboard_IndicatorNumLock = 0x00008001, + Keyboard_IndicatorCapsLock = 0x00008002, + Keyboard_IndicatorScrollLock = 0x00008003, + Keyboard_IndicatorWinLock = 0x00008004, + Keyboard_IndicatorPower = 0x00008005, + Keyboard_IndicatorMuted = 0x00008006, + Keyboard_IndicatorMacro = 0x00008007, + /*### Mouse ###*/ Mouse1 = 0x00100001, Mouse2 = 0x00100002, Mouse3 = 0x00100003, Mouse4 = 0x00100004, - Mouse5 = 0x00100005, + Mouse5 = 0x00100005, Mouse6 = 0x00100006, Mouse7 = 0x00100007, Mouse8 = 0x00100008, From 5707a247ee8360475beefa16499dd34029341ac9 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 27 Aug 2023 21:41:41 +0200 Subject: [PATCH 81/96] Removed excessive spaces --- RGB.NET.Core/Leds/LedId.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Core/Leds/LedId.cs b/RGB.NET.Core/Leds/LedId.cs index 18bb0b5..43a6a70 100644 --- a/RGB.NET.Core/Leds/LedId.cs +++ b/RGB.NET.Core/Leds/LedId.cs @@ -385,7 +385,7 @@ public enum LedId Mouse2 = 0x00100002, Mouse3 = 0x00100003, Mouse4 = 0x00100004, - Mouse5 = 0x00100005, + Mouse5 = 0x00100005, Mouse6 = 0x00100006, Mouse7 = 0x00100007, Mouse8 = 0x00100008, From c1a4fee18946828c22c01bcb6e34d8906949d9c6 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 4 Sep 2023 11:50:26 +0200 Subject: [PATCH 82/96] Added Razer Kraken Kitty V2 PID --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 5f449e3..8bb176a 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -244,6 +244,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x051A, RGBDeviceType.Headset, "Nari Ultimate", LedMappings.Headset, RazerEndpointType.Headset }, { 0x051C, RGBDeviceType.Headset, "Nari", LedMappings.Headset, RazerEndpointType.Headset }, { 0x0527, RGBDeviceType.Headset, "Kraken Ultimate", LedMappings.Headset, RazerEndpointType.Headset }, + { 0x0560, RGBDeviceType.Headset, "Kraken Kitty V2", LedMappings.Headset, RazerEndpointType.Headset }, { 0x0F19, RGBDeviceType.Headset, "Kraken Kitty Edition", LedMappings.Headset, RazerEndpointType.Headset }, // Keypads From 012fdf62a4c9430d273e04fe8f6a6778db34eb83 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 22 Sep 2023 21:55:53 +0200 Subject: [PATCH 83/96] Added PIDs for Blade 18, Naga V2 Pro (wired?) and Mouse Dock Pro --- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 8bb176a..9abc8c8 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -146,6 +146,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless { 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired + { 0x02A0, RGBDeviceType.Keyboard, "Blade 18", LedMappings.Blade, RazerEndpointType.Keyboard }, { 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x02A5, RGBDeviceType.Keyboard, "BlackWidow V4 75%", LedMappings.Keyboard, RazerEndpointType.Keyboard }, { 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, @@ -223,6 +224,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x00A1, RGBDeviceType.Mouse, "DeathAdder V2 Lite", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A5, RGBDeviceType.Mouse, "Viper V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A6, RGBDeviceType.Mouse, "Viper V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, + { 0x00A7, RGBDeviceType.Mouse, "Naga V2 Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00A8, RGBDeviceType.Mouse, "Naga V2 Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00AA, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse }, { 0x00AB, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse }, @@ -261,6 +263,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider { 0x0F08, RGBDeviceType.HeadsetStand, "Base Station Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 16.12.2022: Not tested but based on the V2 I assume this is also a mousepad { 0x0F20, RGBDeviceType.HeadsetStand, "Base Station V2 Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 16.12.2022: Not sure why, but it's handled as a mousepad { 0x007E, RGBDeviceType.LedStripe, "Razer Mouse Dock Chroma", LedMappings.Mousepad, RazerEndpointType.Mousepad }, //roxaskeyheart 06.02.2023: Probably handled the same as a mousepad + { 0x00A4, RGBDeviceType.LedStripe, "Mouse Dock Pro", LedMappings.Mousepad, RazerEndpointType.Mousepad }, // DarthAffe 22.09.2023: Most likely also a mousepad? { 0x0517, RGBDeviceType.Speaker, "Nommo Chroma", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0518, RGBDeviceType.Speaker, "Nommo Pro", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, { 0x0F07, RGBDeviceType.Unknown, "Chroma Mug Holder", LedMappings.ChromaLink, RazerEndpointType.ChromaLink }, From 736d58c7a305c6060bb6c5a7e784375266e31164 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 17 Oct 2023 14:20:04 +0100 Subject: [PATCH 84/96] Wooting - Add uwu support --- .../Enum/WootingDeviceType.cs | 47 ++++++++++--------- .../Enum/WootingLayoutType.cs | 1 + .../WootingLedMappings.cs} | 41 +++++++++++++--- .../Generic/WootingRGBDevice.cs | 14 ++++++ .../Helper/EnumExtension.cs | 34 -------------- .../Keyboard/WootingKeyboardRGBDevice.cs | 12 +---- .../Keypad/WootingKeypadRGBDevice.cs | 44 +++++++++++++++++ .../Keypad/WootingKeypadRGBDeviceInfo.cs | 17 +++++++ .../Native/_WootingDeviceInfo.cs | 6 ++- .../WootingDeviceProvider.cs | 8 +++- 10 files changed, 150 insertions(+), 74 deletions(-) rename RGB.NET.Devices.Wooting/{Keyboard/WootingKeyboardLedMappings.cs => Generic/WootingLedMappings.cs} (91%) delete mode 100644 RGB.NET.Devices.Wooting/Helper/EnumExtension.cs create mode 100644 RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs create mode 100644 RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDeviceInfo.cs diff --git a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs index 513fae5..63ff83a 100644 --- a/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs +++ b/RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs @@ -1,24 +1,29 @@ -// ReSharper disable InconsistentNaming - -namespace RGB.NET.Devices.Wooting.Enum; - -/// -/// Represents the type of a wooting device -/// -public enum WootingDeviceType -{ - /// - /// 10 Keyless Keyboard. E.g. Wooting One - /// - KeyboardTKL = 1, - - /// - /// Full Size keyboard. E.g. Wooting Two - /// +// ReSharper disable InconsistentNaming + +namespace RGB.NET.Devices.Wooting.Enum; + +/// +/// Represents the type of a wooting device +/// +public enum WootingDeviceType +{ + /// + /// 10 Keyless Keyboard. E.g. Wooting One + /// + KeyboardTKL = 1, + + /// + /// Full Size keyboard. E.g. Wooting Two + /// Keyboard = 2, - /// - /// Full Size keyboard. E.g. Wooting Two - /// - KeyboardSixtyPercent = 3 + /// + /// 60 percent keyboard, E.g. Wooting 60HE + /// + KeyboardSixtyPercent = 3, + + /// + /// Three key keypad. E.g. Wooting Uwu + /// + Keypad3Keys = 4, } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Enum/WootingLayoutType.cs b/RGB.NET.Devices.Wooting/Enum/WootingLayoutType.cs index e01a6d1..70c1520 100644 --- a/RGB.NET.Devices.Wooting/Enum/WootingLayoutType.cs +++ b/RGB.NET.Devices.Wooting/Enum/WootingLayoutType.cs @@ -13,6 +13,7 @@ namespace RGB.NET.Devices.Wooting.Enum; /// public enum WootingLayoutType { + Unknown = -1, ANSI = 0, ISO = 1 } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardLedMappings.cs b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs similarity index 91% rename from RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardLedMappings.cs rename to RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs index 0b44237..23746cb 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardLedMappings.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs @@ -1,15 +1,15 @@ -// ReSharper disable InconsistentNaming +// ReSharper disable InconsistentNaming +using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Enum; -using System.Collections.Generic; -namespace RGB.NET.Devices.Wooting.Keyboard; +namespace RGB.NET.Devices.Wooting.Generic; /// /// Contains all the hardware-id mappings for Wooting devices. /// -internal static class WootingKeyboardLedMappings +internal static class WootingLedMappings { #region Properties & Fields @@ -305,6 +305,34 @@ internal static class WootingKeyboardLedMappings { LedId.Keyboard_Function, (5, 13) } }; + private static readonly Dictionary ThreeKeyKeypad = new() + { + //top left - bottom left + [LedId.LedStripe1] = (0, 0), + [LedId.LedStripe2] = (1, 0), + [LedId.LedStripe3] = (3, 0), + + //bottom left - bottom right + [LedId.LedStripe4] = (4, 1), + [LedId.LedStripe5] = (4, 2), + [LedId.LedStripe6] = (4, 4), + [LedId.LedStripe7] = (4, 5), + + //bottom right - top right + [LedId.LedStripe8] = (3, 6), + [LedId.LedStripe9] = (1, 6), + [LedId.LedStripe10] = (0, 6), + + //top right - top left + [LedId.LedStripe11] = (0, 4), + [LedId.LedStripe12] = (0, 2), + + //Analog Keys + [LedId.Keypad1] = (3, 2), + [LedId.Keypad2] = (3, 3), + [LedId.Keypad3] = (3, 4), + }; + /// /// Contains all the hardware-id mappings for Wooting devices. /// @@ -312,8 +340,9 @@ internal static class WootingKeyboardLedMappings { [WootingDeviceType.Keyboard] = Fullsize, [WootingDeviceType.KeyboardTKL] = TKL, - [WootingDeviceType.KeyboardSixtyPercent] = SixtyPercent + [WootingDeviceType.KeyboardSixtyPercent] = SixtyPercent, + [WootingDeviceType.Keypad3Keys] = ThreeKeyKeypad }; #endregion -} \ No newline at end of file +} diff --git a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs index 8697eb1..7bc089e 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs @@ -1,4 +1,5 @@ using RGB.NET.Core; +using RGB.NET.Devices.Wooting.Native; namespace RGB.NET.Devices.Wooting.Generic; @@ -23,4 +24,17 @@ public abstract class WootingRGBDevice : AbstractRGBDevice -/// Offers some extensions and helper-methods for enum related things. -/// -internal static class EnumExtension -{ - /// - /// Gets the value of the . - /// - /// The enum value to get the description from. - /// The value of the or the result of the source. - internal static string GetDescription(this System.Enum source) - => source.GetAttribute()?.Description ?? source.ToString(); - - /// - /// Gets the attribute of type T. - /// - /// The enum value to get the attribute from - /// The generic attribute type - /// The . - private static T? GetAttribute(this System.Enum source) - where T : Attribute - { - FieldInfo? fi = source.GetType().GetField(source.ToString()); - if (fi == null) return null; - T[] attributes = (T[])fi.GetCustomAttributes(typeof(T), false); - return attributes.Length > 0 ? attributes[0] : null; - } -} \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index 79e1baf..773d233 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -37,22 +37,14 @@ public sealed class WootingKeyboardRGBDevice : WootingRGBDevice mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.WootingDeviceType]; + Dictionary mapping = WootingLedMappings.Mapping[DeviceInfo.WootingDeviceType]; foreach (KeyValuePair led in mapping) AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19)); } /// - protected override object GetLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.WootingDeviceType][ledId]; - - public override void Dispose() - { - _WootingSDK.SelectDevice(DeviceInfo.WootingDeviceIndex); - _WootingSDK.Reset(); - - base.Dispose(); - } + protected override object GetLedCustomData(LedId ledId) => WootingLedMappings.Mapping[DeviceInfo.WootingDeviceType][ledId]; #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs new file mode 100644 index 0000000..5bf5524 --- /dev/null +++ b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using RGB.NET.Core; +using RGB.NET.Devices.Wooting.Generic; +using RGB.NET.Devices.Wooting.Keyboard; + +namespace RGB.NET.Devices.Wooting.Keypad; + +/// +/// +/// Represents a Wooting keyboard. +/// +public sealed class WootingKeypadRGBDevice : WootingRGBDevice, IKeypad +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Wooting for the keyboard + /// The update queue used to update this device. + internal WootingKeypadRGBDevice(WootingKeypadRGBDeviceInfo info, IUpdateQueue updateQueue) + : base(info, updateQueue) + { + InitializeLayout(); + } + + #endregion + + #region Methods + + private void InitializeLayout() + { + Dictionary mapping = WootingLedMappings.Mapping[DeviceInfo.WootingDeviceType]; + + foreach (KeyValuePair led in mapping) + AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19)); + } + + /// + protected override object GetLedCustomData(LedId ledId) => WootingLedMappings.Mapping[DeviceInfo.WootingDeviceType][ledId]; + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDeviceInfo.cs b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDeviceInfo.cs new file mode 100644 index 0000000..55088e1 --- /dev/null +++ b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDeviceInfo.cs @@ -0,0 +1,17 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Wooting.Generic; +using RGB.NET.Devices.Wooting.Native; + +namespace RGB.NET.Devices.Wooting.Keypad; + +/// +/// Represents a generic information for a . +/// +public sealed class WootingKeypadRGBDeviceInfo : WootingRGBDeviceInfo +{ + internal WootingKeypadRGBDeviceInfo(_WootingDeviceInfo deviceInfo, byte deviceIndex) + : base(RGBDeviceType.Keypad, deviceInfo, deviceIndex) + { + + } +} diff --git a/RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs b/RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs index a672f31..6a59c81 100644 --- a/RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs +++ b/RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs @@ -17,11 +17,13 @@ internal struct _WootingDeviceInfo internal byte MaxColumns { get; private set; } - internal byte KeycodeLimit { get; private set; } + internal byte MaxLedIndex { get; private set; } internal WootingDeviceType DeviceType { get; private set; } - internal bool V2Interface { get; set; } + internal bool V2Interface { get; private set; } internal WootingLayoutType LayoutType { get; private set; } + + internal bool UsesSmallPackets { get; private set; } } \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 6d16b2f..415ae4c 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using RGB.NET.Core; +using RGB.NET.Devices.Wooting.Enum; using RGB.NET.Devices.Wooting.Generic; using RGB.NET.Devices.Wooting.Keyboard; +using RGB.NET.Devices.Wooting.Keypad; using RGB.NET.Devices.Wooting.Native; namespace RGB.NET.Devices.Wooting; @@ -100,7 +102,11 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider _WootingSDK.SelectDevice(i); _WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo))!; - yield return new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(nativeDeviceInfo, i), updateQueue); + yield return nativeDeviceInfo.DeviceType switch + { + WootingDeviceType.Keypad3Keys => new WootingKeypadRGBDevice(new WootingKeypadRGBDeviceInfo(nativeDeviceInfo, i), updateQueue), + _ => new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(nativeDeviceInfo, i), updateQueue), + }; } } } From 69d320fca3f121b6c1ba65e1a4668b44de576af0 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 17 Oct 2023 17:49:09 +0100 Subject: [PATCH 85/96] Ignore UwU non-RGB --- RGB.NET.Devices.Wooting/WootingDeviceProvider.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 415ae4c..c92661f 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -101,6 +101,10 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider WootingUpdateQueue updateQueue = new(GetUpdateTrigger(), i); _WootingSDK.SelectDevice(i); _WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo))!; + + //Uwu non-rgb returns zero here. + if (nativeDeviceInfo.MaxLedIndex == 0) + continue; yield return nativeDeviceInfo.DeviceType switch { From 7ad1e595a9c7d4d086775e8d41bc0ebac6188926 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 17 Oct 2023 19:29:40 +0100 Subject: [PATCH 86/96] Added Missing LEDs --- .../Generic/WootingLedMappings.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs index 23746cb..9b7860b 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs @@ -307,27 +307,29 @@ internal static class WootingLedMappings private static readonly Dictionary ThreeKeyKeypad = new() { - //top left - bottom left - [LedId.LedStripe1] = (0, 0), - [LedId.LedStripe2] = (1, 0), + //left (from top to bottom) + [LedId.LedStripe1] = (1, 0), + [LedId.LedStripe2] = (2, 0), [LedId.LedStripe3] = (3, 0), - //bottom left - bottom right + //bottom (from left to right) [LedId.LedStripe4] = (4, 1), [LedId.LedStripe5] = (4, 2), [LedId.LedStripe6] = (4, 4), [LedId.LedStripe7] = (4, 5), - //bottom right - top right + //right (from bottom to top) [LedId.LedStripe8] = (3, 6), - [LedId.LedStripe9] = (1, 6), - [LedId.LedStripe10] = (0, 6), + [LedId.LedStripe9] = (2, 6), + [LedId.LedStripe10] = (1, 6), - //top right - top left - [LedId.LedStripe11] = (0, 4), - [LedId.LedStripe12] = (0, 2), + //top (from right to left) + [LedId.LedStripe11] = (0, 6), + [LedId.LedStripe12] = (0, 4), + [LedId.LedStripe13] = (0, 2), + [LedId.LedStripe14] = (0, 0), - //Analog Keys + //analog keys [LedId.Keypad1] = (3, 2), [LedId.Keypad2] = (3, 3), [LedId.Keypad3] = (3, 4), From fcf86ff9daaea162998227c378643843742ee9bb Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Wed, 18 Oct 2023 14:11:44 +0100 Subject: [PATCH 87/96] Fix analog key coords --- RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs index 9b7860b..081e993 100644 --- a/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs +++ b/RGB.NET.Devices.Wooting/Generic/WootingLedMappings.cs @@ -330,9 +330,9 @@ internal static class WootingLedMappings [LedId.LedStripe14] = (0, 0), //analog keys - [LedId.Keypad1] = (3, 2), - [LedId.Keypad2] = (3, 3), - [LedId.Keypad3] = (3, 4), + [LedId.Keypad1] = (2, 1), + [LedId.Keypad2] = (2, 3), + [LedId.Keypad3] = (2, 5), }; /// From 883d6cbea449a6bb42141326d7dc521edef82495 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 31 Oct 2023 21:51:40 +0100 Subject: [PATCH 88/96] Added ToString to Scale --- RGB.NET.Core/Positioning/Scale.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RGB.NET.Core/Positioning/Scale.cs b/RGB.NET.Core/Positioning/Scale.cs index 973bf9c..18644e6 100644 --- a/RGB.NET.Core/Positioning/Scale.cs +++ b/RGB.NET.Core/Positioning/Scale.cs @@ -50,6 +50,12 @@ public readonly struct Scale : IEquatable #region Methods + /// + /// Converts the and value of this to a human-readable string. + /// + /// A string that contains the and value of this . For example "[Horizontal: 1, Vertical: 0.5]". + public override string ToString() => $"[Horizontal: {Horizontal}, Vertical: {Vertical}]\""; + /// /// Tests whether the specified is equivalent to this . /// From 188de3c5587bfd47d963bf33f93f9c05f664721a Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 31 Oct 2023 21:54:58 +0100 Subject: [PATCH 89/96] Fixed an error when parsing custom layout data if the xml-element contains an attribute --- RGB.NET.Layout/DeviceLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs index 24efd37..e33e760 100644 --- a/RGB.NET.Layout/DeviceLayout.cs +++ b/RGB.NET.Layout/DeviceLayout.cs @@ -174,7 +174,7 @@ public class DeviceLayout : IDeviceLayout /// The deserialized custom data object. protected virtual object? GetCustomData(object? customData, Type? type) { - XmlNode? node = (customData as XmlNode) ?? (customData as IEnumerable)?.FirstOrDefault()?.ParentNode; //HACK DarthAffe 16.01.2021: This gives us the CustomData-Node + XmlNode? node = (customData as XmlNode) ?? (customData as IEnumerable)?.FirstOrDefault(x => x.ParentNode != null)?.ParentNode; //HACK DarthAffe 16.01.2021: This gives us the CustomData-Node if ((node == null) || (type == null)) return null; using MemoryStream ms = new(); From be252790d443c9d4b7689c1922d93eee9f785879 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 31 Oct 2023 22:14:05 +0100 Subject: [PATCH 90/96] Added extension to save layouts --- RGB.NET.Layout/LayoutExtension.cs | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/RGB.NET.Layout/LayoutExtension.cs b/RGB.NET.Layout/LayoutExtension.cs index a666637..915380b 100644 --- a/RGB.NET.Layout/LayoutExtension.cs +++ b/RGB.NET.Layout/LayoutExtension.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Xml.Serialization; using RGB.NET.Core; namespace RGB.NET.Layout; @@ -51,4 +53,48 @@ public static class LayoutExtension device.RemoveLed(led); } } + + /// + /// Saves the specified layout to the given location. + /// + /// The layout to save. + /// The location to save to. + public static void Save(this IDeviceLayout layout, string targetFile) + { + using FileStream fs = new(targetFile, FileMode.Create); + layout.Save(fs); + } + + /// + /// Saves the specified layout to the given stream. + /// + /// The layout to save. + /// The stream to save to. + public static void Save(this IDeviceLayout layout, Stream stream) + { + Type? customDataType = layout.CustomData?.GetType(); + Type? customLedDataType = layout.Leds.FirstOrDefault(x => x.CustomData != null)?.GetType(); + + Type[] customTypes; + if ((customDataType != null) && (customLedDataType != null)) + customTypes = new[] { customDataType, customLedDataType }; + else if (customDataType != null) + customTypes = new[] { customDataType }; + else if (customLedDataType != null) + customTypes = new[] { customLedDataType }; + else + customTypes = Array.Empty(); + + if (layout is DeviceLayout deviceLayout) + { + deviceLayout.InternalCustomData = deviceLayout.CustomData; + + foreach (ILedLayout led in deviceLayout.Leds) + if (led is LedLayout ledLayout) + ledLayout.InternalCustomData = ledLayout.CustomData; + } + + XmlSerializer serializer = new(typeof(DeviceLayout), null, customTypes, null, null); + serializer.Serialize(stream, layout); + } } \ No newline at end of file From 08fbb0e526b2aa3d5f2fb09f65791091ca725780 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 1 Nov 2023 20:37:12 +0100 Subject: [PATCH 91/96] Fix custom LED data type not being determined correctly --- RGB.NET.Layout/LayoutExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Layout/LayoutExtension.cs b/RGB.NET.Layout/LayoutExtension.cs index 915380b..0426e3b 100644 --- a/RGB.NET.Layout/LayoutExtension.cs +++ b/RGB.NET.Layout/LayoutExtension.cs @@ -73,7 +73,7 @@ public static class LayoutExtension public static void Save(this IDeviceLayout layout, Stream stream) { Type? customDataType = layout.CustomData?.GetType(); - Type? customLedDataType = layout.Leds.FirstOrDefault(x => x.CustomData != null)?.GetType(); + Type? customLedDataType = layout.Leds.FirstOrDefault(x => x.CustomData != null)?.CustomData?.GetType(); Type[] customTypes; if ((customDataType != null) && (customLedDataType != null)) From a0c90029ebfe88c8810374f977233493754b424f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 14 Nov 2023 22:34:13 +0100 Subject: [PATCH 92/96] Added .NET 8 build-target --- .github/workflows/ci.yml | 19 +++++++++++++++---- .github/workflows/pr_verify.yml | 11 +++++++---- .github/workflows/release.yml | 19 ++++++++++++++----- RGB.NET.Core/RGB.NET.Core.csproj | 2 +- .../RGB.NET.Devices.Asus.csproj | 2 +- .../RGB.NET.Devices.CoolerMaster.csproj | 2 +- .../RGB.NET.Devices.Corsair.csproj | 2 +- .../RGB.NET.Devices.Corsair_Legacy.csproj | 2 +- .../RGB.NET.Devices.DMX.csproj | 2 +- .../RGB.NET.Devices.Debug.csproj | 2 +- .../RGB.NET.Devices.Logitech.csproj | 2 +- .../RGB.NET.Devices.Msi.csproj | 2 +- .../RGB.NET.Devices.Novation.csproj | 2 +- .../RGB.NET.Devices.OpenRGB.csproj | 2 +- .../RGB.NET.Devices.PicoPi.csproj | 2 +- .../RGB.NET.Devices.Razer.csproj | 2 +- .../RGB.NET.Devices.SteelSeries.csproj | 2 +- .../RGB.NET.Devices.WS281X.csproj | 2 +- .../Keyboard/WootingKeyboardRGBDevice.cs | 1 - .../Keypad/WootingKeypadRGBDevice.cs | 1 - .../RGB.NET.Devices.Wooting.csproj | 2 +- RGB.NET.HID/RGB.NET.HID.csproj | 2 +- RGB.NET.Layout/RGB.NET.Layout.csproj | 2 +- RGB.NET.Presets/RGB.NET.Presets.csproj | 2 +- .../RGB.NET.Core.Tests.csproj | 2 +- .../RGB.NET.Presets.Tests.csproj | 2 +- 26 files changed, 57 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36bab7a..db64c8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,16 +11,19 @@ on: jobs: build: - runs-on: windows-2022 + runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: | + 8.0.x + 7.0.x + 6.0.x - name: Git Semantic Version id: versioning uses: PaulHatch/semantic-version@v4.0.3 @@ -45,6 +48,12 @@ jobs: name: RGB.NET-NET7 path: bin/net7.0/RGB.NET.*.dll if-no-files-found: error + - name: Upload a Build Artifact NET8 + uses: actions/upload-artifact@v2.2.4 + with: + name: RGB.NET-NET8 + path: bin/net8.0/RGB.NET.*.dll + if-no-files-found: error - name: Upload Nuget Build Artifact uses: actions/upload-artifact@v2.2.4 with: @@ -53,3 +62,5 @@ jobs: if-no-files-found: error - name: Nuget Push run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json + - name: Symbols Push + run: dotnet nuget push **\*.snupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json diff --git a/.github/workflows/pr_verify.yml b/.github/workflows/pr_verify.yml index b47d33e..d556fa2 100644 --- a/.github/workflows/pr_verify.yml +++ b/.github/workflows/pr_verify.yml @@ -7,14 +7,17 @@ on: jobs: build: - runs-on: windows-2022 + runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: | + 8.0.x + 7.0.x + 6.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 121fb30..f6e3df3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,16 +10,19 @@ on: jobs: build: - runs-on: windows-2022 + runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: | + 8.0.x + 7.0.x + 6.0.x - name: Git Semantic Version id: versioning uses: PaulHatch/semantic-version@v4.0.3 @@ -44,6 +47,12 @@ jobs: name: RGB.NET-NET7 path: bin/net7.0/RGB.NET.*.dll if-no-files-found: error + - name: Upload a Build Artifact NET8 + uses: actions/upload-artifact@v2.2.4 + with: + name: RGB.NET-NET8 + path: bin/net8.0/RGB.NET.*.dll + if-no-files-found: error - name: Upload Nuget Build Artifact uses: actions/upload-artifact@v2.2.4 with: @@ -55,6 +64,6 @@ jobs: with: tag_name: ${{ steps.versioning.outputs.version_tag }} generate_release_notes: true - files: bin/net7.0/RGB.NET.*.dll + files: bin/net8.0/RGB.NET.*.dll - name: Nuget Push run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 8499b1e..1022bf0 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index dc67689..ecf4ea7 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index 2adfaa5..73017c6 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index ccb143e..ee6cfca 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj index dff737c..c80995d 100644 --- a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj +++ b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj index e6e876e..df8e547 100644 --- a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj index 980153c..1f17728 100644 --- a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj +++ b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index fd412e7..6ae10dd 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 7d604a6..12f416f 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index cda9c5e..c249fc2 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index f3b3a81..6b32521 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj index 6cf8a2c..a2b134f 100644 --- a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj +++ b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 27f7261..3632399 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index f75e2d8..76525ce 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj index 5487a8e..39f4d52 100644 --- a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj +++ b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index 773d233..0ba3600 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Generic; -using RGB.NET.Devices.Wooting.Native; namespace RGB.NET.Devices.Wooting.Keyboard; diff --git a/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs index 5bf5524..984072b 100644 --- a/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keypad/WootingKeypadRGBDevice.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Generic; -using RGB.NET.Devices.Wooting.Keyboard; namespace RGB.NET.Devices.Wooting.Keypad; diff --git a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj index 8a34dcd..37d84ab 100644 --- a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj +++ b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.HID/RGB.NET.HID.csproj b/RGB.NET.HID/RGB.NET.HID.csproj index 7bf502b..58b5b0f 100644 --- a/RGB.NET.HID/RGB.NET.HID.csproj +++ b/RGB.NET.HID/RGB.NET.HID.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Layout/RGB.NET.Layout.csproj b/RGB.NET.Layout/RGB.NET.Layout.csproj index 3c90185..473f421 100644 --- a/RGB.NET.Layout/RGB.NET.Layout.csproj +++ b/RGB.NET.Layout/RGB.NET.Layout.csproj @@ -1,6 +1,6 @@ - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/RGB.NET.Presets/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index 048087a..c7b6129 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -1,6 +1,6 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 latest enable diff --git a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj index 7e98ef5..7fb09e7 100644 --- a/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj +++ b/Tests/RGB.NET.Core.Tests/RGB.NET.Core.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false diff --git a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj index ca57230..ba91ec3 100644 --- a/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj +++ b/Tests/RGB.NET.Presets.Tests/RGB.NET.Presets.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false From 8aaf602cdd80cdc6b6a68d719867cc7d47e09b74 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 22 Dec 2023 20:16:14 +0100 Subject: [PATCH 93/96] Added GameController as Core device type; Updated Corsair SDK to 4.0.84 --- RGB.NET.Core/Devices/RGBDeviceType.cs | 5 + .../Devices/TypeInterfaces/IGameController.cs | 7 + RGB.NET.Core/Leds/LedId.cs | 130 ++++++++++++++++++ .../CorsairDeviceProvider.cs | 8 ++ .../Enum/CorsairChannelDeviceType.cs | 1 + .../Enum/CorsairDeviceType.cs | 5 + .../Enum/CorsairLedGroup.cs | 7 +- .../CorsairGameControllerRGBDevice.cs | 34 +++++ .../CorsairGameControllerRGBDeviceInfo.cs | 20 +++ .../Generic/LedMappings.cs | 1 + RGB.NET.Devices.Corsair/README.md | 4 +- ...RGB.NET.Devices.Corsair.csproj.DotSettings | 1 + 12 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs create mode 100644 RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDevice.cs create mode 100644 RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDeviceInfo.cs diff --git a/RGB.NET.Core/Devices/RGBDeviceType.cs b/RGB.NET.Core/Devices/RGBDeviceType.cs index 88e4f82..57be106 100644 --- a/RGB.NET.Core/Devices/RGBDeviceType.cs +++ b/RGB.NET.Core/Devices/RGBDeviceType.cs @@ -93,6 +93,11 @@ public enum RGBDeviceType /// LedController = 1 << 15, + /// + /// Represents a game controller. + /// + GameController = 1 << 16, + /// /// Represents a device where the type is not known or not present in the list. /// diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs b/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs new file mode 100644 index 0000000..d2c5507 --- /dev/null +++ b/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs @@ -0,0 +1,7 @@ +namespace RGB.NET.Core; + +/// +/// Represents a gamecontroller-device +/// +public interface IGameController: IRGBDevice +{ } \ No newline at end of file diff --git a/RGB.NET.Core/Leds/LedId.cs b/RGB.NET.Core/Leds/LedId.cs index 43a6a70..a0b12c9 100644 --- a/RGB.NET.Core/Leds/LedId.cs +++ b/RGB.NET.Core/Leds/LedId.cs @@ -6294,6 +6294,136 @@ public enum LedId Cooler127 = 0x00D0007F, Cooler128 = 0x00D00080, + /*### GameController ###*/ + GameController1 = 0x00E00001, + GameController2 = 0x00E00002, + GameController3 = 0x00E00003, + GameController4 = 0x00E00004, + GameController5 = 0x00E00005, + GameController6 = 0x00E00006, + GameController7 = 0x00E00007, + GameController8 = 0x00E00008, + GameController9 = 0x00E00009, + GameController10 = 0x00E0000A, + GameController11 = 0x00E0000B, + GameController12 = 0x00E0000C, + GameController13 = 0x00E0000D, + GameController14 = 0x00E0000E, + GameController15 = 0x00E0000F, + GameController16 = 0x00E00010, + GameController17 = 0x00E00011, + GameController18 = 0x00E00012, + GameController19 = 0x00E00013, + GameController20 = 0x00E00014, + GameController21 = 0x00E00015, + GameController22 = 0x00E00016, + GameController23 = 0x00E00017, + GameController24 = 0x00E00018, + GameController25 = 0x00E00019, + GameController26 = 0x00E0001A, + GameController27 = 0x00E0001B, + GameController28 = 0x00E0001C, + GameController29 = 0x00E0001D, + GameController30 = 0x00E0001E, + GameController31 = 0x00E0001F, + GameController32 = 0x00E00020, + GameController33 = 0x00E00021, + GameController34 = 0x00E00022, + GameController35 = 0x00E00023, + GameController36 = 0x00E00024, + GameController37 = 0x00E00025, + GameController38 = 0x00E00026, + GameController39 = 0x00E00027, + GameController40 = 0x00E00028, + GameController41 = 0x00E00029, + GameController42 = 0x00E0002A, + GameController43 = 0x00E0002B, + GameController44 = 0x00E0002C, + GameController45 = 0x00E0002D, + GameController46 = 0x00E0002E, + GameController47 = 0x00E0002F, + GameController48 = 0x00E00030, + GameController49 = 0x00E00031, + GameController50 = 0x00E00032, + GameController51 = 0x00E00033, + GameController52 = 0x00E00034, + GameController53 = 0x00E00035, + GameController54 = 0x00E00036, + GameController55 = 0x00E00037, + GameController56 = 0x00E00038, + GameController57 = 0x00E00039, + GameController58 = 0x00E0003A, + GameController59 = 0x00E0003B, + GameController60 = 0x00E0003C, + GameController61 = 0x00E0003D, + GameController62 = 0x00E0003E, + GameController63 = 0x00E0003F, + GameController64 = 0x00E00040, + GameController65 = 0x00E00041, + GameController66 = 0x00E00042, + GameController67 = 0x00E00043, + GameController68 = 0x00E00044, + GameController69 = 0x00E00045, + GameController70 = 0x00E00046, + GameController71 = 0x00E00047, + GameController72 = 0x00E00048, + GameController73 = 0x00E00049, + GameController74 = 0x00E0004A, + GameController75 = 0x00E0004B, + GameController76 = 0x00E0004C, + GameController77 = 0x00E0004D, + GameController78 = 0x00E0004E, + GameController79 = 0x00E0004F, + GameController80 = 0x00E00050, + GameController81 = 0x00E00051, + GameController82 = 0x00E00052, + GameController83 = 0x00E00053, + GameController84 = 0x00E00054, + GameController85 = 0x00E00055, + GameController86 = 0x00E00056, + GameController87 = 0x00E00057, + GameController88 = 0x00E00058, + GameController89 = 0x00E00059, + GameController90 = 0x00E0005A, + GameController91 = 0x00E0005B, + GameController92 = 0x00E0005C, + GameController93 = 0x00E0005D, + GameController94 = 0x00E0005E, + GameController95 = 0x00E0005F, + GameController96 = 0x00E00060, + GameController97 = 0x00E00061, + GameController98 = 0x00E00062, + GameController99 = 0x00E00063, + GameController100 = 0x00E00064, + GameController101 = 0x00E00065, + GameController102 = 0x00E00066, + GameController103 = 0x00E00067, + GameController104 = 0x00E00068, + GameController105 = 0x00E00069, + GameController106 = 0x00E0006A, + GameController107 = 0x00E0006B, + GameController108 = 0x00E0006C, + GameController109 = 0x00E0006D, + GameController110 = 0x00E0006E, + GameController111 = 0x00E0006F, + GameController112 = 0x00E00070, + GameController113 = 0x00E00071, + GameController114 = 0x00E00072, + GameController115 = 0x00E00073, + GameController116 = 0x00E00074, + GameController117 = 0x00E00075, + GameController118 = 0x00E00076, + GameController119 = 0x00E00077, + GameController120 = 0x00E00078, + GameController121 = 0x00E00079, + GameController122 = 0x00E0007A, + GameController123 = 0x00E0007B, + GameController124 = 0x00E0007C, + GameController125 = 0x00E0007D, + GameController126 = 0x00E0007E, + GameController127 = 0x00E0007F, + GameController128 = 0x00E00080, + /*### Custom ###*/ Custom1 = 0x0FE00001, Custom2 = 0x0FE00002, diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 89f4684..3a4a4da 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -217,6 +217,10 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider yield return new CorsairCoolerRGBDevice(new CorsairCoolerRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); break; + case CorsairDeviceType.GameController: + yield return new CorsairGameControllerRGBDevice(new CorsairGameControllerRGBDeviceInfo(device, deviceLedCount, 0), updateQueue); + break; + case CorsairDeviceType.FanLedController: case CorsairDeviceType.LedController: case CorsairDeviceType.Unknown: @@ -264,6 +268,10 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "QL Fan"), updateQueue); break; + case CorsairChannelDeviceType.FanQX: + yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "QX Fan"), updateQueue); + break; + case CorsairChannelDeviceType.EightLedSeriesFan: yield return new CorsairFanRGBDevice(new CorsairFanRGBDeviceInfo(device, ledCount, offset, "8-Led-Series Fan Fan"), updateQueue); break; diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs index 65a38fa..afadf30 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs @@ -20,4 +20,5 @@ public enum CorsairChannelDeviceType Pump = 9, DRAM = 10, WaterBlock = 11, + FanQX = 12, }; \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs index b41be14..9e78403 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs @@ -76,6 +76,11 @@ public enum CorsairDeviceType : uint /// Touchbar = 0x0800, + /// + /// iCUE-SDK: for game controllers + /// + GameController = 0x1000, + /// /// iCUE-SDK: for all devices /// diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs index 3ec299d..58b7079 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedGroup.cs @@ -80,5 +80,10 @@ public enum CorsairLedGroup /// /// iCUE-SDK: for touchbar leds /// - Touchbar = 14 + Touchbar = 14, + + /// + /// iCUE-SDK: for game controller leds + /// + GameController = 15 } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDevice.cs b/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDevice.cs new file mode 100644 index 0000000..2c4234d --- /dev/null +++ b/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDevice.cs @@ -0,0 +1,34 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; +using System.Collections.Generic; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a corsair gamecontroller. +/// +public sealed class CorsairGameControllerRGBDevice : CorsairRGBDevice, IGameController +{ + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the gamecontroller + /// The queue used to update this device. + internal CorsairGameControllerRGBDevice(CorsairGameControllerRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) + : base(info, updateQueue) + { } + + #endregion + + #region Methods + + protected override LedMapping CreateMapping(IEnumerable ids) => LedMappings.CreateGameControllerMapping(ids); + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDeviceInfo.cs new file mode 100644 index 0000000..5d968d7 --- /dev/null +++ b/RGB.NET.Devices.Corsair/GameController/CorsairGameControllerRGBDeviceInfo.cs @@ -0,0 +1,20 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair; + +/// +/// +/// Represents a generic information for a . +/// +public sealed class CorsairGameControllerRGBDeviceInfo : CorsairRGBDeviceInfo +{ + #region Constructors + + /// + internal CorsairGameControllerRGBDeviceInfo(_CorsairDeviceInfo nativeInfo, int ledCount, int ledOffset) + : base(RGBDeviceType.GameController, nativeInfo, ledCount, ledOffset) + { } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs index ffbfa0f..f37ec87 100644 --- a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs @@ -160,6 +160,7 @@ internal static class LedMappings internal static LedMapping CreateMousepadMapping(IEnumerable ids) => CreateMapping(ids, LedId.Mousepad1); internal static LedMapping CreateHeadsetMapping(IEnumerable ids) => CreateMapping(ids, LedId.Headset1); internal static LedMapping CreateMouseMapping(IEnumerable ids) => CreateMapping(ids, LedId.Mouse1); + internal static LedMapping CreateGameControllerMapping(IEnumerable ids) => CreateMapping(ids, LedId.GameController1); internal static LedMapping CreateUnknownMapping(IEnumerable ids) => CreateMapping(ids, LedId.Unknown1); internal static LedMapping CreateMapping(IEnumerable ids, LedId referenceId) diff --git a/RGB.NET.Devices.Corsair/README.md b/RGB.NET.Devices.Corsair/README.md index c6c1803..191ad60 100644 --- a/RGB.NET.Devices.Corsair/README.md +++ b/RGB.NET.Devices.Corsair/README.md @@ -11,7 +11,7 @@ surface.Load(CorsairDeviceProvider.Instance); This providers requires native SDK-dlls. You can get them directly from Corsair at [https://github.com/CorsairOfficial/cue-sdk/releases](https://github.com/CorsairOfficial/cue-sdk/releases) -(Developed and tested with iCUE SDK v4.0.48) +(Developed and tested with iCUE SDK v4.0.84) Since the SDK-dlls are native it's important to use the correct architecture you're building your application for. (If in doubt you can always include both.) @@ -20,7 +20,7 @@ Since the SDK-dlls are native it's important to use the correct architecture you You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX64NativePaths`. -### x86 +### x86 (only SDKs before v4.0.84) `redist\i386\iCUESDK_2019.dll` from the SDK-zip needs to be distributed as `\x86\iCUESDK_2019.dll` (or simply named `iCUESDK.dll`) You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX86NativePaths`. diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings index 16defe6..9eb538f 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings @@ -1,6 +1,7 @@  True True + True True True True From d85f1559b301b34bc1db40559d5f0b4bce4bbea3 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 22 Dec 2023 20:56:56 +0100 Subject: [PATCH 94/96] Applied some C#12 stuff --- .../Decorators/AbstractDecorateable.cs | 2 +- RGB.NET.Core/Decorators/AbstractDecorator.cs | 4 +- RGB.NET.Core/Decorators/IDecoratable.cs | 3 +- RGB.NET.Core/Decorators/ILedGroupDecorator.cs | 3 +- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 2 +- .../Devices/AbstractRGBDeviceProvider.cs | 8 +- .../Devices/TypeInterfaces/ICooler.cs | 3 +- RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs | 3 +- RGB.NET.Core/Devices/TypeInterfaces/IFan.cs | 3 +- .../Devices/TypeInterfaces/IGameController.cs | 3 +- .../Devices/TypeInterfaces/IGraphicsCard.cs | 3 +- .../Devices/TypeInterfaces/IHeadset.cs | 3 +- .../Devices/TypeInterfaces/IHeadsetStand.cs | 3 +- .../Devices/TypeInterfaces/IKeypad.cs | 3 +- .../Devices/TypeInterfaces/ILedMatrix.cs | 3 +- .../Devices/TypeInterfaces/ILedStripe.cs | 3 +- .../Devices/TypeInterfaces/IMainboard.cs | 3 +- RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs | 3 +- .../Devices/TypeInterfaces/IMousepad.cs | 3 +- .../Devices/TypeInterfaces/ISpeaker.cs | 3 +- .../Devices/TypeInterfaces/IUnknownDevice.cs | 3 +- .../Events/DevicesChangedEventArgs.cs | 17 +--- RGB.NET.Core/Events/UpdatedEventArgs.cs | 3 +- RGB.NET.Core/Helper/TimerHelper.cs | 4 +- RGB.NET.Core/Ids/IdGenerator.cs | 10 +- RGB.NET.Core/Leds/LedMapping.cs | 6 +- RGB.NET.Core/MVVM/IBindable.cs | 3 +- .../Misc/AbstractReferenceCounting.cs | 2 +- RGB.NET.Core/Misc/ActionDisposable.cs | 19 +--- RGB.NET.Core/RGBSurface.cs | 4 +- RGB.NET.Core/Update/CustomUpdateData.cs | 2 +- RGB.NET.Core/Update/Devices/IUpdateQueue.cs | 3 +- RGB.NET.Core/Update/Devices/UpdateQueue.cs | 2 +- .../Generic/IAsusRGBDevice.cs | 3 +- .../Keyboard/AsusKeyboardRGBDevice.cs | 16 ++-- .../Keyboard/AsusKeyboardRGBDeviceInfo.cs | 2 +- .../CoolerMasterDeviceProvider.cs | 4 +- .../Generic/ICoolerMasterRGBDevice.cs | 3 +- .../Native/_CoolerMasterSDK.cs | 16 ++-- .../CorsairDeviceProvider.cs | 4 +- .../Generic/LedMappings.cs | 2 +- .../Native/_CorsairDeviceFilter.cs | 1 + .../CorsairLegacyDeviceProvider.cs | 12 +-- .../Custom/CorsairCustomRGBDevice.cs | 9 +- .../Custom/CorsairCustomRGBDeviceInfo.cs | 2 +- .../Generic/CorsairDeviceUpdateQueue.cs | 6 +- .../Generic/CorsairProtocolDetails.cs | 5 +- .../Generic/CorsairRGBDevice.cs | 9 +- .../Generic/CorsairRGBDeviceInfo.cs | 5 +- .../Generic/LedMappings.cs | 10 +- .../Helper/NativeExtensions.cs | 2 +- .../Native/_CUESDK.cs | 72 +++++++-------- .../Native/_CorsairChannelInfo.cs | 3 +- .../Native/_CorsairChannelsInfo.cs | 3 +- .../Native/_CorsairDeviceInfo.cs | 3 +- .../Native/_CorsairLedPositions.cs | 3 +- .../Native/_CorsairProtocolDetails.cs | 5 +- RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 2 +- .../E131/E131DMXDeviceDefinition.cs | 2 +- .../Generic/IDMXDeviceDefinition.cs | 3 +- .../Generic/LedChannelMapping.cs | 14 +-- RGB.NET.Devices.Debug/DebugDeviceProvider.cs | 2 +- .../DebugDeviceUpdateQueue.cs | 10 +- .../Generic/ILogitechRGBDevice.cs | 3 +- .../HID/LightspeedHidLoader.cs | 20 ++-- .../LogitechDeviceProvider.cs | 6 +- .../Native/_LogitechGSDK.cs | 52 +++++------ RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs | 3 +- RGB.NET.Devices.Msi/MsiDeviceProvider.cs | 4 +- RGB.NET.Devices.Msi/Native/_MsiSDK.cs | 8 +- .../Generic/INovationRGBDevice.cs | 3 +- .../Abstract/IOpenRGBDevice.cs | 3 +- .../OpenRGBDeviceProvider.cs | 4 +- RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs | 2 +- .../PicoPiDeviceProvider.cs | 2 +- .../ChromaLink/RazerChromaLinkUpdateQueue.cs | 6 +- .../Generic/IRazerRGBDevice.cs | 3 +- RGB.NET.Devices.Razer/Generic/LedMappings.cs | 8 +- .../Generic/RazerUpdateQueue.cs | 6 +- .../Headset/RazerHeadsetUpdateQueue.cs | 6 +- .../Keyboard/RazerKeyboardUpdateQueue.cs | 6 +- .../Keypad/RazerKeypadUpdateQueue.cs | 6 +- .../Mouse/RazerMouseUpdateQueue.cs | 6 +- .../Mousepad/RazerMousepadUpdateQueue.cs | 6 +- RGB.NET.Devices.Razer/Native/_Color.cs | 11 +-- RGB.NET.Devices.Razer/Native/_RazerSDK.cs | 92 +++++++++---------- RGB.NET.Devices.Razer/RazerDeviceProvider.cs | 4 +- .../API/Model/Event.cs | 2 +- .../Attribute/APIName.cs | 13 +-- .../Attribute/SteelSeriesEnumExtension.cs | 4 +- .../Generic/ISteelSeriesRGBDevice.cs | 3 +- .../Arduino/ArduinoWS2812USBUpdateQueue.cs | 2 +- .../BitwizardWS281XDeviceDefinition.cs | 2 +- .../NodeMCU/NodeMCUWS2812USBUpdateQueue.cs | 4 +- .../WS281XDeviceProvider.cs | 2 +- .../Generic/IWootingRGBDevice.cs | 3 +- RGB.NET.Devices.Wooting/Native/_WootingSDK.cs | 46 +++++----- .../WootingDeviceProvider.cs | 8 +- RGB.NET.HID/HIDLoader.cs | 2 +- RGB.NET.Layout/DeviceLayout.cs | 2 +- RGB.NET.Layout/LayoutExtension.cs | 2 +- .../Decorators/IGradientDecorator.cs | 3 +- .../Textures/Gradients/AbstractGradient.cs | 2 +- .../Textures/Gradients/LinearGradient.cs | 2 +- .../RGB.NET.Core.Tests/Helper/SimplexNoise.cs | 4 +- 105 files changed, 329 insertions(+), 422 deletions(-) diff --git a/RGB.NET.Core/Decorators/AbstractDecorateable.cs b/RGB.NET.Core/Decorators/AbstractDecorateable.cs index 5312eab..706aa45 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorateable.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorateable.cs @@ -11,7 +11,7 @@ public abstract class AbstractDecoratable : AbstractBindable, IDecoratable { #region Properties & Fields - private readonly List _decorators = new(); + private readonly List _decorators = []; /// public IReadOnlyList Decorators { get; } diff --git a/RGB.NET.Core/Decorators/AbstractDecorator.cs b/RGB.NET.Core/Decorators/AbstractDecorator.cs index 159fb4b..f9c7059 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorator.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorator.cs @@ -29,7 +29,7 @@ public abstract class AbstractDecorator : AbstractBindable, IDecorator /// /// Gets a readonly-list of all this decorator is attached to. /// - protected List DecoratedObjects { get; } = new(); + protected List DecoratedObjects { get; } = []; #endregion @@ -46,7 +46,7 @@ public abstract class AbstractDecorator : AbstractBindable, IDecorator /// protected virtual void Detach() { - List decoratables = new(DecoratedObjects); + List decoratables = [..DecoratedObjects]; foreach (IDecoratable decoratable in decoratables) { IEnumerable types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType diff --git a/RGB.NET.Core/Decorators/IDecoratable.cs b/RGB.NET.Core/Decorators/IDecoratable.cs index 5fddf47..413b698 100644 --- a/RGB.NET.Core/Decorators/IDecoratable.cs +++ b/RGB.NET.Core/Decorators/IDecoratable.cs @@ -6,8 +6,7 @@ namespace RGB.NET.Core; /// /// Represents a basic decoratable. /// -public interface IDecoratable : INotifyPropertyChanged -{ } +public interface IDecoratable : INotifyPropertyChanged; /// /// diff --git a/RGB.NET.Core/Decorators/ILedGroupDecorator.cs b/RGB.NET.Core/Decorators/ILedGroupDecorator.cs index 051ca9d..51bd302 100644 --- a/RGB.NET.Core/Decorators/ILedGroupDecorator.cs +++ b/RGB.NET.Core/Decorators/ILedGroupDecorator.cs @@ -4,5 +4,4 @@ /// /// Represents a basic decorator decorating a . /// -public interface ILedGroupDecorator : IDecorator -{ } \ No newline at end of file +public interface ILedGroupDecorator : IDecorator; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index a03bfa2..9e3572b 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -53,7 +53,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice /// Gets a dictionary containing all of the . /// - protected Dictionary LedMapping { get; } = new(); + protected Dictionary LedMapping { get; } = []; /// /// Gets the update queue used to update this device. diff --git a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs index 2d1f2eb..ff2f7df 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs @@ -25,7 +25,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// /// The list of devices managed by this device-provider. /// - protected List InternalDevices { get; } = new(); + protected List InternalDevices { get; } = []; /// public virtual IReadOnlyList Devices => new ReadOnlyCollection(InternalDevices); @@ -34,7 +34,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider /// Gets the dictionary containing the registered update triggers. /// Normally should be used to access them. /// - protected Dictionary UpdateTriggerMapping { get; } = new(); + protected Dictionary UpdateTriggerMapping { get; } = []; /// public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)>(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList()); @@ -116,7 +116,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider { if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); - List devices = new(); + List devices = []; foreach (IRGBDevice device in LoadDevices()) { try @@ -189,7 +189,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider foreach (IRGBDevice device in Devices) device.Dispose(); - List devices = new(InternalDevices); + List devices = [..InternalDevices]; foreach (IRGBDevice device in devices) RemoveDevice(device); diff --git a/RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs b/RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs index 1e1eb2f..da7c2a0 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs @@ -3,5 +3,4 @@ /// /// Represents a cooler-device /// -public interface ICooler : IRGBDevice -{ } \ No newline at end of file +public interface ICooler : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs b/RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs index 3bb4c23..a395d91 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs @@ -3,5 +3,4 @@ /// /// Represents a DRAM-device /// -public interface IDRAM : IRGBDevice -{ } \ No newline at end of file +public interface IDRAM : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IFan.cs b/RGB.NET.Core/Devices/TypeInterfaces/IFan.cs index 9f0c803..fd11b08 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IFan.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IFan.cs @@ -3,5 +3,4 @@ /// /// represents a fan-device /// -public interface IFan : IRGBDevice -{ } \ No newline at end of file +public interface IFan : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs b/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs index d2c5507..ebfe6a1 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs @@ -3,5 +3,4 @@ /// /// Represents a gamecontroller-device /// -public interface IGameController: IRGBDevice -{ } \ No newline at end of file +public interface IGameController: IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs b/RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs index 372ec09..9d58944 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs @@ -3,5 +3,4 @@ /// /// Represents a graphics-card-device /// -public interface IGraphicsCard : IRGBDevice -{ } \ No newline at end of file +public interface IGraphicsCard : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs b/RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs index 0256cd5..fea115e 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs @@ -3,5 +3,4 @@ /// /// Represents a headset-device /// -public interface IHeadset : IRGBDevice -{ } \ No newline at end of file +public interface IHeadset : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs b/RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs index 537c856..afc31c7 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs @@ -3,5 +3,4 @@ /// /// Represents a headset-stand-device /// -public interface IHeadsetStand : IRGBDevice -{ } \ No newline at end of file +public interface IHeadsetStand : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs b/RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs index 2a65233..ff6a970 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs @@ -3,5 +3,4 @@ /// /// Represents a keypad-device /// -public interface IKeypad : IRGBDevice -{ } \ No newline at end of file +public interface IKeypad : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs b/RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs index b0f401e..48d029b 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs @@ -3,5 +3,4 @@ /// /// Represents a led-matrix-device /// -public interface ILedMatrix : IRGBDevice -{ } \ No newline at end of file +public interface ILedMatrix : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs b/RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs index 4bb5fd8..355cd28 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs @@ -3,5 +3,4 @@ /// /// Represents a led-stripe-device /// -public interface ILedStripe : IRGBDevice -{ } \ No newline at end of file +public interface ILedStripe : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs b/RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs index 10af8f4..5e7b270 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs @@ -3,5 +3,4 @@ /// /// Represents a mainboard-device /// -public interface IMainboard : IRGBDevice -{ } \ No newline at end of file +public interface IMainboard : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs b/RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs index 76e62e2..d045976 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs @@ -3,5 +3,4 @@ /// /// Represents a mouse-device /// -public interface IMouse : IRGBDevice -{ } \ No newline at end of file +public interface IMouse : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs b/RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs index c89b254..af87521 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs @@ -3,5 +3,4 @@ /// /// Represents a mousepad-device /// -public interface IMousepad : IRGBDevice -{ } \ No newline at end of file +public interface IMousepad : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs b/RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs index cde47e4..226d6a8 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs @@ -3,5 +3,4 @@ /// /// Represents a speaker-device /// -public interface ISpeaker : IRGBDevice -{ } \ No newline at end of file +public interface ISpeaker : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs b/RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs index 1d136ad..a037453 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs @@ -3,5 +3,4 @@ /// /// Represents a device with unkown or not specified type. /// -public interface IUnknownDevice : IRGBDevice -{ } \ No newline at end of file +public interface IUnknownDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs index a0d648b..5a856e5 100644 --- a/RGB.NET.Core/Events/DevicesChangedEventArgs.cs +++ b/RGB.NET.Core/Events/DevicesChangedEventArgs.cs @@ -2,22 +2,13 @@ namespace RGB.NET.Core; -public sealed class DevicesChangedEventArgs : EventArgs +public sealed class DevicesChangedEventArgs(IRGBDevice device, DevicesChangedEventArgs.DevicesChangedAction action) + : EventArgs { #region Properties & Fields - public IRGBDevice Device { get; } - public DevicesChangedAction Action { get; } - - #endregion - - #region Constructors - - public DevicesChangedEventArgs(IRGBDevice device, DevicesChangedAction action) - { - this.Device = device; - this.Action = action; - } + public IRGBDevice Device { get; } = device; + public DevicesChangedAction Action { get; } = action; #endregion diff --git a/RGB.NET.Core/Events/UpdatedEventArgs.cs b/RGB.NET.Core/Events/UpdatedEventArgs.cs index b4251d4..467e503 100644 --- a/RGB.NET.Core/Events/UpdatedEventArgs.cs +++ b/RGB.NET.Core/Events/UpdatedEventArgs.cs @@ -6,5 +6,4 @@ namespace RGB.NET.Core; /// /// Represents the information supplied with an -event. /// -public class UpdatedEventArgs : EventArgs -{ } \ No newline at end of file +public class UpdatedEventArgs : EventArgs; \ No newline at end of file diff --git a/RGB.NET.Core/Helper/TimerHelper.cs b/RGB.NET.Core/Helper/TimerHelper.cs index 432170b..e2742ab 100644 --- a/RGB.NET.Core/Helper/TimerHelper.cs +++ b/RGB.NET.Core/Helper/TimerHelper.cs @@ -46,7 +46,7 @@ public static class TimerHelper } // ReSharper disable once InconsistentNaming - private static readonly HashSet _timerLeases = new(); + private static readonly HashSet _timerLeases = []; #endregion @@ -143,7 +143,7 @@ public static class TimerHelper /// public static void DisposeAllHighResolutionTimerRequests() { - List timerLeases = new(_timerLeases); + List timerLeases = [.._timerLeases]; foreach (HighResolutionTimerDisposable timer in timerLeases) timer.Dispose(); } diff --git a/RGB.NET.Core/Ids/IdGenerator.cs b/RGB.NET.Core/Ids/IdGenerator.cs index c6270e7..f9bf217 100644 --- a/RGB.NET.Core/Ids/IdGenerator.cs +++ b/RGB.NET.Core/Ids/IdGenerator.cs @@ -12,9 +12,9 @@ public static class IdGenerator #region Properties & Fields // ReSharper disable InconsistentNaming - private static readonly HashSet _registeredIds = new(); - private static readonly Dictionary> _idMappings = new(); - private static readonly Dictionary> _counter = new(); + private static readonly HashSet _registeredIds = []; + private static readonly Dictionary> _idMappings = []; + private static readonly Dictionary> _counter = []; // ReSharper restore InconsistentNaming #endregion @@ -33,8 +33,8 @@ public static class IdGenerator { if (!_idMappings.TryGetValue(callingAssembly, out Dictionary? idMapping)) { - _idMappings.Add(callingAssembly, idMapping = new Dictionary()); - _counter.Add(callingAssembly, new Dictionary()); + _idMappings.Add(callingAssembly, idMapping = []); + _counter.Add(callingAssembly, []); } Dictionary counterMapping = _counter[callingAssembly]; diff --git a/RGB.NET.Core/Leds/LedMapping.cs b/RGB.NET.Core/Leds/LedMapping.cs index 0aab16d..a296bbe 100644 --- a/RGB.NET.Core/Leds/LedMapping.cs +++ b/RGB.NET.Core/Leds/LedMapping.cs @@ -13,14 +13,14 @@ public sealed class LedMapping : IEnumerable<(LedId ledId, T mapping)> { #region Constants - public static LedMapping Empty { get; } = new(); + public static LedMapping Empty { get; } = []; #endregion #region Properties & Fields - private readonly Dictionary _mapping = new(); - private readonly Dictionary _reverseMapping = new(); + private readonly Dictionary _mapping = []; + private readonly Dictionary _reverseMapping = []; /// /// Gets the number of entries in this mapping. diff --git a/RGB.NET.Core/MVVM/IBindable.cs b/RGB.NET.Core/MVVM/IBindable.cs index 24d1fa5..9719288 100644 --- a/RGB.NET.Core/MVVM/IBindable.cs +++ b/RGB.NET.Core/MVVM/IBindable.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Core; /// /// Represents a basic bindable class which notifies when a property value changes. /// -public interface IBindable : INotifyPropertyChanged -{ } \ No newline at end of file +public interface IBindable : INotifyPropertyChanged; \ No newline at end of file diff --git a/RGB.NET.Core/Misc/AbstractReferenceCounting.cs b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs index 09d64ef..f55c56a 100644 --- a/RGB.NET.Core/Misc/AbstractReferenceCounting.cs +++ b/RGB.NET.Core/Misc/AbstractReferenceCounting.cs @@ -6,7 +6,7 @@ public abstract class AbstractReferenceCounting : IReferenceCounting { #region Properties & Fields - private readonly HashSet _referencingObjects = new(); + private readonly HashSet _referencingObjects = []; /// public int ActiveReferenceCount diff --git a/RGB.NET.Core/Misc/ActionDisposable.cs b/RGB.NET.Core/Misc/ActionDisposable.cs index 843605e..7844a57 100644 --- a/RGB.NET.Core/Misc/ActionDisposable.cs +++ b/RGB.NET.Core/Misc/ActionDisposable.cs @@ -2,26 +2,11 @@ namespace RGB.NET.Core; -public sealed class ActionDisposable : IDisposable +public sealed class ActionDisposable(Action onDispose) : IDisposable { - #region Properties & Fields - - private readonly Action _onDispose; - - #endregion - - #region Constructors - - public ActionDisposable(Action onDispose) - { - this._onDispose = onDispose; - } - - #endregion - #region Methods - public void Dispose() => _onDispose(); + public void Dispose() => onDispose(); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 8219191..5c3387f 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -22,7 +22,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable private readonly IList _devices = new List(); private readonly IList _updateTriggers = new List(); - private readonly List _ledGroups = new(); + private readonly List _ledGroups = []; /// /// Gets a readonly list containing all loaded . @@ -184,7 +184,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable { List devices; lock (Devices) - devices = new List(_devices); + devices = [.._devices]; foreach (IRGBDevice device in devices) try { Detach(device); } diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index 4888cd1..736723a 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -52,7 +52,7 @@ public sealed class CustomUpdateData : ICustomUpdateData { #region Properties & Fields - private readonly Dictionary _data = new(); + private readonly Dictionary _data = []; #endregion diff --git a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs index 2943379..03a3e65 100644 --- a/RGB.NET.Core/Update/Devices/IUpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/IUpdateQueue.cs @@ -31,5 +31,4 @@ public interface IUpdateQueue : IReferenceCounting, IDisposa /// /// Represents a generic update queue processing -data using -identifiers. /// -public interface IUpdateQueue : IUpdateQueue -{ } \ No newline at end of file +public interface IUpdateQueue : IUpdateQueue; \ No newline at end of file diff --git a/RGB.NET.Core/Update/Devices/UpdateQueue.cs b/RGB.NET.Core/Update/Devices/UpdateQueue.cs index c17e3a9..22ef7f9 100644 --- a/RGB.NET.Core/Update/Devices/UpdateQueue.cs +++ b/RGB.NET.Core/Update/Devices/UpdateQueue.cs @@ -16,7 +16,7 @@ public abstract class UpdateQueue : AbstractReferenceCountin private readonly object _dataLock = new(); private readonly IDeviceUpdateTrigger _updateTrigger; - private readonly Dictionary _currentDataSet = new(); + private readonly Dictionary _currentDataSet = []; /// public bool RequiresFlush { get; private set; } diff --git a/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs index cb7d4a9..027c83a 100644 --- a/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Asus; /// /// Represents a asus RGB-device. /// -public interface IAsusRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface IAsusRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index ee5f549..1200429 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -25,8 +25,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice? _ledMapping; - private readonly Dictionary _ledAsusLed = new(); - private readonly Dictionary _ledAsusLights = new(); + private readonly Dictionary _ledAsusLed = []; + private readonly Dictionary _ledAsusLights = []; IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; @@ -35,11 +35,11 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDeviceNote: These LED mappings should be based on light indexes. /// // ReSharper disable once InconsistentNaming - public static readonly List ExtraLedMappings = new() - { - new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15), - new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15) - }; + public static readonly List ExtraLedMappings = + [ + new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15), + new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15) + ]; #endregion @@ -66,7 +66,7 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice to get the real model /// - private static readonly List GENERIC_DEVICE_NAMES = new() { "NotebookKeyboard" }; + private static readonly List GENERIC_DEVICE_NAMES = ["NotebookKeyboard"]; /// public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 8678e1a..cecc41d 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -37,13 +37,13 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/CMSDK.dll" }; + public static List PossibleX86NativePaths { get; } = ["x86/CMSDK.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/CMSDK.dll" }; + public static List PossibleX64NativePaths { get; } = ["x64/CMSDK.dll"]; #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs index 5cf66bb..8c1fb92 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.CoolerMaster; /// /// Represents a CoolerMaster RGB-device. /// -public interface ICoolerMasterRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface ICoolerMasterRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs index 6b51c39..6be82b0 100644 --- a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs +++ b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs @@ -16,14 +16,14 @@ internal static class _CoolerMasterSDK { #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. /// internal static void Reload() { - if (_handle != IntPtr.Zero) + if (_handle != 0) { foreach (CoolerMasterDevicesIndexes index in Enum.GetValues(typeof(CoolerMasterDevicesIndexes))) EnableLedControl(false, index); @@ -34,7 +34,7 @@ internal static class _CoolerMasterSDK private static void LoadCMSDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; // HACK: Load library at runtime to support both, x86 and x64 with one managed dll List possiblePathList = (Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths) @@ -47,7 +47,7 @@ internal static class _CoolerMasterSDK #if NET6_0 if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}"); #else - if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}"); + if (_handle == 0) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}"); #endif _getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_handle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer)); @@ -62,7 +62,7 @@ internal static class _CoolerMasterSDK internal static void UnloadCMSDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; _getSDKVersionPointer = null; _setControlDevicenPointer = null; @@ -74,14 +74,14 @@ internal static class _CoolerMasterSDK _setAllLedColorPointer = null; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] - private static extern IntPtr LoadLibrary(string dllToLoad); + private static extern nint LoadLibrary(string dllToLoad); [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] - private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); + private static extern nint GetProcAddress(nint dllHandle, string name); #endregion diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 3a4a4da..4dba9ea 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -37,13 +37,13 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/iCUESDK.dll", "x86/CUESDK_2019.dll" }; + public static List PossibleX86NativePaths { get; } = ["x86/iCUESDK.dll", "x86/CUESDK_2019.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll" }; + public static List PossibleX64NativePaths { get; } = ["x64/iCUESDK.dll", "x64/iCUESDK.x64_2019.dll", "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll"]; /// /// Gets or sets the timeout used when connecting to the SDK. diff --git a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs index f37ec87..58e9937 100644 --- a/RGB.NET.Devices.Corsair/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Corsair/Generic/LedMappings.cs @@ -165,7 +165,7 @@ internal static class LedMappings internal static LedMapping CreateMapping(IEnumerable ids, LedId referenceId) { - LedMapping mapping = new(); + LedMapping mapping = []; int counter = 0; foreach (CorsairLedId corsairLedId in ids.OrderBy(x => x)) mapping.Add(referenceId + counter++, corsairLedId); diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs index f598d27..c2005c5 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairDeviceFilter.cs @@ -19,6 +19,7 @@ internal sealed class _CorsairDeviceFilter /// /// iCUE-SDK: mask that describes device types, formed as logical “or” of CorsairDeviceType enum values /// + // ReSharper disable once NotAccessedField.Global internal CorsairDeviceType deviceTypeMask; #endregion diff --git a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs index f82bec2..9f770e8 100644 --- a/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs @@ -38,13 +38,13 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" }; + public static List PossibleX86NativePaths { get; } = ["x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" }; + public static List PossibleX64NativePaths { get; } = ["x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll"]; /// /// Gets the protocol details for the current SDK-connection. @@ -170,7 +170,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider foreach (_CorsairChannelInfo channelInfo in channels) { int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo)); - IntPtr channelDeviceInfoPtr = channelInfo.devices; + nint channelDeviceInfoPtr = channelInfo.devices; for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++) { _CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!; @@ -178,7 +178,7 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue); ledOffset += channelDeviceInfo.deviceLedCount; - channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize); + channelDeviceInfoPtr += channelDeviceInfoStructSize; } } break; @@ -195,13 +195,13 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider _CorsairChannelsInfo? channelsInfo = deviceInfo.channels; if (channelsInfo == null) yield break; - IntPtr channelInfoPtr = channelsInfo.channels; + nint channelInfoPtr = channelsInfo.channels; for (int channel = 0; channel < channelsInfo.channelsCount; channel++) { yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!; int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo)); - channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize); + channelInfoPtr += channelInfoStructSize; } } diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs index c285e5a..cc2b57b 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs @@ -1,7 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global -using System; using System.Linq; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -24,7 +23,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDeviceThe specific information provided by CUE for the custom-device. /// The queue used to update this device. internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue) - : base(info, new LedMapping(), updateQueue) + : base(info, [], updateQueue) { } #endregion @@ -40,7 +39,7 @@ public class CorsairCustomRGBDevice : CorsairRGBDevice 0) diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs index 3664f0d..783089e 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs @@ -41,7 +41,7 @@ public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo /// The offset used to find the LEDs of this device. 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)) + GetModelName(nativeInfo.model == 0 ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo)) { this.LedOffset = ledOffset; diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs index 6282932..a766911 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairDeviceUpdateQueue.cs @@ -40,8 +40,8 @@ public class CorsairDeviceUpdateQueue : UpdateQueue try { int structSize = Marshal.SizeOf(typeof(_CorsairLedColor)); - IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length); - IntPtr addPtr = new(ptr.ToInt64()); + nint ptr = Marshal.AllocHGlobal(structSize * dataSet.Length); + nint addPtr = ptr; try { foreach ((object key, Color color) in dataSet) @@ -55,7 +55,7 @@ public class CorsairDeviceUpdateQueue : UpdateQueue }; Marshal.StructureToPtr(corsairColor, addPtr, false); - addPtr = new IntPtr(addPtr.ToInt64() + structSize); + addPtr += structSize; } _CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr); diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs index f2cd520..8bab4b4 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairProtocolDetails.cs @@ -1,7 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedAutoPropertyAccessor.Global -using System; using System.Runtime.InteropServices; using RGB.NET.Devices.CorsairLegacy.Native; @@ -54,8 +53,8 @@ public class CorsairProtocolDetails /// The native CorsairProtocolDetails-struct internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails) { - this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion); - this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion); + this.SdkVersion = nativeDetails.sdkVersion == 0 ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion); + this.ServerVersion = nativeDetails.serverVersion == 0 ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion); this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion; this.ServerProtocolVersion = nativeDetails.serverProtocolVersion; this.BreakingChanges = nativeDetails.breakingChanges != 0; diff --git a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs index fb9aa2e..e86a92a 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.CorsairLegacy.Native; @@ -50,14 +49,14 @@ public abstract class CorsairRGBDevice : AbstractRGBDevice : AbstractRGBDevice /// Gets the mapping for graphics cards. /// - public static LedMapping GraphicsCard { get; } = new(); + public static LedMapping GraphicsCard { get; } = []; /// /// Gets the mapping for headsets. /// - public static LedMapping HeadsetStand { get; } = new(); + public static LedMapping HeadsetStand { get; } = []; /// /// Gets the mapping for mainboards. /// - public static LedMapping Mainboard { get; } = new(); + public static LedMapping Mainboard { get; } = []; /// /// Gets the mapping for memory. /// - public static LedMapping Memory { get; } = new(); + public static LedMapping Memory { get; } = []; /// /// Gets the mapping for mousepads. /// - public static LedMapping Mousepad { get; } = new(); + public static LedMapping Mousepad { get; } = []; /// /// Gets the mapping for headsets. diff --git a/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs b/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs index e153e7a..0da20e5 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs @@ -7,7 +7,7 @@ internal static class NativeExtensions { internal static Rectangle ToRectangle(this _CorsairLedPosition position) { - //HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0. + //HACK DarthAffe 08.07.2018: It seems like corsair introduced a issue here - it's always 0. float width = position.width < 0.5f ? 10 : (float)position.width; float height = position.height < 0.5f ? 10 : (float)position.height; float posX = (float)position.left; diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs index 718f446..3ace435 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs @@ -16,7 +16,7 @@ internal static class _CUESDK { #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. @@ -29,7 +29,7 @@ internal static class _CUESDK private static void LoadCUESDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -71,23 +71,23 @@ internal static class _CUESDK internal static void UnloadCUESDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; - _corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero; - _corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero; - _corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero; - _corsairSetLayerPriorityPointer = IntPtr.Zero; - _corsairGetDeviceCountPointer = IntPtr.Zero; - _corsairGetDeviceInfoPointer = IntPtr.Zero; - _corsairGetLedIdForKeyNamePointer = IntPtr.Zero; - _corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero; - _corsairRequestControlPointer = IntPtr.Zero; - _corsairReleaseControlPointer = IntPtr.Zero; - _corsairPerformProtocolHandshakePointer = IntPtr.Zero; - _corsairGetLastErrorPointer = IntPtr.Zero; + _corsairSetLedsColorsBufferByDeviceIndexPointer = 0; + _corsairSetLedsColorsFlushBufferPointer = 0; + _corsairGetLedsColorsByDeviceIndexPointer = 0; + _corsairSetLayerPriorityPointer = 0; + _corsairGetDeviceCountPointer = 0; + _corsairGetDeviceInfoPointer = 0; + _corsairGetLedIdForKeyNamePointer = 0; + _corsairGetLedPositionsByDeviceIndexPointer = 0; + _corsairRequestControlPointer = 0; + _corsairReleaseControlPointer = 0; + _corsairPerformProtocolHandshakePointer = 0; + _corsairGetLastErrorPointer = 0; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } #endregion @@ -96,18 +96,18 @@ internal static class _CUESDK #region Pointers - private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer; - private static IntPtr _corsairSetLedsColorsFlushBufferPointer; - private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer; - private static IntPtr _corsairSetLayerPriorityPointer; - private static IntPtr _corsairGetDeviceCountPointer; - private static IntPtr _corsairGetDeviceInfoPointer; - private static IntPtr _corsairGetLedIdForKeyNamePointer; - private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer; - private static IntPtr _corsairRequestControlPointer; - private static IntPtr _corsairReleaseControlPointer; - private static IntPtr _corsairPerformProtocolHandshakePointer; - private static IntPtr _corsairGetLastErrorPointer; + private static nint _corsairSetLedsColorsBufferByDeviceIndexPointer; + private static nint _corsairSetLedsColorsFlushBufferPointer; + private static nint _corsairGetLedsColorsByDeviceIndexPointer; + private static nint _corsairSetLayerPriorityPointer; + private static nint _corsairGetDeviceCountPointer; + private static nint _corsairGetDeviceInfoPointer; + private static nint _corsairGetLedIdForKeyNamePointer; + private static nint _corsairGetLedPositionsByDeviceIndexPointer; + private static nint _corsairRequestControlPointer; + private static nint _corsairReleaseControlPointer; + private static nint _corsairPerformProtocolHandshakePointer; + private static nint _corsairGetLastErrorPointer; #endregion @@ -118,8 +118,8 @@ internal static class _CUESDK /// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer. /// This function does not take logical layout into account. /// - internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors); + internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, nint ledsColors) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors); /// /// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function. @@ -132,8 +132,8 @@ internal static class _CUESDK /// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input. /// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices. /// - internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors); + internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, nint ledsColors) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors); /// /// CUE-SDK: set layer priority for this shared client. @@ -150,12 +150,12 @@ internal static class _CUESDK /// /// CUE-SDK: returns information about device at provided index. /// - internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex); + internal static unsafe nint CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex); /// /// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions. /// - internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex); + internal static unsafe nint CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex); /// /// CUE-SDK: retrieves led id for key name taking logical layout into account. @@ -183,9 +183,9 @@ internal static class _CUESDK /// internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_corsairGetLastErrorPointer))(); - private static IntPtr ThrowIfZero(IntPtr ptr) + private static nint ThrowIfZero(nint ptr) { - if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized."); + if (ptr == 0) throw new RGBDeviceException("The Corsair-SDK is not initialized."); return ptr; } diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs index c30bfe6..82c07b8 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs @@ -3,7 +3,6 @@ #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.CorsairLegacy.Native; @@ -29,5 +28,5 @@ internal class _CorsairChannelInfo /// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device. /// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device. /// - internal IntPtr devices; + internal nint devices; } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs index 61900b9..3dd7d04 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelsInfo.cs @@ -3,7 +3,6 @@ #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.CorsairLegacy.Native; @@ -24,5 +23,5 @@ internal class _CorsairChannelsInfo /// CUE-SDK: array containing information about each separate channel of the DIY-device. /// Index of the channel in the array is same as index of the channel on the DIY-device. /// - internal IntPtr channels; + internal nint channels; } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs index af3c03e..f2f7eb8 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs @@ -3,7 +3,6 @@ #pragma warning disable 649 // Field 'x' is never assigned #pragma warning disable IDE1006 // Naming Styles -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.CorsairLegacy.Native; @@ -23,7 +22,7 @@ internal class _CorsairDeviceInfo /// /// CUE-SDK: null - terminated device model(like “K95RGB”) /// - internal IntPtr model; + internal nint model; /// /// CUE-SDK: enum describing physical layout of the keyboard or mouse diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs index db3d41d..a3f0dbd 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPositions.cs @@ -2,7 +2,6 @@ #pragma warning disable 414 // Field 'x' is assigned but its value never used #pragma warning disable 649 // Field 'x' is never assigned -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.CorsairLegacy.Native; @@ -22,5 +21,5 @@ internal class _CorsairLedPositions /// /// CUE-SDK: array of led positions /// - internal IntPtr pLedPosition; + internal nint pLedPosition; } \ No newline at end of file diff --git a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs index 23a5477..5b85faa 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Native/_CorsairProtocolDetails.cs @@ -2,7 +2,6 @@ #pragma warning disable 414 // Field 'x' is assigned but its value never used #pragma warning disable 649 // Field 'x' is never assigned -using System; using System.Runtime.InteropServices; namespace RGB.NET.Devices.CorsairLegacy.Native; @@ -17,12 +16,12 @@ internal struct _CorsairProtocolDetails /// /// CUE-SDK: null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found /// - internal IntPtr sdkVersion; + internal nint sdkVersion; /// /// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found. /// - internal IntPtr serverVersion; + internal nint serverVersion; /// /// CUE-SDK: integer number that specifies version of protocol that is implemented by current SDK. diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs index d5f2456..b5d725c 100644 --- a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -35,7 +35,7 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider /// /// Gets a list of all defined device-definitions. /// - public List DeviceDefinitions { get; } = new(); + public List DeviceDefinitions { get; } = []; #endregion diff --git a/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs index 8e0934b..b8b8336 100644 --- a/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs +++ b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs @@ -55,7 +55,7 @@ public sealed class E131DMXDeviceDefinition : IDMXDeviceDefinition /// /// Gets or sets the led-mappings used to create the device. /// - public Dictionary getValueFunc)>> Leds { get; } = new(); + public Dictionary getValueFunc)>> Leds { get; } = []; /// /// The time in ms after which the device is updated even if no changes are made in the meantime to prevent the target from timing out or similar problems. diff --git a/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs b/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs index 5ec87df..0700b3f 100644 --- a/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs +++ b/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs @@ -3,5 +3,4 @@ /// /// Marker interface for DMX device definitions. /// -public interface IDMXDeviceDefinition -{ } \ No newline at end of file +public interface IDMXDeviceDefinition; \ No newline at end of file diff --git a/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs index aa1aa29..4f9359f 100644 --- a/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs +++ b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs @@ -5,20 +5,12 @@ using RGB.NET.Core; namespace RGB.NET.Devices.DMX; -internal sealed class LedChannelMapping : IEnumerable<(int channel, Func getValue)> +internal sealed class LedChannelMapping(List<(int channel, Func getValue)> mappings) + : IEnumerable<(int channel, Func getValue)> { #region Properties & Fields - private readonly List<(int channel, Func getValue)> _mappings; - - #endregion - - #region Constructors - - public LedChannelMapping(List<(int channel, Func getValue)> mappings) - { - this._mappings = new List<(int channel, Func getValue)>(mappings); - } + private readonly List<(int channel, Func getValue)> _mappings = [..mappings]; #endregion diff --git a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs index 836c6db..636e57f 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceProvider.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceProvider.cs @@ -32,7 +32,7 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider } } - private List<(IDeviceLayout layout, Action>? updateLedsAction)> _fakeDeviceDefinitions = new(); + private readonly List<(IDeviceLayout layout, Action>? updateLedsAction)> _fakeDeviceDefinitions = []; #endregion diff --git a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs index 2789821..df86acc 100644 --- a/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs +++ b/RGB.NET.Devices.Debug/DebugDeviceUpdateQueue.cs @@ -3,16 +3,8 @@ using RGB.NET.Core; namespace RGB.NET.Devices.Debug; -internal sealed class DebugDeviceUpdateQueue : UpdateQueue +internal sealed class DebugDeviceUpdateQueue() : UpdateQueue(new DeviceUpdateTrigger()) { - #region Constructors - - public DebugDeviceUpdateQueue() - : base(new DeviceUpdateTrigger()) - { } - - #endregion - #region Methods protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) => true; diff --git a/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs index 9ff7cc9..4bcdfe3 100644 --- a/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Logitech; /// /// Represents a logitech RGB-device. /// -public interface ILogitechRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface ILogitechRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs index 355e457..de49881 100644 --- a/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs +++ b/RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs @@ -23,20 +23,20 @@ public sealed class LightspeedHIDLoader : IEnumerable RECEIVER_PIDS = new() - { - 0xC539, - 0xC53A, - 0xC541, - 0xC545, - 0xC547 - }; + private static readonly List RECEIVER_PIDS = + [ + 0xC539, + 0xC53A, + 0xC541, + 0xC545, + 0xC547 + ]; #endregion #region Properties & Fields - private readonly Dictionary> _deviceDefinitions = new(); + private readonly Dictionary> _deviceDefinitions = []; /// /// Gets the vendor id used for this loader. @@ -117,7 +117,7 @@ public sealed class LightspeedHIDLoader : IEnumerable map = new(); + Dictionary map = []; if (!deviceUsages.TryGetValue(1, out HidDevice? device) || !device.TryOpen(out HidStream stream)) return map; diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 4a12b39..22411f8 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -40,13 +40,13 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/LogitechLedEnginesWrapper.dll" }; + public static List PossibleX86NativePaths { get; } = ["x86/LogitechLedEnginesWrapper.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/LogitechLedEnginesWrapper.dll" }; + public static List PossibleX64NativePaths { get; } = ["x64/LogitechLedEnginesWrapper.dll"]; private LogitechPerDeviceUpdateQueue? _perDeviceUpdateQueue; private LogitechPerKeyUpdateQueue? _perKeyUpdateQueue; @@ -162,7 +162,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider /// /// Gets the HID-definitions for wireless per-device-devices. /// - public static LightspeedHIDLoader PerDeviceWirelessDeviceDefinitions { get; } = new(); + public static LightspeedHIDLoader PerDeviceWirelessDeviceDefinitions { get; } = []; #endregion diff --git a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs index 76efa36..42ebb6c 100644 --- a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs +++ b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs @@ -17,7 +17,7 @@ internal static class _LogitechGSDK { #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. @@ -30,7 +30,7 @@ internal static class _LogitechGSDK private static void LoadLogitechGSDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -70,21 +70,21 @@ internal static class _LogitechGSDK internal static void UnloadLogitechGSDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; - _logiLedInitPointer = IntPtr.Zero; - _logiLedShutdownPointer = IntPtr.Zero; - _logiLedSetTargetDevicePointer = IntPtr.Zero; - _logiLedGetSdkVersionPointer = IntPtr.Zero; - _lgiLedSaveCurrentLightingPointer = IntPtr.Zero; - _logiLedRestoreLightingPointer = IntPtr.Zero; - _logiLedSetLightingPointer = IntPtr.Zero; - _logiLedSetLightingForKeyWithKeyNamePointer = IntPtr.Zero; - _logiLedSetLightingFromBitmapPointer = IntPtr.Zero; - _logiLedSetLightingForTargetZonePointer = IntPtr.Zero; + _logiLedInitPointer = 0; + _logiLedShutdownPointer = 0; + _logiLedSetTargetDevicePointer = 0; + _logiLedGetSdkVersionPointer = 0; + _lgiLedSaveCurrentLightingPointer = 0; + _logiLedRestoreLightingPointer = 0; + _logiLedSetLightingPointer = 0; + _logiLedSetLightingForKeyWithKeyNamePointer = 0; + _logiLedSetLightingFromBitmapPointer = 0; + _logiLedSetLightingForTargetZonePointer = 0; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } #endregion @@ -93,16 +93,16 @@ internal static class _LogitechGSDK #region Pointers - private static IntPtr _logiLedInitPointer; - private static IntPtr _logiLedShutdownPointer; - private static IntPtr _logiLedSetTargetDevicePointer; - private static IntPtr _logiLedGetSdkVersionPointer; - private static IntPtr _lgiLedSaveCurrentLightingPointer; - private static IntPtr _logiLedRestoreLightingPointer; - private static IntPtr _logiLedSetLightingPointer; - private static IntPtr _logiLedSetLightingForKeyWithKeyNamePointer; - private static IntPtr _logiLedSetLightingFromBitmapPointer; - private static IntPtr _logiLedSetLightingForTargetZonePointer; + private static nint _logiLedInitPointer; + private static nint _logiLedShutdownPointer; + private static nint _logiLedSetTargetDevicePointer; + private static nint _logiLedGetSdkVersionPointer; + private static nint _lgiLedSaveCurrentLightingPointer; + private static nint _logiLedRestoreLightingPointer; + private static nint _logiLedSetLightingPointer; + private static nint _logiLedSetLightingForKeyWithKeyNamePointer; + private static nint _logiLedSetLightingFromBitmapPointer; + private static nint _logiLedSetLightingForTargetZonePointer; #endregion @@ -146,9 +146,9 @@ internal static class _LogitechGSDK internal static unsafe bool LogiLedSetLightingForTargetZone(LogitechDeviceType deviceType, int zone, int redPercentage, int greenPercentage, int bluePercentage) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_logiLedSetLightingForTargetZonePointer))(deviceType, zone, redPercentage, greenPercentage, bluePercentage); - private static IntPtr ThrowIfZero(IntPtr ptr) + private static nint ThrowIfZero(nint ptr) { - if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Logitech-SDK is not initialized."); + if (ptr == 0) throw new RGBDeviceException("The Logitech-SDK is not initialized."); return ptr; } diff --git a/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs index b880753..b6b8361 100644 --- a/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Msi; /// /// Represents a MSI RGB-device. /// -public interface IMsiRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface IMsiRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index 1a305cc..54be621 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -37,13 +37,13 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { "x86/MysticLight_SDK.dll" }; + public static List PossibleX86NativePaths { get; } = ["x86/MysticLight_SDK.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { "x64/MysticLight_SDK.dll" }; + public static List PossibleX64NativePaths { get; } = ["x64/MysticLight_SDK.dll"]; #endregion diff --git a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs index c13ef81..1bc63fd 100644 --- a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs +++ b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs @@ -16,7 +16,7 @@ internal static class _MsiSDK { #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. @@ -29,7 +29,7 @@ internal static class _MsiSDK private static void LoadMsiSDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -75,7 +75,7 @@ internal static class _MsiSDK internal static void UnloadMsiSDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; _initializePointer = null; _getDeviceInfoPointer = null; @@ -93,7 +93,7 @@ internal static class _MsiSDK _getErrorMessagePointer = null; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] diff --git a/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs index 6b8e05c..e59696e 100644 --- a/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Novation; /// /// Represents a novation RGB-device. /// -public interface INovationRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface INovationRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.OpenRGB/Abstract/IOpenRGBDevice.cs b/RGB.NET.Devices.OpenRGB/Abstract/IOpenRGBDevice.cs index 7659d94..1235c90 100644 --- a/RGB.NET.Devices.OpenRGB/Abstract/IOpenRGBDevice.cs +++ b/RGB.NET.Devices.OpenRGB/Abstract/IOpenRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.OpenRGB; /// /// Represents a generic OpenRGB Device. /// -public interface IOpenRGBDevice : IRGBDevice -{ } +public interface IOpenRGBDevice : IRGBDevice; diff --git a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs index 4ad82cc..26b3a2a 100644 --- a/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs +++ b/RGB.NET.Devices.OpenRGB/OpenRGBDeviceProvider.cs @@ -17,7 +17,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider // ReSharper disable once InconsistentNaming private static readonly object _lock = new(); - private readonly List _clients = new(); + private readonly List _clients = []; private static OpenRGBDeviceProvider? _instance; @@ -36,7 +36,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider /// /// Gets a list of all defined device-definitions. /// - public List DeviceDefinitions { get; } = new(); + public List DeviceDefinitions { get; } = []; /// /// Indicates whether all devices will be added, or just the ones with a 'Direct' mode. Defaults to false. diff --git a/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs b/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs index 85c6c0b..937b6b8 100644 --- a/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs +++ b/RGB.NET.Devices.PicoPi/PicoPi/LedMappings.cs @@ -12,7 +12,7 @@ public static class LedMappings /// /// Gets the defautlt offset-mapping. /// - public static LedMapping StripeMapping = new(); + public static LedMapping StripeMapping = []; #endregion diff --git a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs index c799460..ebcdff5 100644 --- a/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs +++ b/RGB.NET.Devices.PicoPi/PicoPiDeviceProvider.cs @@ -49,7 +49,7 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider { PicoPiSDK.HID_BULK_CONTROLLER_PID, RGBDeviceType.LedStripe, "WS2812B-Controller", LedMappings.StripeMapping, 0 }, }; - private readonly List _sdks = new(); + private readonly List _sdks = []; /// /// Gets or sets the endpoint used to update devices. (default ). diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs index 3d63bf0..17b7add 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerChromaLinkUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.CHROMALINK_MAX_LEDS]; @@ -35,14 +35,14 @@ public sealed class RazerChromaLinkUpdateQueue : RazerUpdateQueue _ChromaLinkCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateChromaLinkEffect(_Defines.CHROMALINK_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateChromaLinkEffect(_Defines.CHROMALINK_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs index 35a3871..5ae8b82 100644 --- a/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/IRazerRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Razer; /// /// Represents a razer RGB-device. /// -public interface IRazerRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface IRazerRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Generic/LedMappings.cs b/RGB.NET.Devices.Razer/Generic/LedMappings.cs index 373aae7..d1a3dab 100644 --- a/RGB.NET.Devices.Razer/Generic/LedMappings.cs +++ b/RGB.NET.Devices.Razer/Generic/LedMappings.cs @@ -386,20 +386,20 @@ public static class LedMappings /// /// Gets the mapping for mousepads. /// - public static LedMapping Mousepad { get; } = new(); + public static LedMapping Mousepad { get; } = []; /// /// Gets the mapping for headsets. /// - public static LedMapping Headset { get; } = new(); + public static LedMapping Headset { get; } = []; /// /// Gets the mapping for keypads. /// - public static LedMapping Keypad { get; } = new(); + public static LedMapping Keypad { get; } = []; /// /// Gets the mapping for chroma link devices. /// - public static LedMapping ChromaLink { get; } = new(); + public static LedMapping ChromaLink { get; } = []; } diff --git a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs index 105fee9..615e48b 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerUpdateQueue.cs @@ -34,7 +34,7 @@ public abstract class RazerUpdateQueue : UpdateQueue { try { - IntPtr effectParams = CreateEffectParams(dataSet); + nint effectParams = CreateEffectParams(dataSet); Guid effectId = Guid.NewGuid(); CreateEffect(effectParams, ref effectId); @@ -60,7 +60,7 @@ public abstract class RazerUpdateQueue : UpdateQueue /// /// The parameters of the effect. /// The id this effect is created with. - protected abstract void CreateEffect(IntPtr effectParams, ref Guid effectId); + protected abstract void CreateEffect(nint effectParams, ref Guid effectId); /// public override void Reset() @@ -77,7 +77,7 @@ public abstract class RazerUpdateQueue : UpdateQueue /// /// The data to be updated. /// An pointing to the effect parameter struct. - protected abstract IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet); + protected abstract nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs index 24cc57b..8ddbce3 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerHeadsetUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.HEADSET_MAX_LEDS]; @@ -35,14 +35,14 @@ public sealed class RazerHeadsetUpdateQueue : RazerUpdateQueue _HeadsetCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateHeadsetEffect(_Defines.HEADSET_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateHeadsetEffect(_Defines.HEADSET_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs index b351d5f..68e0f5f 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerKeyboardUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.KEYBOARD_MAX_LEDS]; @@ -34,14 +34,14 @@ public sealed class RazerKeyboardUpdateQueue : RazerUpdateQueue _KeyboardCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateKeyboardEffect(_Defines.KEYBOARD_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateKeyboardEffect(_Defines.KEYBOARD_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs index 9b6908a..7e2470e 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerKeypadUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.KEYPAD_MAX_LEDS]; @@ -34,14 +34,14 @@ public sealed class RazerKeypadUpdateQueue : RazerUpdateQueue _KeypadCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateKeypadEffect(_Defines.KEYPAD_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateKeypadEffect(_Defines.KEYPAD_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs index 22295d0..cbdde12 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerMouseUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.MOUSE_MAX_LEDS]; @@ -34,7 +34,7 @@ public sealed class RazerMouseUpdateQueue : RazerUpdateQueue _MouseCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; @@ -42,7 +42,7 @@ public sealed class RazerMouseUpdateQueue : RazerUpdateQueue /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateMouseEffect(_Defines.MOUSE_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateMouseEffect(_Defines.MOUSE_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs index 57d912a..8f510e4 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs @@ -25,7 +25,7 @@ public sealed class RazerMousepadUpdateQueue : RazerUpdateQueue #region Methods /// - protected override IntPtr CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) + protected override nint CreateEffectParams(in ReadOnlySpan<(object key, Color color)> dataSet) { _Color[] colors = new _Color[_Defines.MOUSEPAD_MAX_LEDS]; @@ -34,14 +34,14 @@ public sealed class RazerMousepadUpdateQueue : RazerUpdateQueue _MousepadCustomEffect effectParams = new() { Color = colors }; - IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); + nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } /// - protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateMousepadEffect(_Defines.MOUSEPAD_EFFECT_ID, effectParams, ref effectId); + protected override void CreateEffect(nint effectParams, ref Guid effectId) => _RazerSDK.CreateMousepadEffect(_Defines.MOUSEPAD_EFFECT_ID, effectParams, ref effectId); #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Native/_Color.cs b/RGB.NET.Devices.Razer/Native/_Color.cs index 6b792a0..c7d2167 100644 --- a/RGB.NET.Devices.Razer/Native/_Color.cs +++ b/RGB.NET.Devices.Razer/Native/_Color.cs @@ -10,11 +10,12 @@ namespace RGB.NET.Devices.Razer.Native; // ReSharper disable once InconsistentNaming [StructLayout(LayoutKind.Sequential, Size = sizeof(uint))] -internal struct _Color +[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Native-naming")] +internal struct _Color(byte red, byte green, byte blue) { #region Properties & Fields - public uint Color; + public uint Color = red + ((uint)green << 8) + ((uint)blue << 16); #endregion @@ -23,11 +24,5 @@ internal struct _Color public _Color(Color color) : this(color.GetR(), color.GetG(), color.GetB()) { } - public _Color(byte red, byte green, byte blue) - : this() - { - Color = red + ((uint)green << 8) + ((uint)blue << 16); - } - #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs index a94143d..4b99cc6 100644 --- a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs +++ b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs @@ -16,7 +16,7 @@ internal static class _RazerSDK { #region Libary Management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; /// /// Reloads the SDK. @@ -29,7 +29,7 @@ internal static class _RazerSDK private static void LoadRazerSDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -71,23 +71,23 @@ internal static class _RazerSDK internal static void UnloadRazerSDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; - _initPointer = IntPtr.Zero; - _unInitPointer = IntPtr.Zero; - _queryDevicePointer = IntPtr.Zero; - _createEffectPointer = IntPtr.Zero; - _createHeadsetEffectPointer = IntPtr.Zero; - _createChromaLinkEffectPointer = IntPtr.Zero; - _createKeyboardEffectPointer = IntPtr.Zero; - _createKeypadEffectPointer = IntPtr.Zero; - _createMouseEffectPointer = IntPtr.Zero; - _createMousepadEffectPointer = IntPtr.Zero; - _setEffectPointer = IntPtr.Zero; - _deleteEffectPointer = IntPtr.Zero; + _initPointer = 0; + _unInitPointer = 0; + _queryDevicePointer = 0; + _createEffectPointer = 0; + _createHeadsetEffectPointer = 0; + _createChromaLinkEffectPointer = 0; + _createKeyboardEffectPointer = 0; + _createKeypadEffectPointer = 0; + _createMouseEffectPointer = 0; + _createMousepadEffectPointer = 0; + _setEffectPointer = 0; + _deleteEffectPointer = 0; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } #endregion @@ -96,18 +96,18 @@ internal static class _RazerSDK #region Pointers - private static IntPtr _initPointer; - private static IntPtr _unInitPointer; - private static IntPtr _queryDevicePointer; - private static IntPtr _createEffectPointer; - private static IntPtr _createHeadsetEffectPointer; - private static IntPtr _createChromaLinkEffectPointer; - private static IntPtr _createKeyboardEffectPointer; - private static IntPtr _createKeypadEffectPointer; - private static IntPtr _createMouseEffectPointer; - private static IntPtr _createMousepadEffectPointer; - private static IntPtr _setEffectPointer; - private static IntPtr _deleteEffectPointer; + private static nint _initPointer; + private static nint _unInitPointer; + private static nint _queryDevicePointer; + private static nint _createEffectPointer; + private static nint _createHeadsetEffectPointer; + private static nint _createChromaLinkEffectPointer; + private static nint _createKeyboardEffectPointer; + private static nint _createKeypadEffectPointer; + private static nint _createMouseEffectPointer; + private static nint _createMousepadEffectPointer; + private static nint _setEffectPointer; + private static nint _deleteEffectPointer; #endregion @@ -128,9 +128,9 @@ internal static class _RazerSDK internal static unsafe RazerError QueryDevice(Guid deviceId, out _DeviceInfo deviceInfo) { int structSize = Marshal.SizeOf(typeof(_DeviceInfo)); - IntPtr deviceInfoPtr = Marshal.AllocHGlobal(structSize); + nint deviceInfoPtr = Marshal.AllocHGlobal(structSize); - RazerError error = ((delegate* unmanaged[Cdecl])ThrowIfZero(_queryDevicePointer))(deviceId, deviceInfoPtr); + RazerError error = ((delegate* unmanaged[Cdecl])ThrowIfZero(_queryDevicePointer))(deviceId, deviceInfoPtr); deviceInfo = (_DeviceInfo)Marshal.PtrToStructure(deviceInfoPtr, typeof(_DeviceInfo))!; Marshal.FreeHGlobal(deviceInfoPtr); @@ -138,26 +138,26 @@ internal static class _RazerSDK return error; } - internal static unsafe RazerError CreateEffect(Guid deviceId, int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createEffectPointer))(deviceId, effectType, param, ref effectId); + internal static unsafe RazerError CreateEffect(Guid deviceId, int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createEffectPointer))(deviceId, effectType, param, ref effectId); - internal static unsafe RazerError CreateHeadsetEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createHeadsetEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateHeadsetEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createHeadsetEffectPointer))(effectType, param, ref effectId); - internal static unsafe RazerError CreateChromaLinkEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createChromaLinkEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateChromaLinkEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createChromaLinkEffectPointer))(effectType, param, ref effectId); - internal static unsafe RazerError CreateKeyboardEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createKeyboardEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateKeyboardEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createKeyboardEffectPointer))(effectType, param, ref effectId); - internal static unsafe RazerError CreateKeypadEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createKeypadEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateKeypadEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createKeypadEffectPointer))(effectType, param, ref effectId); - internal static unsafe RazerError CreateMouseEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createMouseEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateMouseEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createMouseEffectPointer))(effectType, param, ref effectId); - internal static unsafe RazerError CreateMousepadEffect(int effectType, IntPtr param, ref Guid effectId) - => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createMousepadEffectPointer))(effectType, param, ref effectId); + internal static unsafe RazerError CreateMousepadEffect(int effectType, nint param, ref Guid effectId) + => ((delegate* unmanaged[Cdecl])ThrowIfZero(_createMousepadEffectPointer))(effectType, param, ref effectId); internal static unsafe RazerError SetEffect(Guid effectId) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_setEffectPointer))(effectId); @@ -165,9 +165,9 @@ internal static class _RazerSDK internal static unsafe RazerError DeleteEffect(Guid effectId) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_deleteEffectPointer))(effectId); - private static IntPtr ThrowIfZero(IntPtr ptr) + private static nint ThrowIfZero(nint ptr) { - if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Razer-SDK is not initialized."); + if (ptr == 0) throw new RGBDeviceException("The Razer-SDK is not initialized."); return ptr; } diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 9abc8c8..28bd7da 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -39,13 +39,13 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new() { @"%systemroot%\SysWOW64\RzChromaSDK.dll" }; + public static List PossibleX86NativePaths { get; } = [@"%systemroot%\SysWOW64\RzChromaSDK.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new() { @"%systemroot%\System32\RzChromaSDK.dll", @"%systemroot%\System32\RzChromaSDK64.dll" }; + public static List PossibleX64NativePaths { get; } = [@"%systemroot%\System32\RzChromaSDK.dll", @"%systemroot%\System32\RzChromaSDK64.dll"]; /// /// Forces to load the devices represented by the emulator even if they aren't reported to exist. diff --git a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs index 2862e94..c2aa064 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs @@ -15,7 +15,7 @@ internal sealed class Event // ReSharper disable once CollectionNeverQueried.Global [JsonPropertyName("data")] - public Dictionary Data { get; } = new(); + public Dictionary Data { get; } = []; #endregion diff --git a/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs b/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs index d500a53..f0aff23 100644 --- a/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs +++ b/RGB.NET.Devices.SteelSeries/Attribute/APIName.cs @@ -1,19 +1,10 @@ namespace RGB.NET.Devices.SteelSeries; -internal sealed class APIName : System.Attribute +internal sealed class APIName(string name) : System.Attribute { #region Properties & Fields - public string Name { get; set; } - - #endregion - - #region Constructors - - public APIName(string name) - { - this.Name = name; - } + public string Name { get; set; } = name; #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.SteelSeries/Attribute/SteelSeriesEnumExtension.cs b/RGB.NET.Devices.SteelSeries/Attribute/SteelSeriesEnumExtension.cs index aef597b..df89db9 100644 --- a/RGB.NET.Devices.SteelSeries/Attribute/SteelSeriesEnumExtension.cs +++ b/RGB.NET.Devices.SteelSeries/Attribute/SteelSeriesEnumExtension.cs @@ -10,8 +10,8 @@ internal static class SteelSeriesEnumExtension #region Properties & Fields // ReSharper disable InconsistentNaming - private static readonly Dictionary _deviceTypeNames = new(); - private static readonly Dictionary _ledIdNames = new(); + private static readonly Dictionary _deviceTypeNames = []; + private static readonly Dictionary _ledIdNames = []; // ReSharper restore InconsistentNaming #endregion diff --git a/RGB.NET.Devices.SteelSeries/Generic/ISteelSeriesRGBDevice.cs b/RGB.NET.Devices.SteelSeries/Generic/ISteelSeriesRGBDevice.cs index 8694869..736e047 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/ISteelSeriesRGBDevice.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/ISteelSeriesRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.SteelSeries; /// /// Represents a steelseries RGB-device. /// -internal interface ISteelSeriesRGBDevice : IRGBDevice -{ } \ No newline at end of file +internal interface ISteelSeriesRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs index 2d035ff..587c070 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs @@ -21,7 +21,7 @@ public sealed class ArduinoWS2812USBUpdateQueue : SerialConnectionUpdateQueue _dataBuffer = new(); + private readonly Dictionary _dataBuffer = []; #endregion diff --git a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs index 131a879..d4d18f8 100644 --- a/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs +++ b/RGB.NET.Devices.WS281X/Bitwizard/BitwizardWS281XDeviceDefinition.cs @@ -39,7 +39,7 @@ public sealed class BitwizardWS281XDeviceDefinition : IWS281XDeviceDefinition /// /// Gets a list of LED-strips configured on this device. /// - public List<(int pin, int stripLength)> Strips { get; } = new(); + public List<(int pin, int stripLength)> Strips { get; } = []; /// /// Gets or sets the amount of leds controlled by one pin. diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index a78343c..38a51f1 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -23,8 +23,8 @@ public sealed class NodeMCUWS2812USBUpdateQueue : UpdateQueue private HttpClient _httpClient = new(); private UdpClient? _udpClient; - private readonly Dictionary _dataBuffer = new(); - private readonly Dictionary _sequenceNumbers = new(); + private readonly Dictionary _dataBuffer = []; + private readonly Dictionary _sequenceNumbers = []; private readonly Action _sendDataAction; diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index e150028..109877a 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -37,7 +37,7 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider /// // ReSharper disable once CollectionNeverUpdated.Global // ReSharper disable once ReturnTypeCanBeEnumerable.Global - public List DeviceDefinitions { get; } = new(); + public List DeviceDefinitions { get; } = []; #endregion diff --git a/RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs b/RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs index 89ab9b5..c54544b 100644 --- a/RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs @@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Wooting.Generic; /// /// Represents a Wooting RGB-device. /// -public interface IWootingRGBDevice : IRGBDevice -{ } \ No newline at end of file +public interface IWootingRGBDevice : IRGBDevice; \ No newline at end of file diff --git a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs index 0258cf5..cc0018c 100644 --- a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs +++ b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs @@ -15,7 +15,7 @@ internal static class _WootingSDK { #region Library management - private static IntPtr _handle = IntPtr.Zero; + private static nint _handle = 0; internal static object SdkLock = new(); /// @@ -29,7 +29,7 @@ internal static class _WootingSDK private static void LoadWootingSDK() { - if (_handle != IntPtr.Zero) return; + if (_handle != 0) return; List possiblePathList = GetPossibleLibraryPaths().ToList(); @@ -71,21 +71,21 @@ internal static class _WootingSDK internal static void UnloadWootingSDK() { - if (_handle == IntPtr.Zero) return; + if (_handle == 0) return; Close(); - _getDeviceInfoPointer = IntPtr.Zero; - _keyboardConnectedPointer = IntPtr.Zero; - _resetPointer = IntPtr.Zero; - _closePointer = IntPtr.Zero; - _arrayUpdateKeyboardPointer = IntPtr.Zero; - _arraySetSinglePointer = IntPtr.Zero; - _getDeviceCountPointer = IntPtr.Zero; - _selectDevicePointer = IntPtr.Zero; + _getDeviceInfoPointer = 0; + _keyboardConnectedPointer = 0; + _resetPointer = 0; + _closePointer = 0; + _arrayUpdateKeyboardPointer = 0; + _arraySetSinglePointer = 0; + _getDeviceCountPointer = 0; + _selectDevicePointer = 0; NativeLibrary.Free(_handle); - _handle = IntPtr.Zero; + _handle = 0; } #endregion @@ -94,18 +94,18 @@ internal static class _WootingSDK #region Pointers - private static IntPtr _getDeviceInfoPointer; - private static IntPtr _keyboardConnectedPointer; - private static IntPtr _resetPointer; - private static IntPtr _closePointer; - private static IntPtr _arrayUpdateKeyboardPointer; - private static IntPtr _arraySetSinglePointer; - private static IntPtr _getDeviceCountPointer; - private static IntPtr _selectDevicePointer; + private static nint _getDeviceInfoPointer; + private static nint _keyboardConnectedPointer; + private static nint _resetPointer; + private static nint _closePointer; + private static nint _arrayUpdateKeyboardPointer; + private static nint _arraySetSinglePointer; + private static nint _getDeviceCountPointer; + private static nint _selectDevicePointer; #endregion - internal static unsafe IntPtr GetDeviceInfo() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_getDeviceInfoPointer))(); + internal static unsafe nint GetDeviceInfo() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_getDeviceInfoPointer))(); internal static unsafe bool KeyboardConnected() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_keyboardConnectedPointer))(); internal static unsafe bool Reset() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_resetPointer))(); internal static unsafe bool Close() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_closePointer))(); @@ -115,9 +115,9 @@ internal static class _WootingSDK internal static unsafe byte GetDeviceCount() => ((delegate* unmanaged[Cdecl])ThrowIfZero(_getDeviceCountPointer))(); internal static unsafe void SelectDevice(byte index) => ((delegate* unmanaged[Cdecl])ThrowIfZero(_selectDevicePointer))(index); - private static IntPtr ThrowIfZero(IntPtr ptr) + private static nint ThrowIfZero(nint ptr) { - if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Wooting-SDK is not initialized."); + if (ptr == 0) throw new RGBDeviceException("The Wooting-SDK is not initialized."); return ptr; } diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index c92661f..8b36ff7 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -38,26 +38,26 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications. /// The first match will be used. /// - public static List PossibleX86NativePathsWindows { get; } = new() { "x86/wooting-rgb-sdk.dll" }; + public static List PossibleX86NativePathsWindows { get; } = ["x86/wooting-rgb-sdk.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 windows applications. /// The first match will be used. /// - public static List PossibleX64NativePathsWindows { get; } = new() { "x64/wooting-rgb-sdk64.dll" }; + public static List PossibleX64NativePathsWindows { get; } = ["x64/wooting-rgb-sdk64.dll"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 linux applications. /// The first match will be used. /// - public static List PossibleNativePathsLinux { get; } = new() { "x64/libwooting-rgb-sdk.so" }; + public static List PossibleNativePathsLinux { get; } = ["x64/libwooting-rgb-sdk.so"]; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 MacOS applications. /// The first match will be used. /// // ReSharper disable once InconsistentNaming - public static List PossibleNativePathsMacOS { get; } = new() { "x64/libwooting-rgb-sdk.dylib" }; + public static List PossibleNativePathsMacOS { get; } = ["x64/libwooting-rgb-sdk.dylib"]; #endregion diff --git a/RGB.NET.HID/HIDLoader.cs b/RGB.NET.HID/HIDLoader.cs index b39df67..987618d 100644 --- a/RGB.NET.HID/HIDLoader.cs +++ b/RGB.NET.HID/HIDLoader.cs @@ -24,7 +24,7 @@ public sealed class HIDLoader : IEnumerable> _deviceDefinitions = new(); + private readonly Dictionary> _deviceDefinitions = []; /// /// Gets the vendor id used for this loader. diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs index e33e760..adf769d 100644 --- a/RGB.NET.Layout/DeviceLayout.cs +++ b/RGB.NET.Layout/DeviceLayout.cs @@ -92,7 +92,7 @@ public class DeviceLayout : IDeviceLayout /// Normally you should use to access this data. /// [XmlArray("Leds")] - public List InternalLeds { get; set; } = new(); + public List InternalLeds { get; set; } = []; /// /// Gets or sets a list of representing all the of the . diff --git a/RGB.NET.Layout/LayoutExtension.cs b/RGB.NET.Layout/LayoutExtension.cs index 0426e3b..0c5383c 100644 --- a/RGB.NET.Layout/LayoutExtension.cs +++ b/RGB.NET.Layout/LayoutExtension.cs @@ -24,7 +24,7 @@ public static class LayoutExtension device.Size = new Size(layout.Width, layout.Height); device.DeviceInfo.LayoutMetadata = layout.CustomData; - HashSet ledIds = new(); + HashSet ledIds = []; foreach (ILedLayout layoutLed in layout.Leds) { if (Enum.TryParse(layoutLed.Id, true, out LedId ledId)) diff --git a/RGB.NET.Presets/Decorators/IGradientDecorator.cs b/RGB.NET.Presets/Decorators/IGradientDecorator.cs index 9373e4e..7563176 100644 --- a/RGB.NET.Presets/Decorators/IGradientDecorator.cs +++ b/RGB.NET.Presets/Decorators/IGradientDecorator.cs @@ -6,5 +6,4 @@ namespace RGB.NET.Presets.Decorators; /// /// Represents a basic decorator decorating a . /// -public interface IGradientDecorator : IDecorator -{ } \ No newline at end of file +public interface IGradientDecorator : IDecorator; \ No newline at end of file diff --git a/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs b/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs index 50c5142..b8a54af 100644 --- a/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs @@ -24,7 +24,7 @@ public abstract class AbstractGradient : AbstractDecoratable /// /// Gets a list of the stops used by this . /// - public ObservableCollection GradientStops { get; } = new(); + public ObservableCollection GradientStops { get; } = []; private bool _wrapGradient; /// diff --git a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs index 18fa252..e756a0b 100644 --- a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs +++ b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs @@ -16,7 +16,7 @@ public sealed class LinearGradient : AbstractGradient #region Properties & Fields private bool _isOrderedGradientListDirty = true; - private readonly List _orderedGradientStops = new(); + private readonly List _orderedGradientStops = []; #endregion diff --git a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs index 322eb5c..da9159a 100644 --- a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs +++ b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs @@ -172,7 +172,7 @@ public static class SimplexNoise // Add contributions from each corner to get the final noise value. // The result is scaled to return values in the interval [-1,1]. - return 40.0f * (n0 + n1 + n2); // TODO: The scale factor is preliminary! + return 40.0f * (n0 + n1 + n2); } @@ -276,7 +276,7 @@ public static class SimplexNoise // Add contributions from each corner to get the final noise value. // The result is scaled to stay just inside [-1,1] - return 32.0f * (n0 + n1 + n2 + n3); // TODO: The scale factor is preliminary! + return 32.0f * (n0 + n1 + n2 + n3); } private static byte[] _perm; From cc2c7bc973607245fdbecdb4c31da1270783732e Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Fri, 22 Dec 2023 23:14:55 +0000 Subject: [PATCH 95/96] Added tag-creation to ci workflow --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db64c8c..c4091ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,3 +64,9 @@ jobs: run: dotnet nuget push **\*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json - name: Symbols Push run: dotnet nuget push **\*.snupkg --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json + - name: Create Tag + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ steps.versioning.outputs.version }} + tag_prefix: v From aeab93001f128e9f198179c4b3b2f6d4035680c2 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 27 Dec 2023 15:48:20 +0100 Subject: [PATCH 96/96] More code styling fixes --- RGB.NET.Core/Decorators/AbstractDecorator.cs | 2 +- RGB.NET.Core/Extensions/RectangleExtensions.cs | 13 +++++++------ RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs | 2 +- .../Generic/RGBColorUpdateQueue.cs | 6 +++--- .../Helper/ColorExtensions.cs | 2 +- .../Arduino/ArduinoWS2812USBUpdateQueue.cs | 8 ++++---- RGB.NET.Layout/LayoutExtension.cs | 8 ++++---- Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs | 7 ++++--- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/RGB.NET.Core/Decorators/AbstractDecorator.cs b/RGB.NET.Core/Decorators/AbstractDecorator.cs index f9c7059..2043ef6 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorator.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorator.cs @@ -53,7 +53,7 @@ public abstract class AbstractDecorator : AbstractBindable, IDecorator && (t.Name == typeof(IDecoratable<>).Name) && t.GenericTypeArguments[0].IsInstanceOfType(this)); foreach (Type decoratableType in types) - decoratableType.GetMethod(nameof(IDecoratable.RemoveDecorator))?.Invoke(decoratable, new object[] { this }); + decoratableType.GetMethod(nameof(IDecoratable.RemoveDecorator))?.Invoke(decoratable, [this]); } } diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs index 68fec32..c97256f 100644 --- a/RGB.NET.Core/Extensions/RectangleExtensions.cs +++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs @@ -151,12 +151,13 @@ public static class RectangleExtensions /// A array of containing the new locations of the corners of the original rectangle. public static Point[] Rotate(this in Rectangle rect, in Rotation rotation, in Point origin = new()) { - Point[] points = { - rect.Location, // top left - new(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right - new(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right - new(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right - }; + Point[] points = + [ + rect.Location, // top left + new Point(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right + new Point(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right + new Point(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right + ]; float sin = MathF.Sin(rotation.Radians); float cos = MathF.Cos(rotation.Radians); diff --git a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs index 7ebdab8..600a1ea 100644 --- a/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs +++ b/RGB.NET.Devices.DMX/E131/E131UpdateQueue.cs @@ -21,7 +21,7 @@ public sealed class E131UpdateQueue : UpdateQueue /// Gets the byte-representation of a E1.31 packet as described in http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf. /// CID, SequenceNumber, Universe and PropertyValues needs to be updated before use! /// - internal byte[] DataPacket { get; } = { 0x00, 0x10, 0x00, 0x00, 0x41, 0x53, 0x43, 0x2D, 0x45, 0x31, 0x2E, 0x31, 0x37, 0x00, 0x00, 0x00, 0x72, 0x6E, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x72, 0x0B, 0x02, 0xA1, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + internal byte[] DataPacket { get; } = [0x00, 0x10, 0x00, 0x00, 0x41, 0x53, 0x43, 0x2D, 0x45, 0x31, 0x2E, 0x31, 0x37, 0x00, 0x00, 0x00, 0x72, 0x6E, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x72, 0x0B, 0x02, 0xA1, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; /// /// The sequence-number used to detect the order in which packages where sent. diff --git a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs index 6279593..aa3f53d 100644 --- a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs @@ -12,7 +12,7 @@ public sealed class RGBColorUpdateQueue : MidiUpdateQueue #region Properties & Fields private static readonly (Color, int)[] COLOR_PALETTE = - { + [ (new Color(0, 0, 0), 0), (new Color(28, 28, 28), 1), (new Color(124, 124, 124), 2), @@ -130,8 +130,8 @@ public sealed class RGBColorUpdateQueue : MidiUpdateQueue (new Color(0, 64, 0), 123), (new Color(61, 48, 0), 125), (new Color(180, 93, 0), 126), - (new Color(74, 20, 0), 127), - }; + (new Color(74, 20, 0), 127) + ]; #endregion diff --git a/RGB.NET.Devices.SteelSeries/Helper/ColorExtensions.cs b/RGB.NET.Devices.SteelSeries/Helper/ColorExtensions.cs index b101ff7..501156e 100644 --- a/RGB.NET.Devices.SteelSeries/Helper/ColorExtensions.cs +++ b/RGB.NET.Devices.SteelSeries/Helper/ColorExtensions.cs @@ -4,5 +4,5 @@ namespace RGB.NET.Devices.SteelSeries.Helper; internal static class ColorExtensions { - internal static int[] ToIntArray(this Color color) => new int[] { color.GetR(), color.GetG(), color.GetB() }; + internal static int[] ToIntArray(this Color color) => [color.GetR(), color.GetG(), color.GetB()]; } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs index 587c070..c6b1c00 100644 --- a/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/Arduino/ArduinoWS2812USBUpdateQueue.cs @@ -13,9 +13,9 @@ public sealed class ArduinoWS2812USBUpdateQueue : SerialConnectionUpdateQueue 0) diff --git a/RGB.NET.Layout/LayoutExtension.cs b/RGB.NET.Layout/LayoutExtension.cs index 0c5383c..d336e14 100644 --- a/RGB.NET.Layout/LayoutExtension.cs +++ b/RGB.NET.Layout/LayoutExtension.cs @@ -77,13 +77,13 @@ public static class LayoutExtension Type[] customTypes; if ((customDataType != null) && (customLedDataType != null)) - customTypes = new[] { customDataType, customLedDataType }; + customTypes = [customDataType, customLedDataType]; else if (customDataType != null) - customTypes = new[] { customDataType }; + customTypes = [customDataType]; else if (customLedDataType != null) - customTypes = new[] { customLedDataType }; + customTypes = [customLedDataType]; else - customTypes = Array.Empty(); + customTypes = []; if (layout is DeviceLayout deviceLayout) { diff --git a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs index da9159a..a55592d 100644 --- a/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs +++ b/Tests/RGB.NET.Core.Tests/Helper/SimplexNoise.cs @@ -66,7 +66,7 @@ public static class SimplexNoise else { _perm = new byte[512]; - Random random = new Random(value); + Random random = new(value); random.NextBytes(_perm); } @@ -281,7 +281,8 @@ public static class SimplexNoise private static byte[] _perm; - private static readonly byte[] PermOriginal = { + private static readonly byte[] PermOriginal = + [ 151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, @@ -308,7 +309,7 @@ public static class SimplexNoise 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 - }; + ]; private static int FastFloor(float x) {