Skip to content

Commit

Permalink
Applied Led-Position-Fix from #331 to Corsair-Legacy-DeviceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthAffe committed Jul 25, 2023
1 parent 8faedd1 commit 2a2053c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +60,21 @@ protected override void InitializeLayout()

ptr = new IntPtr(ptr.ToInt64() + structSize);
}

if (DeviceInfo.LedOffset > 0)
FixOffsetDeviceLayout();
}

/// <summary>
/// Fixes the locations for devices split by offset by aligning them to the top left.
/// </summary>
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)
Expand Down

0 comments on commit 2a2053c

Please sign in to comment.