Skip to content

Commit

Permalink
Merge pull request #345 from DarthAffe/SDK/CorsairLegacy
Browse files Browse the repository at this point in the history
Applied Led-Position-Fix from #331 to Corsair-Legacy-DeviceProvider
  • Loading branch information
DarthAffe authored Jul 25, 2023
2 parents fd6bfa0 + 2a2053c commit b4bbc6a
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 b4bbc6a

Please sign in to comment.