mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Improved aura-support
This commit is contained in:
parent
54c3e92a72
commit
503d6d3bf5
@ -51,6 +51,11 @@ namespace RGB.NET.Core
|
||||
/// <summary>
|
||||
/// Represents a Graphics card
|
||||
/// </summary>
|
||||
GraphicsCard = 1 << 7
|
||||
GraphicsCard = 1 << 7,
|
||||
|
||||
/// <summary>
|
||||
/// Represents a DRAM-bank
|
||||
/// </summary>
|
||||
DRAM = 1 << 8,
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,13 +12,14 @@ namespace RGB.NET.Core
|
||||
/// <summary>
|
||||
/// Loads all devices the given <see cref="IRGBDeviceProvider"/> is able to provide.
|
||||
/// </summary>
|
||||
/// <param name="deviceProvider"></param>
|
||||
public void LoadDevices(IRGBDeviceProvider deviceProvider)
|
||||
/// <param name="deviceProvider">The <see cref="IRGBDeviceProvider"/> to load the devices from.</param>
|
||||
/// <param name="throwExceptions">Specifies whether exception during the initialization sequence should be thrown or not.</param>
|
||||
public void LoadDevices(IRGBDeviceProvider deviceProvider, bool throwExceptions = false)
|
||||
{
|
||||
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
|
||||
|
||||
List<IRGBDevice> addedDevices = new List<IRGBDevice>();
|
||||
if (deviceProvider.IsInitialized || deviceProvider.Initialize())
|
||||
if (deviceProvider.IsInitialized || deviceProvider.Initialize(throwExceptions))
|
||||
{
|
||||
_deviceProvider.Add(deviceProvider);
|
||||
|
||||
|
||||
@ -93,6 +93,7 @@ namespace RGB.NET.Devices.Aura
|
||||
|
||||
#region Mainboard
|
||||
|
||||
//TODO DarthAffe 21.10.2017: Requesting mainboards seems to fail if only a non mb-device (tested with only a gpu) is connected
|
||||
int mainboardCount = _AuraSDK.EnumerateMbController(IntPtr.Zero, 0);
|
||||
if (mainboardCount > 0)
|
||||
{
|
||||
@ -113,22 +114,43 @@ namespace RGB.NET.Devices.Aura
|
||||
|
||||
#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);
|
||||
//TODO DarthAffe 21.10.2017: This somehow returns non-existant gpus (at least for me) which cause huge lags (if a real aura-ready gpu is connected this doesn't happen)
|
||||
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);
|
||||
// }
|
||||
//}
|
||||
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 DRAM
|
||||
|
||||
//TODO DarthAffe 21.10.2017: This somehow returns non-existant gpus (at least for me) which cause huge lags (if a real aura-ready gpu is connected this doesn't happen)
|
||||
int dramCount = _AuraSDK.EnumerateDram(IntPtr.Zero, 0);
|
||||
if (dramCount > 0)
|
||||
{
|
||||
IntPtr dramHandles = Marshal.AllocHGlobal(dramCount * IntPtr.Size);
|
||||
_AuraSDK.EnumerateDram(dramHandles, dramCount);
|
||||
|
||||
for (int i = 0; i < dramCount; i++)
|
||||
{
|
||||
IntPtr handle = Marshal.ReadIntPtr(dramHandles, i);
|
||||
_AuraSDK.SetDramMode(handle, 1);
|
||||
AuraDramRGBDevice device = new AuraDramRGBDevice(new AuraDramRGBDeviceInfo(RGBDeviceType.DRAM, handle));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -176,7 +198,22 @@ namespace RGB.NET.Devices.Aura
|
||||
/// <inheritdoc />
|
||||
public void ResetDevices()
|
||||
{
|
||||
//TODO DarthAffe 07.10.2017: This seems to be impossible right now
|
||||
foreach (IRGBDevice device in Devices)
|
||||
{
|
||||
AuraRGBDeviceInfo deviceInfo = (AuraRGBDeviceInfo)device.DeviceInfo;
|
||||
switch (deviceInfo.DeviceType)
|
||||
{
|
||||
case RGBDeviceType.Mainboard:
|
||||
_AuraSDK.SetMbMode(deviceInfo.Handle, 0);
|
||||
break;
|
||||
case RGBDeviceType.GraphicsCard:
|
||||
_AuraSDK.SetGPUMode(deviceInfo.Handle, 0);
|
||||
break;
|
||||
case RGBDeviceType.DRAM:
|
||||
_AuraSDK.SetDramMode(deviceInfo.Handle, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
56
RGB.NET.Devices.Aura/Dram/AuraDramRGBDevice.cs
Normal file
56
RGB.NET.Devices.Aura/Dram/AuraDramRGBDevice.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Aura.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Aura
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a Aura dram.
|
||||
/// </summary>
|
||||
public class AuraDramRGBDevice : AuraRGBDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="AuraDramRGBDevice"/>.
|
||||
/// </summary>
|
||||
public AuraDramRGBDeviceInfo DramDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Aura.AuraDramRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by Aura for the DRAM.</param>
|
||||
internal AuraDramRGBDevice(AuraDramRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.DramDeviceInfo = info;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 21.10.2017: Look for a good default layout
|
||||
int ledCount = _AuraSDK.GetGPULedCount(DramDeviceInfo.Handle);
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
InitializeLed(new AuraLedId(this, AuraLedIds.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\Aura\Drams\{DramDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Aura\Drams"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ApplyColorData() => _AuraSDK.SetDramColor(DramDeviceInfo.Handle, ColorData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
28
RGB.NET.Devices.Aura/Dram/AuraDramRGBDeviceInfo.cs
Normal file
28
RGB.NET.Devices.Aura/Dram/AuraDramRGBDeviceInfo.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Aura
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Aura.AuraDramRGBDevice" />.
|
||||
/// </summary>
|
||||
public class AuraDramRGBDeviceInfo : AuraRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Aura.AuraDramRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
|
||||
internal AuraDramRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle)
|
||||
: base(deviceType, handle)
|
||||
{
|
||||
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Aura\Drams\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -21,8 +21,10 @@ namespace RGB.NET.Devices.Aura
|
||||
|
||||
GraphicsCardLed1 = 0x11,
|
||||
|
||||
MouseLed1 = 0x21,
|
||||
DramLed1 = 0x21,
|
||||
|
||||
KeyboardLed1 = 0x31,
|
||||
MouseLed1 = 0x31,
|
||||
|
||||
KeyboardLed1 = 0x41,
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,8 +17,6 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
|
||||
private static IntPtr _dllHandle = IntPtr.Zero;
|
||||
|
||||
private static List<IntPtr> _helperLibraries = new List<IntPtr>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the loaded architecture (x64/x86).
|
||||
/// </summary>
|
||||
@ -62,10 +60,16 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
_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));
|
||||
_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));
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
private static void UnloadAuraSDK()
|
||||
@ -111,11 +115,17 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
private static SetClaymoreKeyboardModePointer _setClaymoreKeyboardModePointer;
|
||||
private static SetClaymoreKeyboardColorPointer _setClaymoreKeyboardColorPointer;
|
||||
|
||||
private static CreateRogMousePointer _enumerateRogMouseControllerPointer;
|
||||
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
|
||||
@ -129,7 +139,7 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
[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);
|
||||
private delegate int GetMbColorPointer(IntPtr handle, IntPtr colors, int size);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int EnumerateGPUPointer(IntPtr handles, int size);
|
||||
@ -158,6 +168,17 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
[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
|
||||
@ -167,9 +188,10 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
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)
|
||||
internal static byte[] GetMbColor(IntPtr handle)
|
||||
{
|
||||
byte[] colors = new byte[ledCount * 3];
|
||||
int count = _getDramColorPointer(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);
|
||||
@ -187,11 +209,27 @@ namespace RGB.NET.Devices.Aura.Native
|
||||
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 bool CreateRogMouse(IntPtr handle) => _enumerateRogMousePointer(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);
|
||||
|
||||
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
|
||||
|
||||
@ -46,6 +46,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AuraDeviceProvider.cs" />
|
||||
<Compile Include="Dram\AuraDramRGBDevice.cs" />
|
||||
<Compile Include="Dram\AuraDramRGBDeviceInfo.cs" />
|
||||
<Compile Include="Enum\AuraLedIds.cs" />
|
||||
<Compile Include="Enum\AuraLogicalKeyboardLayout.cs" />
|
||||
<Compile Include="Enum\AuraPhysicalKeyboardLayout.cs" />
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=dram/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic_005Cupdate/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user