(MAJOR) Added success-indication to device updates and forced flushes after nonsuccessful ones.

Added exception handling the last missing queues.
This commit is contained in:
DarthAffe committed 2023-03-05 18:04:50 +01:00
1 parent 37e4954583
commit 30ccfdcd85
21 files changed
+151 -50

No files matched your search

@@ -25,7 +25,7 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue
#region Methods
/// <inheritdoc />
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
try
{
@@ -35,11 +35,15 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100),
(int)Math.Round(color.G * 100),
(int)Math.Round(color.B * 100));
return true;
}
catch (Exception ex)
{
LogitechDeviceProvider.Instance.Throw(ex, true);
LogitechDeviceProvider.Instance.Throw(ex);
}
return false;
}
#endregion
@@ -25,7 +25,7 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
#region Methods
/// <inheritdoc />
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
try
{
@@ -40,11 +40,15 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
(int)MathF.Round(color.G * 100),
(int)MathF.Round(color.B * 100));
}
return true;
}
catch (Exception ex)
{
LogitechDeviceProvider.Instance.Throw(ex, true);
LogitechDeviceProvider.Instance.Throw(ex);
}
return false;
}
#endregion
@@ -33,18 +33,29 @@ public class LogitechZoneUpdateQueue : UpdateQueue
#region Methods
/// <inheritdoc />
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All);
foreach ((object key, Color color) in dataSet)
try
{
int zone = (int)key;
_LogitechGSDK.LogiLedSetLightingForTargetZone(_deviceType, zone,
(int)MathF.Round(color.R * 100),
(int)MathF.Round(color.G * 100),
(int)MathF.Round(color.B * 100));
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All);
foreach ((object key, Color color) in dataSet)
{
int zone = (int)key;
_LogitechGSDK.LogiLedSetLightingForTargetZone(_deviceType, zone,
(int)MathF.Round(color.R * 100),
(int)MathF.Round(color.G * 100),
(int)MathF.Round(color.B * 100));
}
return true;
}
catch (Exception ex)
{
LogitechDeviceProvider.Instance.Throw(ex);
}
return false;
}
#endregion