WIP - Fixed corsair partial devices getting longer

the first device has the correct size, all following ones are larger than intended. tested with corsaid lighting node core and sp120
This commit is contained in:
Diogo Trindade committed 2023-06-03 19:44:37 +01:00
1 parent a0bdd837e2
commit ca3c9fc5d3
1 file changed
+13 -1
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
@@ -58,6 +58,18 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
}
if (DeviceInfo.LedOffset > 0)
FixOffsetDeviceLayout();
}
protected virtual void FixOffsetDeviceLayout()
{
float minX = this.Min(x => x.Location.X);
float minY = this.Min(x => x.Location.Y);
foreach (Led led in this)
led.Location = led.Location.Translate(-minX, -minY);
}
protected abstract LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids);