mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +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,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
@@ -18,7 +19,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private static CorsairDeviceProvider _instance;
|
||||
private static CorsairDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
@@ -28,35 +29,24 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// 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/CUESDK.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" };
|
||||
public static List<string> PossibleX86NativePaths { get; } = new() { "x86/CUESDK.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.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/CUESDK.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" };
|
||||
public static List<string> PossibleX64NativePaths { get; } = new() { "x64/CUESDK.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.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 => _CUESDK.LoadedArchitecture;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the protocol details for the current SDK-connection.
|
||||
/// </summary>
|
||||
public CorsairProtocolDetails ProtocolDetails { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets whether the application has exclusive access to the SDK or not.
|
||||
/// </summary>
|
||||
public bool HasExclusiveAccess { get; private set; }
|
||||
public CorsairProtocolDetails? ProtocolDetails { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last error documented by CUE.
|
||||
@@ -64,7 +54,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
public CorsairError LastError => _CUESDK.CorsairGetLastError();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; }
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; } = Enumerable.Empty<IRGBDevice>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for corsair devices.
|
||||
@@ -100,7 +90,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
|
||||
try
|
||||
{
|
||||
UpdateTrigger?.Stop();
|
||||
UpdateTrigger.Stop();
|
||||
|
||||
_CUESDK.Reload();
|
||||
|
||||
@@ -115,33 +105,23 @@ namespace RGB.NET.Devices.Corsair
|
||||
+ $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n"
|
||||
+ $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})");
|
||||
|
||||
if (exclusiveAccessIfPossible)
|
||||
{
|
||||
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
||||
throw new CUEException(LastError);
|
||||
|
||||
HasExclusiveAccess = true;
|
||||
}
|
||||
else
|
||||
HasExclusiveAccess = false;
|
||||
|
||||
// DarthAffe 07.07.2018: 127 is CUE, we want to directly compete with it as in older versions.
|
||||
if (!_CUESDK.CorsairSetLayerPriority(127))
|
||||
// DarthAffe 02.02.2021: 127 is iCUE
|
||||
if (!_CUESDK.CorsairSetLayerPriority(128))
|
||||
throw new CUEException(LastError);
|
||||
|
||||
Dictionary<string, int> modelCounter = new Dictionary<string, int>();
|
||||
Dictionary<string, int> modelCounter = new();
|
||||
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||
for (int i = 0; i < deviceCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
|
||||
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, RGBDeviceType.Unknown, nativeDeviceInfo, modelCounter);
|
||||
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo))!;
|
||||
CorsairRGBDeviceInfo info = new(i, RGBDeviceType.Unknown, nativeDeviceInfo, modelCounter);
|
||||
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
||||
continue; // Everything that doesn't support lighting control is useless
|
||||
|
||||
CorsairDeviceUpdateQueue deviceUpdateQueue = null;
|
||||
CorsairDeviceUpdateQueue? deviceUpdateQueue = null;
|
||||
foreach (ICorsairRGBDevice device in GetRGBDevice(info, i, nativeDeviceInfo, modelCounter))
|
||||
{
|
||||
if ((device == null) || !loadFilter.HasFlag(device.DeviceInfo.DeviceType)) continue;
|
||||
@@ -161,7 +141,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
catch { if (throwExceptions) throw; }
|
||||
}
|
||||
|
||||
UpdateTrigger?.Start();
|
||||
UpdateTrigger.Start();
|
||||
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||
IsInitialized = true;
|
||||
@@ -207,7 +187,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
case CorsairDeviceType.Cooler:
|
||||
case CorsairDeviceType.CommanderPro:
|
||||
case CorsairDeviceType.LightningNodePro:
|
||||
_CorsairChannelsInfo channelsInfo = nativeDeviceInfo.channels;
|
||||
_CorsairChannelsInfo? channelsInfo = nativeDeviceInfo.channels;
|
||||
if (channelsInfo != null)
|
||||
{
|
||||
IntPtr channelInfoPtr = channelsInfo.channels;
|
||||
@@ -217,14 +197,14 @@ namespace RGB.NET.Devices.Corsair
|
||||
CorsairLedId referenceLed = GetChannelReferenceId(info.CorsairDeviceType, channel);
|
||||
if (referenceLed == CorsairLedId.Invalid) continue;
|
||||
|
||||
_CorsairChannelInfo channelInfo = (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo));
|
||||
_CorsairChannelInfo channelInfo = (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
|
||||
|
||||
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
|
||||
IntPtr channelDeviceInfoPtr = channelInfo.devices;
|
||||
|
||||
for (int device = 0; device < channelInfo.devicesCount; device++)
|
||||
{
|
||||
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo));
|
||||
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;
|
||||
|
||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(info, nativeDeviceInfo, channelDeviceInfo, referenceLed, modelCounter));
|
||||
referenceLed += channelDeviceInfo.deviceLedCount;
|
||||
@@ -278,8 +258,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
private void Reset()
|
||||
{
|
||||
ProtocolDetails = null;
|
||||
HasExclusiveAccess = false;
|
||||
Devices = null;
|
||||
Devices = Enumerable.Empty<IRGBDevice>();
|
||||
IsInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly Dictionary<LedId, CorsairLedId> _idMapping = new Dictionary<LedId, CorsairLedId>();
|
||||
private readonly Dictionary<LedId, CorsairLedId> _idMapping = new();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Count);
|
||||
IntPtr addPtr = new IntPtr(ptr.ToInt64());
|
||||
IntPtr addPtr = new(ptr.ToInt64());
|
||||
foreach (KeyValuePair<object, Color> data in dataSet)
|
||||
{
|
||||
_CorsairLedColor color = new _CorsairLedColor
|
||||
{
|
||||
_CorsairLedColor color = new()
|
||||
{
|
||||
ledId = (int)data.Key,
|
||||
r = data.Value.GetR(),
|
||||
g = data.Value.GetG(),
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// String containing version of SDK(like "1.0.0.1").
|
||||
/// Always contains valid value even if there was no CUE found.
|
||||
/// </summary>
|
||||
public string SdkVersion { get; }
|
||||
public string? SdkVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// String containing version of CUE(like "1.0.0.1") or NULL if CUE was not found.
|
||||
/// </summary>
|
||||
public string ServerVersion { get; }
|
||||
public string? ServerVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Integer that specifies version of protocol that is implemented by current SDK.
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
@@ -27,13 +24,13 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
protected Dictionary<CorsairLedId, Led> InternalLedMapping { get; } = new Dictionary<CorsairLedId, Led>();
|
||||
protected Dictionary<CorsairLedId, Led> InternalLedMapping { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the update queue performing updates for this device.
|
||||
/// </summary>
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
protected CorsairDeviceUpdateQueue DeviceUpdateQueue { get; set; }
|
||||
protected CorsairDeviceUpdateQueue? DeviceUpdateQueue { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -45,7 +42,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="ledId">The <see cref="CorsairLedId"/> of the <see cref="Led"/> to get.</param>
|
||||
/// <returns>The <see cref="Led"/> with the specified <see cref="CorsairLedId"/> or null if no <see cref="Led"/> is found.</returns>
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public Led this[CorsairLedId ledId] => InternalLedMapping.TryGetValue(ledId, out Led led) ? led : null;
|
||||
public Led? this[CorsairLedId ledId] => InternalLedMapping.TryGetValue(ledId, out Led? led) ? led : null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -75,14 +72,13 @@ namespace RGB.NET.Devices.Corsair
|
||||
|
||||
foreach (Led led in LedMapping.Values)
|
||||
{
|
||||
CorsairLedId ledId = (CorsairLedId)led.CustomData;
|
||||
if (ledId != CorsairLedId.Invalid)
|
||||
if (led.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))
|
||||
InternalLedMapping.Add(ledId, led);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +90,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
=> DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))));
|
||||
=> DeviceUpdateQueue?.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))));
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class HeadsetIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.Headset1, CorsairLedId.LeftLogo },
|
||||
{ LedId.Headset2, CorsairLedId.RightLogo },
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class HeadsetStandIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.HeadsetStand1, CorsairLedId.HeadsetStandZone1 },
|
||||
{ LedId.HeadsetStand2, CorsairLedId.HeadsetStandZone2 },
|
||||
{ LedId.HeadsetStand3, CorsairLedId.HeadsetStandZone3 },
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class DictionaryExtension
|
||||
{
|
||||
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary) => dictionary.ToDictionary(x => x.Value, x => x.Key);
|
||||
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary)
|
||||
where TKey : notnull
|
||||
where TValue : notnull
|
||||
=> dictionary.ToDictionary(x => x.Value, x => x.Key);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class KeyboardIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.Invalid, CorsairLedId.Invalid },
|
||||
{ LedId.Logo, CorsairLedId.Logo },
|
||||
{ LedId.Keyboard_Escape, CorsairLedId.Escape },
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class MemoryIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.Invalid, CorsairLedId.Invalid },
|
||||
{ LedId.DRAM1, CorsairLedId.DRAM1 },
|
||||
{ LedId.DRAM2, CorsairLedId.DRAM2 },
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class MouseIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||
{ LedId.Mouse2, CorsairLedId.B2 },
|
||||
{ LedId.Mouse3, CorsairLedId.B3 },
|
||||
@@ -15,15 +15,15 @@ namespace RGB.NET.Devices.Corsair
|
||||
{ LedId.Mouse6, CorsairLedId.B6 },
|
||||
};
|
||||
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> GLAIVE = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> GLAIVE = new()
|
||||
{
|
||||
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||
{ LedId.Mouse2, CorsairLedId.B2 },
|
||||
{ LedId.Mouse3, CorsairLedId.B5 },
|
||||
};
|
||||
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> M65_RGB_ELITE = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> M65_RGB_ELITE = new()
|
||||
{
|
||||
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||
{ LedId.Mouse2, CorsairLedId.B3 },
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
internal static class MousepadIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new Dictionary<LedId, CorsairLedId>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
|
||||
{
|
||||
{ LedId.Mousepad1, CorsairLedId.Zone1 },
|
||||
{ LedId.Mousepad2, CorsairLedId.Zone2 },
|
||||
{ LedId.Mousepad3, CorsairLedId.Zone3 },
|
||||
|
||||
@@ -16,12 +16,7 @@ namespace RGB.NET.Devices.Corsair.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.Corsair.Native
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
List<string> possiblePathList = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
|
||||
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
string? dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
@@ -80,18 +75,18 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
|
||||
#region Pointers
|
||||
|
||||
private static CorsairSetLedsColorsBufferByDeviceIndexPointer _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
||||
private static CorsairSetLedsColorsFlushBufferPointer _corsairSetLedsColorsFlushBufferPointer;
|
||||
private static CorsairGetLedsColorsByDeviceIndexPointer _corsairGetLedsColorsByDeviceIndexPointer;
|
||||
private static CorsairSetLayerPriorityPointer _corsairSetLayerPriorityPointer;
|
||||
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
|
||||
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
|
||||
private static CorsairGetLedIdForKeyNamePointer _corsairGetLedIdForKeyNamePointer;
|
||||
private static CorsairGetLedPositionsByDeviceIndexPointer _corsairGetLedPositionsByDeviceIndexPointer;
|
||||
private static CorsairRequestControlPointer _corsairRequestControlPointer;
|
||||
private static CorsairReleaseControlPointer _corsairReleaseControlPointer;
|
||||
private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer;
|
||||
private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer;
|
||||
private static CorsairSetLedsColorsBufferByDeviceIndexPointer? _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
||||
private static CorsairSetLedsColorsFlushBufferPointer? _corsairSetLedsColorsFlushBufferPointer;
|
||||
private static CorsairGetLedsColorsByDeviceIndexPointer? _corsairGetLedsColorsByDeviceIndexPointer;
|
||||
private static CorsairSetLayerPriorityPointer? _corsairSetLayerPriorityPointer;
|
||||
private static CorsairGetDeviceCountPointer? _corsairGetDeviceCountPointer;
|
||||
private static CorsairGetDeviceInfoPointer? _corsairGetDeviceInfoPointer;
|
||||
private static CorsairGetLedIdForKeyNamePointer? _corsairGetLedIdForKeyNamePointer;
|
||||
private static CorsairGetLedPositionsByDeviceIndexPointer? _corsairGetLedPositionsByDeviceIndexPointer;
|
||||
private static CorsairRequestControlPointer? _corsairRequestControlPointer;
|
||||
private static CorsairReleaseControlPointer? _corsairReleaseControlPointer;
|
||||
private static CorsairPerformProtocolHandshakePointer? _corsairPerformProtocolHandshakePointer;
|
||||
private static CorsairGetLastErrorPointer? _corsairGetLastErrorPointer;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -144,68 +139,70 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
|
||||
/// This function does not take logical layout into account.
|
||||
/// </summary>
|
||||
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairSetLedsColorsBufferByDeviceIndexPointer(deviceIndex, size, ledsColors);
|
||||
internal static bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> (_corsairSetLedsColorsBufferByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex, size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
|
||||
/// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync
|
||||
/// </summary>
|
||||
internal static bool CorsairSetLedsColorsFlushBuffer() => _corsairSetLedsColorsFlushBufferPointer();
|
||||
internal static bool CorsairSetLedsColorsFlushBuffer() => (_corsairSetLedsColorsFlushBufferPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: get current color for the list of requested LEDs.
|
||||
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
|
||||
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
|
||||
/// </summary>
|
||||
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors) => _corsairGetLedsColorsByDeviceIndexPointer(deviceIndex, size, ledsColors);
|
||||
internal static bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> (_corsairGetLedsColorsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex, size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: set layer priority for this shared client.
|
||||
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function.
|
||||
/// Layers with higher priority value are shown on top of layers with lower priority.
|
||||
/// </summary>
|
||||
internal static bool CorsairSetLayerPriority(int priority) => _corsairSetLayerPriorityPointer(priority);
|
||||
internal static bool CorsairSetLayerPriority(int priority) => (_corsairSetLayerPriorityPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(priority);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
||||
/// </summary>
|
||||
internal static int CorsairGetDeviceCount() => _corsairGetDeviceCountPointer();
|
||||
internal static int CorsairGetDeviceCount() => (_corsairGetDeviceCountPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns information about device at provided index.
|
||||
/// </summary>
|
||||
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => _corsairGetDeviceInfoPointer(deviceIndex);
|
||||
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => (_corsairGetDeviceInfoPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
||||
/// </summary>
|
||||
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => _corsairGetLedPositionsByDeviceIndexPointer(deviceIndex);
|
||||
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => (_corsairGetLedPositionsByDeviceIndexPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
||||
/// </summary>
|
||||
internal static CorsairLedId CorsairGetLedIdForKeyName(char keyName) => _corsairGetLedIdForKeyNamePointer(keyName);
|
||||
internal static CorsairLedId CorsairGetLedIdForKeyName(char keyName) => (_corsairGetLedIdForKeyNamePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(keyName);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: requestes control using specified access mode.
|
||||
/// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control.
|
||||
/// </summary>
|
||||
internal static bool CorsairRequestControl(CorsairAccessMode accessMode) => _corsairRequestControlPointer(accessMode);
|
||||
internal static bool CorsairRequestControl(CorsairAccessMode accessMode) => (_corsairRequestControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: releases previously requested control for specified access mode.
|
||||
/// </summary>
|
||||
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode) => _corsairReleaseControlPointer(accessMode);
|
||||
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode) => (_corsairReleaseControlPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE.
|
||||
/// </summary>
|
||||
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake() => _corsairPerformProtocolHandshakePointer();
|
||||
internal static _CorsairProtocolDetails CorsairPerformProtocolHandshake() => (_corsairPerformProtocolHandshakePointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
|
||||
/// </summary>
|
||||
internal static CorsairError CorsairGetLastError() => _corsairGetLastErrorPointer();
|
||||
internal static CorsairError CorsairGetLastError() => (_corsairGetLastErrorPointer ?? throw new RGBDeviceException("The Corsair-SDK is not initialized.")).Invoke();
|
||||
|
||||
// ReSharper restore EventExceptionNotDocumented
|
||||
|
||||
|
||||
@@ -47,6 +47,6 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
/// <summary>
|
||||
/// CUE-SDK: structure that describes channels of the DIY-devices
|
||||
/// </summary>
|
||||
internal _CorsairChannelsInfo channels;
|
||||
internal _CorsairChannelsInfo? channels;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user