Applied some C#12 stuff

This commit is contained in:
DarthAffe committed 2023-12-22 20:56:56 +01:00
1 parent 0444730aca
commit d85f1559b3
105 files changed
+329 -422

No files matched your search

@@ -5,5 +5,4 @@ namespace RGB.NET.Devices.Wooting.Generic;
/// <summary>
/// Represents a Wooting RGB-device.
/// </summary>
public interface IWootingRGBDevice : IRGBDevice
{ }
public interface IWootingRGBDevice : IRGBDevice;
+23 -23
View File
@@ -15,7 +15,7 @@ internal static class _WootingSDK
{
#region Library management
private static IntPtr _handle = IntPtr.Zero;
private static nint _handle = 0;
internal static object SdkLock = new();
/// <summary>
@@ -29,7 +29,7 @@ internal static class _WootingSDK
private static void LoadWootingSDK()
{
if (_handle != IntPtr.Zero) return;
if (_handle != 0) return;
List<string> possiblePathList = GetPossibleLibraryPaths().ToList();
@@ -71,21 +71,21 @@ internal static class _WootingSDK
internal static void UnloadWootingSDK()
{
if (_handle == IntPtr.Zero) return;
if (_handle == 0) return;
Close();
_getDeviceInfoPointer = IntPtr.Zero;
_keyboardConnectedPointer = IntPtr.Zero;
_resetPointer = IntPtr.Zero;
_closePointer = IntPtr.Zero;
_arrayUpdateKeyboardPointer = IntPtr.Zero;
_arraySetSinglePointer = IntPtr.Zero;
_getDeviceCountPointer = IntPtr.Zero;
_selectDevicePointer = IntPtr.Zero;
_getDeviceInfoPointer = 0;
_keyboardConnectedPointer = 0;
_resetPointer = 0;
_closePointer = 0;
_arrayUpdateKeyboardPointer = 0;
_arraySetSinglePointer = 0;
_getDeviceCountPointer = 0;
_selectDevicePointer = 0;
NativeLibrary.Free(_handle);
_handle = IntPtr.Zero;
_handle = 0;
}
#endregion
@@ -94,18 +94,18 @@ internal static class _WootingSDK
#region Pointers
private static IntPtr _getDeviceInfoPointer;
private static IntPtr _keyboardConnectedPointer;
private static IntPtr _resetPointer;
private static IntPtr _closePointer;
private static IntPtr _arrayUpdateKeyboardPointer;
private static IntPtr _arraySetSinglePointer;
private static IntPtr _getDeviceCountPointer;
private static IntPtr _selectDevicePointer;
private static nint _getDeviceInfoPointer;
private static nint _keyboardConnectedPointer;
private static nint _resetPointer;
private static nint _closePointer;
private static nint _arrayUpdateKeyboardPointer;
private static nint _arraySetSinglePointer;
private static nint _getDeviceCountPointer;
private static nint _selectDevicePointer;
#endregion
internal static unsafe IntPtr GetDeviceInfo() => ((delegate* unmanaged[Cdecl]<IntPtr>)ThrowIfZero(_getDeviceInfoPointer))();
internal static unsafe nint GetDeviceInfo() => ((delegate* unmanaged[Cdecl]<nint>)ThrowIfZero(_getDeviceInfoPointer))();
internal static unsafe bool KeyboardConnected() => ((delegate* unmanaged[Cdecl]<bool>)ThrowIfZero(_keyboardConnectedPointer))();
internal static unsafe bool Reset() => ((delegate* unmanaged[Cdecl]<bool>)ThrowIfZero(_resetPointer))();
internal static unsafe bool Close() => ((delegate* unmanaged[Cdecl]<bool>)ThrowIfZero(_closePointer))();
@@ -115,9 +115,9 @@ internal static class _WootingSDK
internal static unsafe byte GetDeviceCount() => ((delegate* unmanaged[Cdecl]<byte>)ThrowIfZero(_getDeviceCountPointer))();
internal static unsafe void SelectDevice(byte index) => ((delegate* unmanaged[Cdecl]<byte, void>)ThrowIfZero(_selectDevicePointer))(index);
private static IntPtr ThrowIfZero(IntPtr ptr)
private static nint ThrowIfZero(nint ptr)
{
if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Wooting-SDK is not initialized.");
if (ptr == 0) throw new RGBDeviceException("The Wooting-SDK is not initialized.");
return ptr;
}
@@ -38,26 +38,26 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications.
/// The first match will be used.
/// </summary>
public static List<string> PossibleX86NativePathsWindows { get; } = new() { "x86/wooting-rgb-sdk.dll" };
public static List<string> PossibleX86NativePathsWindows { get; } = ["x86/wooting-rgb-sdk.dll"];
/// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 windows applications.
/// The first match will be used.
/// </summary>
public static List<string> PossibleX64NativePathsWindows { get; } = new() { "x64/wooting-rgb-sdk64.dll" };
public static List<string> PossibleX64NativePathsWindows { get; } = ["x64/wooting-rgb-sdk64.dll"];
/// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 linux applications.
/// The first match will be used.
/// </summary>
public static List<string> PossibleNativePathsLinux { get; } = new() { "x64/libwooting-rgb-sdk.so" };
public static List<string> PossibleNativePathsLinux { get; } = ["x64/libwooting-rgb-sdk.so"];
/// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 MacOS applications.
/// The first match will be used.
/// </summary>
// ReSharper disable once InconsistentNaming
public static List<string> PossibleNativePathsMacOS { get; } = new() { "x64/libwooting-rgb-sdk.dylib" };
public static List<string> PossibleNativePathsMacOS { get; } = ["x64/libwooting-rgb-sdk.dylib"];
#endregion