From 2a2053cc53dd2cd0542f18bcdddf967134b77a76 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 25 Jul 2023 20:11:58 +0200 Subject: [PATCH] Applied Led-Position-Fix from #331 to Corsair-Legacy-DeviceProvider --- .../Custom/CorsairCustomRGBDevice.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs index 4f5a301c..4e15555e 100644 --- a/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using System; +using System.Linq; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.CorsairLegacy.Native; @@ -59,6 +60,21 @@ protected override void InitializeLayout() ptr = new IntPtr(ptr.ToInt64() + structSize); } + + if (DeviceInfo.LedOffset > 0) + FixOffsetDeviceLayout(); + } + + /// + /// Fixes the locations for devices split by offset by aligning them to the top left. + /// + 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); } private static LedId GetReferenceLed(RGBDeviceType deviceType)