From 074fcc820337f2cb242069afeeff6775a9f5e8dc Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 17 Dec 2020 16:29:01 +0100 Subject: [PATCH] Removed legacy Asus-Project --- .../AsusDeviceProvider.cs | 280 -------------- .../AsusDeviceProviderLoader.cs | 24 -- .../Dram/AsusDramRGBDevice.cs | 56 --- .../Dram/AsusDramRGBDeviceInfo.cs | 33 -- .../Enum/AsusLogicalKeyboardLayout.cs | 15 - .../Enum/AsusPhysicalKeyboardLayout.cs | 15 - .../Generic/AsusRGBDevice.cs | 94 ----- .../Generic/AsusRGBDeviceInfo.cs | 63 ---- .../Generic/AsusUpdateQueue.cs | 70 ---- .../Generic/IAsusRGBDevice.cs | 12 - .../GraphicsCard/AsusGraphicsCardRGBDevice.cs | 48 --- .../AsusGraphicsCardRGBDeviceInfo.cs | 33 -- .../Helper/WMIHelper.cs | 63 ---- .../Keyboard/AsusKeyboardRGBDevice.cs | 48 --- .../Keyboard/AsusKeyboardRGBDeviceInfo.cs | 63 ---- .../Mainboard/AsusMainboardRGBDevice.cs | 56 --- .../Mainboard/AsusMainboardRGBDeviceInfo.cs | 33 -- .../Mouse/AsusMouseRGBDevice.cs | 47 --- .../Mouse/AsusMouseRGBDeviceInfo.cs | 33 -- .../Native/_AsusSDK.cs | 341 ------------------ .../RGB.NET.Devices.Asus_Legacy.csproj | 56 --- ...NET.Devices.Asus_Legacy.csproj.DotSettings | 10 - RGB.NET.sln | 7 - 23 files changed, 1500 deletions(-) delete mode 100644 RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/AsusDeviceProviderLoader.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Enum/AsusLogicalKeyboardLayout.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Enum/AsusPhysicalKeyboardLayout.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Generic/AsusUpdateQueue.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Generic/IAsusRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Helper/WMIHelper.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDeviceInfo.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs delete mode 100644 RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj delete mode 100644 RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj.DotSettings diff --git a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs deleted file mode 100644 index 6dbae09..0000000 --- a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs +++ /dev/null @@ -1,280 +0,0 @@ -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedMember.Global - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Globalization; -using System.Runtime.InteropServices; -using RGB.NET.Core; -using RGB.NET.Devices.Asus.Native; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a device provider responsible for Cooler Master devices. - /// - [Obsolete("Use this only if you need syncback-capability")] - public class AsusDeviceProvider : IRGBDeviceProvider - { - #region Properties & Fields - - private static AsusDeviceProvider _instance; - /// - /// Gets the singleton instance. - /// - public static AsusDeviceProvider Instance => _instance ?? new AsusDeviceProvider(); - - /// - /// 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 List { "x86/AURA_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 List { }; - - /// - /// - /// Indicates if the SDK is initialized and ready to use. - /// - public bool IsInitialized { get; private set; } - - /// - /// Gets the loaded architecture (x64/x86). - /// - public string LoadedArchitecture => _AsusSDK.LoadedArchitecture; - - /// - /// - /// Gets whether the application has exclusive access to the SDK or not. - /// - public bool HasExclusiveAccess { get; private set; } - - /// - public IEnumerable Devices { get; private set; } - - /// - /// Gets or sets a function to get the culture for a specific device. - /// - // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global - public Func GetCulture { get; set; } = CultureHelper.GetCurrentCulture; - - /// - /// The used to trigger the updates for asus devices. - /// - public DeviceUpdateTrigger UpdateTrigger { get; private set; } - - #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 AsusDeviceProvider() - { - if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}"); - _instance = this; - - UpdateTrigger = new DeviceUpdateTrigger(); - } - - #endregion - - #region Methods - - /// - public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false) - { - IsInitialized = false; - - try - { - UpdateTrigger?.Stop(); - - _AsusSDK.Reload(); - - IList devices = new List(); - - #region Mainboard - - if (loadFilter.HasFlag(RGBDeviceType.Mainboard)) - try - { - //TODO DarthAffe 26.11.2017: This is not a fix! There might really be a second controller on the mainboard, but for now this should prevent the random crash for some guys. - // DarthAffe 26.11.2017: https://rog.asus.com/forum/showthread.php?97754-Access-Violation-Wrong-EnumerateMB-Result&p=688901#post688901 - int mainboardCount = Math.Min(1, _AsusSDK.EnumerateMbController(IntPtr.Zero, 0)); - if (mainboardCount > 0) - { - IntPtr mainboardHandles = Marshal.AllocHGlobal(mainboardCount * IntPtr.Size); - _AsusSDK.EnumerateMbController(mainboardHandles, mainboardCount); - - for (int i = 0; i < mainboardCount; i++) - { - try - { - IntPtr handle = Marshal.ReadIntPtr(mainboardHandles, i); - _AsusSDK.SetMbMode(handle, 1); - AsusMainboardRGBDevice device = new AsusMainboardRGBDevice(new AsusMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle)); - device.Initialize(UpdateTrigger); - devices.Add(device); - } - catch { if (throwExceptions) throw; } - } - } - } - catch { if (throwExceptions) throw; } - - #endregion - - #region Graphics cards - - //TODO DarthAffe 21.10.2017: This somehow returns non-existant gpus (at least for me) which cause huge lags (if a real asus-ready gpu is connected this doesn't happen) - - if (loadFilter.HasFlag(RGBDeviceType.GraphicsCard)) - try - { - int graphicCardCount = _AsusSDK.EnumerateGPU(IntPtr.Zero, 0); - if (graphicCardCount > 0) - { - IntPtr grapicsCardHandles = Marshal.AllocHGlobal(graphicCardCount * IntPtr.Size); - _AsusSDK.EnumerateGPU(grapicsCardHandles, graphicCardCount); - - for (int i = 0; i < graphicCardCount; i++) - { - try - { - IntPtr handle = Marshal.ReadIntPtr(grapicsCardHandles, i); - _AsusSDK.SetGPUMode(handle, 1); - AsusGraphicsCardRGBDevice device = new AsusGraphicsCardRGBDevice(new AsusGraphicsCardRGBDeviceInfo(RGBDeviceType.GraphicsCard, handle)); - device.Initialize(UpdateTrigger); - devices.Add(device); - } - catch { if (throwExceptions) throw; } - } - } - } - catch { if (throwExceptions) throw; } - - #endregion - - #region DRAM - - //TODO DarthAffe 29.10.2017: I don't know why they are even documented, but the asus guy said they aren't in the SDK right now. - //try - //{ - //int dramCount = _AsusSDK.EnumerateDram(IntPtr.Zero, 0); - //if (dramCount > 0) - //{ - // IntPtr dramHandles = Marshal.AllocHGlobal(dramCount * IntPtr.Size); - // _AsusSDK.EnumerateDram(dramHandles, dramCount); - - // for (int i = 0; i < dramCount; i++) - // { - //try - //{ - // IntPtr handle = Marshal.ReadIntPtr(dramHandles, i); - // _AsusSDK.SetDramMode(handle, 1); - // AsusDramRGBDevice device = new AsusDramRGBDevice(new AsusDramRGBDeviceInfo(RGBDeviceType.DRAM, handle)); - // device.Initialize(UpdateTrigger); - // devices.Add(device); - // } - //catch { if (throwExceptions) throw; } - // } - //} - //} - // catch { if (throwExceptions) throw; } - - #endregion - - #region Keyboard - - if (loadFilter.HasFlag(RGBDeviceType.Keyboard)) - try - { - IntPtr keyboardHandle = Marshal.AllocHGlobal(IntPtr.Size); - if (_AsusSDK.CreateClaymoreKeyboard(keyboardHandle)) - { - _AsusSDK.SetClaymoreKeyboardMode(keyboardHandle, 1); - AsusKeyboardRGBDevice device = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(RGBDeviceType.Keyboard, keyboardHandle, GetCulture())); - device.Initialize(UpdateTrigger); - devices.Add(device); - } - } - catch { if (throwExceptions) throw; } - - #endregion - - #region Mouse - - if (loadFilter.HasFlag(RGBDeviceType.Mouse)) - try - { - IntPtr mouseHandle = Marshal.AllocHGlobal(IntPtr.Size); - if (_AsusSDK.CreateRogMouse(mouseHandle)) - { - _AsusSDK.SetRogMouseMode(mouseHandle, 1); - AsusMouseRGBDevice device = new AsusMouseRGBDevice(new AsusMouseRGBDeviceInfo(RGBDeviceType.Mouse, mouseHandle)); - device.Initialize(UpdateTrigger); - devices.Add(device); - } - } - catch { if (throwExceptions) throw; } - - #endregion - - UpdateTrigger?.Start(); - - Devices = new ReadOnlyCollection(devices); - IsInitialized = true; - } - catch - { - if (throwExceptions) - throw; - return false; - } - - return true; - } - - /// - public void ResetDevices() - { - foreach (IRGBDevice device in Devices) - { - AsusRGBDeviceInfo deviceInfo = (AsusRGBDeviceInfo)device.DeviceInfo; - switch (deviceInfo.DeviceType) - { - case RGBDeviceType.Mainboard: - _AsusSDK.SetMbMode(deviceInfo.Handle, 0); - break; - case RGBDeviceType.GraphicsCard: - _AsusSDK.SetGPUMode(deviceInfo.Handle, 0); - break; - //case RGBDeviceType.DRAM: - // _AsusSDK.SetDramMode(deviceInfo.Handle, 0); - // break; - } - } - } - - /// - public void Dispose() - { - try { UpdateTrigger?.Dispose(); } - catch { /* at least we tried */ } - - try { _AsusSDK.UnloadAsusSDK(); } - catch { /* at least we tried */ } - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProviderLoader.cs b/RGB.NET.Devices.Asus_Legacy/AsusDeviceProviderLoader.cs deleted file mode 100644 index 576dfb5..0000000 --- a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProviderLoader.cs +++ /dev/null @@ -1,24 +0,0 @@ -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// Represents a device provider loaded used to dynamically load asus devices into an application. - /// - public class AsusDeviceProviderLoader : IRGBDeviceProviderLoader - { - #region Properties & Fields - - /// - public bool RequiresInitialization => false; - - #endregion - - #region Methods - - /// - public IRGBDeviceProvider GetDeviceProvider() => AsusDeviceProvider.Instance; - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDevice.cs deleted file mode 100644 index 6cdc398..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDevice.cs +++ /dev/null @@ -1,56 +0,0 @@ -//using RGB.NET.Core; -//using RGB.NET.Devices.Asus.Native; - -//namespace RGB.NET.Devices.Asus -//{ -// /// -// /// -// /// Represents a Asus dram. -// /// -// public class AsusDramRGBDevice : AsusRGBDevice -// { -// #region Properties & Fields - -// /// -// /// Gets information about the . -// /// -// public AsusDramRGBDeviceInfo DramDeviceInfo { get; } - -// #endregion - -// #region Constructors - -// /// -// /// -// /// Initializes a new instance of the class. -// /// -// /// The specific information provided by Asus for the DRAM. -// internal AsusDramRGBDevice(AsusDramRGBDeviceInfo info) -// : base(info) -// { -// this.DramDeviceInfo = info; -// } - -// #endregion - -// #region Methods - -// /// -// protected override void InitializeLayout() -// { -// //TODO DarthAffe 21.10.2017: Look for a good default layout -// int ledCount = _AsusSDK.GetGPULedCount(DramDeviceInfo.Handle); -// for (int i = 0; i < ledCount; i++) -// InitializeLed(new AsusLedId(this, AsusLedIds.DramLed1 + i, i), new Rectangle(i * 10, 0, 10, 10)); - -// //TODO DarthAffe 21.10.2017: We don't know the model, how to save layouts and images? -// ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Drams\{DramDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), -// null, PathHelper.GetAbsolutePath(@"Images\Asus\Drams")); -// } - -// /// -// protected override void ApplyColorData() => _AsusSDK.SetDramColor(DramDeviceInfo.Handle, ColorData); - -// #endregion -// } -//} diff --git a/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDeviceInfo.cs deleted file mode 100644 index 9f92cac..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Dram/AsusDramRGBDeviceInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a . - /// - public class AsusDramRGBDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - public override bool SupportsSyncBack => true; - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - internal AsusDramRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) - : base(deviceType, handle) - { } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Enum/AsusLogicalKeyboardLayout.cs b/RGB.NET.Devices.Asus_Legacy/Enum/AsusLogicalKeyboardLayout.cs deleted file mode 100644 index 60105e5..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Enum/AsusLogicalKeyboardLayout.cs +++ /dev/null @@ -1,15 +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.Asus -{ - /// - /// Contains list of available logical layouts for asus keyboards. - /// - public enum AsusLogicalKeyboardLayout - { - TODO - }; -} diff --git a/RGB.NET.Devices.Asus_Legacy/Enum/AsusPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Asus_Legacy/Enum/AsusPhysicalKeyboardLayout.cs deleted file mode 100644 index b5e80de..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Enum/AsusPhysicalKeyboardLayout.cs +++ /dev/null @@ -1,15 +0,0 @@ -// ReSharper disable UnusedMember.Global -// ReSharper disable InconsistentNaming - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.Asus -{ - /// - /// Contains list of available physical layouts for asus keyboards. - /// - public enum AsusPhysicalKeyboardLayout - { - TODO - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDevice.cs deleted file mode 100644 index 011383b..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDevice.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// - /// Represents a generic Asus-device. (keyboard, mouse, headset, mousepad). - /// - public abstract class AsusRGBDevice : AbstractRGBDevice, IAsusRGBDevice - where TDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - /// - /// Gets information about the . - /// - public override TDeviceInfo DeviceInfo { get; } - - /// - /// Gets or sets the update queue performing updates for this device. - /// - // ReSharper disable once MemberCanBePrivate.Global - protected AsusUpdateQueue UpdateQueue { get; set; } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The generic information provided by Asus for the device. - protected AsusRGBDevice(TDeviceInfo info) - { - this.DeviceInfo = info; - } - - #endregion - - #region Methods - - /// - /// Initializes the device. - /// - public void Initialize(IDeviceUpdateTrigger updateTrigger) - { - InitializeLayout(); - - if (Size == Size.Invalid) - { - Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); - Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); - } - - UpdateQueue = new AsusUpdateQueue(updateTrigger); - UpdateQueue.Initialize(GetUpdateColorAction(), DeviceInfo.Handle, LedMapping.Count); - } - - /// - /// Initializes the and of the device. - /// - protected abstract void InitializeLayout(); - - /// - protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); - - /// - /// Gets a action to update the physical device. - /// - /// - protected abstract Action GetUpdateColorAction(); - - /// - /// - public override void Dispose() - { - try { UpdateQueue?.Dispose(); } - catch { /* at least we tried */ } - - if ((DeviceInfo is AsusRGBDeviceInfo deviceInfo) && (deviceInfo.Handle != IntPtr.Zero)) - Marshal.FreeHGlobal(deviceInfo.Handle); - - base.Dispose(); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDeviceInfo.cs deleted file mode 100644 index 7c6ff69..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Generic/AsusRGBDeviceInfo.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a Corsair-. - /// - public abstract class AsusRGBDeviceInfo : IRGBDeviceInfo - { - #region Properties & Fields - - /// - public RGBDeviceType DeviceType { get; } - - /// - public string DeviceName { get; } - - /// - public string Manufacturer { get; } - - /// - public string Model { get; } - - /// - public Uri Image { get; set; } - - /// - public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; - - /// - public abstract bool SupportsSyncBack { get; } - - /// - /// Gets the index of the . - /// - internal IntPtr Handle { get; } - - #endregion - - #region Constructors - - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - /// The manufacturer-name of the . - /// The model-name of the . - internal AsusRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, string model = "Generic Asus-Device", string manufacturer = "Asus") - { - this.DeviceType = deviceType; - this.Handle = handle; - this.Model = model; - this.Manufacturer = manufacturer; - - DeviceName = $"{Manufacturer} {Model}"; - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Generic/AsusUpdateQueue.cs b/RGB.NET.Devices.Asus_Legacy/Generic/AsusUpdateQueue.cs deleted file mode 100644 index 28fa936..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Generic/AsusUpdateQueue.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents the update-queue performing updates for asus devices. - /// - public class AsusUpdateQueue : UpdateQueue - { - #region Properties & Fields - - /// - /// Gets or sets the internal color-data cache. - /// - // ReSharper disable once MemberCanBePrivate.Global - protected byte[] ColorData { get; private set; } - - private Action _updateAction; - private IntPtr _handle; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The update trigger used by this queue. - public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger) - : base(updateTrigger) - { } - - #endregion - - #region Methods - - /// - /// Initializes the queue. - /// - /// The update-action called by the queue to perform updates. - /// The handle of the device this queue performs updates for. - /// The amount of leds of the device this queue performs updates for. - public void Initialize(Action updateAction, IntPtr handle, int ledCount) - { - _updateAction = updateAction; - _handle = handle; - - ColorData = new byte[ledCount * 3]; - } - - /// - protected override void Update(Dictionary dataSet) - { - foreach (KeyValuePair data in dataSet) - { - int index = ((int)data.Key) * 3; - ColorData[index] = data.Value.GetR(); - ColorData[index + 1] = data.Value.GetB(); - ColorData[index + 2] = data.Value.GetG(); - } - - _updateAction(_handle, ColorData); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Generic/IAsusRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Generic/IAsusRGBDevice.cs deleted file mode 100644 index 720fd3c..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Generic/IAsusRGBDevice.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// Represents a asus RGB-device. - /// - internal interface IAsusRGBDevice : IRGBDevice - { - void Initialize(IDeviceUpdateTrigger updateTrigger); - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs deleted file mode 100644 index 67a4988..0000000 --- a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using RGB.NET.Core; -using RGB.NET.Devices.Asus.Native; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a Asus graphicsCard. - /// - public class AsusGraphicsCardRGBDevice : AsusRGBDevice, IGraphicsCard - { - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - /// The specific information provided by Asus for the graphics card. - internal AsusGraphicsCardRGBDevice(AsusGraphicsCardRGBDeviceInfo info) - : base(info) - { } - - #endregion - - #region Methods - - /// - protected override void InitializeLayout() - { - //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetGPULedCount(DeviceInfo.Handle); - for (int i = 0; i < ledCount; i++) - InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); - - //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\GraphicsCards", $"{ DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); - } - - /// - protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1; - - /// - protected override Action GetUpdateColorAction() => _AsusSDK.SetGPUColor; - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDeviceInfo.cs deleted file mode 100644 index ccf27c7..0000000 --- a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDeviceInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a . - /// - public class AsusGraphicsCardRGBDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - public override bool SupportsSyncBack => false; - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - internal AsusGraphicsCardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) - : base(deviceType, handle, WMIHelper.GetGraphicsCardsInfo() ?? "Generic Asus-Device") - { } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Helper/WMIHelper.cs b/RGB.NET.Devices.Asus_Legacy/Helper/WMIHelper.cs deleted file mode 100644 index 0ea746e..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Helper/WMIHelper.cs +++ /dev/null @@ -1,63 +0,0 @@ -#if NETFULL -using System.Management; - -namespace RGB.NET.Devices.Asus -{ - // ReSharper disable once InconsistentNaming - internal static class WMIHelper - { - #region Properties & Fields - - private static ManagementObjectSearcher _mainboardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Manufacturer,Product FROM Win32_BaseBoard"); - private static ManagementObjectSearcher _graphicsCardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_VideoController"); - - private static (string manufacturer, string model)? _mainboardInfo; - private static string _graphicsCardInfo; - - #endregion - - #region Methods - - internal static (string manufacturer, string model)? GetMainboardInfo() - { - if (!_mainboardInfo.HasValue) - foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get()) - { - _mainboardInfo = (managementBaseObject["Manufacturer"]?.ToString(), managementBaseObject["Product"]?.ToString()); - break; - } - - return _mainboardInfo; - } - - internal static string GetGraphicsCardsInfo() - { - if (_graphicsCardInfo == null) - foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get()) - { - _graphicsCardInfo = managementBaseObject["Name"]?.ToString(); - break; - } - - return _graphicsCardInfo; - } - - #endregion - } -} -#else -namespace RGB.NET.Devices.Asus -{ - // ReSharper disable once InconsistentNaming - internal static class WMIHelper - { - #region Methods - - internal static (string manufacturer, string model)? GetMainboardInfo() => null; - - internal static string GetGraphicsCardsInfo() => null; - - #endregion - } -} -#endif diff --git a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs deleted file mode 100644 index 8b72fb5..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using RGB.NET.Core; -using RGB.NET.Devices.Asus.Native; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a Asus keyboard. - /// - public class AsusKeyboardRGBDevice : AsusRGBDevice, IKeyboard - { - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - /// The specific information provided by Asus for the keyboard. - internal AsusKeyboardRGBDevice(AsusKeyboardRGBDeviceInfo info) - : base(info) - { } - - #endregion - - #region Methods - - /// - protected override void InitializeLayout() - { - //TODO DarthAffe 07.10.2017: This doesn't make sense at all ... Find someone with such a keyboard! - int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(DeviceInfo.Handle); - for (int i = 0; i < ledCount; i++) - InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19)); - - string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Asus\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); - } - - /// - protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; - - /// - protected override Action GetUpdateColorAction() => _AsusSDK.SetClaymoreKeyboardColor; - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDeviceInfo.cs deleted file mode 100644 index db343c0..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Globalization; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a . - /// - public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - public override bool SupportsSyncBack => false; - - /// - /// Gets the physical layout of the keyboard. - /// - public AsusPhysicalKeyboardLayout PhysicalLayout { get; private set; } - - /// - /// Gets the logical layout of the keyboard. - /// - public AsusLogicalKeyboardLayout LogicalLayout { get; private set; } - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - /// The of the layout this keyboard is using. - internal AsusKeyboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, CultureInfo culture) - : base(deviceType, handle, "Claymore") - { - SetLayouts(culture.KeyboardLayoutId); - } - - #endregion - - #region Methods - - private void SetLayouts(int keyboardLayoutId) - { - switch (keyboardLayoutId) - { - //TODO DarthAffe 07.10.2017: Implement - default: - PhysicalLayout = AsusPhysicalKeyboardLayout.TODO; - LogicalLayout = AsusLogicalKeyboardLayout.TODO; - break; - } - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs deleted file mode 100644 index 52035f0..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using RGB.NET.Core; -using RGB.NET.Devices.Asus.Native; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a Asus mainboard. - /// - public class AsusMainboardRGBDevice : AsusRGBDevice, IMainboard - { - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - /// The specific information provided by Asus for the mainboard. - internal AsusMainboardRGBDevice(AsusMainboardRGBDeviceInfo info) - : base(info) - { } - - #endregion - - #region Methods - - /// - protected override void InitializeLayout() - { - //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetMbLedCount(DeviceInfo.Handle); - for (int i = 0; i < ledCount; i++) - InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); - - //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mainboards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); - } - - /// - protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1; - - /// - public override void SyncBack() - { - byte[] colorData = _AsusSDK.GetMbColor(DeviceInfo.Handle); - for (int i = 0; i < LedMapping.Count; i++) - SetLedColorWithoutRequest(LedMapping[LedId.Mainboard1 + i], new Color(colorData[(i * 3)], colorData[(i * 3) + 2], colorData[(i * 3) + 1])); - } - - /// - protected override Action GetUpdateColorAction() => _AsusSDK.SetMbColor; - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDeviceInfo.cs deleted file mode 100644 index 172f55d..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDeviceInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a . - /// - public class AsusMainboardRGBDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - public override bool SupportsSyncBack => true; - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - internal AsusMainboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) - : base(deviceType, handle, WMIHelper.GetMainboardInfo()?.model ?? "Generic Asus-Device") - { } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs deleted file mode 100644 index e238b0c..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using RGB.NET.Core; -using RGB.NET.Devices.Asus.Native; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a Asus mouse. - /// - public class AsusMouseRGBDevice : AsusRGBDevice, IMouse - { - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - /// The specific information provided by Asus for the mouse. - internal AsusMouseRGBDevice(AsusMouseRGBDeviceInfo info) - : base(info) - { } - - #endregion - - #region Methods - - /// - protected override void InitializeLayout() - { - //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetRogMouseLedCount(DeviceInfo.Handle); - for (int i = 0; i < ledCount; i++) - InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); - - ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mouses", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); - } - - /// - protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; - - /// - protected override Action GetUpdateColorAction() => _AsusSDK.SetRogMouseColor; - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDeviceInfo.cs deleted file mode 100644 index ddb7135..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDeviceInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a generic information for a . - /// - public class AsusMouseRGBDeviceInfo : AsusRGBDeviceInfo - { - #region Properties & Fields - - /// - public override bool SupportsSyncBack => false; - - #endregion - - #region Constructors - - /// - /// - /// Internal constructor of managed . - /// - /// The type of the . - /// The handle of the . - internal AsusMouseRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) - : base(deviceType, handle, "Rog") - { } - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs b/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs deleted file mode 100644 index 437a3ea..0000000 --- a/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs +++ /dev/null @@ -1,341 +0,0 @@ -// ReSharper disable UnusedMethodReturnValue.Global -// ReSharper disable UnusedMember.Global - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; -using System.Security; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus.Native -{ - // ReSharper disable once InconsistentNaming - internal static class _AsusSDK - { - #region Libary Management - - private static IntPtr _dllHandle = IntPtr.Zero; - - /// - /// Gets the loaded architecture (x64/x86). - /// - internal static string LoadedArchitecture { get; private set; } - - /// - /// Reloads the SDK. - /// - internal static void Reload() - { - UnloadAsusSDK(); - LoadAsusSDK(); - } - - private static void LoadAsusSDK() - { - if (_dllHandle != IntPtr.Zero) return; - - // HACK: Load library at runtime to support both, x86 and x64 with one managed dll - List possiblePathList = Environment.Is64BitProcess ? AsusDeviceProvider.PossibleX64NativePaths : AsusDeviceProvider.PossibleX86NativePaths; - string dllPath = possiblePathList.FirstOrDefault(File.Exists); - if (dllPath == null) throw new RGBDeviceException($"Can't find the Asus-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); - - SetDllDirectory(Path.GetDirectoryName(Path.GetFullPath(dllPath))); - - _dllHandle = LoadLibrary(dllPath); - - _enumerateMbControllerPointer = (EnumerateMbControllerPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "EnumerateMbController"), typeof(EnumerateMbControllerPointer)); - _getMbLedCountPointer = (GetMbLedCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetMbLedCount"), typeof(GetMbLedCountPointer)); - _setMbModePointer = (SetMbModePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetMbMode"), typeof(SetMbModePointer)); - _setMbColorPointer = (SetMbColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetMbColor"), typeof(SetMbColorPointer)); - _getMbColorPointer = (GetMbColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetMbColor"), typeof(GetMbColorPointer)); - - _enumerateGPUPointer = (EnumerateGPUPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "EnumerateGPU"), typeof(EnumerateGPUPointer)); - _getGPULedCountPointer = (GetGPULedCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetGPULedCount"), typeof(GetGPULedCountPointer)); - _setGPUModePointer = (SetGPUModePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetGPUMode"), typeof(SetGPUModePointer)); - _setGPUColorPointer = (SetGPUColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetGPUColor"), typeof(SetGPUColorPointer)); - - _createClaymoreKeyboardPointer = (CreateClaymoreKeyboardPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateClaymoreKeyboard"), typeof(CreateClaymoreKeyboardPointer)); - _getClaymoreKeyboardLedCountPointer = (GetClaymoreKeyboardLedCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetClaymoreKeyboardLedCount"), typeof(GetClaymoreKeyboardLedCountPointer)); - _setClaymoreKeyboardModePointer = (SetClaymoreKeyboardModePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetClaymoreKeyboardMode"), typeof(SetClaymoreKeyboardModePointer)); - _setClaymoreKeyboardColorPointer = (SetClaymoreKeyboardColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetClaymoreKeyboardColor"), typeof(SetClaymoreKeyboardColorPointer)); - - _enumerateRogMousePointer = (CreateRogMousePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CreateRogMouse"), typeof(CreateRogMousePointer)); - _getRogMouseLedCountPointer = (GetRogMouseLedCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "RogMouseLedCount"), typeof(GetRogMouseLedCountPointer)); // DarthAffe 07.10.2017: Be careful with the naming here - i don't know why but there is no 'Get'! - _setRogMouseModePointer = (SetRogMouseModePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetRogMouseMode"), typeof(SetRogMouseModePointer)); - _setRogMouseColorPointer = (SetRogMouseColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetRogMouseColor"), typeof(SetRogMouseColorPointer)); - - //TODO DarthAffe 29.10.2017: I don't know why they are even documented, but the asus guy said they aren't in the SDK right now. - //_enumerateDramPointer = (EnumerateDramPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "EnumerateDram"), typeof(EnumerateDramPointer)); - //_getDramLedCountPointer = (GetDramLedCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramLedCount"), typeof(GetDramLedCountPointer)); - //_setDramModePointer = (SetDramModePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetDramMode"), typeof(SetDramModePointer)); - //_setDramColorPointer = (SetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetDramColor"), typeof(SetDramColorPointer)); - //_getDramColorPointer = (GetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramColor"), typeof(GetDramColorPointer)); - } - - internal static void UnloadAsusSDK() - { - if (_dllHandle == IntPtr.Zero) return; - - // ReSharper disable once EmptyEmbeddedStatement - DarthAffe 07.10.2017: We might need to reduce the internal reference counter more than once to set the library free - while (FreeLibrary(_dllHandle)) ; - _dllHandle = IntPtr.Zero; - } - - [DllImport("kernel32.dll")] - private static extern bool SetDllDirectory(string lpPathName); - - [DllImport("kernel32.dll")] - private static extern IntPtr LoadLibrary(string dllToLoad); - - [DllImport("kernel32.dll")] - private static extern bool FreeLibrary(IntPtr dllHandle); - - [DllImport("kernel32.dll")] - private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name); - - #endregion - - #region SDK-METHODS - - #region Pointers - - private static EnumerateMbControllerPointer _enumerateMbControllerPointer; - private static GetMbLedCountPointer _getMbLedCountPointer; - private static SetMbModePointer _setMbModePointer; - private static SetMbColorPointer _setMbColorPointer; - private static GetMbColorPointer _getMbColorPointer; - - private static EnumerateGPUPointer _enumerateGPUPointer; - private static GetGPULedCountPointer _getGPULedCountPointer; - private static SetGPUModePointer _setGPUModePointer; - private static SetGPUColorPointer _setGPUColorPointer; - - private static CreateClaymoreKeyboardPointer _createClaymoreKeyboardPointer; - private static GetClaymoreKeyboardLedCountPointer _getClaymoreKeyboardLedCountPointer; - private static SetClaymoreKeyboardModePointer _setClaymoreKeyboardModePointer; - private static SetClaymoreKeyboardColorPointer _setClaymoreKeyboardColorPointer; - - private static CreateRogMousePointer _enumerateRogMousePointer; - private static GetRogMouseLedCountPointer _getRogMouseLedCountPointer; - private static SetRogMouseModePointer _setRogMouseModePointer; - private static SetRogMouseColorPointer _setRogMouseColorPointer; - - //private static EnumerateDramPointer _enumerateDramPointer; - //private static SetDramModePointer _setDramModePointer; - //private static GetDramLedCountPointer _getDramLedCountPointer; - //private static SetDramColorPointer _setDramColorPointer; - //private static GetDramColorPointer _getDramColorPointer; - - #endregion - - #region Delegates - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int EnumerateMbControllerPointer(IntPtr handles, int size); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int GetMbLedCountPointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetMbModePointer(IntPtr handle, int mode); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetMbColorPointer(IntPtr handle, byte[] colors, int size); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int GetMbColorPointer(IntPtr handle, IntPtr colors, int size); - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int EnumerateGPUPointer(IntPtr handles, int size); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int GetGPULedCountPointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetGPUModePointer(IntPtr handle, int mode); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetGPUColorPointer(IntPtr handle, byte[] colors, int size); - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool CreateClaymoreKeyboardPointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int GetClaymoreKeyboardLedCountPointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetClaymoreKeyboardModePointer(IntPtr handle, int mode); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetClaymoreKeyboardColorPointer(IntPtr handle, byte[] colors, int size); - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool CreateRogMousePointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int GetRogMouseLedCountPointer(IntPtr handle); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetRogMouseModePointer(IntPtr handle, int mode); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void SetRogMouseColorPointer(IntPtr handle, byte[] colors, int size); - - //[UnmanagedFunctionPointer(CallingConvention.StdCall)] - //private delegate int EnumerateDramPointer(IntPtr handles, int size); - //[UnmanagedFunctionPointer(CallingConvention.StdCall)] - //private delegate int GetDramLedCountPointer(IntPtr handle); - //[UnmanagedFunctionPointer(CallingConvention.StdCall)] - //private delegate void SetDramModePointer(IntPtr handle, int mode); - //[UnmanagedFunctionPointer(CallingConvention.StdCall)] - //private delegate void SetDramColorPointer(IntPtr handle, byte[] colors, int size); - //[UnmanagedFunctionPointer(CallingConvention.StdCall)] - //private delegate int GetDramColorPointer(IntPtr handle, IntPtr colors, int size); - - #endregion - - // ReSharper disable EventExceptionNotDocumented - - //HACK DarthAffe 12.05.2019: Using HandleProcessCorruptedStateExceptions and SecurityCritical allows to capture AccessViolationExceptions - // which is used here to prevent hard crashes on wrong pointers. - // Since this might cause isntabilities in the running application it's only a workaround and should be fixed in depth. - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int EnumerateMbController(IntPtr handles, int size) - { - try { return _enumerateMbControllerPointer(handles, size); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int GetMbLedCount(IntPtr handle) - { - try { return _getMbLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetMbMode(IntPtr handle, int mode) - { - try { _setMbModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetMbColor(IntPtr handle, byte[] colors) - { - try { _setMbColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static byte[] GetMbColor(IntPtr handle) - { - int count = _getMbColorPointer(handle, IntPtr.Zero, 0); - byte[] colors = new byte[count]; - IntPtr readColorsPtr = Marshal.AllocHGlobal(colors.Length); - _getMbColorPointer(handle, readColorsPtr, colors.Length); - Marshal.Copy(readColorsPtr, colors, 0, colors.Length); - Marshal.FreeHGlobal(readColorsPtr); - return colors; - } - - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int EnumerateGPU(IntPtr handles, int size) - { - try { return _enumerateGPUPointer(handles, size); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int GetGPULedCount(IntPtr handle) - { - try { return _getGPULedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetGPUMode(IntPtr handle, int mode) - { - try { _setGPUModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetGPUColor(IntPtr handle, byte[] colors) - { - try { _setGPUColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static bool CreateClaymoreKeyboard(IntPtr handle) - { - try { return _createClaymoreKeyboardPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int GetClaymoreKeyboardLedCount(IntPtr handle) - { - try { return _getClaymoreKeyboardLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetClaymoreKeyboardMode(IntPtr handle, int mode) - { - try { _setClaymoreKeyboardModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetClaymoreKeyboardColor(IntPtr handle, byte[] colors) - { - try { _setClaymoreKeyboardColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static bool CreateRogMouse(IntPtr handle) - { - try { return _enumerateRogMousePointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static int GetRogMouseLedCount(IntPtr handle) - { - try { return _getRogMouseLedCountPointer(handle); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetRogMouseMode(IntPtr handle, int mode) - { - try { _setRogMouseModePointer(handle, mode); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - [SecurityCritical] - [HandleProcessCorruptedStateExceptions] - internal static void SetRogMouseColor(IntPtr handle, byte[] colors) - { - try { _setRogMouseColorPointer(handle, colors, colors.Length); } catch (Exception ex) { throw new RGBDeviceException(ex.Message); }; - } - - //internal static int EnumerateDram(IntPtr handles, int size) => _enumerateDramPointer(handles, size); - //internal static int GetDramLedCount(IntPtr handle) => _getDramLedCountPointer(handle); - //internal static void SetDramMode(IntPtr handle, int mode) => _setDramModePointer(handle, mode); - //internal static void SetDramColor(IntPtr handle, byte[] colors) => _setDramColorPointer(handle, colors, colors.Length); - - //internal static byte[] GetDramColor(IntPtr handle) - //{ - // int count = _getDramColorPointer(handle, IntPtr.Zero, 0); - // byte[] colors = new byte[count]; - // IntPtr readColorsPtr = Marshal.AllocHGlobal(colors.Length); - // _getDramColorPointer(handle, readColorsPtr, colors.Length); - // Marshal.Copy(readColorsPtr, colors, 0, colors.Length); - // Marshal.FreeHGlobal(readColorsPtr); - // return colors; - //} - - // ReSharper restore EventExceptionNotDocumented - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj b/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj deleted file mode 100644 index 08b032a..0000000 --- a/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - net5.0 - latest - enable - - Darth Affe - Wyrez - en-US - en-US - RGB.NET.Devices.Asus - RGB.NET.Devices.Asus_Legacy - RGB.NET.Devices.Asus - RGB.NET.Devices.Asus_Legacy - RGB.NET.Devices.Asus - Asus-Device-Implementations of RGB.NET based on the v2-SDK - Asus-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals - Copyright © Darth Affe 2020 - Copyright © Darth Affe 2020 - http://lib.arge.be/icon.png - https://github.com/DarthAffe/RGB.NET - https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE - Github - https://github.com/DarthAffe/RGB.NET - True - - - - 0.0.1 - 0.0.1 - 0.0.1 - - ..\bin\ - true - True - True - - - - $(DefineConstants);TRACE;DEBUG - true - full - false - - - - pdbonly - true - $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE - - - - - - \ No newline at end of file diff --git a/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj.DotSettings b/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj.DotSettings deleted file mode 100644 index a88918e..0000000 --- a/RGB.NET.Devices.Asus_Legacy/RGB.NET.Devices.Asus_Legacy.csproj.DotSettings +++ /dev/null @@ -1,10 +0,0 @@ - - True - True - True - True - True - True - True - True - True \ No newline at end of file diff --git a/RGB.NET.sln b/RGB.NET.sln index 2d2701e..02cec92 100644 --- a/RGB.NET.sln +++ b/RGB.NET.sln @@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presets", "Presets", "{EBC3 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Core", "RGB.NET.Core\RGB.NET.Core.csproj", "{F3ED5768-7251-4347-8D8F-2866313DA658}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Asus_Legacy", "RGB.NET.Devices.Asus_Legacy\RGB.NET.Devices.Asus_Legacy.csproj", "{105FD573-D165-49D1-B8EC-937570616F29}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.CoolerMaster", "RGB.NET.Devices.CoolerMaster\RGB.NET.Devices.CoolerMaster.csproj", "{E8F927F5-E7CF-464A-B9AE-824C2B29A7D1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Corsair", "RGB.NET.Devices.Corsair\RGB.NET.Devices.Corsair.csproj", "{BDE3DAD5-75C9-4C50-848D-1E766E916006}" @@ -59,10 +57,6 @@ Global {F3ED5768-7251-4347-8D8F-2866313DA658}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3ED5768-7251-4347-8D8F-2866313DA658}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3ED5768-7251-4347-8D8F-2866313DA658}.Release|Any CPU.Build.0 = Release|Any CPU - {105FD573-D165-49D1-B8EC-937570616F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {105FD573-D165-49D1-B8EC-937570616F29}.Debug|Any CPU.Build.0 = Debug|Any CPU - {105FD573-D165-49D1-B8EC-937570616F29}.Release|Any CPU.ActiveCfg = Release|Any CPU - {105FD573-D165-49D1-B8EC-937570616F29}.Release|Any CPU.Build.0 = Release|Any CPU {E8F927F5-E7CF-464A-B9AE-824C2B29A7D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E8F927F5-E7CF-464A-B9AE-824C2B29A7D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {E8F927F5-E7CF-464A-B9AE-824C2B29A7D1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -140,7 +134,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {105FD573-D165-49D1-B8EC-937570616F29} = {D13032C6-432E-4F43-8A32-071133C22B16} {E8F927F5-E7CF-464A-B9AE-824C2B29A7D1} = {D13032C6-432E-4F43-8A32-071133C22B16} {BDE3DAD5-75C9-4C50-848D-1E766E916006} = {D13032C6-432E-4F43-8A32-071133C22B16} {8496134D-16F5-43E6-B847-604964B240AD} = {D13032C6-432E-4F43-8A32-071133C22B16}