From 54c3e92a7200fca420b5c854fa33b9025eea9abe Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 7 Oct 2017 15:08:12 +0200 Subject: [PATCH] Added initial implementation of the Asus Aura SDK --- NuGet/RGB.NET.Devices.Aura.nuspec | 32 +++ RGB.NET.Core/Devices/RGBDeviceType.cs | 14 +- RGB.NET.Devices.Aura/AuraDeviceProvider.cs | 184 ++++++++++++++++ RGB.NET.Devices.Aura/Enum/AuraLedIds.cs | 28 +++ .../Enum/AuraLogicalKeyboardLayout.cs | 15 ++ .../Enum/AuraPhysicalKeyboardLayout.cs | 13 ++ RGB.NET.Devices.Aura/Generic/AuraLedId.cs | 111 ++++++++++ RGB.NET.Devices.Aura/Generic/AuraRGBDevice.cs | 145 +++++++++++++ .../Generic/AuraRGBDeviceInfo.cs | 55 +++++ .../GraphicsCard/AuraGraphicsCardRGBDevice.cs | 56 +++++ .../AuraGraphicsCardRGBDeviceInfo.cs | 28 +++ .../Keyboard/AuraKeyboardRGBDevice.cs | 56 +++++ .../Keyboard/AuraKeyboardRGBDeviceInfo.cs | 62 ++++++ RGB.NET.Devices.Aura/Layouts/DeviceLayout.xsd | 63 ++++++ .../Mainboard/AuraMainboardRGBDevice.cs | 56 +++++ .../Mainboard/AuraMainboardRGBDeviceInfo.cs | 28 +++ .../Mouse/AuraMouseRGBDevice.cs | 55 +++++ .../Mouse/AuraMouseRGBDeviceInfo.cs | 28 +++ RGB.NET.Devices.Aura/Native/_AuraSDK.cs | 199 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 35 +++ .../RGB.NET.Devices.Aura.csproj | 96 +++++++++ .../RGB.NET.Devices.Aura.csproj.DotSettings | 8 + RGB.NET.Devices.Aura/packages.config | 4 + .../targets/RGB.NET.Devices.Aura.targets | 150 +++++++++++++ RGB.NET.sln | 10 +- 25 files changed, 1528 insertions(+), 3 deletions(-) create mode 100644 NuGet/RGB.NET.Devices.Aura.nuspec create mode 100644 RGB.NET.Devices.Aura/AuraDeviceProvider.cs create mode 100644 RGB.NET.Devices.Aura/Enum/AuraLedIds.cs create mode 100644 RGB.NET.Devices.Aura/Enum/AuraLogicalKeyboardLayout.cs create mode 100644 RGB.NET.Devices.Aura/Enum/AuraPhysicalKeyboardLayout.cs create mode 100644 RGB.NET.Devices.Aura/Generic/AuraLedId.cs create mode 100644 RGB.NET.Devices.Aura/Generic/AuraRGBDevice.cs create mode 100644 RGB.NET.Devices.Aura/Generic/AuraRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDevice.cs create mode 100644 RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDevice.cs create mode 100644 RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Aura/Layouts/DeviceLayout.xsd create mode 100644 RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDevice.cs create mode 100644 RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDevice.cs create mode 100644 RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDeviceInfo.cs create mode 100644 RGB.NET.Devices.Aura/Native/_AuraSDK.cs create mode 100644 RGB.NET.Devices.Aura/Properties/AssemblyInfo.cs create mode 100644 RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj create mode 100644 RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj.DotSettings create mode 100644 RGB.NET.Devices.Aura/packages.config create mode 100644 RGB.NET.Devices.Aura/targets/RGB.NET.Devices.Aura.targets diff --git a/NuGet/RGB.NET.Devices.Aura.nuspec b/NuGet/RGB.NET.Devices.Aura.nuspec new file mode 100644 index 0000000..d13d336 --- /dev/null +++ b/NuGet/RGB.NET.Devices.Aura.nuspec @@ -0,0 +1,32 @@ + + + + RGB.NET.Devices.Aura + RGB.NET.Devices.Aura + 1.0.0.0 + Darth Affe + Darth Affe + https://github.com/DarthAffe/RGB.NET + https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE + true + Aura-Device-Implementations of RGB.NET + + Aura-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals + Copyright © Wyrez 2017 + en-US + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Core/Devices/RGBDeviceType.cs b/RGB.NET.Core/Devices/RGBDeviceType.cs index 0b804a8..01c8a8c 100644 --- a/RGB.NET.Core/Devices/RGBDeviceType.cs +++ b/RGB.NET.Core/Devices/RGBDeviceType.cs @@ -39,8 +39,18 @@ namespace RGB.NET.Core LedStripe = 1 << 4, /// - /// Represents a LED-matrix + /// Represents a LED-matrix. /// - LedMatrix = 1 << 5 + LedMatrix = 1 << 5, + + /// + /// Represents a Mainboard. + /// + Mainboard = 1 << 6, + + /// + /// Represents a Graphics card + /// + GraphicsCard = 1 << 7 } } diff --git a/RGB.NET.Devices.Aura/AuraDeviceProvider.cs b/RGB.NET.Devices.Aura/AuraDeviceProvider.cs new file mode 100644 index 0000000..ff1a8c8 --- /dev/null +++ b/RGB.NET.Devices.Aura/AuraDeviceProvider.cs @@ -0,0 +1,184 @@ +// 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.Aura.Native; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a device provider responsible for Cooler Master devices. + /// + public class AuraDeviceProvider : IRGBDeviceProvider + { + #region Properties & Fields + + private static AuraDeviceProvider _instance; + /// + /// Gets the singleton instance. + /// + public static AuraDeviceProvider Instance => _instance ?? new AuraDeviceProvider(); + + /// + /// 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 => _AuraSDK.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. + /// + public Func GetCulture { get; set; } = CultureHelper.GetCurrentCulture; + + #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 AuraDeviceProvider() + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instanc of type {nameof(AuraDeviceProvider)}"); + _instance = this; + } + + #endregion + + #region Methods + + /// + public bool Initialize(bool exclusiveAccessIfPossible = false, bool throwExceptions = false) + { + IsInitialized = false; + + try + { + _AuraSDK.Reload(); + + IList devices = new List(); + + #region Mainboard + + int mainboardCount = _AuraSDK.EnumerateMbController(IntPtr.Zero, 0); + if (mainboardCount > 0) + { + IntPtr mainboardHandles = Marshal.AllocHGlobal(mainboardCount * IntPtr.Size); + _AuraSDK.EnumerateMbController(mainboardHandles, mainboardCount); + + for (int i = 0; i < mainboardCount; i++) + { + IntPtr handle = Marshal.ReadIntPtr(mainboardHandles, i); + _AuraSDK.SetMbMode(handle, 1); + AuraMainboardRGBDevice device = new AuraMainboardRGBDevice(new AuraMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle)); + device.Initialize(); + devices.Add(device); + } + } + + #endregion + + #region Graphics cards + + //TODO DarthAffe 07.10.2017: GPU works but causes huge lags on update + //int graphicCardCount = _AuraSDK.EnumerateGPU(IntPtr.Zero, 0); + //if (graphicCardCount > 0) + //{ + // IntPtr grapicsCardHandles = Marshal.AllocHGlobal(graphicCardCount * IntPtr.Size); + // _AuraSDK.EnumerateGPU(grapicsCardHandles, graphicCardCount); + + // for (int i = 0; i < graphicCardCount; i++) + // { + // IntPtr handle = Marshal.ReadIntPtr(grapicsCardHandles, i); + // _AuraSDK.SetGPUMode(handle, 1); + // AuraGraphicsCardRGBDevice device = new AuraGraphicsCardRGBDevice(new AuraGraphicsCardRGBDeviceInfo(RGBDeviceType.GraphicsCard, handle)); + // device.Initialize(); + // devices.Add(device); + // } + //} + + #endregion + + #region Keyboard + + IntPtr keyboardHandle = Marshal.AllocHGlobal(IntPtr.Size); + if (_AuraSDK.CreateClaymoreKeyboard(keyboardHandle)) + { + _AuraSDK.SetClaymoreKeyboardMode(keyboardHandle, 1); + AuraKeyboardRGBDevice device = new AuraKeyboardRGBDevice(new AuraKeyboardRGBDeviceInfo(RGBDeviceType.Keyboard, keyboardHandle, GetCulture())); + device.Initialize(); + devices.Add(device); + } + + #endregion + + #region Mouse + + IntPtr mouseHandle = Marshal.AllocHGlobal(IntPtr.Size); + if (_AuraSDK.CreateRogMouse(mouseHandle)) + { + _AuraSDK.SetRogMouseMode(mouseHandle, 1); + AuraMouseRGBDevice device = new AuraMouseRGBDevice(new AuraMouseRGBDeviceInfo(RGBDeviceType.Mouse, mouseHandle)); + device.Initialize(); + devices.Add(device); + } + + #endregion + + Devices = new ReadOnlyCollection(devices); + } + catch + { + if (throwExceptions) + throw; + else + return false; + } + + IsInitialized = true; + + return true; + } + + /// + public void ResetDevices() + { + //TODO DarthAffe 07.10.2017: This seems to be impossible right now + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Enum/AuraLedIds.cs b/RGB.NET.Devices.Aura/Enum/AuraLedIds.cs new file mode 100644 index 0000000..26e50f3 --- /dev/null +++ b/RGB.NET.Devices.Aura/Enum/AuraLedIds.cs @@ -0,0 +1,28 @@ +// ReSharper disable InconsistentNaming + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.Aura +{ + /// + /// Contains list of all LEDs available for all Aura devices. + /// + public enum AuraLedIds + { + Invalid = -1, + + //TODO DarthAffe 07.10.2017: Create useful Ids for all devices + + MainboardAudio1 = 0x01, + MainboardAudio2 = 0x02, + MainboardAudio3 = 0x03, + MainboardAudio4 = 0x04, + MainboardRGBStrip1 = 0x05, + + GraphicsCardLed1 = 0x11, + + MouseLed1 = 0x21, + + KeyboardLed1 = 0x31, + } +} diff --git a/RGB.NET.Devices.Aura/Enum/AuraLogicalKeyboardLayout.cs b/RGB.NET.Devices.Aura/Enum/AuraLogicalKeyboardLayout.cs new file mode 100644 index 0000000..bedc9f7 --- /dev/null +++ b/RGB.NET.Devices.Aura/Enum/AuraLogicalKeyboardLayout.cs @@ -0,0 +1,15 @@ +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global + +#pragma warning disable 1591 // Missing XML comment for publicly visible type or member + +namespace RGB.NET.Devices.Aura +{ + /// + /// Contains list of available logical layouts for aura keyboards. + /// + public enum AuraLogicalKeyboardLayout + { + TODO + }; +} diff --git a/RGB.NET.Devices.Aura/Enum/AuraPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Aura/Enum/AuraPhysicalKeyboardLayout.cs new file mode 100644 index 0000000..5814662 --- /dev/null +++ b/RGB.NET.Devices.Aura/Enum/AuraPhysicalKeyboardLayout.cs @@ -0,0 +1,13 @@ +// ReSharper disable UnusedMember.Global +// ReSharper disable InconsistentNaming + +namespace RGB.NET.Devices.Aura +{ + /// + /// Contains list of available physical layouts for aura keyboards. + /// + public enum AuraPhysicalKeyboardLayout + { + TODO + } +} diff --git a/RGB.NET.Devices.Aura/Generic/AuraLedId.cs b/RGB.NET.Devices.Aura/Generic/AuraLedId.cs new file mode 100644 index 0000000..c4a0000 --- /dev/null +++ b/RGB.NET.Devices.Aura/Generic/AuraLedId.cs @@ -0,0 +1,111 @@ +using System.Diagnostics; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a Id of a on a . + /// + [DebuggerDisplay("{" + nameof(LedId) + "}")] + public class AuraLedId : ILedId + { + #region Properties & Fields + + internal readonly AuraLedIds LedId; + + internal readonly int Index; + + /// + public IRGBDevice Device { get; } + + /// + public bool IsValid => LedId != AuraLedIds.Invalid; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The the belongs to. + /// The of the represented . + public AuraLedId(IRGBDevice device, AuraLedIds ledId) + { + this.Device = device; + this.LedId = ledId; + } + + /// + /// Initializes a new instance of the class. + /// + /// The the belongs to. + /// The of the represented . + /// The index in the mapping array of the device. + public AuraLedId(IRGBDevice device, AuraLedIds ledId, int index) + { + this.Device = device; + this.LedId = ledId; + this.Index = index; + } + + #endregion + + #region Methods + + /// + /// Converts the Id of this to a human-readable string. + /// + /// A string that contains the Id of this . For example "Enter". + public override string ToString() => LedId.ToString(); + + /// + /// 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) + { + AuraLedId compareLedId = obj as AuraLedId; + if (ReferenceEquals(compareLedId, null)) + return false; + + if (ReferenceEquals(this, compareLedId)) + return true; + + if (GetType() != compareLedId.GetType()) + return false; + + return compareLedId.LedId == LedId; + } + + /// + /// Returns a hash code for this . + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() => LedId.GetHashCode(); + + #endregion + + #region Operators + + /// + /// Returns a value that indicates whether two specified are equal. + /// + /// The first to compare. + /// The second to compare. + /// true if and are equal; otherwise, false. + public static bool operator ==(AuraLedId ledId1, AuraLedId ledId2) => ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); + + /// + /// Returns a value that indicates whether two specified are equal. + /// + /// The first to compare. + /// The second to compare. + /// true if and are not equal; otherwise, false. + public static bool operator !=(AuraLedId ledId1, AuraLedId ledId2) => !(ledId1 == ledId2); + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Generic/AuraRGBDevice.cs b/RGB.NET.Devices.Aura/Generic/AuraRGBDevice.cs new file mode 100644 index 0000000..546803d --- /dev/null +++ b/RGB.NET.Devices.Aura/Generic/AuraRGBDevice.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Core.Layout; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic Aura-device. (keyboard, mouse, headset, mousepad). + /// + public abstract class AuraRGBDevice : AbstractRGBDevice + { + #region Properties & Fields + + /// + /// Gets or sets the internal color-data cache. + /// + protected byte[] ColorData { get; private set; } + + /// + /// + /// Gets information about the . + /// + public override IRGBDeviceInfo DeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The generic information provided by Aura for the device. + protected AuraRGBDevice(IRGBDeviceInfo info) + { + this.DeviceInfo = info; + } + + #endregion + + #region Methods + + /// + /// Initializes the device. + /// + internal void Initialize() + { + InitializeLayout(); + + if (InternalSize == null) + { + Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); + InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); + } + + ColorData = new byte[LedMapping.Count * 3]; + } + + /// + /// Initializes the and of the device. + /// + protected abstract void InitializeLayout(); + + /// + /// Applies the given layout. + /// + /// The file containing the layout. + /// The name of the layout used to get the images of the leds. + /// The path images for this device are collected in. + protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) + { + DeviceLayout layout = DeviceLayout.Load(layoutPath); + if (layout != null) + { + LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); + + InternalSize = new Size(layout.Width, layout.Height); + + if (layout.Leds != null) + foreach (LedLayout layoutLed in layout.Leds) + { + if (Enum.TryParse(layoutLed.Id, true, out AuraLedIds ledId)) + { + if (LedMapping.TryGetValue(new AuraLedId(this, ledId), out Led led)) + { + led.LedRectangle.Location.X = layoutLed.X; + led.LedRectangle.Location.Y = layoutLed.Y; + led.LedRectangle.Size.Width = layoutLed.Width; + led.LedRectangle.Size.Height = layoutLed.Height; + + led.Shape = layoutLed.Shape; + led.ShapeData = layoutLed.ShapeData; + + LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); + led.Image = (!string.IsNullOrEmpty(image?.Image)) + ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) + : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); + } + } + } + } + } + + /// + protected override void UpdateLeds(IEnumerable ledsToUpdate) + { + List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); + + if (leds.Count > 0) + { + foreach (Led led in leds) + { + int index = (((AuraLedId)led.Id).Index) * 3; + ColorData[index] = led.Color.R; + ColorData[index + 1] = led.Color.G; + ColorData[index + 2] = led.Color.B; + } + + ApplyColorData(); + } + } + + /// + /// Sends the color-data-cache to the device. + /// + protected abstract void ApplyColorData(); + + /// + public override void Dispose() + { + if ((DeviceInfo is AuraRGBDeviceInfo deviceInfo) && (deviceInfo.Handle != IntPtr.Zero)) + Marshal.FreeHGlobal(deviceInfo.Handle); + + ColorData = null; + + base.Dispose(); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Generic/AuraRGBDeviceInfo.cs b/RGB.NET.Devices.Aura/Generic/AuraRGBDeviceInfo.cs new file mode 100644 index 0000000..2c302ec --- /dev/null +++ b/RGB.NET.Devices.Aura/Generic/AuraRGBDeviceInfo.cs @@ -0,0 +1,55 @@ +using System; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic information for a Corsair-. + /// + public class AuraRGBDeviceInfo : IRGBDeviceInfo + { + #region Properties & Fields + + /// + public RGBDeviceType DeviceType { get; } + + /// + public string Manufacturer { get; } + + /// + public string Model { get; } + + /// + public Uri Image { get; protected set; } + + /// + public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; + + /// + /// 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 AuraRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, string manufacturer = "Unknown", string model = "Generic Aura-Device") + { + this.DeviceType = deviceType; + this.Handle = handle; + this.Manufacturer = manufacturer; + this.Model = model; + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDevice.cs new file mode 100644 index 0000000..082db89 --- /dev/null +++ b/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDevice.cs @@ -0,0 +1,56 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Aura.Native; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a Aura graphicsCard. + /// + public class AuraGraphicsCardRGBDevice : AuraRGBDevice + { + #region Properties & Fields + + /// + /// Gets information about the . + /// + public AuraGraphicsCardRGBDeviceInfo GraphicsCardDeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Aura for the graphics card. + internal AuraGraphicsCardRGBDevice(AuraGraphicsCardRGBDeviceInfo info) + : base(info) + { + this.GraphicsCardDeviceInfo = info; + } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + //TODO DarthAffe 07.10.2017: Look for a good default layout + int ledCount = _AuraSDK.GetGPULedCount(GraphicsCardDeviceInfo.Handle); + for (int i = 0; i < ledCount; i++) + InitializeLed(new AuraLedId(this, AuraLedIds.GraphicsCardLed1 + i, 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($@"Layouts\Aura\GraphicsCards\{GraphicsCardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + null, PathHelper.GetAbsolutePath(@"Images\Aura\GraphicsCards")); + } + + /// + protected override void ApplyColorData() => _AuraSDK.SetGPUColor(GraphicsCardDeviceInfo.Handle, ColorData); + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDeviceInfo.cs b/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDeviceInfo.cs new file mode 100644 index 0000000..0209796 --- /dev/null +++ b/RGB.NET.Devices.Aura/GraphicsCard/AuraGraphicsCardRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +using System; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic information for a . + /// + public class AuraGraphicsCardRGBDeviceInfo : AuraRGBDeviceInfo + { + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The type of the . + /// The handle of the . + internal AuraGraphicsCardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) + : base(deviceType, handle) + { + Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Aura\GraphicsCards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDevice.cs b/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDevice.cs new file mode 100644 index 0000000..afe6937 --- /dev/null +++ b/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDevice.cs @@ -0,0 +1,56 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Aura.Native; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a Aura keyboard. + /// + public class AuraKeyboardRGBDevice : AuraRGBDevice + { + #region Properties & Fields + + /// + /// Gets information about the . + /// + public AuraKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Aura for the keyboard. + internal AuraKeyboardRGBDevice(AuraKeyboardRGBDeviceInfo info) + : base(info) + { + this.KeyboardDeviceInfo = info; + } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + //TODO DarthAffe 07.10.2017: Look for a good default layout + int ledCount = _AuraSDK.GetClaymoreKeyboardLedCount(KeyboardDeviceInfo.Handle); + for (int i = 0; i < ledCount; i++) + InitializeLed(new AuraLedId(this, AuraLedIds.KeyboardLed1 + i, i), new Rectangle(i * 19, 0, 19, 19)); + + string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Aura\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Aura\Keyboards")); + } + + /// + protected override void ApplyColorData() => _AuraSDK.SetClaymoreKeyboardColor(KeyboardDeviceInfo.Handle, ColorData); + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDeviceInfo.cs new file mode 100644 index 0000000..22455af --- /dev/null +++ b/RGB.NET.Devices.Aura/Keyboard/AuraKeyboardRGBDeviceInfo.cs @@ -0,0 +1,62 @@ +using System; +using System.Globalization; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic information for a . + /// + public class AuraKeyboardRGBDeviceInfo : AuraRGBDeviceInfo + { + #region Properties & Fields + + /// + /// Gets the physical layout of the keyboard. + /// + public AuraPhysicalKeyboardLayout PhysicalLayout { get; private set; } + + /// + /// Gets the logical layout of the keyboard. + /// + public AuraLogicalKeyboardLayout 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 AuraKeyboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, CultureInfo culture) + : base(deviceType, handle, "Asus", "Claymore") + { + SetLayouts(culture.KeyboardLayoutId); + + Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Aura\Keyboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute); + } + + #endregion + + #region Methods + + private void SetLayouts(int keyboardLayoutId) + { + switch (keyboardLayoutId) + { + //TODO DarthAffe 07.10.2017: Implement + default: + PhysicalLayout = AuraPhysicalKeyboardLayout.TODO; + LogicalLayout = AuraLogicalKeyboardLayout.TODO; + break; + } + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Layouts/DeviceLayout.xsd b/RGB.NET.Devices.Aura/Layouts/DeviceLayout.xsd new file mode 100644 index 0000000..92690b3 --- /dev/null +++ b/RGB.NET.Devices.Aura/Layouts/DeviceLayout.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDevice.cs b/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDevice.cs new file mode 100644 index 0000000..252a284 --- /dev/null +++ b/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDevice.cs @@ -0,0 +1,56 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Aura.Native; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a Aura mainboard. + /// + public class AuraMainboardRGBDevice : AuraRGBDevice + { + #region Properties & Fields + + /// + /// Gets information about the . + /// + public AuraMainboardRGBDeviceInfo MainboardDeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Aura for the mainboard. + internal AuraMainboardRGBDevice(AuraMainboardRGBDeviceInfo info) + : base(info) + { + this.MainboardDeviceInfo = info; + } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + //TODO DarthAffe 07.10.2017: Look for a good default layout + int ledCount = _AuraSDK.GetMbLedCount(MainboardDeviceInfo.Handle); + for (int i = 0; i < ledCount; i++) + InitializeLed(new AuraLedId(this, AuraLedIds.MainboardAudio1 + i, 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($@"Layouts\Aura\Mainboards\{MainboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + null, PathHelper.GetAbsolutePath(@"Images\Aura\Mainboards")); + } + + /// + protected override void ApplyColorData() => _AuraSDK.SetMbColor(MainboardDeviceInfo.Handle, ColorData); + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDeviceInfo.cs b/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDeviceInfo.cs new file mode 100644 index 0000000..f06f567 --- /dev/null +++ b/RGB.NET.Devices.Aura/Mainboard/AuraMainboardRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +using System; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic information for a . + /// + public class AuraMainboardRGBDeviceInfo : AuraRGBDeviceInfo + { + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The type of the . + /// The handle of the . + internal AuraMainboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) + : base(deviceType, handle) + { + Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Aura\Mainboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDevice.cs b/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDevice.cs new file mode 100644 index 0000000..2e22c21 --- /dev/null +++ b/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDevice.cs @@ -0,0 +1,55 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Aura.Native; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a Aura mouse. + /// + public class AuraMouseRGBDevice : AuraRGBDevice + { + #region Properties & Fields + + /// + /// Gets information about the . + /// + public AuraMouseRGBDeviceInfo MouseDeviceInfo { get; } + + #endregion + + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Aura for the mouse. + internal AuraMouseRGBDevice(AuraMouseRGBDeviceInfo info) + : base(info) + { + this.MouseDeviceInfo = info; + } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + //TODO DarthAffe 07.10.2017: Look for a good default layout + int ledCount = _AuraSDK.GetRogMouseLedCount(MouseDeviceInfo.Handle); + for (int i = 0; i < ledCount; i++) + InitializeLed(new AuraLedId(this, AuraLedIds.MouseLed1 + i, i), new Rectangle(i * 10, 0, 10, 10)); + + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Aura\Mouses\{MouseDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + null, PathHelper.GetAbsolutePath(@"Images\Aura\Mouses")); + } + + /// + protected override void ApplyColorData() => _AuraSDK.SetRogMouseColor(MouseDeviceInfo.Handle, ColorData); + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDeviceInfo.cs new file mode 100644 index 0000000..26981a5 --- /dev/null +++ b/RGB.NET.Devices.Aura/Mouse/AuraMouseRGBDeviceInfo.cs @@ -0,0 +1,28 @@ +using System; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Aura +{ + /// + /// + /// Represents a generic information for a . + /// + public class AuraMouseRGBDeviceInfo : AuraRGBDeviceInfo + { + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The type of the . + /// The handle of the . + internal AuraMouseRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) + : base(deviceType, handle, "Asus", "Rog") + { + Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Aura\Mouses\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute); + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Native/_AuraSDK.cs b/RGB.NET.Devices.Aura/Native/_AuraSDK.cs new file mode 100644 index 0000000..c92175f --- /dev/null +++ b/RGB.NET.Devices.Aura/Native/_AuraSDK.cs @@ -0,0 +1,199 @@ +// 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.Exceptions; + +namespace RGB.NET.Devices.Aura.Native +{ + // ReSharper disable once InconsistentNaming + internal static class _AuraSDK + { + #region Libary Management + + private static IntPtr _dllHandle = IntPtr.Zero; + + private static List _helperLibraries = new List(); + + /// + /// Gets the loaded architecture (x64/x86). + /// + internal static string LoadedArchitecture { get; private set; } + + /// + /// Reloads the SDK. + /// + internal static void Reload() + { + UnloadAuraSDK(); + LoadAuraSDK(); + } + + private static void LoadAuraSDK() + { + if (_dllHandle != IntPtr.Zero) return; + + // HACK: Load library at runtime to support both, x86 and x64 with one managed dll + List possiblePathList = Environment.Is64BitProcess ? AuraDeviceProvider.PossibleX64NativePaths : AuraDeviceProvider.PossibleX86NativePaths; + string dllPath = possiblePathList.FirstOrDefault(File.Exists); + if (dllPath == null) throw new RGBDeviceException($"Can't find the Aura-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)); + + _enumerateRogMouseControllerPointer = (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)); + } + + private static void UnloadAuraSDK() + { + 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 _enumerateRogMouseControllerPointer; + private static GetRogMouseLedCountPointer _getRogMouseLedCountPointer; + private static SetRogMouseModePointer _setRogMouseModePointer; + private static SetRogMouseColorPointer _setRogMouseColorPointer; + + #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 void 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); + + #endregion + + // ReSharper disable EventExceptionNotDocumented + + internal static int EnumerateMbController(IntPtr handles, int size) => _enumerateMbControllerPointer(handles, size); + internal static int GetMbLedCount(IntPtr handle) => _getMbLedCountPointer(handle); + internal static void SetMbMode(IntPtr handle, int mode) => _setMbModePointer(handle, mode); + internal static void SetMbColor(IntPtr handle, byte[] colors) => _setMbColorPointer(handle, colors, colors.Length); + + internal static byte[] GetMbColor(IntPtr handle, int ledCount) + { + byte[] colors = new byte[ledCount * 3]; + IntPtr readColorsPtr = Marshal.AllocHGlobal(colors.Length); + _getMbColorPointer(handle, readColorsPtr, colors.Length); + Marshal.Copy(readColorsPtr, colors, 0, colors.Length); + Marshal.FreeHGlobal(readColorsPtr); + return colors; + } + + internal static int EnumerateGPU(IntPtr handles, int size) => _enumerateGPUPointer(handles, size); + internal static int GetGPULedCount(IntPtr handle) => _getGPULedCountPointer(handle); + internal static void SetGPUMode(IntPtr handle, int mode) => _setGPUModePointer(handle, mode); + internal static void SetGPUColor(IntPtr handle, byte[] colors) => _setGPUColorPointer(handle, colors, colors.Length); + + internal static bool CreateClaymoreKeyboard(IntPtr handle) => _createClaymoreKeyboardPointer(handle); + internal static int GetClaymoreKeyboardLedCount(IntPtr handle) => _getClaymoreKeyboardLedCountPointer(handle); + internal static void SetClaymoreKeyboardMode(IntPtr handle, int mode) => _setClaymoreKeyboardModePointer(handle, mode); + internal static void SetClaymoreKeyboardColor(IntPtr handle, byte[] colors) => _setClaymoreKeyboardColorPointer(handle, colors, colors.Length); + + internal static bool CreateRogMouse(IntPtr handle) => _enumerateRogMouseControllerPointer(handle); + internal static int GetRogMouseLedCount(IntPtr handle) => _getRogMouseLedCountPointer(handle); + internal static void SetRogMouseMode(IntPtr handle, int mode) => _setRogMouseModePointer(handle, mode); + internal static void SetRogMouseColor(IntPtr handle, byte[] colors) => _setRogMouseColorPointer(handle, colors, colors.Length); + + // ReSharper restore EventExceptionNotDocumented + + #endregion + } +} diff --git a/RGB.NET.Devices.Aura/Properties/AssemblyInfo.cs b/RGB.NET.Devices.Aura/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..57c63b3 --- /dev/null +++ b/RGB.NET.Devices.Aura/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RGB.NET.Devices.Aura")] +[assembly: AssemblyDescription("Aura-Device-Implementations of RGB.NET")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Wyrez")] +[assembly: AssemblyProduct("RGB.NET.Devices.Aura")] +[assembly: AssemblyCopyright("Copyright © Wyrez 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("dda8c4c2-8abf-4fa0-9af9-c47ad0bfe47d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj b/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj new file mode 100644 index 0000000..54eb47e --- /dev/null +++ b/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj @@ -0,0 +1,96 @@ + + + + + Debug + AnyCPU + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59} + Library + Properties + RGB.NET.Devices.Aura + RGB.NET.Devices.Aura + v4.5 + 512 + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + ..\bin\RGB.NET.Devices.Aura.xml + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + ..\bin\RGB.NET.Devices.Aura.xml + + + + + + ..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + {5a4f9a75-75fe-47cd-90e5-914d5b20d232} + RGB.NET.Core + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj.DotSettings b/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj.DotSettings new file mode 100644 index 0000000..8ae9131 --- /dev/null +++ b/RGB.NET.Devices.Aura/RGB.NET.Devices.Aura.csproj.DotSettings @@ -0,0 +1,8 @@ + + True + True + True + True + True + True + True \ No newline at end of file diff --git a/RGB.NET.Devices.Aura/packages.config b/RGB.NET.Devices.Aura/packages.config new file mode 100644 index 0000000..a59695c --- /dev/null +++ b/RGB.NET.Devices.Aura/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.Aura/targets/RGB.NET.Devices.Aura.targets b/RGB.NET.Devices.Aura/targets/RGB.NET.Devices.Aura.targets new file mode 100644 index 0000000..8f912c4 --- /dev/null +++ b/RGB.NET.Devices.Aura/targets/RGB.NET.Devices.Aura.targets @@ -0,0 +1,150 @@ + + + + + + + + + + + False + + + False + + + + + + + + %(RecursiveDir)%(FileName)%(Extension) + Always + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bin\%(RecursiveDir)%(Filename)%(Extension) + + + + + + + + + + + + + + + + + + + + + + + $(PostBuildEventDependsOn); + CopyAuraSDKFiles; + + + $(BuildDependsOn); + CopyAuraSDKFiles; + + + $(CleanDependsOn); + CleanAuraSDKFiles; + + + + + + + + CollectAuraSDKFiles; + $(PipelineCollectFilesPhaseDependsOn); + + + diff --git a/RGB.NET.sln b/RGB.NET.sln index 5dfc45a..006cd61 100644 --- a/RGB.NET.sln +++ b/RGB.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Core", "RGB.NET.Core\RGB.NET.Core.csproj", "{5A4F9A75-75FE-47CD-90E5-914D5B20D232}" EndProject @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{06416566 NuGet\RGB.NET.Brushes.nuspec = NuGet\RGB.NET.Brushes.nuspec NuGet\RGB.NET.Core.nuspec = NuGet\RGB.NET.Core.nuspec NuGet\RGB.NET.Decorators.nuspec = NuGet\RGB.NET.Decorators.nuspec + NuGet\RGB.NET.Devices.Aura.nuspec = NuGet\RGB.NET.Devices.Aura.nuspec NuGet\RGB.NET.Devices.CoolerMaster.nuspec = NuGet\RGB.NET.Devices.CoolerMaster.nuspec NuGet\RGB.NET.Devices.Corsair.nuspec = NuGet\RGB.NET.Devices.Corsair.nuspec NuGet\RGB.NET.Devices.Logitech.nuspec = NuGet\RGB.NET.Devices.Logitech.nuspec @@ -54,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Decorators", "RGB.N {5A4F9A75-75FE-47CD-90E5-914D5B20D232} = {5A4F9A75-75FE-47CD-90E5-914D5B20D232} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Aura", "RGB.NET.Devices.Aura\RGB.NET.Devices.Aura.csproj", "{4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,6 +107,10 @@ Global {7012C431-244A-453F-B7FD-59E030CDBC44}.Debug|Any CPU.Build.0 = Debug|Any CPU {7012C431-244A-453F-B7FD-59E030CDBC44}.Release|Any CPU.ActiveCfg = Release|Any CPU {7012C431-244A-453F-B7FD-59E030CDBC44}.Release|Any CPU.Build.0 = Release|Any CPU + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -119,6 +126,7 @@ Global {85609427-D433-44E2-A249-CE890B66D845} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} {DB2911F6-404C-4BC8-B35F-232A7450755F} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} {7012C431-244A-453F-B7FD-59E030CDBC44} = {FFBCAF88-6646-43EC-9F24-2D719D3779C8} + {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CDECA6C7-8D18-4AF3-94F7-C70A69B8571B}