Added exception-handling to all UpdateQueues

This commit is contained in:
DarthAffe committed 2023-03-05 16:34:01 +01:00
1 parent 6e313ea6a1
commit 37e4954583
18 files changed
+222 -97

No files matched your search

@@ -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);
}
}