From 05c06333485231ae3486cc0cbb9deb625d6cd369 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 26 Jan 2017 20:14:38 +0100 Subject: [PATCH] Fixed some stuff to get Corsair-Devices working --- RGB.NET.Core/Brushes/AbstractBrush.cs | 110 ++++++++++++++++++ RGB.NET.Core/Devices/AbstractRGBDevice.cs | 9 +- .../Events/SurfaceLayoutChangedEventArgs.cs | 49 ++++++++ RGB.NET.Core/Groups/AbstractLedGroup.cs | 24 +++- RGB.NET.Core/Groups/ILedGroup.cs | 10 ++ RGB.NET.Core/Leds/Color.cs | 6 +- RGB.NET.Core/Leds/ILedId.cs | 5 + RGB.NET.Core/Leds/Led.cs | 3 +- RGB.NET.Core/RGB.NET.Core.csproj | 2 + RGB.NET.Core/RGBSurface.cs | 11 +- RGB.NET.Core/RGBSurfaceDeviceEvents.cs | 17 ++- RGB.NET.Core/RGBSurfaceDeviceLoader.cs | 12 +- .../Generic/CorsairLedId.cs | 23 ++-- .../Generic/CorsairRGBDevice.cs | 34 +++++- .../Headset/CorsairHeadsetRGBDevice.cs | 4 +- .../Keyboard/CorsairKeyboardRGBDevice.cs | 2 +- .../Mouse/CorsairMouseRGBDevice.cs | 20 ++-- .../Mousmat/CorsairMousematRGBDevice.cs | 2 +- 18 files changed, 308 insertions(+), 35 deletions(-) create mode 100644 RGB.NET.Core/Brushes/AbstractBrush.cs create mode 100644 RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs diff --git a/RGB.NET.Core/Brushes/AbstractBrush.cs b/RGB.NET.Core/Brushes/AbstractBrush.cs new file mode 100644 index 0000000..f198908 --- /dev/null +++ b/RGB.NET.Core/Brushes/AbstractBrush.cs @@ -0,0 +1,110 @@ +// ReSharper disable VirtualMemberNeverOverriden.Global +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable VirtualMemberNeverOverridden.Global + +using System.Collections.Generic; +using System.Linq; + +namespace RGB.NET.Core +{ + /// + /// Represents a basic brush. + /// + public abstract class AbstractBrush : AbstractEffectTarget, IBrush + { + #region Properties & Fields + + /// + public BrushCalculationMode BrushCalculationMode { get; set; } = BrushCalculationMode.Relative; + + /// + public double Brightness { get; set; } + + /// + public double Opacity { get; set; } + + /// + public IList ColorCorrections { get; } = new List(); + + /// + public Rectangle RenderedRectangle { get; protected set; } + + /// + public Dictionary RenderedTargets { get; } = new Dictionary(); + + /// + protected override IBrush EffectTarget => this; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The overall percentage brightness of the brush. (default: 1.0) + /// The overall percentage opacity of the brush. (default: 1.0) + protected AbstractBrush(double brightness = 1, double opacity = 1) + { + this.Brightness = brightness; + this.Opacity = opacity; + } + + #endregion + + #region Methods + + /// + /// Performas the render pass of the brush and calculates the raw colors for all requested points. + /// + /// The rectangle in which the brush should be drawn. + /// The targets (keys/points) of which the color should be calculated. + public virtual void PerformRender(Rectangle rectangle, IEnumerable renderTargets) + { + RenderedRectangle = rectangle; + RenderedTargets.Clear(); + + foreach (BrushRenderTarget point in renderTargets) + RenderedTargets[point] = new Color(GetColorAtPoint(rectangle, point)); // Clone the color, we don't want to have reference issues here and brushes might return the same color multiple times! + } + + /// + /// Performs the finalize pass of the brush and calculates the final colors for all previously calculated points. + /// + public virtual void PerformFinalize() + { + List renderTargets = RenderedTargets.Keys.ToList(); + foreach (BrushRenderTarget renderTarget in renderTargets) + FinalizeColor(RenderedTargets[renderTarget]); // Cloning here again shouldn't be needed since we did this above. + } + + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The target (key/point) from which the color should be taken. + /// The color at the specified point. + protected abstract Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget); + + /// + /// Finalizes the color by appliing the overall brightness and opacity.
+ /// This method should always be the last call of a implementation. + /// If you overwrite this method please make sure that you never return the same color-object twice to prevent reference-issues! + ///
+ /// The color to finalize. + /// The finalized color. + protected virtual void FinalizeColor(Color color) + { + foreach (IColorCorrection colorCorrection in ColorCorrections) + colorCorrection.ApplyTo(color); + + // Since we use HSV to calculate there is no way to make a color 'brighter' than 100% + // Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness' + // THIS IS NOT A HSB CALCULATION!!! + color.Value *= Brightness <= 0 ? 0 : (Brightness >= 1.0 ? 1.0 : Brightness); + color.A = (byte)(color.A * (Opacity <= 0 ? 0 : (Opacity >= 1.0 ? 1.0 : Opacity))); + } + + #endregion + } +} diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index d983043..0fc40cb 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -70,9 +70,11 @@ namespace RGB.NET.Core DeviceUpdate(); // Send LEDs to SDK - IEnumerable ledsToUpdate = flushLeds ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty); + IEnumerable ledsToUpdate = (flushLeds ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).ToList(); foreach (Led ledToUpdate in ledsToUpdate) ledToUpdate.Update(); + + UpdateLeds(ledsToUpdate); } /// @@ -81,6 +83,11 @@ namespace RGB.NET.Core protected virtual void DeviceUpdate() { } + /// + /// Sends all the updated to the device. + /// + protected abstract void UpdateLeds(IEnumerable ledsToUpdate); + /// /// Initializes the with the specified id. /// diff --git a/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs new file mode 100644 index 0000000..e4f03b2 --- /dev/null +++ b/RGB.NET.Core/Events/SurfaceLayoutChangedEventArgs.cs @@ -0,0 +1,49 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global + +using System; + +namespace RGB.NET.Core +{ + /// + /// Represents the information supplied with an -event. + /// + public class SurfaceLayoutChangedEventArgs : EventArgs + { + #region Properties & Fields + + /// + /// Gets the that caused the change. Returns null if the change isn't caused by a . + /// + public IRGBDevice Device { get; } + + /// + /// Gets a value indicating if the event is caused by the addition of a new to the . + /// + public bool DeviceAdded { get; } + + /// + /// Gets a value indicating if the event is caused by a changed location of one of the devices on the . + /// + public bool DeviceLocationChanged { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The that caused the change + /// A value indicating if the event is caused by the addition of a new to the . + /// A value indicating if the event is caused by a changed location of one of the devices on the . + public SurfaceLayoutChangedEventArgs(IRGBDevice device, bool deviceAdded, bool deviceLocationChanged) + { + this.Device = device; + this.DeviceAdded = deviceAdded; + this.DeviceLocationChanged = deviceLocationChanged; + } + + #endregion + } +} diff --git a/RGB.NET.Core/Groups/AbstractLedGroup.cs b/RGB.NET.Core/Groups/AbstractLedGroup.cs index f00cc0a..a1c65e5 100644 --- a/RGB.NET.Core/Groups/AbstractLedGroup.cs +++ b/RGB.NET.Core/Groups/AbstractLedGroup.cs @@ -3,7 +3,7 @@ namespace RGB.NET.Core { /// - /// Represents a generic ledgroup. + /// Represents a generic . /// public abstract class AbstractLedGroup : AbstractEffectTarget, ILedGroup { @@ -22,11 +22,33 @@ namespace RGB.NET.Core #endregion + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Specifies whether this should be automatically attached or not. + protected AbstractLedGroup(bool autoAttach) + { + if (autoAttach) + RGBSurface.AttachLedGroup(this); + } + + #endregion + #region Methods /// public abstract IEnumerable GetLeds(); + /// + public virtual void OnAttach() + { } + + /// + public virtual void OnDetach() + { } + #endregion } } diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs index 70d1eaa..177ed89 100644 --- a/RGB.NET.Core/Groups/ILedGroup.cs +++ b/RGB.NET.Core/Groups/ILedGroup.cs @@ -25,5 +25,15 @@ namespace RGB.NET.Core /// /// The list containing all of this . IEnumerable GetLeds(); + + /// + /// Called when the is attached to the . + /// + void OnAttach(); + + /// + /// Called when the is detached from the . + /// + void OnDetach(); } } diff --git a/RGB.NET.Core/Leds/Color.cs b/RGB.NET.Core/Leds/Color.cs index 9f2d46c..96ab789 100644 --- a/RGB.NET.Core/Leds/Color.cs +++ b/RGB.NET.Core/Leds/Color.cs @@ -278,9 +278,9 @@ namespace RGB.NET.Core if (color.A == 255) { A = color.A; - R = color.A; - G = color.A; - B = color.A; + R = color.R; + G = color.G; + B = color.B; } else { diff --git a/RGB.NET.Core/Leds/ILedId.cs b/RGB.NET.Core/Leds/ILedId.cs index 373ccc5..92aefd3 100644 --- a/RGB.NET.Core/Leds/ILedId.cs +++ b/RGB.NET.Core/Leds/ILedId.cs @@ -5,6 +5,11 @@ /// public interface ILedId { + /// + /// Gets the the belongs to. + /// + IRGBDevice Device { get; } + /// /// Gets a value indicating if this is valid. /// diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index b9efb55..eb05323 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -59,7 +59,8 @@ namespace RGB.NET.Core { if (!IsLocked) { - RequestedColor.Blend(value); + // DarthAffe 26.01.2017: DON'T USE THE PROPERTY HERE! Working on the copy doesn't work! + _requestedColor.Blend(value); // ReSharper disable ExplicitCallerInfoArgument OnPropertyChanged(nameof(RequestedColor)); diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index db842ba..297a8d3 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -42,6 +42,7 @@ + @@ -55,6 +56,7 @@ + diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 7fe5b67..45d2528 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -19,7 +19,7 @@ namespace RGB.NET.Core private static IList _deviceProvider = new List(); private static IList _devices = new List(); - + // ReSharper disable InconsistentNaming private static readonly LinkedList _ledGroups = new LinkedList(); @@ -38,6 +38,11 @@ namespace RGB.NET.Core /// public static Rectangle SurfaceRectangle => new Rectangle(_surfaceRectangle); + /// + /// Gets a list of all on this . + /// + public static IEnumerable Leds => _devices.SelectMany(x => x); + #endregion #region Constructors @@ -141,6 +146,8 @@ namespace RGB.NET.Core if (_ledGroups.Contains(ledGroup)) return false; _ledGroups.AddLast(ledGroup); + ledGroup.OnAttach(); + return true; } } @@ -160,6 +167,8 @@ namespace RGB.NET.Core if (node == null) return false; _ledGroups.Remove(node); + node.Value.OnDetach(); + return true; } } diff --git a/RGB.NET.Core/RGBSurfaceDeviceEvents.cs b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs index 5ef5e2c..3bd5acb 100644 --- a/RGB.NET.Core/RGBSurfaceDeviceEvents.cs +++ b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs @@ -7,23 +7,29 @@ namespace RGB.NET.Core #region EventHandler /// - /// Represents the event-handler of the -event. + /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void ExceptionEventHandler(ExceptionEventArgs args); /// - /// Represents the event-handler of the -event. + /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void UpdatingEventHandler(UpdatingEventArgs args); /// - /// Represents the event-handler of the -event. + /// Represents the event-handler of the -event. /// /// The arguments provided by the event. public delegate void UpdatedEventHandler(UpdatedEventArgs args); + /// + /// Represents the event-handler of the -event. + /// + /// + public delegate void SurfaceLayoutChangedEventHandler(SurfaceLayoutChangedEventArgs args); + #endregion #region Events @@ -45,6 +51,11 @@ namespace RGB.NET.Core /// public static event UpdatedEventHandler Updated; + /// + /// Occurs when the layout of this changed. + /// + public static event SurfaceLayoutChangedEventHandler SurfaceLayoutChanged; + // ReSharper restore EventNeverSubscribedTo.Global #endregion diff --git a/RGB.NET.Core/RGBSurfaceDeviceLoader.cs b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs index c67f771..8b7a8b2 100644 --- a/RGB.NET.Core/RGBSurfaceDeviceLoader.cs +++ b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs @@ -16,6 +16,7 @@ namespace RGB.NET.Core { if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return; + IRGBDevice addedDevice = null; if (deviceProvider.IsInitialized || deviceProvider.Initialize()) { _deviceProvider.Add(deviceProvider); @@ -24,18 +25,27 @@ namespace RGB.NET.Core { if (_devices.Contains(device)) continue; + addedDevice = device; + device.PropertyChanged += DeviceOnPropertyChanged; _devices.Add(device); } } - UpdateSurfaceRectangle(); + if (addedDevice != null) + { + UpdateSurfaceRectangle(); + SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevice, true, false)); + } } private static void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location))) + { + SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(sender as IRGBDevice, false, true)); UpdateSurfaceRectangle(); + } } #endregion diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs index 137fe8a..17fbe31 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs @@ -6,15 +6,18 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a Id of a on a . /// - [DebuggerDisplay("{" + nameof(_ledId) + "}")] + [DebuggerDisplay("{" + nameof(LedId) + "}")] public class CorsairLedId : ILedId { #region Properties & Fields - private readonly CorsairLedIds _ledId; + internal readonly CorsairLedIds LedId; /// - public bool IsValid => _ledId != CorsairLedIds.Invalid; + public IRGBDevice Device { get; } + + /// + public bool IsValid => LedId != CorsairLedIds.Invalid; #endregion @@ -23,10 +26,12 @@ namespace RGB.NET.Devices.Corsair /// /// Initializes a new instance of the class. /// - /// The corsair-id of the represented . - public CorsairLedId(CorsairLedIds ledId) + /// The the belongs to. + /// The of the represented . + public CorsairLedId(IRGBDevice device, CorsairLedIds ledId) { - this._ledId = ledId; + this.Device = device; + this.LedId = ledId; } #endregion @@ -39,7 +44,7 @@ namespace RGB.NET.Devices.Corsair /// A string that contains the Id of this . For example "Enter". public override string ToString() { - return _ledId.ToString(); + return LedId.ToString(); } /// @@ -59,7 +64,7 @@ namespace RGB.NET.Devices.Corsair if (GetType() != compareLedId.GetType()) return false; - return compareLedId._ledId == _ledId; + return compareLedId.LedId == LedId; } /// @@ -68,7 +73,7 @@ namespace RGB.NET.Devices.Corsair /// An integer value that specifies the hash code for this . public override int GetHashCode() { - return _ledId.GetHashCode(); + return LedId.GetHashCode(); } #endregion diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index e0e1055..dbfb993 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -1,5 +1,9 @@ -using System.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; namespace RGB.NET.Devices.Corsair { @@ -51,6 +55,34 @@ namespace RGB.NET.Devices.Corsair /// protected abstract void InitializeLeds(); + /// + protected override void UpdateLeds(IEnumerable ledsToUpdate) + { + List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); + + if (leds.Count > 0) // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array + { + int structSize = Marshal.SizeOf(typeof(_CorsairLedColor)); + IntPtr ptr = Marshal.AllocHGlobal(structSize * leds.Count); + IntPtr addPtr = new IntPtr(ptr.ToInt64()); + foreach (Led led in leds) + { + _CorsairLedColor color = new _CorsairLedColor + { + ledId = (int)((CorsairLedId)led.Id).LedId, + r = led.Color.R, + g = led.Color.G, + b = led.Color.B + }; + + Marshal.StructureToPtr(color, addPtr, false); + addPtr = new IntPtr(addPtr.ToInt64() + structSize); + } + _CUESDK.CorsairSetLedsColors(leds.Count, ptr); + Marshal.FreeHGlobal(ptr); + } + } + #endregion } } diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index e1e2195..4221cee 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -40,8 +40,8 @@ namespace RGB.NET.Devices.Corsair /// protected override void InitializeLeds() { - InitializeLed(new CorsairLedId(CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10)); } #endregion diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index e18fd93..6eed1b8 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -52,7 +52,7 @@ namespace RGB.NET.Devices.Corsair for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); - InitializeLed(new CorsairLedId(ledPosition.ledId), + InitializeLed(new CorsairLedId(this, ledPosition.ledId), new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index 4af9621..f295703 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -44,22 +44,22 @@ namespace RGB.NET.Devices.Corsair switch (MouseDeviceInfo.PhysicalLayout) { case CorsairPhysicalMouseLayout.Zones1: - InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones2: - InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones3: - InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B3), new Rectangle(20, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B3), new Rectangle(20, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones4: - InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B3), new Rectangle(20, 0, 10, 10)); - InitializeLed(new CorsairLedId(CorsairLedIds.B4), new Rectangle(30, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B2), new Rectangle(10, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B3), new Rectangle(20, 0, 10, 10)); + InitializeLed(new CorsairLedId(this, CorsairLedIds.B4), new Rectangle(30, 0, 10, 10)); break; default: throw new RGBDeviceException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'"); diff --git a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs index c12d158..9fd238c 100644 --- a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs @@ -62,7 +62,7 @@ namespace RGB.NET.Devices.Corsair } foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) - InitializeLed(new CorsairLedId(ledPosition.ledId), + InitializeLed(new CorsairLedId(this, ledPosition.ledId), new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); }