From 9175887327308d05337a48f190008fec186325fb Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sat, 20 Jun 2020 22:30:55 +0200 Subject: [PATCH 1/4] Throw on LED control enable fail Added devices indices for MM830, CK530 and MK850 --- .../CoolerMasterDeviceProvider.cs | 3 ++- .../Enum/CoolerMasterDevicesIndexes.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 0f34084..05546aa 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -132,7 +132,8 @@ namespace RGB.NET.Devices.CoolerMaster continue; } - _CoolerMasterSDK.EnableLedControl(true, index); + if (!_CoolerMasterSDK.EnableLedControl(true, index)) + throw new RGBDeviceException("Failed to enable LED control for device " + index); device.Initialize(UpdateTrigger); devices.Add(device); diff --git a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs index cf84cbc..45d8ae2 100644 --- a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs +++ b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterDevicesIndexes.cs @@ -69,6 +69,18 @@ namespace RGB.NET.Devices.CoolerMaster [DeviceType(RGBDeviceType.Keyboard)] CK551 = 13, + [Description("MM830")] + [DeviceType(RGBDeviceType.Mouse)] + MM830 = 14, + + [Description("CK530")] + [DeviceType(RGBDeviceType.Keyboard)] + CK530 = 15, + + [Description("MK850")] + [DeviceType(RGBDeviceType.Keyboard)] + MK850 = 16, + [DeviceType(RGBDeviceType.None)] Default = 0xFFFF } From 52fd670ba7ed5e92d6e1a2c94561001eea1d0f8c Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 8 Jul 2020 21:24:56 +0200 Subject: [PATCH 2/4] Improved usabillity of decorators a bit --- .../Decorators/AbstractDecorateable.cs | 17 +++++++---------- RGB.NET.Core/Decorators/AbstractDecorator.cs | 19 +++++++++++-------- RGB.NET.Core/Decorators/IDecoratable.cs | 10 ++++++++-- RGB.NET.Decorators/Brush/FlashDecorator.cs | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/RGB.NET.Core/Decorators/AbstractDecorateable.cs b/RGB.NET.Core/Decorators/AbstractDecorateable.cs index 94b8f05..d12afcd 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorateable.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorateable.cs @@ -12,18 +12,15 @@ namespace RGB.NET.Core #region Properties & Fields private readonly List _decorators = new List(); - /// - /// Gets a readonly-list of all attached to this . - /// - protected IReadOnlyCollection Decorators { get; } - #endregion - - #region Constructors - - protected AbstractDecoratable() + /// + public IReadOnlyCollection Decorators { - Decorators = new ReadOnlyCollection(_decorators); + get + { + lock (_decorators) + return new ReadOnlyCollection(_decorators); + } } #endregion diff --git a/RGB.NET.Core/Decorators/AbstractDecorator.cs b/RGB.NET.Core/Decorators/AbstractDecorator.cs index 381f4f5..50e007c 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorator.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorator.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; namespace RGB.NET.Core { @@ -42,16 +44,17 @@ namespace RGB.NET.Core /// /// Detaches the decorator from all it is currently attached to. /// - /// The type of the this decorator is attached to. - /// The type of this . - protected virtual void Detach() - where TDecoratable : IDecoratable - where TDecorator : AbstractDecorator + protected virtual void Detach() { List decoratables = new List(DecoratedObjects); foreach (IDecoratable decoratable in decoratables) - if (decoratable is TDecoratable typedDecoratable) - typedDecoratable.RemoveDecorator((TDecorator)this); + { + IEnumerable types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType + && (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 }); + } } #endregion diff --git a/RGB.NET.Core/Decorators/IDecoratable.cs b/RGB.NET.Core/Decorators/IDecoratable.cs index 9e2a32c..781d9f1 100644 --- a/RGB.NET.Core/Decorators/IDecoratable.cs +++ b/RGB.NET.Core/Decorators/IDecoratable.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; namespace RGB.NET.Core { @@ -13,9 +14,14 @@ namespace RGB.NET.Core /// Represents a basic decoratable for a specific type of /// /// - public interface IDecoratable : IDecoratable + public interface IDecoratable : IDecoratable where T : IDecorator { + /// + /// Gets a readonly-list of all attached to this . + /// + IReadOnlyCollection Decorators { get; } + /// /// Adds an to the . /// diff --git a/RGB.NET.Decorators/Brush/FlashDecorator.cs b/RGB.NET.Decorators/Brush/FlashDecorator.cs index 618b243..580fce4 100644 --- a/RGB.NET.Decorators/Brush/FlashDecorator.cs +++ b/RGB.NET.Decorators/Brush/FlashDecorator.cs @@ -129,7 +129,7 @@ namespace RGB.NET.Decorators.Brush else { if ((++_repetitionCount >= Repetitions) && (Repetitions > 0)) - Detach(); + Detach(); _currentPhaseValue = Attack; _currentPhase = ADSRPhase.Attack; } From 6696f2278aa7b68f1228b82a516f7741d027ccdd Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Wed, 8 Jul 2020 22:52:17 +0200 Subject: [PATCH 3/4] MSI - Provide sender when calling PathHelper.GetAbsolutePath --- RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs | 2 +- RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs | 2 +- RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs index f5cf4e4..74bd673 100644 --- a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs @@ -41,7 +41,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs index a7e11cb..455e63a 100644 --- a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs @@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs index a153190..bbcbd57 100644 --- a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs @@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// From 567247de592396c236bc8e23491e6d58bb4d79d7 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Wed, 8 Jul 2020 22:52:17 +0200 Subject: [PATCH 4/4] MSI - Provide sender when calling PathHelper.GetAbsolutePath --- RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs | 2 +- RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs | 2 +- RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs index f5cf4e4..74bd673 100644 --- a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs @@ -41,7 +41,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs index a7e11cb..455e63a 100644 --- a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs @@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs index a153190..bbcbd57 100644 --- a/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs @@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi } //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } ///