mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Added exception-handling to all UpdateQueues
This commit is contained in:
1 parent
6e313ea6a1
commit
37e4954583
18 files changed
+222
-97
No files matched your search
@@ -27,12 +27,19 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue
|
||||
/// <inheritdoc />
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
Color color = dataSet[0].color;
|
||||
try
|
||||
{
|
||||
Color color = dataSet[0].color;
|
||||
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB);
|
||||
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100),
|
||||
(int)Math.Round(color.G * 100),
|
||||
(int)Math.Round(color.B * 100));
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB);
|
||||
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100),
|
||||
(int)Math.Round(color.G * 100),
|
||||
(int)Math.Round(color.B * 100));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogitechDeviceProvider.Instance.Throw(ex, true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -27,16 +27,23 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
|
||||
/// <inheritdoc />
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB);
|
||||
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
try
|
||||
{
|
||||
// These will be LogitechLedId but the SDK expects an int and doesn't care about invalid values
|
||||
int keyName = (int)key;
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyName,
|
||||
(int)MathF.Round(color.R * 100),
|
||||
(int)MathF.Round(color.G * 100),
|
||||
(int)MathF.Round(color.B * 100));
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB);
|
||||
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
{
|
||||
// These will be LogitechLedId but the SDK expects an int and doesn't care about invalid values
|
||||
int keyName = (int)key;
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyName,
|
||||
(int)MathF.Round(color.R * 100),
|
||||
(int)MathF.Round(color.G * 100),
|
||||
(int)MathF.Round(color.B * 100));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogitechDeviceProvider.Instance.Throw(ex, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user