mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Fixed warnings
This commit is contained in:
1 parent
57dc9afb32
commit
a0a1521658
118 files changed
+802
-1181
No files matched your search
@@ -4,7 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CoolerMaster.Helper;
|
||||
using RGB.NET.Devices.CoolerMaster.Native;
|
||||
@@ -19,7 +19,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private static CoolerMasterDeviceProvider _instance;
|
||||
private static CoolerMasterDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CoolerMasterDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
@@ -29,44 +29,27 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/CMSDK.dll" };
|
||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CMSDK.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/CMSDK.dll" };
|
||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CMSDK.dll" };
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Indicates if the SDK is initialized and ready to use.
|
||||
/// </summary>
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the loaded architecture (x64/x86).
|
||||
/// </summary>
|
||||
public string LoadedArchitecture => _CoolerMasterSDK.LoadedArchitecture;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets whether the application has exclusive access to the SDK or not.
|
||||
/// </summary>
|
||||
public bool HasExclusiveAccess { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a function to get the culture for a specific device.
|
||||
/// </summary>
|
||||
// ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global
|
||||
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; } = Enumerable.Empty<IRGBDevice>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for cooler master devices.
|
||||
/// </summary>
|
||||
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
|
||||
public DeviceUpdateTrigger UpdateTrigger { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -95,7 +78,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
try
|
||||
{
|
||||
UpdateTrigger?.Stop();
|
||||
UpdateTrigger.Stop();
|
||||
|
||||
_CoolerMasterSDK.Reload();
|
||||
if (_CoolerMasterSDK.GetSDKVersion() <= 0) return false;
|
||||
@@ -118,7 +101,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{
|
||||
case RGBDeviceType.Keyboard:
|
||||
CoolerMasterPhysicalKeyboardLayout physicalLayout = _CoolerMasterSDK.GetDeviceLayout(index);
|
||||
device = new CoolerMasterKeyboardRGBDevice(new CoolerMasterKeyboardRGBDeviceInfo(index, physicalLayout, GetCulture()));
|
||||
device = new CoolerMasterKeyboardRGBDevice(new CoolerMasterKeyboardRGBDeviceInfo(index, physicalLayout));
|
||||
break;
|
||||
|
||||
case RGBDeviceType.Mouse:
|
||||
@@ -142,7 +125,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
catch { if (throwExceptions) throw; }
|
||||
}
|
||||
|
||||
UpdateTrigger?.Start();
|
||||
UpdateTrigger.Start();
|
||||
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||
IsInitialized = true;
|
||||
|
||||
@@ -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.CoolerMaster
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains list of available logical layouts for cooler master keyboards.
|
||||
/// </summary>
|
||||
public enum CoolerMasterLogicalKeyboardLayout
|
||||
{
|
||||
DE
|
||||
};
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// Gets or sets the update queue performing updates for this device.
|
||||
/// </summary>
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
protected CoolerMasterUpdateQueue UpdateQueue { get; set; }
|
||||
protected CoolerMasterUpdateQueue? UpdateQueue { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
if (Size == Size.Invalid)
|
||||
{
|
||||
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||
Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
|
||||
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
protected abstract void InitializeLayout();
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue?.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose" />
|
||||
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}.Dispose" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CoolerMaster.Helper;
|
||||
|
||||
namespace RGB.NET.Devices.CoolerMaster
|
||||
@@ -45,7 +44,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
this.DeviceType = deviceType;
|
||||
this.DeviceIndex = deviceIndex;
|
||||
|
||||
Model = deviceIndex.GetDescription();
|
||||
Model = deviceIndex.GetDescription() ?? "Unknown";
|
||||
DeviceName = $"{Manufacturer} {Model}";
|
||||
}
|
||||
|
||||
|
||||
@@ -14,38 +14,29 @@ namespace RGB.NET.Devices.CoolerMaster.Helper
|
||||
/// Gets the value of the <see cref="DescriptionAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">The enum value to get the description from.</param>
|
||||
/// <typeparam name="T">The generic enum-type</typeparam>
|
||||
/// <returns>The value of the <see cref="DescriptionAttribute"/> or the <see cref="Enum.ToString()" /> result of the source.</returns>
|
||||
internal static string GetDescription<T>(this T source)
|
||||
where T : struct
|
||||
{
|
||||
return source.GetAttribute<DescriptionAttribute, T>()?.Description ?? source.ToString();
|
||||
}
|
||||
internal static string? GetDescription(this Enum source)
|
||||
=> source.GetAttribute<DescriptionAttribute>()?.Description ?? source.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the <see cref="DeviceTypeAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">The enum value to get the description from.</param>
|
||||
/// <typeparam name="T">The generic enum-type</typeparam>
|
||||
/// <returns>The value of the <see cref="DeviceTypeAttribute"/> or the <see cref="Enum.ToString()" /> result of the source.</returns>
|
||||
internal static RGBDeviceType GetDeviceType<T>(this T source)
|
||||
where T : struct
|
||||
{
|
||||
return source.GetAttribute<DeviceTypeAttribute, T>()?.DeviceType ?? RGBDeviceType.Unknown;
|
||||
}
|
||||
internal static RGBDeviceType GetDeviceType(this Enum source)
|
||||
=> source.GetAttribute<DeviceTypeAttribute>()?.DeviceType ?? RGBDeviceType.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attribute of type T.
|
||||
/// </summary>
|
||||
/// <param name="source">The enum value to get the attribute from</param>
|
||||
/// <typeparam name="T">The generic attribute type</typeparam>
|
||||
/// <typeparam name="TEnum">The generic enum-type</typeparam>
|
||||
/// <returns>The <see cref="Attribute"/>.</returns>
|
||||
private static T GetAttribute<T, TEnum>(this TEnum source)
|
||||
private static T? GetAttribute<T>(this Enum source)
|
||||
where T : Attribute
|
||||
where TEnum : struct
|
||||
{
|
||||
FieldInfo fi = source.GetType().GetField(source.ToString());
|
||||
FieldInfo? fi = source.GetType().GetField(source.ToString());
|
||||
if (fi == null) return null;
|
||||
T[] attributes = (T[])fi.GetCustomAttributes(typeof(T), false);
|
||||
return attributes.Length > 0 ? attributes[0] : null;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
#region MasterKeysL
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysL_US = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysL_US = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -131,8 +131,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, (5,20) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysL_EU = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysL_EU = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -253,8 +253,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
#region MasterKeysM
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysM_US = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysM_US = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -354,8 +354,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, (5,17) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysM_EU = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysM_EU = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -460,8 +460,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
#region MasterKeysS
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysS_US = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysS_US = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -556,8 +556,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_ArrowRight, (5,17) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysS_EU = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysS_EU = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -657,8 +657,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
#region MasterKeysMK750
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_US = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_US = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -801,8 +801,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_Custom22, (6,17) },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_EU = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_EU = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -946,8 +946,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_Custom22, (6,17) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_JP = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> MasterKeysMK750_JP = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -1099,8 +1099,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
#region CKxxx
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_US = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_US = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -1212,8 +1212,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, (5,20) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_EU = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_EU = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -1326,8 +1326,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, (5,20) }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_JP = new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
private static readonly Dictionary<LedId, (int row, int column)> CKxxx_JP = new()
|
||||
{
|
||||
{ LedId.Keyboard_Escape, (0,0) },
|
||||
{ LedId.Keyboard_F1, (0,1) },
|
||||
{ LedId.Keyboard_F2, (0,2) },
|
||||
@@ -1450,7 +1450,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// Contains all the hardware-id mappings for CoolerMaster devices.
|
||||
/// </summary>
|
||||
public static readonly Dictionary<CoolerMasterDevicesIndexes, Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>> Mapping =
|
||||
new Dictionary<CoolerMasterDevicesIndexes, Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>>
|
||||
new()
|
||||
{
|
||||
{ CoolerMasterDevicesIndexes.MasterKeys_L, new Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>
|
||||
{
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
if (!CoolerMasterKeyboardLedMappings.Mapping.TryGetValue(DeviceInfo.DeviceIndex, out Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>> deviceMappings))
|
||||
if (!CoolerMasterKeyboardLedMappings.Mapping.TryGetValue(DeviceInfo.DeviceIndex, out Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>? deviceMappings))
|
||||
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex}");
|
||||
if (!deviceMappings.TryGetValue(DeviceInfo.PhysicalLayout, out Dictionary<LedId, (int row, int column)> mapping))
|
||||
if (!deviceMappings.TryGetValue(DeviceInfo.PhysicalLayout, out Dictionary<LedId, (int row, int column)>? mapping))
|
||||
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex} with physical layout {DeviceInfo.PhysicalLayout}");
|
||||
|
||||
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
|
||||
AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
|
||||
foreach ((LedId ledId, (int row, int column)) in mapping)
|
||||
AddLed(ledId, new Point(column * 19, row * 19), new Size(19, 19));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CoolerMaster
|
||||
{
|
||||
@@ -16,11 +15,6 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// </summary>
|
||||
public CoolerMasterPhysicalKeyboardLayout PhysicalLayout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CoolerMasterLogicalKeyboardLayout"/> of the <see cref="CoolerMasterKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CoolerMasterLogicalKeyboardLayout LogicalLayout { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@@ -32,23 +26,10 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.</param>
|
||||
/// <param name="physicalKeyboardLayout">The <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterPhysicalKeyboardLayout" /> of the <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.</param>
|
||||
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using</param>
|
||||
internal CoolerMasterKeyboardRGBDeviceInfo(CoolerMasterDevicesIndexes deviceIndex, CoolerMasterPhysicalKeyboardLayout physicalKeyboardLayout, CultureInfo culture)
|
||||
internal CoolerMasterKeyboardRGBDeviceInfo(CoolerMasterDevicesIndexes deviceIndex, CoolerMasterPhysicalKeyboardLayout physicalKeyboardLayout)
|
||||
: base(RGBDeviceType.Keyboard, deviceIndex)
|
||||
{
|
||||
this.PhysicalLayout = physicalKeyboardLayout;
|
||||
|
||||
SetLayouts(culture.KeyboardLayoutId);
|
||||
}
|
||||
|
||||
private void SetLayouts(int keyboardLayoutId)
|
||||
{
|
||||
switch (keyboardLayoutId)
|
||||
{
|
||||
//TODO DarthAffe 02.04.2017: Check all available keyboards and there layout-ids
|
||||
default:
|
||||
LogicalLayout = CoolerMasterLogicalKeyboardLayout.DE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static readonly Dictionary<CoolerMasterDevicesIndexes, Dictionary<LedId, (int row, int column)>> Mapping =
|
||||
new Dictionary<CoolerMasterDevicesIndexes, Dictionary<LedId, (int row, int column)>>
|
||||
new()
|
||||
{
|
||||
{ CoolerMasterDevicesIndexes.MasterMouse_L, new Dictionary<LedId, (int row, int column)>
|
||||
{
|
||||
|
||||
@@ -16,12 +16,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
#region Libary Management
|
||||
|
||||
private static IntPtr _dllHandle = IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the loaded architecture (x64/x86).
|
||||
/// </summary>
|
||||
internal static string LoadedArchitecture { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the SDK.
|
||||
/// </summary>
|
||||
@@ -37,7 +32,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
List<string> possiblePathList = Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths;
|
||||
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
string? dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CoolerMaster-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
@@ -76,14 +71,14 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
|
||||
#region Pointers
|
||||
|
||||
private static GetSDKVersionPointer _getSDKVersionPointer;
|
||||
private static SetControlDevicePointer _setControlDevicenPointer;
|
||||
private static IsDevicePlugPointer _isDevicePlugPointer;
|
||||
private static GetDeviceLayoutPointer _getDeviceLayoutPointer;
|
||||
private static EnableLedControlPointer _enableLedControlPointer;
|
||||
private static RefreshLedPointer _refreshLedPointer;
|
||||
private static SetLedColorPointer _setLedColorPointer;
|
||||
private static SetAllLedColorPointer _setAllLedColorPointer;
|
||||
private static GetSDKVersionPointer? _getSDKVersionPointer;
|
||||
private static SetControlDevicePointer? _setControlDevicenPointer;
|
||||
private static IsDevicePlugPointer? _isDevicePlugPointer;
|
||||
private static GetDeviceLayoutPointer? _getDeviceLayoutPointer;
|
||||
private static EnableLedControlPointer? _enableLedControlPointer;
|
||||
private static RefreshLedPointer? _refreshLedPointer;
|
||||
private static SetLedColorPointer? _setLedColorPointer;
|
||||
private static SetAllLedColorPointer? _setAllLedColorPointer;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -125,49 +120,49 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
/// <summary>
|
||||
/// CM-SDK: Get SDK Dll's Version.
|
||||
/// </summary>
|
||||
internal static int GetSDKVersion() => _getSDKVersionPointer();
|
||||
internal static int GetSDKVersion() => (_getSDKVersionPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke();
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: set operating device
|
||||
/// </summary>
|
||||
internal static void SetControlDevice(CoolerMasterDevicesIndexes devicesIndexes)
|
||||
=> _setControlDevicenPointer(devicesIndexes);
|
||||
=> (_setControlDevicenPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(devicesIndexes);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: verify if the deviced is plugged in
|
||||
/// </summary>
|
||||
internal static bool IsDevicePlugged(CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _isDevicePlugPointer(devIndex);
|
||||
=> (_isDevicePlugPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: Obtain current device layout
|
||||
/// </summary>
|
||||
internal static CoolerMasterPhysicalKeyboardLayout GetDeviceLayout(CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _getDeviceLayoutPointer(devIndex);
|
||||
=> (_getDeviceLayoutPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: set control over device’s LED
|
||||
/// </summary>
|
||||
internal static bool EnableLedControl(bool value, CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _enableLedControlPointer(value, devIndex);
|
||||
=> (_enableLedControlPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(value, devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: Print out the lights setting from Buffer to LED
|
||||
/// </summary>
|
||||
internal static bool RefreshLed(bool autoRefresh, CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _refreshLedPointer(autoRefresh, devIndex);
|
||||
=> (_refreshLedPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(autoRefresh, devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: Set single Key LED color
|
||||
/// </summary>
|
||||
internal static bool SetLedColor(int row, int column, byte r, byte g, byte b, CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _setLedColorPointer(row, column, r, g, b, devIndex);
|
||||
=> (_setLedColorPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(row, column, r, g, b, devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CM-SDK: Set Keyboard "every LED" color
|
||||
/// </summary>
|
||||
internal static bool SetAllLedColor(_CoolerMasterColorMatrix colorMatrix, CoolerMasterDevicesIndexes devIndex = CoolerMasterDevicesIndexes.Default)
|
||||
=> _setAllLedColorPointer(colorMatrix, devIndex);
|
||||
=> (_setAllLedColorPointer ?? throw new RGBDeviceException("The CoolerMaster-SDK is not initialized.")).Invoke(colorMatrix, devIndex);
|
||||
|
||||
// ReSharper restore EventExceptionNotDocumented
|
||||
|
||||
|
||||
Reference in new issue
Block a user