From 5cb5962c1ea6bd616d61dfb380e333194e546803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ayta=C3=A7=20Kayadelen?= Date: Wed, 14 Jun 2023 22:41:07 +0200 Subject: [PATCH 1/3] remove System.Management dependency --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 2 +- RGB.NET.Devices.Asus/Helper/WMIHelper.cs | 82 ------------------- .../Keyboard/AsusKeyboardRGBDeviceInfo.cs | 11 +-- .../RGB.NET.Devices.Asus.csproj | 4 - 4 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 RGB.NET.Devices.Asus/Helper/WMIHelper.cs diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index e3b093c..1f0784e 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -63,7 +63,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider yield return (AsusDeviceType)device.Type switch { - AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()), + AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, 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()), diff --git a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs b/RGB.NET.Devices.Asus/Helper/WMIHelper.cs deleted file mode 100644 index 482f3a3..0000000 --- a/RGB.NET.Devices.Asus/Helper/WMIHelper.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Management; - -namespace RGB.NET.Devices.Asus; - -// ReSharper disable once InconsistentNaming -internal static class WMIHelper -{ - #region Properties & Fields - - // ReSharper disable InconsistentNaming - private static readonly ManagementObjectSearcher? _systemModelSearcher; - private static readonly ManagementObjectSearcher? _mainboardSearcher; - private static readonly ManagementObjectSearcher? _graphicsCardSearcher; - // ReSharper restore InconsistentNaming - - private static string? _systemModelInfo; - private static (string manufacturer, string model)? _mainboardInfo; - private static string? _graphicsCardInfo; - - #endregion - - #region Constructors - - static WMIHelper() - { - if (OperatingSystem.IsWindows()) - { - _systemModelSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Model FROM Win32_ComputerSystem"); - _mainboardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Manufacturer,Product FROM Win32_BaseBoard"); - _graphicsCardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_VideoController"); - } - } - - #endregion - - #region Methods - - internal static string? GetSystemModelInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if ((_systemModelInfo == null) && (_systemModelSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get()) - { - _systemModelInfo = managementBaseObject["Model"].ToString(); - break; - } - - return _systemModelInfo; - } - - internal static (string manufacturer, string model)? GetMainboardInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if (!_mainboardInfo.HasValue && (_mainboardSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get()) - { - _mainboardInfo = (managementBaseObject["Manufacturer"].ToString() ?? string.Empty, managementBaseObject["Product"].ToString() ?? string.Empty); - break; - } - - return _mainboardInfo; - } - - internal static string? GetGraphicsCardsInfo() - { - if (!OperatingSystem.IsWindows()) return null; - - if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null)) - foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get()) - { - _graphicsCardInfo = managementBaseObject["Name"].ToString(); - break; - } - - return _graphicsCardInfo; - } - - #endregion -} \ No newline at end of file diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index b40ec59..b99688a 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using AuraServiceLib; +using AuraServiceLib; using RGB.NET.Core; namespace RGB.NET.Devices.Asus; @@ -11,12 +10,6 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi { #region Properties & Fields - /// - /// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well. - /// Keep a list of those and rely on to get the real model - /// - private static readonly List GENERIC_DEVICE_NAMES = new() { "NotebookKeyboard" }; - /// public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; @@ -37,7 +30,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi #region Methods - private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName; + private static string? GetKeyboardModel(string deviceName) => deviceName; #endregion } \ 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 dc67689..6d14d24 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -56,10 +56,6 @@ - - - - From 1bd5b54892344399fa216ea17eb0897e7d4c8397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ayta=C3=A7=20Kayadelen?= Date: Wed, 6 Dec 2023 22:19:43 +0100 Subject: [PATCH 2/3] pull --- RGB.NET.Devices.Asus/AsusDeviceProvider.cs | 2 +- .../Keyboard/AsusKeyboardRGBDeviceInfo.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index f939cb5..5515bc1 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -76,7 +76,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider yield return (AsusDeviceType)device.Type switch { - AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, device.Name), GetUpdateTrigger()), + AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, "Asus Motherboard"), 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()), diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index b99688a..f86a766 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -1,4 +1,5 @@ -using AuraServiceLib; +using System.Collections.Generic; +using AuraServiceLib; using RGB.NET.Core; namespace RGB.NET.Devices.Asus; @@ -10,6 +11,11 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi { #region Properties & Fields + /// + /// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well. + /// + private static readonly List GENERIC_DEVICE_NAMES = new() { "NotebookKeyboard" }; + /// public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; @@ -30,7 +36,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi #region Methods - private static string? GetKeyboardModel(string deviceName) => deviceName; + private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Motherboard" : deviceName; #endregion } \ No newline at end of file From 54c09a1d6fb19183e7c65e5ea3744784f36a703e Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sun, 20 Oct 2024 11:23:23 +0200 Subject: [PATCH 3/3] Fixed default name for Asus Keyboards --- RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index 608405f..8516bec 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -36,7 +36,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi #region Methods - private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Motherboard" : deviceName; + private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Keyboard" : deviceName; #endregion } \ No newline at end of file