mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Refactoring
This commit is contained in:
1 parent
a0a1521658
commit
6a4ebb3d2a
37 files changed
+123
-300
No files matched your search
@@ -42,7 +42,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// Indicates if the SDK is initialized and ready to use.
|
||||
/// </summary>
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the protocol details for the current SDK-connection.
|
||||
/// </summary>
|
||||
@@ -84,7 +84,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <inheritdoc />
|
||||
/// <exception cref="RGBDeviceException">Thrown if the SDK is already initialized or if the SDK is not compatible to CUE.</exception>
|
||||
/// <exception cref="CUEException">Thrown if the CUE-SDK provides an error.</exception>
|
||||
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
|
||||
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false)
|
||||
{
|
||||
IsInitialized = false;
|
||||
|
||||
@@ -126,8 +126,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
if ((device == null) || !loadFilter.HasFlag(device.DeviceInfo.DeviceType)) continue;
|
||||
|
||||
if (deviceUpdateQueue == null)
|
||||
deviceUpdateQueue = new CorsairDeviceUpdateQueue(UpdateTrigger, info.CorsairDeviceIndex);
|
||||
deviceUpdateQueue ??= new CorsairDeviceUpdateQueue(UpdateTrigger, info.CorsairDeviceIndex);
|
||||
|
||||
device.Initialize(deviceUpdateQueue);
|
||||
|
||||
@@ -231,28 +230,14 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
if (deviceType == CorsairDeviceType.Cooler)
|
||||
return CorsairLedId.CustomLiquidCoolerChannel1Led1;
|
||||
else
|
||||
|
||||
return channel switch
|
||||
{
|
||||
switch (channel)
|
||||
{
|
||||
case 0: return CorsairLedId.CustomDeviceChannel1Led1;
|
||||
case 1: return CorsairLedId.CustomDeviceChannel2Led1;
|
||||
case 2: return CorsairLedId.CustomDeviceChannel3Led1;
|
||||
}
|
||||
}
|
||||
|
||||
return CorsairLedId.Invalid;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ResetDevices()
|
||||
{
|
||||
if (IsInitialized)
|
||||
try
|
||||
{
|
||||
_CUESDK.Reload();
|
||||
}
|
||||
catch {/* shit happens */}
|
||||
0 => CorsairLedId.CustomDeviceChannel1Led1,
|
||||
1 => CorsairLedId.CustomDeviceChannel2Led1,
|
||||
2 => CorsairLedId.CustomDeviceChannel3Led1,
|
||||
_ => CorsairLedId.Invalid
|
||||
};
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
@@ -265,9 +250,14 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
try { UpdateTrigger?.Dispose(); }
|
||||
try { UpdateTrigger.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
foreach (IRGBDevice device in Devices)
|
||||
try { device.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
Devices = Enumerable.Empty<IRGBDevice>();
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
}
|
||||
}
|
||||
|
||||
protected override object? GetLedCustomData(LedId ledId) => _idMapping.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||
protected override object GetLedCustomData(LedId ledId) => _idMapping.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||
|
||||
protected virtual LedId GetReferenceLed(RGBDeviceType deviceType)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
}
|
||||
}
|
||||
|
||||
protected override object? GetLedCustomData(LedId ledId)
|
||||
protected override object GetLedCustomData(LedId ledId)
|
||||
{
|
||||
if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase))
|
||||
return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||
|
||||
Reference in new issue
Block a user