Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied Led-Position-Fix from #331 to Corsair-Legacy-DeviceProvider #345

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading