diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index feefc99..5e74c61 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -4,7 +4,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; +using RGB.NET.Core.Layout; namespace RGB.NET.Core { @@ -46,7 +48,7 @@ namespace RGB.NET.Core /// /// Gets a dictionary containing all of the . /// - protected Dictionary LedMapping { get; } = new Dictionary(); + protected Dictionary LedMapping { get; } = new Dictionary(); /// /// Gets a dictionary containing all associated with this . @@ -56,7 +58,7 @@ namespace RGB.NET.Core #region Indexer /// - Led IRGBDevice.this[ILedId ledId] => LedMapping.TryGetValue(ledId, out Led led) ? led : null; + Led IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led led) ? led : null; /// Led IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.LedRectangle.Contains(location)); @@ -111,18 +113,66 @@ namespace RGB.NET.Core /// /// Initializes the with the specified id. /// - /// The to initialize. + /// The to initialize. /// The representing the position of the to initialize. /// - protected virtual Led InitializeLed(ILedId ledId, Rectangle ledRectangle) + protected virtual Led InitializeLed(LedId ledId, Rectangle ledRectangle) { - if (LedMapping.ContainsKey(ledId)) return null; + if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null; - Led led = new Led(this, ledId, ledRectangle); + Led led = new Led(this, ledId, ledRectangle, CreateLedCustomData(ledId)); LedMapping.Add(ledId, led); return led; } + /// + /// Applies the given layout. + /// + /// The file containing the layout. + /// The name of the layout used to get the images of the leds. + /// The path images for this device are collected in. + /// If set to true a new led is initialized for every id in the layout if it doesn't already exist. + protected virtual void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath, bool createMissingLeds = false) + { + DeviceLayout layout = DeviceLayout.Load(layoutPath); + if (layout != null) + { + LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); + + Size = new Size(layout.Width, layout.Height); + + if (layout.Leds != null) + foreach (LedLayout layoutLed in layout.Leds) + { + if (Enum.TryParse(layoutLed.Id, true, out LedId ledId)) + { + if (!LedMapping.TryGetValue(ledId, out Led led) && createMissingLeds) + led = InitializeLed(ledId, new Rectangle()); + + if (led != null) + { + led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); + led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); + + led.Shape = layoutLed.Shape; + led.ShapeData = layoutLed.ShapeData; + + LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); + led.Image = (!string.IsNullOrEmpty(image?.Image)) + ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) + : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); + } + } + } + } + } + + /// + /// Creates provider-specific data associated with this . + /// + /// The . + protected virtual object CreateLedCustomData(LedId ledId) => null; + /// public void AddSpecialDevicePart(T specialDevicePart) where T : class, IRGBDeviceSpecialPart diff --git a/RGB.NET.Core/Devices/DeviceUpdateMode.cs b/RGB.NET.Core/Devices/DeviceUpdateMode.cs index 5f958b9..b6e27d9 100644 --- a/RGB.NET.Core/Devices/DeviceUpdateMode.cs +++ b/RGB.NET.Core/Devices/DeviceUpdateMode.cs @@ -2,14 +2,31 @@ namespace RGB.NET.Core { + /// + /// Contains a list of different device device update modes. + /// [Flags] public enum DeviceUpdateMode { + /// + /// Represents nothing. + /// None = 0, + /// + /// Represents a mode which updates the leds of the device. + /// Sync = 1 << 0, + + /// + /// Represents a mode which reads the color of the leds of the device. + /// This isn't supported by all devices! + /// SyncBack = 1 << 1, + /// + /// Represents all update modes. + /// NoUpdate = 1 << 0xFF } } diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index b766b65..1576cc6 100644 --- a/RGB.NET.Core/Devices/IRGBDevice.cs +++ b/RGB.NET.Core/Devices/IRGBDevice.cs @@ -38,11 +38,11 @@ namespace RGB.NET.Core #region Indexer /// - /// Gets the with the specified . + /// Gets the with the specified . /// - /// The of the to get. - /// The with the specified or null if no is found. - Led this[ILedId ledId] { get; } + /// The of the to get. + /// The with the specified or null if no is found. + Led this[LedId ledId] { get; } /// /// Gets the at the given physical location. diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs index 6869d0e..638f146 100644 --- a/RGB.NET.Core/Groups/ILedGroup.cs +++ b/RGB.NET.Core/Groups/ILedGroup.cs @@ -28,12 +28,12 @@ namespace RGB.NET.Core IEnumerable GetLeds(); /// - /// Called when the is attached to the . + /// Called when the is attached to the . /// void OnAttach(); /// - /// Called when the is detached from the . + /// Called when the is detached from the . /// void OnDetach(); } diff --git a/RGB.NET.Core/Leds/ILedId.cs b/RGB.NET.Core/Leds/ILedId.cs deleted file mode 100644 index 92aefd3..0000000 --- a/RGB.NET.Core/Leds/ILedId.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RGB.NET.Core -{ - /// - /// Represents a generic Id of a . - /// - public interface ILedId - { - /// - /// Gets the the belongs to. - /// - IRGBDevice Device { get; } - - /// - /// Gets a value indicating if this is valid. - /// - bool IsValid { get; } - } -} diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index a97c4bd..84eb272 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -20,9 +20,9 @@ namespace RGB.NET.Core public IRGBDevice Device { get; } /// - /// Gets the of the . + /// Gets the of the . /// - public ILedId Id { get; } + public LedId Id { get; } private Shape _shape = Shape.Rectangle; /// @@ -99,6 +99,11 @@ namespace RGB.NET.Core /// public Uri Image { get; set; } + /// + /// Gets the provider-specific data associated with this led. + /// + public object CustomData { get; } + #endregion #region Constructors @@ -107,13 +112,15 @@ namespace RGB.NET.Core /// Initializes a new instance of the class. /// /// The the is associated with. - /// The of the . + /// The of the . /// The representing the physical location of the relative to the . - internal Led(IRGBDevice device, ILedId id, Rectangle ledRectangle) + /// The provider-specific data associated with this led. + internal Led(IRGBDevice device, LedId id, Rectangle ledRectangle, object customData = null) { this.Device = device; this.Id = id; this.LedRectangle = ledRectangle; + this.CustomData = customData; } #endregion @@ -124,10 +131,7 @@ namespace RGB.NET.Core /// Converts the and the of this to a human-readable string. /// /// A string that contains the and the of this . For example "Enter [A: 255, R: 255, G: 0, B: 0]". - public override string ToString() - { - return $"{Id} {Color}"; - } + public override string ToString() => $"{Id} {Color}"; /// /// Updates the to the requested . diff --git a/RGB.NET.Core/Leds/LedId.cs b/RGB.NET.Core/Leds/LedId.cs index d749c72..abef1fe 100644 --- a/RGB.NET.Core/Leds/LedId.cs +++ b/RGB.NET.Core/Leds/LedId.cs @@ -9,6 +9,8 @@ namespace RGB.NET.Core { Invalid = -1, + Logo = 0, + /*### Keyboard ###*/ Keyboard_Escape = 0x00000001, Keyboard_F1 = 0x00000002, @@ -35,61 +37,64 @@ namespace RGB.NET.Core Keyboard_9 = 0x00000018, Keyboard_0 = 0x00000019, Keyboard_MinusAndUnderscore = 0x0000001A, - Keyboard_Backspace = 0x0000001B, - Keyboard_Tab = 0x0000001C, - Keyboard_Q = 0x0000001D, - Keyboard_W = 0x0000001E, - Keyboard_E = 0x0000001F, - Keyboard_R = 0x00000020, - Keyboard_T = 0x00000021, - Keyboard_Y = 0x00000022, - Keyboard_U = 0x00000023, - Keyboard_I = 0x00000024, - Keyboard_O = 0x00000025, - Keyboard_P = 0x00000026, - Keyboard_BracketLeft = 0x000000027, - Keyboard_Backslash = 0x000000028, - Keyboard_Enter = 0x00000029, - Keyboard_CapsLock = 0x0000002A, - Keyboard_A = 0x0000002B, - Keyboard_S = 0x0000002C, - Keyboard_D = 0x0000002D, - Keyboard_F = 0x0000002E, - Keyboard_G = 0x0000002F, - Keyboard_H = 0x00000030, - Keyboard_J = 0x00000031, - Keyboard_K = 0x00000032, - Keyboard_L = 0x00000033, - Keyboard_SemicolonAndColon = 0x00000034, - Keyboard_ApostropheAndDoubleQuote = 0x00000035, - Keyboard_NonUsTilde = 0x00000036, - Keyboard_LeftShift = 0x00000037, - Keyboard_NonUsBackslash = 0x00000038, - Keyboard_Z = 0x00000039, - Keyboard_X = 0x0000003A, - Keyboard_C = 0x0000003B, - Keyboard_V = 0x0000003C, - Keyboard_B = 0x0000003D, - Keyboard_N = 0x0000003E, - Keyboard_M = 0x0000003F, - Keyboard_CommaAndLessThan = 0x00000040, - Keyboard_RightShift = 0x00000041, - Keyboard_PeriodAndBiggerThan = 0x00000042, - Keyboard_SlashAndQuestionMark = 0x00000043, - Keyboard_LeftCtrl = 0x00000044, - Keyboard_LeftGui = 0x00000045, - Keyboard_LeftAlt = 0x00000046, - Keyboard_Lang2 = 0x00000047, - Keyboard_Space = 0x00000048, - Keyboard_Lang1 = 0x00000049, - Keyboard_International2 = 0x0000004A, - Keyboard_RightAlt = 0x0000004B, - Keyboard_RightGui = 0x0000004C, - Keyboard_Application = 0x0000004D, - Keyboard_RightCtrl = 0x0000004E, - International3 = 0x0000004F, - International5 = 0x00000050, - International4 = 0x00000051, + Keyboard_EqualsAndPlus = 0x0000001B, + Keyboard_Backspace = 0x0000001C, + Keyboard_Tab = 0x0000001D, + Keyboard_Q = 0x0000001E, + Keyboard_W = 0x0000001F, + Keyboard_E = 0x00000020, + Keyboard_R = 0x00000021, + Keyboard_T = 0x00000022, + Keyboard_Y = 0x00000023, + Keyboard_U = 0x00000024, + Keyboard_I = 0x00000025, + Keyboard_O = 0x00000026, + Keyboard_P = 0x00000027, + Keyboard_BracketLeft = 0x000000028, + Keyboard_BracketRight = 0x000000029, + Keyboard_Backslash = 0x00000002A, + Keyboard_Enter = 0x0000002B, + Keyboard_CapsLock = 0x0000002C, + Keyboard_A = 0x0000002D, + Keyboard_S = 0x0000002E, + Keyboard_D = 0x0000002F, + Keyboard_F = 0x00000030, + Keyboard_G = 0x00000031, + Keyboard_H = 0x00000032, + Keyboard_J = 0x00000033, + Keyboard_K = 0x00000034, + Keyboard_L = 0x00000035, + Keyboard_SemicolonAndColon = 0x00000036, + Keyboard_ApostropheAndDoubleQuote = 0x00000037, + Keyboard_NonUsTilde = 0x00000038, + Keyboard_LeftShift = 0x00000039, + Keyboard_NonUsBackslash = 0x0000003A, + Keyboard_Z = 0x0000003B, + Keyboard_X = 0x0000003C, + Keyboard_C = 0x0000003D, + Keyboard_V = 0x0000003E, + Keyboard_B = 0x0000003F, + Keyboard_N = 0x00000040, + Keyboard_M = 0x00000041, + Keyboard_CommaAndLessThan = 0x00000042, + Keyboard_PeriodAndBiggerThan = 0x00000043, + Keyboard_SlashAndQuestionMark = 0x00000044, + Keyboard_RightShift = 0x00000045, + Keyboard_LeftCtrl = 0x00000046, + Keyboard_LeftGui = 0x00000047, + Keyboard_LeftAlt = 0x00000048, + Keyboard_Lang2 = 0x00000049, + Keyboard_Space = 0x0000004A, + Keyboard_Lang1 = 0x0000004B, + Keyboard_RightAlt = 0x0000004C, + Keyboard_RightGui = 0x0000004D, + Keyboard_Application = 0x0000004E, + Keyboard_RightCtrl = 0x0000004F, + Keyboard_International1 = 0x00000050, + Keyboard_International2 = 0x00000051, + Keyboard_International3 = 0x00000052, + Keyboard_International5 = 0x00000053, + Keyboard_International4 = 0x00000054, Keyboard_PrintScreen = 0x00001001, Keyboard_ScrollLock = 0x000001002, @@ -100,10 +105,10 @@ namespace RGB.NET.Core Keyboard_Delete = 0x00001007, Keyboard_End = 0x00001008, Keyboard_PageDown = 0x00001009, - Keyboard_UpArrow = 0x0000100A, - Keyboard_LeftArrow = 0x0000100B, - Keyboard_DownArrow = 0x0000100C, - Keyboard_RightArrow = 0x0000100D, + Keyboard_ArrowUp = 0x0000100A, + Keyboard_ArrowLeft = 0x0000100B, + Keyboard_ArrowDown = 0x0000100C, + Keyboard_ArrowRight = 0x0000100D, Keyboard_NumLock = 0x00002001, Keyboard_NumSlash = 0x00002002, @@ -112,20 +117,22 @@ namespace RGB.NET.Core Keyboard_Num7 = 0x00002005, Keyboard_Num8 = 0x00002006, Keyboard_Num9 = 0x00002007, - Keyboard_NumPlus = 0x00002008, - Keyboard_Num4 = 0x00002009, - Keyboard_Num5 = 0x0000200A, - Keyboard_Num6 = 0x0000200B, - Keyboard_Num1 = 0x0000200C, - Keyboard_Num2 = 0x0000200D, - Keyboard_Num3 = 0x0000200E, - Keyboard_NumEnter = 0x0000200F, - Keyboard_Num0 = 0x00002010, - Keyboard_NumComma = 0x00002011, + Keyboard_NumComma = 0x00002008, + Keyboard_NumPlus = 0x00002009, + Keyboard_Num4 = 0x0000200A, + Keyboard_Num5 = 0x0000200B, + Keyboard_Num6 = 0x0000200C, + Keyboard_Num1 = 0x0000200D, + Keyboard_Num2 = 0x0000200E, + Keyboard_Num3 = 0x0000200F, + Keyboard_NumEnter = 0x00002010, + Keyboard_Num0 = 0x00002011, + Keyboard_Num00 = 0x00002012, + Keyboard_NumPeriodAndDelete = 0x00002013, Keyboard_MediaMute = 0x00003001, Keyboard_MediaVolumeDown = 0x00003002, - Keyboard_MediaVokumeUp = 0x00003003, + Keyboard_MediaVolumeUp = 0x00003003, Keyboard_MediaStop = 0x00003004, Keyboard_MediaPreviousTrack = 0x00003005, Keyboard_MediaPlay = 0x00003006, @@ -207,8 +214,6 @@ namespace RGB.NET.Core Keyboard_Custom31 = 0x0000701F, Keyboard_Custom32 = 0x00007020, - Keyboard_Logo = 0x000FFFFF, - /*### Mouse ###*/ Mouse1 = 0x00100001, Mouse2 = 0x00100002, diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 47bae2f..a37acfa 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -79,7 +79,6 @@ - diff --git a/RGB.NET.Devices.Asus/Enum/AsusLedIds.cs b/RGB.NET.Devices.Asus/Enum/AsusLedIds.cs deleted file mode 100644 index 67c9d7e..0000000 --- a/RGB.NET.Devices.Asus/Enum/AsusLedIds.cs +++ /dev/null @@ -1,30 +0,0 @@ -// ReSharper disable InconsistentNaming - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.Asus -{ - /// - /// Contains list of all LEDs available for all Asus devices. - /// - public enum AsusLedIds - { - Invalid = -1, - - //TODO DarthAffe 07.10.2017: Create useful Ids for all devices - - MainboardLed1 = 0x01, - MainboardLed2 = 0x02, - MainboardLed3 = 0x03, - MainboardLed4 = 0x04, - MainboardLed5 = 0x05, - - GraphicsCardLed1 = 0x11, - - DramLed1 = 0x21, - - MouseLed1 = 0x31, - - KeyboardLed1 = 0x41, - } -} diff --git a/RGB.NET.Devices.Asus/Generic/AsusLedId.cs b/RGB.NET.Devices.Asus/Generic/AsusLedId.cs deleted file mode 100644 index a122968..0000000 --- a/RGB.NET.Devices.Asus/Generic/AsusLedId.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Asus -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class AsusLedId : ILedId - { - #region Properties & Fields - - internal readonly AsusLedIds LedId; - - internal readonly int Index; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != AsusLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public AsusLedId(IRGBDevice device, AsusLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - /// The index in the mapping array of the device. - public AsusLedId(IRGBDevice device, AsusLedIds ledId, int index) - { - this.Device = device; - this.LedId = ledId; - this.Index = index; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() => LedId.ToString(); - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - AsusLedId compareLedId = obj as AsusLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() => LedId.GetHashCode(); - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(AsusLedId ledId1, AsusLedId ledId2) => ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(AsusLedId ledId1, AsusLedId ledId2) => !(ledId1 == ledId2); - - #endregion - } -} diff --git a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs index 471626d..68885cc 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Runtime.InteropServices; using RGB.NET.Core; -using RGB.NET.Core.Layout; namespace RGB.NET.Devices.Asus { @@ -67,44 +65,6 @@ namespace RGB.NET.Devices.Asus /// protected abstract void InitializeLayout(); - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out AsusLedIds ledId)) - { - if (LedMapping.TryGetValue(new AsusLedId(this, ledId), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { @@ -114,7 +74,7 @@ namespace RGB.NET.Devices.Asus { foreach (Led led in leds) { - int index = (((AsusLedId)led.Id).Index) * 3; + int index = ((int)led.CustomData) * 3; ColorData[index] = led.Color.R; ColorData[index + 1] = led.Color.G; ColorData[index + 2] = led.Color.B; diff --git a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs index bf77de2..dd02fc4 100644 --- a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs @@ -30,13 +30,16 @@ namespace RGB.NET.Devices.Asus //TODO DarthAffe 07.10.2017: Look for a good default layout int ledCount = _AsusSDK.GetGPULedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) - InitializeLed(new AsusLedId(this, AsusLedIds.GraphicsCardLed1 + i, i), new Rectangle(i * 10, 0, 10, 10)); + InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); - //TODO DarthAffe 07.10.2017: We don'T know the model, how to save layouts and images? + //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\GraphicsCards")); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1; + /// protected override void ApplyColorData() => _AsusSDK.SetGPUColor(DeviceInfo.Handle, ColorData); diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 5a17dff..d333e7b 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -27,16 +27,19 @@ namespace RGB.NET.Devices.Asus /// protected override void InitializeLayout() { - //TODO DarthAffe 07.10.2017: Look for a good default layout + //TODO DarthAffe 07.10.2017: This doesn't make sense at all ... Find someone with such a keyboard! int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) - InitializeLed(new AsusLedId(this, AsusLedIds.KeyboardLed1 + i, i), new Rectangle(i * 19, 0, 19, 19)); + InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards")); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; + /// protected override void ApplyColorData() => _AsusSDK.SetClaymoreKeyboardColor(DeviceInfo.Handle, ColorData); diff --git a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs index 6b91f5a..dc36764 100644 --- a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs @@ -30,19 +30,22 @@ namespace RGB.NET.Devices.Asus //TODO DarthAffe 07.10.2017: Look for a good default layout int ledCount = _AsusSDK.GetMbLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) - InitializeLed(new AsusLedId(this, AsusLedIds.MainboardLed1 + i, i), new Rectangle(i * 40, 0, 40, 8)); + InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); //TODO DarthAffe 07.10.2017: We don'T know the model, how to save layouts and images? ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\Mainboards")); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1; + /// public override void SyncBack() { byte[] colorData = _AsusSDK.GetMbColor(DeviceInfo.Handle); for (int i = 0; i < LedMapping.Count; i++) - LedMapping[new AsusLedId(this, AsusLedIds.MainboardLed1 + i)].Color = new Color(colorData[(i * 3)], colorData[(i * 3) + 2], colorData[(i * 3) + 1]); + LedMapping[LedId.Mainboard1 + i].Color = new Color(colorData[(i * 3)], colorData[(i * 3) + 2], colorData[(i * 3) + 1]); } /// diff --git a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs index d83963e..c1b689b 100644 --- a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs @@ -30,12 +30,15 @@ namespace RGB.NET.Devices.Asus //TODO DarthAffe 07.10.2017: Look for a good default layout int ledCount = _AsusSDK.GetRogMouseLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) - InitializeLed(new AsusLedId(this, AsusLedIds.MouseLed1 + i, i), new Rectangle(i * 10, 0, 10, 10)); + InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\Mouses")); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; + /// protected override void ApplyColorData() => _AsusSDK.SetRogMouseColor(DeviceInfo.Handle, ColorData); diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index cde110d..733d9d1 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -48,11 +48,9 @@ - - diff --git a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterLedIds.cs b/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterLedIds.cs deleted file mode 100644 index eac0146..0000000 --- a/RGB.NET.Devices.CoolerMaster/Enum/CoolerMasterLedIds.cs +++ /dev/null @@ -1,137 +0,0 @@ -// ReSharper disable InconsistentNaming - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.CoolerMaster -{ - /// - /// Contains list of all LEDs available for all CoolerMaster devices. - /// - public enum CoolerMasterLedIds - { - Invalid = -1, - - Esc = 0, - F1 = 1, - F2 = 2, - F3 = 3, - F4 = 4, - F5 = 6, - F6 = 7, - F7 = 8, - F8 = 9, - F9 = 11, - F10 = 12, - F11 = 13, - F12 = 14, - Snapshot = 15, - ScrollLock = 16, - Pause = 17, - P1 = 18, - P2 = 19, - P3 = 20, - P4 = 21, - - Gravis = 22, - D1 = 23, - D2 = 24, - D3 = 25, - D4 = 26, - D5 = 27, - D6 = 28, - D7 = 29, - D8 = 30, - D9 = 31, - D0 = 32, - Minus = 33, - Equals = 34, - Backspace = 36, - Insert = 37, - Home = 38, - PageUp = 39, - Numlock = 40, - KeypadSlash = 41, - KeypadAsterisk = 42, - KeypadMinus = 43, - - Tab = 44, - Q = 45, - W = 46, - E = 47, - R = 48, - T = 49, - Y = 50, - U = 51, - I = 52, - O = 53, - P = 54, - BracketLeft = 55, - BracketRight = 56, - Backslash = 58, - Delete = 59, - End = 60, - PageDown = 61, - Keypad7 = 62, - Keypad8 = 63, - Keypad9 = 64, - KeypadPlus = 65, - - CapsLock = 66, - A = 67, - S = 68, - D = 69, - F = 70, - G = 71, - H = 72, - J = 73, - K = 74, - L = 75, - Semicolon = 76, - Apostroph = 77, - CODEA2 = 78, - Enter = 80, - Keypad4 = 84, - Keypad5 = 85, - Keypad6 = 86, - - LShift = 88, - CODEA5 = 89, - Z = 90, - X = 91, - C = 92, - V = 93, - B = 94, - N = 95, - M = 96, - Comma = 97, - Period = 98, - Slash = 99, - RShift = 102, - Up = 104, - Keypad1 = 106, - Keypad2 = 107, - Keypad3 = 108, - KeypadEnter = 109, - - LCtrl = 110, - LWin = 111, - LAlt = 112, - Space = 116, - RAlt = 120, - RWin = 121, - App = 122, - RCtrl = 124, - Left = 125, - Down = 126, - Right = 127, - Keypad0 = 128, - Keypad00 = 129, - KeypadPeriod = 130, - - Side1 = 132, - Side2 = 133, - Side3 = 134, - Back1 = 135, - Wheel = 136 - } -} diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterLedId.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterLedId.cs deleted file mode 100644 index f14d517..0000000 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterLedId.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.CoolerMaster -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class CoolerMasterLedId : ILedId - { - #region Properties & Fields - - internal readonly CoolerMasterLedIds LedId; - - internal readonly int Row; - internal readonly int Column; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != CoolerMasterLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public CoolerMasterLedId(IRGBDevice device, CoolerMasterLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - /// The row in the mapping table of the device. - /// The column in the mapping table of the device. - public CoolerMasterLedId(IRGBDevice device, CoolerMasterLedIds ledId, int row, int column) - { - this.Device = device; - this.LedId = ledId; - this.Row = row; - this.Column = column; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() - { - return LedId.ToString(); - } - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - CoolerMasterLedId compareLedId = obj as CoolerMasterLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - return LedId.GetHashCode(); - } - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(CoolerMasterLedId ledId1, CoolerMasterLedId ledId2) - { - return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - } - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(CoolerMasterLedId ledId1, CoolerMasterLedId ledId2) - { - return !(ledId1 == ledId2); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs index b920640..3a59b96 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using RGB.NET.Core; -using RGB.NET.Core.Layout; using RGB.NET.Devices.CoolerMaster.Native; namespace RGB.NET.Devices.CoolerMaster @@ -60,44 +58,6 @@ namespace RGB.NET.Devices.CoolerMaster /// protected abstract void InitializeLayout(); - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out CoolerMasterLedIds ledId)) - { - if (LedMapping.TryGetValue(new CoolerMasterLedId(this, ledId), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { @@ -109,8 +69,8 @@ namespace RGB.NET.Devices.CoolerMaster foreach (Led led in leds) { - CoolerMasterLedId ledId = (CoolerMasterLedId)led.Id; - _CoolerMasterSDK.SetLedColor(ledId.Row, ledId.Column, led.Color.R, led.Color.G, led.Color.B); + (int row, int column) = ((int, int))led.CustomData; + _CoolerMasterSDK.SetLedColor(row, column, led.Color.R, led.Color.G, led.Color.B); } _CoolerMasterSDK.RefreshLed(false); diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs index df91e93..3bd2dba 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardLedMappings.cs @@ -1,7 +1,7 @@ // ReSharper disable InconsistentNaming -using System; using System.Collections.Generic; +using RGB.NET.Core; namespace RGB.NET.Devices.CoolerMaster { @@ -14,691 +14,691 @@ namespace RGB.NET.Devices.CoolerMaster #region MasterKeysL - private static readonly Dictionary> MasterKeysL_US = new Dictionary> + private static readonly Dictionary MasterKeysL_US = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, - { CoolerMasterLedIds.Snapshot, new Tuple(0,15) }, - { CoolerMasterLedIds.ScrollLock, new Tuple(0,16) }, - { CoolerMasterLedIds.Pause, new Tuple(0,17) }, - { CoolerMasterLedIds.P1, new Tuple(0,18) }, - { CoolerMasterLedIds.P2, new Tuple(0,19) }, - { CoolerMasterLedIds.P3, new Tuple(0,20) }, - { CoolerMasterLedIds.P4, new Tuple(0,21) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, + { LedId.Keyboard_PrintScreen, (0,15) }, + { LedId.Keyboard_ScrollLock, (0,16) }, + { LedId.Keyboard_PauseBreak, (0,17) }, + { LedId.Keyboard_Programmable1, (0,18) }, + { LedId.Keyboard_Programmable2, (0,19) }, + { LedId.Keyboard_Programmable3, (0,20) }, + { LedId.Keyboard_Programmable4, (0,21) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Insert, new Tuple(1,15) }, - { CoolerMasterLedIds.Home, new Tuple(1,16) }, - { CoolerMasterLedIds.PageUp, new Tuple(1,17) }, - { CoolerMasterLedIds.Numlock, new Tuple(1,18) }, - { CoolerMasterLedIds.KeypadSlash, new Tuple(1,19) }, - { CoolerMasterLedIds.KeypadAsterisk, new Tuple(1,20) }, - { CoolerMasterLedIds.KeypadMinus, new Tuple(1,21) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_Insert, (1,15) }, + { LedId.Keyboard_Home, (1,16) }, + { LedId.Keyboard_PageUp, (1,17) }, + { LedId.Keyboard_NumLock, (1,18) }, + { LedId.Keyboard_NumSlash, (1,19) }, + { LedId.Keyboard_NumAsterisk, (1,20) }, + { LedId.Keyboard_NumMinus, (1,21) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Backslash, new Tuple(2,14) }, - { CoolerMasterLedIds.Delete, new Tuple(2,15) }, - { CoolerMasterLedIds.End, new Tuple(2,16) }, - { CoolerMasterLedIds.PageDown, new Tuple(2,17) }, - { CoolerMasterLedIds.Keypad7, new Tuple(2,18) }, - { CoolerMasterLedIds.Keypad8, new Tuple(2,19) }, - { CoolerMasterLedIds.Keypad9, new Tuple(2,20) }, - { CoolerMasterLedIds.KeypadPlus, new Tuple(2,21) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Backslash, (2,14) }, + { LedId.Keyboard_Delete, (2,15) }, + { LedId.Keyboard_End, (2,16) }, + { LedId.Keyboard_PageDown, (2,17) }, + { LedId.Keyboard_Num7, (2,18) }, + { LedId.Keyboard_Num8, (2,19) }, + { LedId.Keyboard_Num9, (2,20) }, + { LedId.Keyboard_NumPlus, (2,21) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.Enter, new Tuple(3,14) }, - { CoolerMasterLedIds.Keypad4, new Tuple(3,18) }, - { CoolerMasterLedIds.Keypad5, new Tuple(3,19) }, - { CoolerMasterLedIds.Keypad6, new Tuple(3,20) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_Enter, (3,14) }, + { LedId.Keyboard_Num4, (3,18) }, + { LedId.Keyboard_Num5, (3,19) }, + { LedId.Keyboard_Num6, (3,20) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.Up, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad1, new Tuple(4,18) }, - { CoolerMasterLedIds.Keypad2, new Tuple(4,19) }, - { CoolerMasterLedIds.Keypad3, new Tuple(4,20) }, - { CoolerMasterLedIds.KeypadEnter, new Tuple(4,21) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_ArrowUp, (4,16) }, + { LedId.Keyboard_Num1, (4,18) }, + { LedId.Keyboard_Num2, (4,19) }, + { LedId.Keyboard_Num3, (4,20) }, + { LedId.Keyboard_NumEnter, (4,21) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Left, new Tuple(5,15) }, - { CoolerMasterLedIds.Down, new Tuple(5,16) }, - { CoolerMasterLedIds.Right, new Tuple(5,17) }, - { CoolerMasterLedIds.Keypad0, new Tuple(5,18) }, - { CoolerMasterLedIds.KeypadPeriod, new Tuple(5,20) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_ArrowLeft, (5,15) }, + { LedId.Keyboard_ArrowDown, (5,16) }, + { LedId.Keyboard_ArrowRight, (5,17) }, + { LedId.Keyboard_Num0, (5,18) }, + { LedId.Keyboard_NumPeriodAndDelete, (5,20) } }; - private static readonly Dictionary> MasterKeysL_EU = new Dictionary> + private static readonly Dictionary MasterKeysL_EU = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, - { CoolerMasterLedIds.Snapshot, new Tuple(0,15) }, - { CoolerMasterLedIds.ScrollLock, new Tuple(0,16) }, - { CoolerMasterLedIds.Pause, new Tuple(0,17) }, - { CoolerMasterLedIds.P1, new Tuple(0,18) }, - { CoolerMasterLedIds.P2, new Tuple(0,19) }, - { CoolerMasterLedIds.P3, new Tuple(0,20) }, - { CoolerMasterLedIds.P4, new Tuple(0,21) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, + { LedId.Keyboard_PrintScreen, (0,15) }, + { LedId.Keyboard_ScrollLock, (0,16) }, + { LedId.Keyboard_PauseBreak, (0,17) }, + { LedId.Keyboard_Programmable1, (0,18) }, + { LedId.Keyboard_Programmable2, (0,19) }, + { LedId.Keyboard_Programmable3, (0,20) }, + { LedId.Keyboard_Programmable4, (0,21) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Insert, new Tuple(1,15) }, - { CoolerMasterLedIds.Home, new Tuple(1,16) }, - { CoolerMasterLedIds.PageUp, new Tuple(1,17) }, - { CoolerMasterLedIds.Numlock, new Tuple(1,18) }, - { CoolerMasterLedIds.KeypadSlash, new Tuple(1,19) }, - { CoolerMasterLedIds.KeypadAsterisk, new Tuple(1,20) }, - { CoolerMasterLedIds.KeypadMinus, new Tuple(1,21) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_Insert, (1,15) }, + { LedId.Keyboard_Home, (1,16) }, + { LedId.Keyboard_PageUp, (1,17) }, + { LedId.Keyboard_NumLock, (1,18) }, + { LedId.Keyboard_NumSlash, (1,19) }, + { LedId.Keyboard_NumAsterisk, (1,20) }, + { LedId.Keyboard_NumMinus, (1,21) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Enter, new Tuple(2,14) }, - { CoolerMasterLedIds.Delete, new Tuple(2,15) }, - { CoolerMasterLedIds.End, new Tuple(2,16) }, - { CoolerMasterLedIds.PageDown, new Tuple(2,17) }, - { CoolerMasterLedIds.Keypad7, new Tuple(2,18) }, - { CoolerMasterLedIds.Keypad8, new Tuple(2,19) }, - { CoolerMasterLedIds.Keypad9, new Tuple(2,20) }, - { CoolerMasterLedIds.KeypadPlus, new Tuple(2,21) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Enter, (2,14) }, + { LedId.Keyboard_Delete, (2,15) }, + { LedId.Keyboard_End, (2,16) }, + { LedId.Keyboard_PageDown, (2,17) }, + { LedId.Keyboard_Num7, (2,18) }, + { LedId.Keyboard_Num8, (2,19) }, + { LedId.Keyboard_Num9, (2,20) }, + { LedId.Keyboard_NumPlus, (2,21) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.CODEA2, new Tuple(3,12) }, - { CoolerMasterLedIds.Keypad4, new Tuple(3,18) }, - { CoolerMasterLedIds.Keypad5, new Tuple(3,19) }, - { CoolerMasterLedIds.Keypad6, new Tuple(3,20) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_NonUsTilde, (3,12) }, + { LedId.Keyboard_Num4, (3,18) }, + { LedId.Keyboard_Num5, (3,19) }, + { LedId.Keyboard_Num6, (3,20) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.CODEA5, new Tuple(4,1) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.Up, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad1, new Tuple(4,18) }, - { CoolerMasterLedIds.Keypad2, new Tuple(4,19) }, - { CoolerMasterLedIds.Keypad3, new Tuple(4,20) }, - { CoolerMasterLedIds.KeypadEnter, new Tuple(4,21) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_NonUsBackslash, (4,1) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_ArrowUp, (4,16) }, + { LedId.Keyboard_Num1, (4,18) }, + { LedId.Keyboard_Num2, (4,19) }, + { LedId.Keyboard_Num3, (4,20) }, + { LedId.Keyboard_NumEnter, (4,21) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Left, new Tuple(5,15) }, - { CoolerMasterLedIds.Down, new Tuple(5,16) }, - { CoolerMasterLedIds.Right, new Tuple(5,17) }, - { CoolerMasterLedIds.Keypad0, new Tuple(5,18) }, - { CoolerMasterLedIds.KeypadPeriod, new Tuple(5,20) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_ArrowLeft, (5,15) }, + { LedId.Keyboard_ArrowDown, (5,16) }, + { LedId.Keyboard_ArrowRight, (5,17) }, + { LedId.Keyboard_Num0, (5,18) }, + { LedId.Keyboard_NumPeriodAndDelete, (5,20) } }; #endregion #region MasterKeysM - private static readonly Dictionary> MasterKeysM_US = new Dictionary> + private static readonly Dictionary MasterKeysM_US = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Numlock, new Tuple(1,15) }, - { CoolerMasterLedIds.KeypadSlash, new Tuple(1,16) }, - { CoolerMasterLedIds.KeypadAsterisk, new Tuple(1,17) }, - { CoolerMasterLedIds.KeypadMinus, new Tuple(1,18) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_NumLock, (1,15) }, + { LedId.Keyboard_NumSlash, (1,16) }, + { LedId.Keyboard_NumAsterisk, (1,17) }, + { LedId.Keyboard_NumMinus, (1,18) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Backslash, new Tuple(2,14) }, - { CoolerMasterLedIds.Keypad7, new Tuple(2,15) }, - { CoolerMasterLedIds.Keypad8, new Tuple(2,16) }, - { CoolerMasterLedIds.Keypad9, new Tuple(2,17) }, - { CoolerMasterLedIds.KeypadPlus, new Tuple(2,18) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Backslash, (2,14) }, + { LedId.Keyboard_Num7, (2,15) }, + { LedId.Keyboard_Num8, (2,16) }, + { LedId.Keyboard_Num9, (2,17) }, + { LedId.Keyboard_NumPlus, (2,18) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.Enter, new Tuple(3,14) }, - { CoolerMasterLedIds.Keypad4, new Tuple(3,15) }, - { CoolerMasterLedIds.Keypad5, new Tuple(3,16) }, - { CoolerMasterLedIds.Keypad6, new Tuple(3,17) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_Enter, (3,14) }, + { LedId.Keyboard_Num4, (3,15) }, + { LedId.Keyboard_Num5, (3,16) }, + { LedId.Keyboard_Num6, (3,17) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.U, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad1, new Tuple(4,15) }, - { CoolerMasterLedIds.Keypad2, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad3, new Tuple(4,17) }, - { CoolerMasterLedIds.KeypadEnter, new Tuple(4,18) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_U, (4,16) }, + { LedId.Keyboard_Num1, (4,15) }, + { LedId.Keyboard_Num2, (4,16) }, + { LedId.Keyboard_Num3, (4,17) }, + { LedId.Keyboard_NumEnter, (4,18) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Keypad0, new Tuple(5,15) }, - { CoolerMasterLedIds.Keypad00, new Tuple(5,16) }, - { CoolerMasterLedIds.KeypadPeriod, new Tuple(5,17) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_Num0, (5,15) }, + { LedId.Keyboard_Num00, (5,16) }, + { LedId.Keyboard_NumPeriodAndDelete, (5,17) } }; - private static readonly Dictionary> MasterKeysM_EU = new Dictionary> + private static readonly Dictionary MasterKeysM_EU = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Numlock, new Tuple(1,15) }, - { CoolerMasterLedIds.KeypadSlash, new Tuple(1,16) }, - { CoolerMasterLedIds.KeypadAsterisk, new Tuple(1,17) }, - { CoolerMasterLedIds.KeypadMinus, new Tuple(1,18) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_NumLock, (1,15) }, + { LedId.Keyboard_NumSlash, (1,16) }, + { LedId.Keyboard_NumAsterisk, (1,17) }, + { LedId.Keyboard_NumMinus, (1,18) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Backslash, new Tuple(2,14) }, - { CoolerMasterLedIds.Keypad7, new Tuple(2,15) }, - { CoolerMasterLedIds.Keypad8, new Tuple(2,16) }, - { CoolerMasterLedIds.Keypad9, new Tuple(2,17) }, - { CoolerMasterLedIds.KeypadPlus, new Tuple(2,18) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Backslash, (2,14) }, + { LedId.Keyboard_Num7, (2,15) }, + { LedId.Keyboard_Num8, (2,16) }, + { LedId.Keyboard_Num9, (2,17) }, + { LedId.Keyboard_NumPlus, (2,18) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.CODEA2, new Tuple(3,12) }, - { CoolerMasterLedIds.Keypad4, new Tuple(3,15) }, - { CoolerMasterLedIds.Keypad5, new Tuple(3,16) }, - { CoolerMasterLedIds.Keypad6, new Tuple(3,17) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_NonUsTilde, (3,12) }, + { LedId.Keyboard_Num4, (3,15) }, + { LedId.Keyboard_Num5, (3,16) }, + { LedId.Keyboard_Num6, (3,17) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.CODEA5, new Tuple(4,1) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.U, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad1, new Tuple(4,15) }, - { CoolerMasterLedIds.Keypad2, new Tuple(4,16) }, - { CoolerMasterLedIds.Keypad3, new Tuple(4,17) }, - { CoolerMasterLedIds.KeypadEnter, new Tuple(4,18) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_NonUsBackslash, (4,1) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_U, (4,16) }, + { LedId.Keyboard_Num1, (4,15) }, + { LedId.Keyboard_Num2, (4,16) }, + { LedId.Keyboard_Num3, (4,17) }, + { LedId.Keyboard_NumEnter, (4,18) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Keypad0, new Tuple(5,15) }, - { CoolerMasterLedIds.Keypad00, new Tuple(5,16) }, - { CoolerMasterLedIds.KeypadPeriod, new Tuple(5,17) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_Num0, (5,15) }, + { LedId.Keyboard_Num00, (5,16) }, + { LedId.Keyboard_NumPeriodAndDelete, (5,17) } }; #endregion #region MasterKeysS - private static readonly Dictionary> MasterKeysS_US = new Dictionary> + private static readonly Dictionary MasterKeysS_US = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, - { CoolerMasterLedIds.Snapshot, new Tuple(0,15) }, - { CoolerMasterLedIds.ScrollLock, new Tuple(0,16) }, - { CoolerMasterLedIds.Pause, new Tuple(0,17) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, + { LedId.Keyboard_PrintScreen, (0,15) }, + { LedId.Keyboard_ScrollLock, (0,16) }, + { LedId.Keyboard_PauseBreak, (0,17) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Insert, new Tuple(1,15) }, - { CoolerMasterLedIds.Home, new Tuple(1,16) }, - { CoolerMasterLedIds.PageUp, new Tuple(1,17) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_Insert, (1,15) }, + { LedId.Keyboard_Home, (1,16) }, + { LedId.Keyboard_PageUp, (1,17) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Backslash, new Tuple(2,14) }, - { CoolerMasterLedIds.Delete, new Tuple(2,15) }, - { CoolerMasterLedIds.End, new Tuple(2,16) }, - { CoolerMasterLedIds.PageDown, new Tuple(2,17) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Backslash, (2,14) }, + { LedId.Keyboard_Delete, (2,15) }, + { LedId.Keyboard_End, (2,16) }, + { LedId.Keyboard_PageDown, (2,17) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.Enter, new Tuple(3,14) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_Enter, (3,14) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.Up, new Tuple(4,16) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_ArrowUp, (4,16) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Left, new Tuple(5,15) }, - { CoolerMasterLedIds.Down, new Tuple(5,16) }, - { CoolerMasterLedIds.Right, new Tuple(5,17) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_ArrowLeft, (5,15) }, + { LedId.Keyboard_ArrowDown, (5,16) }, + { LedId.Keyboard_ArrowRight, (5,17) } }; - private static readonly Dictionary> MasterKeysS_EU = new Dictionary> + private static readonly Dictionary MasterKeysS_EU = new Dictionary { - { CoolerMasterLedIds.Esc, new Tuple(0,0) }, - { CoolerMasterLedIds.F1, new Tuple(0,1) }, - { CoolerMasterLedIds.F2, new Tuple(0,2) }, - { CoolerMasterLedIds.F3, new Tuple(0,3) }, - { CoolerMasterLedIds.F4, new Tuple(0,4) }, - { CoolerMasterLedIds.F5, new Tuple(0,6) }, - { CoolerMasterLedIds.F6, new Tuple(0,7) }, - { CoolerMasterLedIds.F7, new Tuple(0,8) }, - { CoolerMasterLedIds.F8, new Tuple(0,9) }, - { CoolerMasterLedIds.F9, new Tuple(0,11) }, - { CoolerMasterLedIds.F10, new Tuple(0,12) }, - { CoolerMasterLedIds.F11, new Tuple(0,13) }, - { CoolerMasterLedIds.F12, new Tuple(0,14) }, - { CoolerMasterLedIds.Snapshot, new Tuple(0,15) }, - { CoolerMasterLedIds.ScrollLock, new Tuple(0,16) }, - { CoolerMasterLedIds.Pause, new Tuple(0,17) }, + { LedId.Keyboard_Escape, (0,0) }, + { LedId.Keyboard_F1, (0,1) }, + { LedId.Keyboard_F2, (0,2) }, + { LedId.Keyboard_F3, (0,3) }, + { LedId.Keyboard_F4, (0,4) }, + { LedId.Keyboard_F5, (0,6) }, + { LedId.Keyboard_F6, (0,7) }, + { LedId.Keyboard_F7, (0,8) }, + { LedId.Keyboard_F8, (0,9) }, + { LedId.Keyboard_F9, (0,11) }, + { LedId.Keyboard_F10, (0,12) }, + { LedId.Keyboard_F11, (0,13) }, + { LedId.Keyboard_F12, (0,14) }, + { LedId.Keyboard_PrintScreen, (0,15) }, + { LedId.Keyboard_ScrollLock, (0,16) }, + { LedId.Keyboard_PauseBreak, (0,17) }, - { CoolerMasterLedIds.Gravis, new Tuple(1,0) }, - { CoolerMasterLedIds.D1, new Tuple(1,1) }, - { CoolerMasterLedIds.D2, new Tuple(1,2) }, - { CoolerMasterLedIds.D3, new Tuple(1,3) }, - { CoolerMasterLedIds.D4, new Tuple(1,4) }, - { CoolerMasterLedIds.D5, new Tuple(1,5) }, - { CoolerMasterLedIds.D6, new Tuple(1,6) }, - { CoolerMasterLedIds.D7, new Tuple(1,7) }, - { CoolerMasterLedIds.D8, new Tuple(1,8) }, - { CoolerMasterLedIds.D9, new Tuple(1,9) }, - { CoolerMasterLedIds.D0, new Tuple(1,10) }, - { CoolerMasterLedIds.Minus, new Tuple(1,11) }, - { CoolerMasterLedIds.Equals, new Tuple(1,12) }, - { CoolerMasterLedIds.Backspace, new Tuple(1,14) }, - { CoolerMasterLedIds.Insert, new Tuple(1,15) }, - { CoolerMasterLedIds.Home, new Tuple(1,16) }, - { CoolerMasterLedIds.PageUp, new Tuple(1,17) }, + { LedId.Keyboard_GraveAccentAndTilde, (1,0) }, + { LedId.Keyboard_1, (1,1) }, + { LedId.Keyboard_2, (1,2) }, + { LedId.Keyboard_3, (1,3) }, + { LedId.Keyboard_4, (1,4) }, + { LedId.Keyboard_5, (1,5) }, + { LedId.Keyboard_6, (1,6) }, + { LedId.Keyboard_7, (1,7) }, + { LedId.Keyboard_8, (1,8) }, + { LedId.Keyboard_9, (1,9) }, + { LedId.Keyboard_0, (1,10) }, + { LedId.Keyboard_MinusAndUnderscore, (1,11) }, + { LedId.Keyboard_EqualsAndPlus, (1,12) }, + { LedId.Keyboard_Backspace, (1,14) }, + { LedId.Keyboard_Insert, (1,15) }, + { LedId.Keyboard_Home, (1,16) }, + { LedId.Keyboard_PageUp, (1,17) }, - { CoolerMasterLedIds.Tab, new Tuple(2,0) }, - { CoolerMasterLedIds.Q, new Tuple(2,1) }, - { CoolerMasterLedIds.W, new Tuple(2,2) }, - { CoolerMasterLedIds.E, new Tuple(2,3) }, - { CoolerMasterLedIds.R, new Tuple(2,4) }, - { CoolerMasterLedIds.T, new Tuple(2,5) }, - { CoolerMasterLedIds.Y, new Tuple(2,6) }, - { CoolerMasterLedIds.U, new Tuple(2,7) }, - { CoolerMasterLedIds.I, new Tuple(2,8) }, - { CoolerMasterLedIds.O, new Tuple(2,9) }, - { CoolerMasterLedIds.P, new Tuple(2,10) }, - { CoolerMasterLedIds.BracketLeft, new Tuple(2,11) }, - { CoolerMasterLedIds.BracketRight, new Tuple(2,12) }, - { CoolerMasterLedIds.Enter, new Tuple(2,14) }, - { CoolerMasterLedIds.Delete, new Tuple(2,15) }, - { CoolerMasterLedIds.End, new Tuple(2,16) }, - { CoolerMasterLedIds.PageDown, new Tuple(2,17) }, + { LedId.Keyboard_Tab, (2,0) }, + { LedId.Keyboard_Q, (2,1) }, + { LedId.Keyboard_W, (2,2) }, + { LedId.Keyboard_E, (2,3) }, + { LedId.Keyboard_R, (2,4) }, + { LedId.Keyboard_T, (2,5) }, + { LedId.Keyboard_Y, (2,6) }, + { LedId.Keyboard_U, (2,7) }, + { LedId.Keyboard_I, (2,8) }, + { LedId.Keyboard_O, (2,9) }, + { LedId.Keyboard_P, (2,10) }, + { LedId.Keyboard_BracketLeft, (2,11) }, + { LedId.Keyboard_BracketRight, (2,12) }, + { LedId.Keyboard_Enter, (2,14) }, + { LedId.Keyboard_Delete, (2,15) }, + { LedId.Keyboard_End, (2,16) }, + { LedId.Keyboard_PageDown, (2,17) }, - { CoolerMasterLedIds.CapsLock, new Tuple(3,0) }, - { CoolerMasterLedIds.A, new Tuple(3,1) }, - { CoolerMasterLedIds.S, new Tuple(3,2) }, - { CoolerMasterLedIds.D, new Tuple(3,3) }, - { CoolerMasterLedIds.F, new Tuple(3,4) }, - { CoolerMasterLedIds.G, new Tuple(3,5) }, - { CoolerMasterLedIds.H, new Tuple(3,6) }, - { CoolerMasterLedIds.J, new Tuple(3,7) }, - { CoolerMasterLedIds.K, new Tuple(3,8) }, - { CoolerMasterLedIds.L, new Tuple(3,9) }, - { CoolerMasterLedIds.Semicolon, new Tuple(3,10) }, - { CoolerMasterLedIds.Apostroph, new Tuple(3,11) }, - { CoolerMasterLedIds.CODEA2, new Tuple(3,12) }, + { LedId.Keyboard_CapsLock, (3,0) }, + { LedId.Keyboard_A, (3,1) }, + { LedId.Keyboard_S, (3,2) }, + { LedId.Keyboard_D, (3,3) }, + { LedId.Keyboard_F, (3,4) }, + { LedId.Keyboard_G, (3,5) }, + { LedId.Keyboard_H, (3,6) }, + { LedId.Keyboard_J, (3,7) }, + { LedId.Keyboard_K, (3,8) }, + { LedId.Keyboard_L, (3,9) }, + { LedId.Keyboard_SemicolonAndColon, (3,10) }, + { LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) }, + { LedId.Keyboard_NonUsTilde, (3,12) }, - { CoolerMasterLedIds.LShift, new Tuple(4,0) }, - { CoolerMasterLedIds.CODEA5, new Tuple(4,1) }, - { CoolerMasterLedIds.Z, new Tuple(4,2) }, - { CoolerMasterLedIds.X, new Tuple(4,3) }, - { CoolerMasterLedIds.C, new Tuple(4,4) }, - { CoolerMasterLedIds.V, new Tuple(4,5) }, - { CoolerMasterLedIds.B, new Tuple(4,6) }, - { CoolerMasterLedIds.N, new Tuple(4,7) }, - { CoolerMasterLedIds.M, new Tuple(4,8) }, - { CoolerMasterLedIds.Comma, new Tuple(4,9) }, - { CoolerMasterLedIds.Period, new Tuple(4,10) }, - { CoolerMasterLedIds.Slash, new Tuple(4,11) }, - { CoolerMasterLedIds.RShift, new Tuple(4,14) }, - { CoolerMasterLedIds.Up, new Tuple(4,16) }, + { LedId.Keyboard_LeftShift, (4,0) }, + { LedId.Keyboard_NonUsBackslash, (4,1) }, + { LedId.Keyboard_Z, (4,2) }, + { LedId.Keyboard_X, (4,3) }, + { LedId.Keyboard_C, (4,4) }, + { LedId.Keyboard_V, (4,5) }, + { LedId.Keyboard_B, (4,6) }, + { LedId.Keyboard_N, (4,7) }, + { LedId.Keyboard_M, (4,8) }, + { LedId.Keyboard_CommaAndLessThan, (4,9) }, + { LedId.Keyboard_PeriodAndBiggerThan, (4,10) }, + { LedId.Keyboard_SlashAndQuestionMark, (4,11) }, + { LedId.Keyboard_RightShift, (4,14) }, + { LedId.Keyboard_ArrowUp, (4,16) }, - { CoolerMasterLedIds.LCtrl, new Tuple(5,0) }, - { CoolerMasterLedIds.LWin, new Tuple(5,1) }, - { CoolerMasterLedIds.LAlt, new Tuple(5,2) }, - { CoolerMasterLedIds.Space, new Tuple(5,6) }, - { CoolerMasterLedIds.RAlt, new Tuple(5,10) }, - { CoolerMasterLedIds.RWin, new Tuple(5,11) }, - { CoolerMasterLedIds.App, new Tuple(5,12) }, - { CoolerMasterLedIds.RCtrl, new Tuple(5,14) }, - { CoolerMasterLedIds.Left, new Tuple(5,15) }, - { CoolerMasterLedIds.Down, new Tuple(5,16) }, - { CoolerMasterLedIds.Right, new Tuple(5,17) } + { LedId.Keyboard_LeftCtrl, (5,0) }, + { LedId.Keyboard_LeftGui, (5,1) }, + { LedId.Keyboard_LeftAlt, (5,2) }, + { LedId.Keyboard_Space, (5,6) }, + { LedId.Keyboard_RightAlt, (5,10) }, + { LedId.Keyboard_RightGui, (5,11) }, + { LedId.Keyboard_Application, (5,12) }, + { LedId.Keyboard_RightCtrl, (5,14) }, + { LedId.Keyboard_ArrowLeft, (5,15) }, + { LedId.Keyboard_ArrowDown, (5,16) }, + { LedId.Keyboard_ArrowRight, (5,17) } }; - + #endregion /// /// Contains all the hardware-id mappings for CoolerMaster devices. /// - public static readonly Dictionary>>> Mapping = - new Dictionary>>> + public static readonly Dictionary>> Mapping = + new Dictionary>> { - { CoolerMasterDevicesIndexes.MasterKeys_L, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_L, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysL_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysL_EU } } }, - { CoolerMasterDevicesIndexes.MasterKeys_M, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_M, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysM_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysM_EU } } }, - { CoolerMasterDevicesIndexes.MasterKeys_S, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_S, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysS_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysS_EU } } }, - { CoolerMasterDevicesIndexes.MasterKeys_L_White, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_L_White, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysL_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysL_EU } } }, - { CoolerMasterDevicesIndexes.MasterKeys_M_White, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_M_White, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysM_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysM_EU } } }, - { CoolerMasterDevicesIndexes.MasterKeys_S_White, new Dictionary>> + { CoolerMasterDevicesIndexes.MasterKeys_S_White, new Dictionary> { { CoolerMasterPhysicalKeyboardLayout.US, MasterKeysS_US }, { CoolerMasterPhysicalKeyboardLayout.EU, MasterKeysS_EU } diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs index 423486c..922ad52 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.CoolerMaster @@ -28,11 +27,10 @@ namespace RGB.NET.Devices.CoolerMaster /// protected override void InitializeLayout() { - Dictionary> mapping = CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout]; + Dictionary mapping = CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout]; - foreach (KeyValuePair> led in mapping) - InitializeLed(new CoolerMasterLedId(this, led.Key, led.Value.Item1, led.Value.Item2), - new Rectangle(led.Value.Item2 * 19, led.Value.Item1 * 19, 19, 19)); + foreach (KeyValuePair led in mapping) + InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( @@ -40,6 +38,9 @@ namespace RGB.NET.Devices.CoolerMaster DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards")); } + /// + protected override object CreateLedCustomData(LedId ledId) => CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId]; + #endregion } } diff --git a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseLedMappings.cs b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseLedMappings.cs index 731d9d2..1e00122 100644 --- a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseLedMappings.cs +++ b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseLedMappings.cs @@ -1,5 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using RGB.NET.Core; namespace RGB.NET.Devices.CoolerMaster { @@ -14,24 +14,24 @@ namespace RGB.NET.Devices.CoolerMaster /// Contains all the hardware-id mappings for CoolerMaster devices. /// // ReSharper disable once InconsistentNaming - public static readonly Dictionary>> Mapping = - new Dictionary>> + public static readonly Dictionary> Mapping = + new Dictionary> { - { CoolerMasterDevicesIndexes.MasterMouse_L, new Dictionary> + { CoolerMasterDevicesIndexes.MasterMouse_L, new Dictionary { - { CoolerMasterLedIds.Side1, new Tuple(0,0) }, - { CoolerMasterLedIds.Side2, new Tuple(1,0) }, - { CoolerMasterLedIds.Side3, new Tuple(2,0) }, - { CoolerMasterLedIds.Back1, new Tuple(3,0) }, + { LedId.Mouse1, (0,0) }, + { LedId.Mouse2, (1,0) }, + { LedId.Mouse3, (2,0) }, + { LedId.Mouse4, (3,0) }, } }, - { CoolerMasterDevicesIndexes.MasterMouse_S, new Dictionary> + { CoolerMasterDevicesIndexes.MasterMouse_S, new Dictionary { - { CoolerMasterLedIds.Back1, new Tuple(0,0) }, - { CoolerMasterLedIds.Wheel, new Tuple(1,0) }, - { CoolerMasterLedIds.Side3, new Tuple(2,0) }, - { CoolerMasterLedIds.Back1, new Tuple(3,0) }, + { LedId.Mouse1, (0,0) }, + { LedId.Mouse2, (1,0) }, + { LedId.Mouse3, (2,0) }, + { LedId.Mouse4, (3,0) }, } }, }; diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index eb43d97..b7c046a 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -48,12 +48,10 @@ - - diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs similarity index 99% rename from RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs rename to RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs index 8c9f0aa..f5a1a69 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedIds.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair /// /// Contains list of all LEDs available for all corsair devices. /// - public enum CorsairLedIds + public enum CorsairLedId { Invalid = 0, Escape = 1, diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs deleted file mode 100644 index 10bd2e3..0000000 --- a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Corsair -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class CorsairLedId : ILedId - { - #region Properties & Fields - - internal readonly CorsairLedIds LedId; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != CorsairLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public CorsairLedId(IRGBDevice device, CorsairLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() - { - return LedId.ToString(); - } - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - CorsairLedId compareLedId = obj as CorsairLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - return LedId.GetHashCode(); - } - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(CorsairLedId ledId1, CorsairLedId ledId2) - { - return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - } - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(CorsairLedId ledId1, CorsairLedId ledId2) - { - return !(ledId1 == ledId2); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index c2fadf5..d70ad9c 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Runtime.InteropServices; using RGB.NET.Core; -using RGB.NET.Core.Layout; using RGB.NET.Devices.Corsair.Native; namespace RGB.NET.Devices.Corsair @@ -25,6 +23,24 @@ namespace RGB.NET.Devices.Corsair /// public override TDeviceInfo DeviceInfo { get; } + /// + /// Gets a dictionary containing all of the . + /// + // ReSharper disable once MemberCanBePrivate.Global + protected Dictionary InternalLedMapping { get; } = new Dictionary(); + + #endregion + + #region Indexer + + /// + /// Gets the with the specified . + /// + /// The of the to get. + /// The with the specified or null if no is found. + // ReSharper disable once MemberCanBePrivate.Global + public Led this[CorsairLedId ledId] => InternalLedMapping.TryGetValue(ledId, out Led led) ? led : null; + #endregion #region Constructors @@ -49,6 +65,13 @@ namespace RGB.NET.Devices.Corsair { InitializeLayout(); + foreach (Led led in LedMapping.Values) + { + CorsairLedId ledId = (CorsairLedId)led.CustomData; + if (ledId != CorsairLedId.Invalid) + InternalLedMapping.Add(ledId, led); + } + if (Size == Size.Invalid) { Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); @@ -61,48 +84,10 @@ namespace RGB.NET.Devices.Corsair /// protected abstract void InitializeLayout(); - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out CorsairLedIds ledId)) - { - if (LedMapping.TryGetValue(new CorsairLedId(this, ledId), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { - List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); + List leds = ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))).ToList(); if (leds.Count > 0) // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array { @@ -113,7 +98,7 @@ namespace RGB.NET.Devices.Corsair { _CorsairLedColor color = new _CorsairLedColor { - ledId = (int)((CorsairLedId)led.Id).LedId, + ledId = (int)led.CustomData, r = led.Color.R, g = led.Color.G, b = led.Color.B @@ -135,7 +120,7 @@ namespace RGB.NET.Devices.Corsair IntPtr addPtr = new IntPtr(ptr.ToInt64()); foreach (Led led in this) { - _CorsairLedColor color = new _CorsairLedColor { ledId = (int)((CorsairLedId)led.Id).LedId }; + _CorsairLedColor color = new _CorsairLedColor { ledId = (int)led.CustomData }; Marshal.StructureToPtr(color, addPtr, false); addPtr = new IntPtr(addPtr.ToInt64() + structSize); } @@ -145,7 +130,7 @@ namespace RGB.NET.Devices.Corsair for (int i = 0; i < LedMapping.Count; i++) { _CorsairLedColor ledColor = (_CorsairLedColor)Marshal.PtrToStructure(readPtr, typeof(_CorsairLedColor)); - LedMapping[new CorsairLedId(this, (CorsairLedIds)ledColor.ledId)].Color = new Color(ledColor.r, ledColor.g, ledColor.b); + this[(CorsairLedId)ledColor.ledId].Color = new Color(ledColor.r, ledColor.g, ledColor.b); readPtr = new IntPtr(readPtr.ToInt64() + structSize); } diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index da46ae5..723d4e4 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -29,13 +29,16 @@ namespace RGB.NET.Devices.Corsair /// protected override void InitializeLayout() { - InitializeLed(new CorsairLedId(this, CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10)); - InitializeLed(new CorsairLedId(this, CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10)); + InitializeLed(LedId.Headset1, new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Headset2, new Rectangle(10, 0, 10, 10)); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Headsets")); } + /// + protected override object CreateLedCustomData(LedId ledId) => HeadsetIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + #endregion } } diff --git a/RGB.NET.Devices.Corsair/Headset/HeadsetIdMapping.cs b/RGB.NET.Devices.Corsair/Headset/HeadsetIdMapping.cs new file mode 100644 index 0000000..d446f09 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Headset/HeadsetIdMapping.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class HeadsetIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Headset1, CorsairLedId.LeftLogo }, + { LedId.Headset2, CorsairLedId.RightLogo }, + }; + } +} diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs index 77c2d34..059e2a3 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -47,14 +47,17 @@ namespace RGB.NET.Devices.Corsair positions.Add(ledPosition); } - foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) - InitializeLed(new CorsairLedId(this, ledPosition.ledId), - new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); + Dictionary mapping = HeadsetStandIdMapping.DEFAULT.SwapKeyValue(); + foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) + InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\HeadsetStands")); } + /// + protected override object CreateLedCustomData(LedId ledId) => HeadsetStandIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + #endregion } } diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/HeadsetStandIdMapping.cs b/RGB.NET.Devices.Corsair/HeadsetStand/HeadsetStandIdMapping.cs new file mode 100644 index 0000000..619f823 --- /dev/null +++ b/RGB.NET.Devices.Corsair/HeadsetStand/HeadsetStandIdMapping.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class HeadsetStandIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.HeadsetStand1, CorsairLedId.HeadsetStandZone1 }, + { LedId.HeadsetStand2, CorsairLedId.HeadsetStandZone2 }, + { LedId.HeadsetStand3, CorsairLedId.HeadsetStandZone3 }, + { LedId.HeadsetStand4, CorsairLedId.HeadsetStandZone4 }, + { LedId.HeadsetStand5, CorsairLedId.HeadsetStandZone5 }, + { LedId.HeadsetStand6, CorsairLedId.HeadsetStandZone6 }, + { LedId.HeadsetStand7, CorsairLedId.HeadsetStandZone7 }, + { LedId.HeadsetStand8, CorsairLedId.HeadsetStandZone8 }, + { LedId.HeadsetStand9, CorsairLedId.HeadsetStandZone9 } + }; + } +} diff --git a/RGB.NET.Devices.Corsair/Helper/DictionaryExtension.cs b/RGB.NET.Devices.Corsair/Helper/DictionaryExtension.cs new file mode 100644 index 0000000..2bc44f5 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Helper/DictionaryExtension.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Linq; + +namespace RGB.NET.Devices.Corsair +{ + internal static class DictionaryExtension + { + public static Dictionary SwapKeyValue(this Dictionary dictionary) => dictionary.ToDictionary(x => x.Value, x => x.Key); + } +} diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 0fcafa5..050c323 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; @@ -38,11 +39,11 @@ namespace RGB.NET.Devices.Corsair int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; + Dictionary mapping = KeyboardIdMapping.DEFAULT.SwapKeyValue(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); - InitializeLed(new CorsairLedId(this, ledPosition.ledId), - new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); + InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } @@ -53,6 +54,9 @@ namespace RGB.NET.Devices.Corsair DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards")); } + /// + protected override object CreateLedCustomData(LedId ledId) => KeyboardIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + #endregion } } diff --git a/RGB.NET.Devices.Corsair/Keyboard/KeyboardIdMapping.cs b/RGB.NET.Devices.Corsair/Keyboard/KeyboardIdMapping.cs new file mode 100644 index 0000000..e3e49c2 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Keyboard/KeyboardIdMapping.cs @@ -0,0 +1,158 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class KeyboardIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Invalid, CorsairLedId.Invalid }, + { LedId.Keyboard_Escape, CorsairLedId.Escape }, + { LedId.Keyboard_F1, CorsairLedId.F1 }, + { LedId.Keyboard_F2, CorsairLedId.F2 }, + { LedId.Keyboard_F3, CorsairLedId.F3 }, + { LedId.Keyboard_F4, CorsairLedId.F4 }, + { LedId.Keyboard_F5, CorsairLedId.F5 }, + { LedId.Keyboard_F6, CorsairLedId.F6 }, + { LedId.Keyboard_F7, CorsairLedId.F7 }, + { LedId.Keyboard_F8, CorsairLedId.F8 }, + { LedId.Keyboard_F9, CorsairLedId.F9 }, + { LedId.Keyboard_F10, CorsairLedId.F10 }, + { LedId.Keyboard_F11, CorsairLedId.F11 }, + { LedId.Keyboard_GraveAccentAndTilde, CorsairLedId.GraveAccentAndTilde }, + { LedId.Keyboard_1, CorsairLedId.D1 }, + { LedId.Keyboard_2, CorsairLedId.D2 }, + { LedId.Keyboard_3, CorsairLedId.D3 }, + { LedId.Keyboard_4, CorsairLedId.D4 }, + { LedId.Keyboard_5, CorsairLedId.D5 }, + { LedId.Keyboard_6, CorsairLedId.D6 }, + { LedId.Keyboard_7, CorsairLedId.D7 }, + { LedId.Keyboard_8, CorsairLedId.D8 }, + { LedId.Keyboard_9, CorsairLedId.D9 }, + { LedId.Keyboard_0, CorsairLedId.D0 }, + { LedId.Keyboard_MinusAndUnderscore, CorsairLedId.MinusAndUnderscore }, + { LedId.Keyboard_Tab, CorsairLedId.Tab }, + { LedId.Keyboard_Q, CorsairLedId.Q }, + { LedId.Keyboard_W, CorsairLedId.W }, + { LedId.Keyboard_E, CorsairLedId.E }, + { LedId.Keyboard_R, CorsairLedId.R }, + { LedId.Keyboard_T, CorsairLedId.T }, + { LedId.Keyboard_Y, CorsairLedId.Y }, + { LedId.Keyboard_U, CorsairLedId.U }, + { LedId.Keyboard_I, CorsairLedId.I }, + { LedId.Keyboard_O, CorsairLedId.O }, + { LedId.Keyboard_P, CorsairLedId.P }, + { LedId.Keyboard_BracketLeft, CorsairLedId.BracketLeft }, + { LedId.Keyboard_CapsLock, CorsairLedId.CapsLock }, + { LedId.Keyboard_A, CorsairLedId.A }, + { LedId.Keyboard_S, CorsairLedId.S }, + { LedId.Keyboard_D, CorsairLedId.D }, + { LedId.Keyboard_F, CorsairLedId.F }, + { LedId.Keyboard_G, CorsairLedId.G }, + { LedId.Keyboard_H, CorsairLedId.H }, + { LedId.Keyboard_J, CorsairLedId.J }, + { LedId.Keyboard_K, CorsairLedId.K }, + { LedId.Keyboard_L, CorsairLedId.L }, + { LedId.Keyboard_SemicolonAndColon, CorsairLedId.SemicolonAndColon }, + { LedId.Keyboard_ApostropheAndDoubleQuote, CorsairLedId.ApostropheAndDoubleQuote }, + { LedId.Keyboard_LeftShift, CorsairLedId.LeftShift }, + { LedId.Keyboard_NonUsBackslash, CorsairLedId.NonUsBackslash }, + { LedId.Keyboard_Z, CorsairLedId.Z }, + { LedId.Keyboard_X, CorsairLedId.X }, + { LedId.Keyboard_C, CorsairLedId.C }, + { LedId.Keyboard_V, CorsairLedId.V }, + { LedId.Keyboard_B, CorsairLedId.B }, + { LedId.Keyboard_N, CorsairLedId.N }, + { LedId.Keyboard_M, CorsairLedId.M }, + { LedId.Keyboard_CommaAndLessThan, CorsairLedId.CommaAndLessThan }, + { LedId.Keyboard_PeriodAndBiggerThan, CorsairLedId.PeriodAndBiggerThan }, + { LedId.Keyboard_SlashAndQuestionMark, CorsairLedId.SlashAndQuestionMark }, + { LedId.Keyboard_LeftCtrl, CorsairLedId.LeftCtrl }, + { LedId.Keyboard_LeftGui, CorsairLedId.LeftGui }, + { LedId.Keyboard_LeftAlt, CorsairLedId.LeftAlt }, + { LedId.Keyboard_Lang2, CorsairLedId.Lang2 }, + { LedId.Keyboard_Space, CorsairLedId.Space }, + { LedId.Keyboard_Lang1, CorsairLedId.Lang1 }, + { LedId.Keyboard_International2, CorsairLedId.International2 }, + { LedId.Keyboard_RightAlt, CorsairLedId.RightAlt }, + { LedId.Keyboard_RightGui, CorsairLedId.RightGui }, + { LedId.Keyboard_Application, CorsairLedId.Application }, + { LedId.Keyboard_Brightness, CorsairLedId.Brightness }, + { LedId.Keyboard_F12, CorsairLedId.F12 }, + { LedId.Keyboard_PrintScreen, CorsairLedId.PrintScreen }, + { LedId.Keyboard_ScrollLock, CorsairLedId.ScrollLock }, + { LedId.Keyboard_PauseBreak, CorsairLedId.PauseBreak }, + { LedId.Keyboard_Insert, CorsairLedId.Insert }, + { LedId.Keyboard_Home, CorsairLedId.Home }, + { LedId.Keyboard_PageUp, CorsairLedId.PageUp }, + { LedId.Keyboard_BracketRight, CorsairLedId.BracketRight }, + { LedId.Keyboard_Backslash, CorsairLedId.Backslash }, + { LedId.Keyboard_NonUsTilde, CorsairLedId.NonUsTilde }, + { LedId.Keyboard_Enter, CorsairLedId.Enter }, + { LedId.Keyboard_International1, CorsairLedId.International1 }, + { LedId.Keyboard_EqualsAndPlus, CorsairLedId.EqualsAndPlus }, + { LedId.Keyboard_International3, CorsairLedId.International3 }, + { LedId.Keyboard_Backspace, CorsairLedId.Backspace }, + { LedId.Keyboard_Delete, CorsairLedId.Delete }, + { LedId.Keyboard_End, CorsairLedId.End }, + { LedId.Keyboard_PageDown, CorsairLedId.PageDown }, + { LedId.Keyboard_RightShift, CorsairLedId.RightShift }, + { LedId.Keyboard_RightCtrl, CorsairLedId.RightCtrl }, + { LedId.Keyboard_ArrowUp, CorsairLedId.UpArrow }, + { LedId.Keyboard_ArrowLeft, CorsairLedId.LeftArrow }, + { LedId.Keyboard_ArrowDown, CorsairLedId.DownArrow }, + { LedId.Keyboard_ArrowRight, CorsairLedId.RightArrow }, + { LedId.Keyboard_WinLock, CorsairLedId.WinLock }, + { LedId.Keyboard_MediaMute, CorsairLedId.Mute }, + { LedId.Keyboard_MediaStop, CorsairLedId.Stop }, + { LedId.Keyboard_MediaPreviousTrack, CorsairLedId.ScanPreviousTrack }, + { LedId.Keyboard_MediaPlay, CorsairLedId.PlayPause }, + { LedId.Keyboard_MediaNextTrack, CorsairLedId.ScanNextTrack }, + { LedId.Keyboard_NumLock, CorsairLedId.NumLock }, + { LedId.Keyboard_NumSlash, CorsairLedId.KeypadSlash }, + { LedId.Keyboard_NumAsterisk, CorsairLedId.KeypadAsterisk }, + { LedId.Keyboard_NumMinus, CorsairLedId.KeypadMinus }, + { LedId.Keyboard_NumPlus, CorsairLedId.KeypadPlus }, + { LedId.Keyboard_NumEnter, CorsairLedId.KeypadEnter }, + { LedId.Keyboard_Num7, CorsairLedId.Keypad7 }, + { LedId.Keyboard_Num8, CorsairLedId.Keypad8 }, + { LedId.Keyboard_Num9, CorsairLedId.Keypad9 }, + { LedId.Keyboard_NumComma, CorsairLedId.KeypadComma }, + { LedId.Keyboard_Num4, CorsairLedId.Keypad4 }, + { LedId.Keyboard_Num5, CorsairLedId.Keypad5 }, + { LedId.Keyboard_Num6, CorsairLedId.Keypad6 }, + { LedId.Keyboard_Num1, CorsairLedId.Keypad1 }, + { LedId.Keyboard_Num2, CorsairLedId.Keypad2 }, + { LedId.Keyboard_Num3, CorsairLedId.Keypad3 }, + { LedId.Keyboard_Num0, CorsairLedId.Keypad0 }, + { LedId.Keyboard_NumPeriodAndDelete, CorsairLedId.KeypadPeriodAndDelete }, + { LedId.Keyboard_Programmable1, CorsairLedId.G1 }, + { LedId.Keyboard_Programmable2, CorsairLedId.G2 }, + { LedId.Keyboard_Programmable3, CorsairLedId.G3 }, + { LedId.Keyboard_Programmable4, CorsairLedId.G4 }, + { LedId.Keyboard_Programmable5, CorsairLedId.G5 }, + { LedId.Keyboard_Programmable6, CorsairLedId.G6 }, + { LedId.Keyboard_Programmable7, CorsairLedId.G7 }, + { LedId.Keyboard_Programmable8, CorsairLedId.G8 }, + { LedId.Keyboard_Programmable9, CorsairLedId.G9 }, + { LedId.Keyboard_Programmable10, CorsairLedId.G10 }, + { LedId.Keyboard_MediaVolumeUp, CorsairLedId.VolumeUp }, + { LedId.Keyboard_MediaVolumeDown, CorsairLedId.VolumeDown }, + { LedId.Keyboard_MacroRecording, CorsairLedId.MR }, + { LedId.Keyboard_Macro1, CorsairLedId.M1 }, + { LedId.Keyboard_Macro2, CorsairLedId.M2 }, + { LedId.Keyboard_Macro3, CorsairLedId.M3 }, + { LedId.Keyboard_Programmable11, CorsairLedId.G11 }, + { LedId.Keyboard_Programmable12, CorsairLedId.G12 }, + { LedId.Keyboard_Programmable13, CorsairLedId.G13 }, + { LedId.Keyboard_Programmable14, CorsairLedId.G14 }, + { LedId.Keyboard_Programmable15, CorsairLedId.G15 }, + { LedId.Keyboard_Programmable16, CorsairLedId.G16 }, + { LedId.Keyboard_Programmable17, CorsairLedId.G17 }, + { LedId.Keyboard_Programmable18, CorsairLedId.G18 }, + { LedId.Keyboard_International5, CorsairLedId.International5 }, + { LedId.Keyboard_International4, CorsairLedId.International4 }, + }; + } +} diff --git a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K70RGB/UK.xml b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K70RGB/UK.xml index 4186dac..eac3582 100644 --- a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K70RGB/UK.xml +++ b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K70RGB/UK.xml @@ -1,4 +1,4 @@ - + Corsair K70 RGB - Physical UK Physical UK-Layout of Corsairs K70 RGB (Logical: BE, CH, DE, ES, EU, FR, IT, ND, MEX, RU, UK, US_Int) @@ -10,483 +10,483 @@ 165 - + Circle 298 6 10mm 10mm - + Circle +9 10mm 10mm - + 375 6 12mm - + 4 28 - + +12.667 - - - + + + - + +12.667 - - - + + + - + +12.667 - - - + + + - + +5 - - + + - + +5 12mm - + 12mm - + 12mm - + 12mm - + 4 49 - - - - - - - - - - - - - + + + + + + + + + + + + + 2 - + +5 - - + + - + +5 - - - + + + - + 4 + 1.5 - - - - - - - - - - - - - + + + + + + + + + + + + + M0,0 L0,0.5 L0.16666666666,0.5 L0.16666666666,1 L1,1 L1,0 Z 1.5 2 - + +5 - - + + - + +5 - - - + + + 2 - + 4 ~ 1.75 - - - - - - - - - - - - + + + + + + + + + + + + - + +90.75 - - + + - + 4 + 1.25 - - - - - - - - - - - - + + + + + + + + + + + + 2.75 - + +24 - + +24 - - - + + + 2 - + 4 ~ 1.5 - - + + 1.25 - + 6.5 - + 1.25 - - - + + + 1.5 - + +5 - - + + - + +5 2 - + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGB/UK.xml b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGB/UK.xml index a0c2d8d..a6e4aae 100644 --- a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGB/UK.xml +++ b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGB/UK.xml @@ -10,349 +10,349 @@ 165 - + Circle 72 6 12mm 12mm - + Circle 91.5 7 10mm 10mm - + Circle +9 10mm 10mm - + Circle +9 10mm 10mm - + Circle 362 10mm 10mm - + Circle +9 10mm 10mm - + 439 6 12mm - + 68 28 - + +12.667 - - - + + + - + +12.667 - - - + + + - + +12.667 - - - + + + - + +5 - - + + - + +5 12mm - + 12mm - + 12mm - + 12mm - + 68 49 - - - - - - - - - - - - - + + + + + + + + + + + + + 2 - + +5 - - + + - + +5 - - - + + + - + 68 + 1.5 - - - - - - - - - - - - - + + + + + + + + + + + + + M0,0 L0,0.5 L0.16666666666,0.5 L0.16666666666,1 L1,1 L1,0 Z 1.5 2 - + +5 - - + + - + +5 - - - + + + 2 - + 68 ~ 1.75 - - - - - - - - - - - - + + + + + + + + + + + + - + +90.75 - - + + - + 68 + 1.25 - - - - - - - - - - - - + + + + + + + + + + + + 2.75 - + +24 - + +24 - - - + + + 2 - + 68 ~ 1.5 - - + + 1.25 - + 6.5 - + 1.25 - - - + + + 1.5 - + +5 - - + + - + +5 2 - + - + 7 28 18mm 18mm - + 18mm 18mm - + 18mm 18mm - + 7 + 18mm 18mm - + 18mm 18mm - + 18mm 18mm - + 7 +4 18mm 18mm - + 18mm 18mm - + 18mm 18mm - + 7 + 18mm 18mm - + 18mm 18mm - + 18mm 18mm - + 7 +4 18mm 18mm - + 18mm 18mm - + 18mm 18mm - + 7 + 18mm 18mm - + 18mm 18mm - + 18mm 18mm @@ -361,292 +361,292 @@ - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGBPLATINUM/UK.xml b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGBPLATINUM/UK.xml index 78b0cfc..20d9d0d 100644 --- a/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGBPLATINUM/UK.xml +++ b/RGB.NET.Devices.Corsair/Layouts/Corsair/Keyboards/K95RGBPLATINUM/UK.xml @@ -10,255 +10,255 @@ 169 - + 91.5 8.333 14.5mm 12mm - + 14.5mm 12mm - + 382 8.333 12mm - + 30 32 - + +12.667 - - - + + + - + +12.667 - - - + + + - + +12.667 - - - + + + - + +5 - - + + - + +5 31 17mm - + 17mm - + 17mm - + 17mm - + 30 53 - - - - - - - - - - - - - + + + + + + + + + + + + + 2 - + +5 - - + + - + +5 - - - + + + - + 30 + 1.5 - - - - - - - - - - - - - + + + + + + + + + + + + + M0,0 L0,0.5 L0.16666666666,0.5 L0.16666666666,1 L1,1 L1,0 Z 1.5 2 - + +5 - - + + - + +5 - - - + + + 2 - + 30 ~ 1.75 - - - - - - - - - - - - + + + + + + + + + + + + - + +90.75 - - + + - + 30 + 1.25 - - - - - - - - - - - - + + + + + + + + + + + + 2.75 - + +24 - + +24 - - - + + + 2 - + 30 ~ 1.5 - - + + 1.25 - + 6.5 - + 1.25 - - - + + + 1.5 - + +5 - - + + - + +5 2 - + - + 7 32 - + 7 + - + 7 +1 - + 7 + - + 7 +1 @@ -351,131 +351,131 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - + + + + + + @@ -500,131 +500,131 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - + + + + + + diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index a56af7d..94ccbfd 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -1,6 +1,7 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global +using System; using RGB.NET.Core; using RGB.NET.Core.Exceptions; @@ -33,31 +34,40 @@ namespace RGB.NET.Devices.Corsair switch (DeviceInfo.PhysicalLayout) { case CorsairPhysicalMouseLayout.Zones1: - InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones2: - 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(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones3: - 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(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); + InitializeLed(LedId.Mouse3, new Rectangle(20, 0, 10, 10)); break; case CorsairPhysicalMouseLayout.Zones4: - 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)); + InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); + InitializeLed(LedId.Mouse3, new Rectangle(20, 0, 10, 10)); + InitializeLed(LedId.Mouse4, new Rectangle(30, 0, 10, 10)); break; default: - throw new RGBDeviceException($"Can't initial mouse with layout '{DeviceInfo.PhysicalLayout}'"); + throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'"); } ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mice")); } + /// + protected override object CreateLedCustomData(LedId ledId) + { + if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase)) + return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + else + return MouseIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + } + #endregion } } diff --git a/RGB.NET.Devices.Corsair/Mouse/MouseIdMapping.cs b/RGB.NET.Devices.Corsair/Mouse/MouseIdMapping.cs new file mode 100644 index 0000000..f01ac58 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Mouse/MouseIdMapping.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class MouseIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Mouse1, CorsairLedId.B1 }, + { LedId.Mouse2, CorsairLedId.B2 }, + { LedId.Mouse3, CorsairLedId.B3 }, + { LedId.Mouse4, CorsairLedId.B4 }, + { LedId.Mouse5, CorsairLedId.B5 }, + { LedId.Mouse6, CorsairLedId.B6 }, + }; + + internal static readonly Dictionary GLAIVE = new Dictionary + { + { LedId.Mouse1, CorsairLedId.B1 }, + { LedId.Mouse2, CorsairLedId.B2 }, + { LedId.Mouse3, CorsairLedId.B5 }, + }; + } +} diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index 8e02dd2..3c5b0c8 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -47,14 +47,17 @@ namespace RGB.NET.Devices.Corsair positions.Add(ledPosition); } - foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) - InitializeLed(new CorsairLedId(this, ledPosition.ledId), - new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); + Dictionary mapping = MousepadIdMapping.DEFAULT.SwapKeyValue(); + foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) + InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mousepads")); } + /// + protected override object CreateLedCustomData(LedId ledId) => MousepadIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + #endregion } } diff --git a/RGB.NET.Devices.Corsair/Mousepad/MousepadIdMapping.cs b/RGB.NET.Devices.Corsair/Mousepad/MousepadIdMapping.cs new file mode 100644 index 0000000..3b49ad6 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Mousepad/MousepadIdMapping.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class MousepadIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Mousepad1, CorsairLedId.Zone1 }, + { LedId.Mousepad2, CorsairLedId.Zone2 }, + { LedId.Mousepad3, CorsairLedId.Zone3 }, + { LedId.Mousepad4, CorsairLedId.Zone4 }, + { LedId.Mousepad5, CorsairLedId.Zone5 }, + { LedId.Mousepad6, CorsairLedId.Zone6 }, + { LedId.Mousepad7, CorsairLedId.Zone7 }, + { LedId.Mousepad8, CorsairLedId.Zone8 }, + { LedId.Mousepad9, CorsairLedId.Zone9 }, + { LedId.Mousepad10, CorsairLedId.Zone10 }, + { LedId.Mousepad11, CorsairLedId.Zone11 }, + { LedId.Mousepad12, CorsairLedId.Zone12 }, + { LedId.Mousepad13, CorsairLedId.Zone13 }, + { LedId.Mousepad14, CorsairLedId.Zone14 }, + { LedId.Mousepad15, CorsairLedId.Zone15 } + }; + } +} diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index 84c8d81..0f1e63e 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -114,7 +114,7 @@ namespace RGB.NET.Devices.Corsair.Native private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate CorsairLedIds CorsairGetLedIdForKeyNamePointer(char keyName); + private delegate CorsairLedId CorsairGetLedIdForKeyNamePointer(char keyName); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool CorsairRequestControlPointer(CorsairAccessMode accessMode); @@ -165,7 +165,7 @@ namespace RGB.NET.Devices.Corsair.Native /// /// CUE-SDK: retrieves led id for key name taking logical layout into account. /// - internal static CorsairLedIds CorsairGetLedIdForKeyName(char keyName) => _corsairGetLedIdForKeyNamePointer(keyName); + internal static CorsairLedId CorsairGetLedIdForKeyName(char keyName) => _corsairGetLedIdForKeyNamePointer(keyName); /// /// CUE-SDK: requestes control using specified access mode. diff --git a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs index 99d2acd..4ea4356 100644 --- a/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs +++ b/RGB.NET.Devices.Corsair/Native/_CorsairLedPosition.cs @@ -17,7 +17,7 @@ namespace RGB.NET.Devices.Corsair.Native /// /// CUE-SDK: identifier of led /// - internal CorsairLedIds ledId; + internal CorsairLedId LedId; /// /// CUE-SDK: values in mm diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index c44f097..31af08d 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -50,26 +50,31 @@ - + - + + + + + + diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings index 12c37b7..9d6bbd4 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings @@ -1,5 +1,6 @@  True + True True True False diff --git a/RGB.NET.Devices.Corsair/SpecialParts/LightbarSpecialPart.cs b/RGB.NET.Devices.Corsair/SpecialParts/LightbarSpecialPart.cs index cdc02e4..3c1b56b 100644 --- a/RGB.NET.Devices.Corsair/SpecialParts/LightbarSpecialPart.cs +++ b/RGB.NET.Devices.Corsair/SpecialParts/LightbarSpecialPart.cs @@ -50,10 +50,10 @@ namespace RGB.NET.Devices.Corsair.SpecialParts /// The device associated with this . public LightbarSpecialPart(IRGBDevice device) { - _leds = device.Where(led => (((CorsairLedId)led.Id).LedId >= CorsairLedIds.Lightbar1) && (((CorsairLedId)led.Id).LedId <= CorsairLedIds.Lightbar19)).ToList(); - _left = _leds.Where(led => ((CorsairLedId)led.Id).LedId < CorsairLedIds.Lightbar10).ToList(); - _right = _leds.Where(led => ((CorsairLedId)led.Id).LedId > CorsairLedIds.Lightbar10).ToList(); - Center = _leds.FirstOrDefault(led => ((CorsairLedId)led.Id).LedId == CorsairLedIds.Lightbar10); + _leds = device.Where(led => ((CorsairLedId)led.CustomData >= CorsairLedId.Lightbar1) && ((CorsairLedId)led.CustomData <= CorsairLedId.Lightbar19)).ToList(); + _left = _leds.Where(led => (CorsairLedId)led.CustomData < CorsairLedId.Lightbar10).ToList(); + _right = _leds.Where(led => (CorsairLedId)led.CustomData > CorsairLedId.Lightbar10).ToList(); + Center = _leds.FirstOrDefault(led => (CorsairLedId)led.CustomData == CorsairLedId.Lightbar10); } #endregion diff --git a/RGB.NET.Devices.Logitech/Enum/LogitechLedIds.cs b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs similarity index 99% rename from RGB.NET.Devices.Logitech/Enum/LogitechLedIds.cs rename to RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs index b3f871b..60d7103 100644 --- a/RGB.NET.Devices.Logitech/Enum/LogitechLedIds.cs +++ b/RGB.NET.Devices.Logitech/Enum/LogitechLedId.cs @@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Logitech /// /// Contains list of all LEDs available for all logitech devices. /// - public enum LogitechLedIds + public enum LogitechLedId { Invalid = 0, ESC = 0x01, diff --git a/RGB.NET.Devices.Logitech/Generic/LogitechLedId.cs b/RGB.NET.Devices.Logitech/Generic/LogitechLedId.cs deleted file mode 100644 index 2144baf..0000000 --- a/RGB.NET.Devices.Logitech/Generic/LogitechLedId.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Logitech -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class LogitechLedId : ILedId - { - #region Properties & Fields - - internal readonly LogitechLedIds LedId; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != LogitechLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public LogitechLedId(IRGBDevice device, LogitechLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() - { - return LedId.ToString(); - } - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - LogitechLedId compareLedId = obj as LogitechLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - return LedId.GetHashCode(); - } - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(LogitechLedId ledId1, LogitechLedId ledId2) - { - return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - } - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(LogitechLedId ledId1, LogitechLedId ledId2) - { - return !(ledId1 == ledId2); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs index 56a0948..bb664ae 100644 --- a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs @@ -1,8 +1,5 @@ -using System; -using System.IO; -using System.Linq; +using System.Linq; using RGB.NET.Core; -using RGB.NET.Core.Layout; namespace RGB.NET.Devices.Logitech { @@ -62,46 +59,7 @@ namespace RGB.NET.Devices.Logitech string basePath = info.ImageBasePath; string layout = info.ImageLayout; string layoutPath = info.LayoutPath; - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, PathHelper.GetAbsolutePath($@"Images\Logitech\{basePath}")); - } - - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out LogitechLedIds ledId)) - { - LogitechLedId id = new LogitechLedId(this, ledId); - if (!LedMapping.TryGetValue(id, out Led led)) - led = InitializeLed(id, new Rectangle()); - - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, PathHelper.GetAbsolutePath($@"Images\Logitech\{basePath}"), true); } #endregion diff --git a/RGB.NET.Devices.Logitech/Helper/BitmapMapping.cs b/RGB.NET.Devices.Logitech/Helper/BitmapMapping.cs deleted file mode 100644 index dba979c..0000000 --- a/RGB.NET.Devices.Logitech/Helper/BitmapMapping.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Logitech -{ - internal static class BitmapMapping - { - #region Constants - - private const int BITMAP_SIZE = 21 * 6 * 4; - - #endregion - - #region Properties & Fields - - internal static Dictionary BitmapOffset { get; } = new Dictionary - { - { LogitechLedIds.ESC, 0 }, - { LogitechLedIds.F1, 4 }, - { LogitechLedIds.F2, 8 }, - { LogitechLedIds.F3, 12 }, - { LogitechLedIds.F4, 16 }, - { LogitechLedIds.F5, 20 }, - { LogitechLedIds.F6, 24 }, - { LogitechLedIds.F7, 28 }, - { LogitechLedIds.F8, 32 }, - { LogitechLedIds.F9, 36 }, - { LogitechLedIds.F10, 40 }, - { LogitechLedIds.F11, 44 }, - { LogitechLedIds.F12, 48 }, - { LogitechLedIds.PRINT_SCREEN, 52 }, - { LogitechLedIds.SCROLL_LOCK, 56 }, - { LogitechLedIds.PAUSE_BREAK, 60 }, - // { LogitechLedIds.?, 64 }, - // { LogitechLedIds.?, 68 }, - // { LogitechLedIds.?, 72 }, - // { LogitechLedIds.?, 76 }, - // { LogitechLedIds.?, 80 }, - - { LogitechLedIds.TILDE, 84 }, - { LogitechLedIds.ONE, 88 }, - { LogitechLedIds.TWO, 92 }, - { LogitechLedIds.THREE, 96 }, - { LogitechLedIds.FOUR, 100 }, - { LogitechLedIds.FIVE, 104 }, - { LogitechLedIds.SIX, 108 }, - { LogitechLedIds.SEVEN, 112 }, - { LogitechLedIds.EIGHT, 116 }, - { LogitechLedIds.NINE, 120 }, - { LogitechLedIds.ZERO, 124 }, - { LogitechLedIds.MINUS, 128 }, - { LogitechLedIds.EQUALS, 132 }, - { LogitechLedIds.BACKSPACE, 136 }, - { LogitechLedIds.INSERT, 140 }, - { LogitechLedIds.HOME, 144 }, - { LogitechLedIds.PAGE_UP, 148 }, - { LogitechLedIds.NUM_LOCK, 152 }, - { LogitechLedIds.NUM_SLASH, 156 }, - { LogitechLedIds.NUM_ASTERISK, 160 }, - { LogitechLedIds.NUM_MINUS, 164 }, - - { LogitechLedIds.TAB, 168 }, - { LogitechLedIds.Q, 172 }, - { LogitechLedIds.W, 176 }, - { LogitechLedIds.E, 180 }, - { LogitechLedIds.R, 184 }, - { LogitechLedIds.T, 188 }, - { LogitechLedIds.Y, 192 }, - { LogitechLedIds.U, 196 }, - { LogitechLedIds.I, 200 }, - { LogitechLedIds.O, 204 }, - { LogitechLedIds.P, 208 }, - { LogitechLedIds.OPEN_BRACKET, 212 }, - { LogitechLedIds.CLOSE_BRACKET, 216 }, - // { LogitechLedIds.?, 220 }, - { LogitechLedIds.KEYBOARD_DELETE, 224 }, - { LogitechLedIds.END, 228 }, - { LogitechLedIds.PAGE_DOWN, 232 }, - { LogitechLedIds.NUM_SEVEN, 236 }, - { LogitechLedIds.NUM_EIGHT, 240 }, - { LogitechLedIds.NUM_NINE, 244 }, - { LogitechLedIds.NUM_PLUS, 248 }, - - { LogitechLedIds.CAPS_LOCK, 252 }, - { LogitechLedIds.A, 256 }, - { LogitechLedIds.S, 260 }, - { LogitechLedIds.D, 264 }, - { LogitechLedIds.F, 268 }, - { LogitechLedIds.G, 272 }, - { LogitechLedIds.H, 276 }, - { LogitechLedIds.J, 280 }, - { LogitechLedIds.K, 284 }, - { LogitechLedIds.L, 288 }, - { LogitechLedIds.SEMICOLON, 292 }, - { LogitechLedIds.APOSTROPHE, 296 }, - { LogitechLedIds.NonUsTilde, 300 }, //TODO DarthAffe 26.03.2017: Find the real ID/Name of this key - it's not documented ... - { LogitechLedIds.ENTER, 304 }, - // { LogitechLedIds.?, 308 }, - // { LogitechLedIds.?, 312 }, - // { LogitechLedIds.?, 316 }, - { LogitechLedIds.NUM_FOUR, 320 }, - { LogitechLedIds.NUM_FIVE, 324 }, - { LogitechLedIds.NUM_SIX, 328 }, - // { LogitechLedIds.?, 332 }, - - { LogitechLedIds.LEFT_SHIFT, 336 }, - { LogitechLedIds.BACKSLASH, 340 }, - { LogitechLedIds.Z, 344 }, - { LogitechLedIds.X, 348 }, - { LogitechLedIds.C, 352 }, - { LogitechLedIds.V, 356 }, - { LogitechLedIds.B, 360 }, - { LogitechLedIds.N, 364 }, - { LogitechLedIds.M, 368 }, - { LogitechLedIds.COMMA, 372 }, - { LogitechLedIds.PERIOD, 376 }, - { LogitechLedIds.FORWARD_SLASH, 380 }, - { LogitechLedIds.RIGHT_SHIFT, 388 }, - // { LogitechLedIds.?, 392 }, - { LogitechLedIds.ARROW_UP, 396 }, - // { LogitechLedIds.?, 400 }, - { LogitechLedIds.NUM_ONE, 404 }, - { LogitechLedIds.NUM_TWO, 408 }, - { LogitechLedIds.NUM_THREE, 412 }, - { LogitechLedIds.NUM_ENTER, 416 }, - - { LogitechLedIds.LEFT_CONTROL, 420 }, - { LogitechLedIds.LEFT_WINDOWS, 424 }, - { LogitechLedIds.LEFT_ALT, 428 }, - // { LogitechLedIds.?, 432 }, - // { LogitechLedIds.?, 436 }, - { LogitechLedIds.SPACE, 440 }, - // { LogitechLedIds.?, 444 }, - // { LogitechLedIds.?, 448 }, - // { LogitechLedIds.?, 452 }, - // { LogitechLedIds.?, 456 }, - // { LogitechLedIds.?, 460 }, - { LogitechLedIds.RIGHT_ALT, 464 }, - { LogitechLedIds.RIGHT_WINDOWS, 468 }, - { LogitechLedIds.APPLICATION_SELECT, 472 }, - { LogitechLedIds.RIGHT_CONTROL, 476 }, - { LogitechLedIds.ARROW_LEFT, 480 }, - { LogitechLedIds.ARROW_DOWN, 484 }, - { LogitechLedIds.ARROW_RIGHT, 488 }, - { LogitechLedIds.NUM_ZERO, 492 }, - { LogitechLedIds.NUM_PERIOD, 496 }, - // { LogitechLedIds.?, 500 }, - }; - - #endregion - - #region Methods - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE]; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void SetColor(ref byte[] bitmap, int offset, Color color) - { - bitmap[offset] = color.B; - bitmap[offset + 1] = color.G; - bitmap[offset + 2] = color.R; - bitmap[offset + 3] = color.A; - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs index 7dea9df..71a1e5f 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs @@ -33,9 +33,12 @@ namespace RGB.NET.Devices.Logitech base.InitializeLayout(); if (LedMapping.Count == 0) - InitializeLed(new LogitechLedId(this, LogitechLedIds.DEVICE), new Rectangle(0, 0, 10, 10)); + InitializeLed(LedId.Custom1, new Rectangle(0, 0, 10, 10)); } + /// + protected override object CreateLedCustomData(LedId ledId) => LogitechLedId.DEVICE; + /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { diff --git a/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs b/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs new file mode 100644 index 0000000..73d882b --- /dev/null +++ b/RGB.NET.Devices.Logitech/PerKey/BitmapMapping.cs @@ -0,0 +1,169 @@ +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Logitech +{ + internal static class BitmapMapping + { + #region Constants + + private const int BITMAP_SIZE = 21 * 6 * 4; + + #endregion + + #region Properties & Fields + + internal static Dictionary BitmapOffset { get; } = new Dictionary + { + { LedId.Keyboard_Escape, 0 }, + { LedId.Keyboard_F1, 4 }, + { LedId.Keyboard_F2, 8 }, + { LedId.Keyboard_F3, 12 }, + { LedId.Keyboard_F4, 16 }, + { LedId.Keyboard_F5, 20 }, + { LedId.Keyboard_F6, 24 }, + { LedId.Keyboard_F7, 28 }, + { LedId.Keyboard_F8, 32 }, + { LedId.Keyboard_F9, 36 }, + { LedId.Keyboard_F10, 40 }, + { LedId.Keyboard_F11, 44 }, + { LedId.Keyboard_F12, 48 }, + { LedId.Keyboard_PrintScreen, 52 }, + { LedId.Keyboard_ScrollLock, 56 }, + { LedId.Keyboard_PauseBreak, 60 }, + // { LedId.Keyboard_?, 64 }, + // { LedId.Keyboard_?, 68 }, + // { LedId.Keyboard_?, 72 }, + // { LedId.Keyboard_?, 76 }, + // { LedId.Keyboard_?, 80 }, + + { LedId.Keyboard_GraveAccentAndTilde, 84 }, + { LedId.Keyboard_1, 88 }, + { LedId.Keyboard_2, 92 }, + { LedId.Keyboard_3, 96 }, + { LedId.Keyboard_4, 100 }, + { LedId.Keyboard_5, 104 }, + { LedId.Keyboard_6, 108 }, + { LedId.Keyboard_7, 112 }, + { LedId.Keyboard_8, 116 }, + { LedId.Keyboard_9, 120 }, + { LedId.Keyboard_0, 124 }, + { LedId.Keyboard_MinusAndUnderscore, 128 }, + { LedId.Keyboard_EqualsAndPlus, 132 }, + { LedId.Keyboard_Backspace, 136 }, + { LedId.Keyboard_Insert, 140 }, + { LedId.Keyboard_Home, 144 }, + { LedId.Keyboard_PageUp, 148 }, + { LedId.Keyboard_NumLock, 152 }, + { LedId.Keyboard_NumSlash, 156 }, + { LedId.Keyboard_NumAsterisk, 160 }, + { LedId.Keyboard_NumMinus, 164 }, + + { LedId.Keyboard_Tab, 168 }, + { LedId.Keyboard_Q, 172 }, + { LedId.Keyboard_W, 176 }, + { LedId.Keyboard_E, 180 }, + { LedId.Keyboard_R, 184 }, + { LedId.Keyboard_T, 188 }, + { LedId.Keyboard_Y, 192 }, + { LedId.Keyboard_U, 196 }, + { LedId.Keyboard_I, 200 }, + { LedId.Keyboard_O, 204 }, + { LedId.Keyboard_P, 208 }, + { LedId.Keyboard_BracketLeft, 212 }, + { LedId.Keyboard_BracketRight, 216 }, + // { LedId.Keyboard_?, 220 }, + { LedId.Keyboard_Delete, 224 }, + { LedId.Keyboard_End, 228 }, + { LedId.Keyboard_PageDown, 232 }, + { LedId.Keyboard_Num7, 236 }, + { LedId.Keyboard_Num8, 240 }, + { LedId.Keyboard_Num9, 244 }, + { LedId.Keyboard_NumPlus, 248 }, + + { LedId.Keyboard_CapsLock, 252 }, + { LedId.Keyboard_A, 256 }, + { LedId.Keyboard_S, 260 }, + { LedId.Keyboard_D, 264 }, + { LedId.Keyboard_F, 268 }, + { LedId.Keyboard_G, 272 }, + { LedId.Keyboard_H, 276 }, + { LedId.Keyboard_J, 280 }, + { LedId.Keyboard_K, 284 }, + { LedId.Keyboard_L, 288 }, + { LedId.Keyboard_SemicolonAndColon, 292 }, + { LedId.Keyboard_ApostropheAndDoubleQuote, 296 }, + { LedId.Keyboard_NonUsTilde, 300 }, //TODO DarthAffe 26.03.2017: Find the real ID/Name of this key - it's not documented ... + { LedId.Keyboard_Enter, 304 }, + // { LedId.Keyboard_?, 308 }, + // { LedId.Keyboard_?, 312 }, + // { LedId.Keyboard_?, 316 }, + { LedId.Keyboard_Num4, 320 }, + { LedId.Keyboard_Num5, 324 }, + { LedId.Keyboard_Num6, 328 }, + // { LedId.Keyboard_?, 332 }, + + { LedId.Keyboard_LeftShift, 336 }, + { LedId.Keyboard_Backslash, 340 }, + { LedId.Keyboard_Z, 344 }, + { LedId.Keyboard_X, 348 }, + { LedId.Keyboard_C, 352 }, + { LedId.Keyboard_V, 356 }, + { LedId.Keyboard_B, 360 }, + { LedId.Keyboard_N, 364 }, + { LedId.Keyboard_M, 368 }, + { LedId.Keyboard_CommaAndLessThan, 372 }, + { LedId.Keyboard_PeriodAndBiggerThan, 376 }, + { LedId.Keyboard_SlashAndQuestionMark, 380 }, + { LedId.Keyboard_RightShift, 388 }, + // { LedId.Keyboard_?, 392 }, + { LedId.Keyboard_ArrowUp, 396 }, + // { LedId.Keyboard_?, 400 }, + { LedId.Keyboard_Num1, 404 }, + { LedId.Keyboard_Num2, 408 }, + { LedId.Keyboard_Num3, 412 }, + { LedId.Keyboard_NumEnter, 416 }, + + { LedId.Keyboard_LeftCtrl, 420 }, + { LedId.Keyboard_LeftGui, 424 }, + { LedId.Keyboard_LeftAlt, 428 }, + // { LedId.Keyboard_?, 432 }, + // { LedId.Keyboard_?, 436 }, + { LedId.Keyboard_Space, 440 }, + // { LedId.Keyboard_?, 444 }, + // { LedId.Keyboard_?, 448 }, + // { LedId.Keyboard_?, 452 }, + // { LedId.Keyboard_?, 456 }, + // { LedId.Keyboard_?, 460 }, + { LedId.Keyboard_RightAlt, 464 }, + { LedId.Keyboard_RightGui, 468 }, + { LedId.Keyboard_Application, 472 }, + { LedId.Keyboard_RightCtrl, 476 }, + { LedId.Keyboard_ArrowLeft, 480 }, + { LedId.Keyboard_ArrowDown, 484 }, + { LedId.Keyboard_ArrowRight, 488 }, + { LedId.Keyboard_Num0, 492 }, + { LedId.Keyboard_NumPeriodAndDelete, 496 }, + // { LedId.Keyboard_?, 500 }, + }; + + #endregion + + #region Methods + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE]; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void SetColor(ref byte[] bitmap, int offset, Color color) + { + bitmap[offset] = color.B; + bitmap[offset + 1] = color.G; + bitmap[offset + 2] = color.R; + bitmap[offset + 3] = color.A; + } + + #endregion + } +} diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs index 256c6ed..56b440e 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs @@ -27,6 +27,9 @@ namespace RGB.NET.Devices.Logitech #region Methods + /// + protected override object CreateLedCustomData(LedId ledId) => PerKeyIdMapping.DEFAULT[ledId]; + /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { @@ -39,7 +42,7 @@ namespace RGB.NET.Devices.Logitech foreach (Led led in leds) { // DarthAffe 26.03.2017: This is only needed since update by name doesn't work as expected for all keys ... - if (BitmapMapping.BitmapOffset.TryGetValue(((LogitechLedId)led.Id).LedId, out int bitmapOffset)) + if (BitmapMapping.BitmapOffset.TryGetValue(led.Id, out int bitmapOffset)) { if (bitmap == null) bitmap = BitmapMapping.CreateBitmap(); @@ -47,7 +50,7 @@ namespace RGB.NET.Devices.Logitech BitmapMapping.SetColor(ref bitmap, bitmapOffset, led.Color); } else - _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)((LogitechLedId)led.Id).LedId, + _LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)led.CustomData, (int)Math.Round(led.Color.RPercent * 100), (int)Math.Round(led.Color.GPercent * 100), (int)Math.Round(led.Color.BPercent * 100)); diff --git a/RGB.NET.Devices.Logitech/PerKey/PerKeyIdMapping.cs b/RGB.NET.Devices.Logitech/PerKey/PerKeyIdMapping.cs new file mode 100644 index 0000000..f891f90 --- /dev/null +++ b/RGB.NET.Devices.Logitech/PerKey/PerKeyIdMapping.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Logitech +{ + internal static class PerKeyIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Invalid, LogitechLedId.Invalid }, + { LedId.Keyboard_Escape, LogitechLedId.ESC }, + { LedId.Keyboard_F1, LogitechLedId.F1 }, + { LedId.Keyboard_F2, LogitechLedId.F2 }, + { LedId.Keyboard_F3, LogitechLedId.F3 }, + { LedId.Keyboard_F4, LogitechLedId.F4 }, + { LedId.Keyboard_F5, LogitechLedId.F5 }, + { LedId.Keyboard_F6, LogitechLedId.F6 }, + { LedId.Keyboard_F7, LogitechLedId.F7 }, + { LedId.Keyboard_F8, LogitechLedId.F8 }, + { LedId.Keyboard_F9, LogitechLedId.F9 }, + { LedId.Keyboard_F10, LogitechLedId.F10 }, + { LedId.Keyboard_F11, LogitechLedId.F11 }, + { LedId.Keyboard_GraveAccentAndTilde, LogitechLedId.TILDE }, + { LedId.Keyboard_1, LogitechLedId.ONE }, + { LedId.Keyboard_2, LogitechLedId.TWO }, + { LedId.Keyboard_3, LogitechLedId.THREE }, + { LedId.Keyboard_4, LogitechLedId.FOUR }, + { LedId.Keyboard_5, LogitechLedId.FIVE }, + { LedId.Keyboard_6, LogitechLedId.SIX }, + { LedId.Keyboard_7, LogitechLedId.SEVEN }, + { LedId.Keyboard_8, LogitechLedId.EIGHT }, + { LedId.Keyboard_9, LogitechLedId.NINE }, + { LedId.Keyboard_0, LogitechLedId.ZERO }, + { LedId.Keyboard_MinusAndUnderscore, LogitechLedId.MINUS }, + { LedId.Keyboard_Tab, LogitechLedId.TAB }, + { LedId.Keyboard_Q, LogitechLedId.Q }, + { LedId.Keyboard_W, LogitechLedId.W }, + { LedId.Keyboard_E, LogitechLedId.E }, + { LedId.Keyboard_R, LogitechLedId.R }, + { LedId.Keyboard_T, LogitechLedId.T }, + { LedId.Keyboard_Y, LogitechLedId.Y }, + { LedId.Keyboard_U, LogitechLedId.U }, + { LedId.Keyboard_I, LogitechLedId.I }, + { LedId.Keyboard_O, LogitechLedId.O }, + { LedId.Keyboard_P, LogitechLedId.P }, + { LedId.Keyboard_BracketLeft, LogitechLedId.OPEN_BRACKET }, + { LedId.Keyboard_CapsLock, LogitechLedId.CAPS_LOCK }, + { LedId.Keyboard_A, LogitechLedId.A }, + { LedId.Keyboard_S, LogitechLedId.S }, + { LedId.Keyboard_D, LogitechLedId.D }, + { LedId.Keyboard_F, LogitechLedId.F }, + { LedId.Keyboard_G, LogitechLedId.G }, + { LedId.Keyboard_H, LogitechLedId.H }, + { LedId.Keyboard_J, LogitechLedId.J }, + { LedId.Keyboard_K, LogitechLedId.K }, + { LedId.Keyboard_L, LogitechLedId.L }, + { LedId.Keyboard_SemicolonAndColon, LogitechLedId.SEMICOLON }, + { LedId.Keyboard_ApostropheAndDoubleQuote, LogitechLedId.APOSTROPHE }, + { LedId.Keyboard_LeftShift, LogitechLedId.LEFT_SHIFT }, + { LedId.Keyboard_Z, LogitechLedId.Z }, + { LedId.Keyboard_X, LogitechLedId.X }, + { LedId.Keyboard_C, LogitechLedId.C }, + { LedId.Keyboard_V, LogitechLedId.V }, + { LedId.Keyboard_B, LogitechLedId.B }, + { LedId.Keyboard_N, LogitechLedId.N }, + { LedId.Keyboard_M, LogitechLedId.M }, + { LedId.Keyboard_CommaAndLessThan, LogitechLedId.COMMA }, + { LedId.Keyboard_PeriodAndBiggerThan, LogitechLedId.PERIOD }, + { LedId.Keyboard_SlashAndQuestionMark, LogitechLedId.FORWARD_SLASH }, + { LedId.Keyboard_LeftCtrl, LogitechLedId.LEFT_CONTROL }, + { LedId.Keyboard_LeftGui, LogitechLedId.LEFT_WINDOWS }, + { LedId.Keyboard_LeftAlt, LogitechLedId.LEFT_ALT }, + { LedId.Keyboard_Space, LogitechLedId.SPACE }, + { LedId.Keyboard_RightAlt, LogitechLedId.RIGHT_ALT }, + { LedId.Keyboard_RightGui, LogitechLedId.RIGHT_WINDOWS }, + { LedId.Keyboard_Application, LogitechLedId.APPLICATION_SELECT }, + { LedId.Keyboard_F12, LogitechLedId.F12 }, + { LedId.Keyboard_PrintScreen, LogitechLedId.PRINT_SCREEN }, + { LedId.Keyboard_ScrollLock, LogitechLedId.SCROLL_LOCK }, + { LedId.Keyboard_PauseBreak, LogitechLedId.PAUSE_BREAK }, + { LedId.Keyboard_Insert, LogitechLedId.INSERT }, + { LedId.Keyboard_Home, LogitechLedId.HOME }, + { LedId.Keyboard_PageUp, LogitechLedId.PAGE_UP }, + { LedId.Keyboard_BracketRight, LogitechLedId.CLOSE_BRACKET }, + { LedId.Keyboard_Backslash, LogitechLedId.BACKSLASH }, + { LedId.Keyboard_NonUsTilde, LogitechLedId.NonUsTilde }, + { LedId.Keyboard_Enter, LogitechLedId.ENTER }, + { LedId.Keyboard_EqualsAndPlus, LogitechLedId.EQUALS }, + { LedId.Keyboard_Backspace, LogitechLedId.BACKSPACE }, + { LedId.Keyboard_Delete, LogitechLedId.KEYBOARD_DELETE }, + { LedId.Keyboard_End, LogitechLedId.END }, + { LedId.Keyboard_PageDown, LogitechLedId.PAGE_DOWN }, + { LedId.Keyboard_RightShift, LogitechLedId.RIGHT_SHIFT }, + { LedId.Keyboard_RightCtrl, LogitechLedId.RIGHT_CONTROL }, + { LedId.Keyboard_ArrowUp, LogitechLedId.ARROW_UP }, + { LedId.Keyboard_ArrowLeft, LogitechLedId.ARROW_LEFT }, + { LedId.Keyboard_ArrowDown, LogitechLedId.ARROW_DOWN }, + { LedId.Keyboard_ArrowRight, LogitechLedId.ARROW_RIGHT }, + { LedId.Keyboard_NumLock, LogitechLedId.NUM_LOCK }, + { LedId.Keyboard_NumSlash, LogitechLedId.NUM_SLASH }, + { LedId.Keyboard_NumAsterisk, LogitechLedId.NUM_ASTERISK }, + { LedId.Keyboard_NumMinus, LogitechLedId.NUM_MINUS }, + { LedId.Keyboard_NumPlus, LogitechLedId.NUM_PLUS }, + { LedId.Keyboard_NumEnter, LogitechLedId.NUM_ENTER }, + { LedId.Keyboard_Num7, LogitechLedId.NUM_SEVEN }, + { LedId.Keyboard_Num8, LogitechLedId.NUM_EIGHT }, + { LedId.Keyboard_Num9, LogitechLedId.NUM_NINE }, + { LedId.Keyboard_Num4, LogitechLedId.NUM_FOUR }, + { LedId.Keyboard_Num5, LogitechLedId.NUM_FIVE }, + { LedId.Keyboard_Num6, LogitechLedId.NUM_SIX }, + { LedId.Keyboard_Num1, LogitechLedId.NUM_ONE }, + { LedId.Keyboard_Num2, LogitechLedId.NUM_TWO }, + { LedId.Keyboard_Num3, LogitechLedId.NUM_THREE }, + { LedId.Keyboard_Num0, LogitechLedId.NUM_ZERO }, + { LedId.Keyboard_NumPeriodAndDelete, LogitechLedId.NUM_PERIOD }, + { LedId.Keyboard_Programmable1, LogitechLedId.G_1 }, + { LedId.Keyboard_Programmable2, LogitechLedId.G_2 }, + { LedId.Keyboard_Programmable3, LogitechLedId.G_3 }, + { LedId.Keyboard_Programmable4, LogitechLedId.G_4 }, + { LedId.Keyboard_Programmable5, LogitechLedId.G_5 }, + { LedId.Keyboard_Programmable6, LogitechLedId.G_6 }, + { LedId.Keyboard_Programmable7, LogitechLedId.G_7 }, + { LedId.Keyboard_Programmable8, LogitechLedId.G_8 }, + { LedId.Keyboard_Programmable9, LogitechLedId.G_9 }, + }; + } +} diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 3f81a26..b9f045a 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -52,16 +52,16 @@ - + - - + + diff --git a/RGB.NET.Devices.Msi/Enum/MsiLedIds.cs b/RGB.NET.Devices.Msi/Enum/MsiLedIds.cs deleted file mode 100644 index f290849..0000000 --- a/RGB.NET.Devices.Msi/Enum/MsiLedIds.cs +++ /dev/null @@ -1,16 +0,0 @@ -// ReSharper disable InconsistentNaming - -#pragma warning disable 1591 // Missing XML comment for publicly visible type or member - -namespace RGB.NET.Devices.Msi -{ - /// - /// Contains list of all LEDs available for all Msi devices. - /// - public enum MsiLedIds - { - Invalid = -1, - - //TODO DarthAffe 11.11.2017: Create useful Ids for all devices - } -} diff --git a/RGB.NET.Devices.Msi/Generic/MsiLedId.cs b/RGB.NET.Devices.Msi/Generic/MsiLedId.cs deleted file mode 100644 index a69bf86..0000000 --- a/RGB.NET.Devices.Msi/Generic/MsiLedId.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Msi -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class MsiLedId : ILedId - { - #region Properties & Fields - - internal readonly MsiLedIds LedId; - - internal readonly int Index; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != MsiLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public MsiLedId(IRGBDevice device, MsiLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - /// The index in the mapping array of the device. - public MsiLedId(IRGBDevice device, MsiLedIds ledId, int index) - { - this.Device = device; - this.LedId = ledId; - this.Index = index; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() => LedId.ToString(); - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - MsiLedId compareLedId = obj as MsiLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() => LedId.GetHashCode(); - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(MsiLedId ledId1, MsiLedId ledId2) => ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(MsiLedId ledId1, MsiLedId ledId2) => !(ledId1 == ledId2); - - #endregion - } -} diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs index 9e3e8ff..2387690 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Linq; using RGB.NET.Core; -using RGB.NET.Core.Layout; using RGB.NET.Devices.Msi.Native; namespace RGB.NET.Devices.Msi @@ -60,44 +57,6 @@ namespace RGB.NET.Devices.Msi /// protected abstract void InitializeLayout(); - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out MsiLedIds ledId)) - { - if (LedMapping.TryGetValue(new MsiLedId(this, ledId), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { @@ -107,7 +66,7 @@ namespace RGB.NET.Devices.Msi { string deviceType = DeviceInfo.MsiDeviceType; foreach (Led led in leds) - _MsiSDK.SetLedColor(deviceType, ((MsiLedId)led.Id).Index, led.Color.R, led.Color.G, led.Color.B); + _MsiSDK.SetLedColor(deviceType, (int)led.CustomData, led.Color.R, led.Color.G, led.Color.B); } } diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index b94243b..b697225 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -45,10 +45,8 @@ - - diff --git a/RGB.NET.Devices.Novation/Enum/NovationLedIds.cs b/RGB.NET.Devices.Novation/Enum/NovationLedId.cs similarity index 98% rename from RGB.NET.Devices.Novation/Enum/NovationLedIds.cs rename to RGB.NET.Devices.Novation/Enum/NovationLedId.cs index 4023634..22f44c3 100644 --- a/RGB.NET.Devices.Novation/Enum/NovationLedIds.cs +++ b/RGB.NET.Devices.Novation/Enum/NovationLedId.cs @@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Novation /// They are represented as Hex 0x[00][11] where [00] is the status flag, [1] the id of the led. /// //TODO DarthAffe 15.08.2017: Check if this is really correct for all devices - public enum NovationLedIds + public enum NovationLedId { Invalid = -1, diff --git a/RGB.NET.Devices.Novation/Generic/NovationLedId.cs b/RGB.NET.Devices.Novation/Generic/NovationLedId.cs deleted file mode 100644 index 992d7d4..0000000 --- a/RGB.NET.Devices.Novation/Generic/NovationLedId.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.Diagnostics; -using RGB.NET.Core; - -namespace RGB.NET.Devices.Novation -{ - /// - /// - /// Represents a Id of a on a . - /// - [DebuggerDisplay("{" + nameof(LedId) + "}")] - public class NovationLedId : ILedId - { - #region Properties & Fields - - internal readonly NovationLedIds LedId; - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => LedId != NovationLedIds.Invalid; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The of the represented . - public NovationLedId(IRGBDevice device, NovationLedIds ledId) - { - this.Device = device; - this.LedId = ledId; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() - { - return LedId.ToString(); - } - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - NovationLedId compareLedId = obj as NovationLedId; - if (ReferenceEquals(compareLedId, null)) - return false; - - if (ReferenceEquals(this, compareLedId)) - return true; - - if (GetType() != compareLedId.GetType()) - return false; - - return compareLedId.LedId == LedId; - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - return LedId.GetHashCode(); - } - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(NovationLedId ledId1, NovationLedId ledId2) - { - return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - } - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(NovationLedId ledId1, NovationLedId ledId2) - { - return !(ledId1 == ledId2); - } - - #endregion - } -} diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index ba24016..f6a3e4f 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using RGB.NET.Core; -using RGB.NET.Core.Layout; using Sanford.Multimedia.Midi; namespace RGB.NET.Devices.Novation @@ -66,44 +64,6 @@ namespace RGB.NET.Devices.Novation /// protected abstract void InitializeLayout(); - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out NovationLedIds ledId)) - { - if (LedMapping.TryGetValue(new NovationLedId(this, ledId), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { @@ -113,11 +73,10 @@ namespace RGB.NET.Devices.Novation { foreach (Led led in leds) { - NovationLedId ledId = led.Id as NovationLedId; - if (ledId == null) continue; + NovationLedId ledId = (NovationLedId)led.CustomData; int color = ConvertColor(led.Color); - SendMessage(ledId.LedId.GetStatus(), ledId.LedId.GetId(), color); + SendMessage(ledId.GetStatus(), ledId.GetId(), color); } } } diff --git a/RGB.NET.Devices.Novation/Helper/DictionaryExtension.cs b/RGB.NET.Devices.Novation/Helper/DictionaryExtension.cs new file mode 100644 index 0000000..607ad97 --- /dev/null +++ b/RGB.NET.Devices.Novation/Helper/DictionaryExtension.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Linq; + +namespace RGB.NET.Devices.Novation +{ + internal static class DictionaryExtension + { + public static Dictionary SwapKeyValue(this Dictionary dictionary) => dictionary.ToDictionary(x => x.Value, x => x.Key); + } +} diff --git a/RGB.NET.Devices.Novation/Helper/NovationLedIdExtension.cs b/RGB.NET.Devices.Novation/Helper/NovationLedIdExtension.cs new file mode 100644 index 0000000..7d8556c --- /dev/null +++ b/RGB.NET.Devices.Novation/Helper/NovationLedIdExtension.cs @@ -0,0 +1,47 @@ +namespace RGB.NET.Devices.Novation +{ + /// + /// Offers some extensions and helper-methods for NovationLedId related things. + /// + public static class NovationLedIdExtension + { + #region Methods + + /// + /// Gets the status-flag associated with the id. + /// + /// The whose status-flag should be determinated. + /// The status-flag of the . + public static int GetStatus(this NovationLedId ledId) => ((int)ledId & 0xFF00) >> 8; + + /// + /// Gets the id associated with the id. + /// + /// The whose idshould be determinated. + /// The id of the . + public static int GetId(this NovationLedId ledId) => (int)ledId & 0x00FF; + + /// + /// Tests if the given is a grid-button. + /// + /// the to test. + /// true if is a grid-button; otherwise, false. + public static bool IsGrid(this NovationLedId ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) < 0x08); + + /// + /// Tests if the given is a scene-button. + /// + /// the to test. + /// true if is a scene-button; otherwise, false. + public static bool IsScene(this NovationLedId ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) == 0x09); + + /// + /// Tests if the given is custom-button. + /// + /// the to test. + /// true if is a custom-button; otherwise, false. + public static bool IsCustom(this NovationLedId ledId) => (ledId.GetStatus() == 0xB0) && ((ledId.GetId() / 0x10) == 0x06) && ((ledId.GetId() % 0x10) > 0x07); + + #endregion + } +} diff --git a/RGB.NET.Devices.Novation/Helper/NovationLedIdsExtension.cs b/RGB.NET.Devices.Novation/Helper/NovationLedIdsExtension.cs deleted file mode 100644 index a68c150..0000000 --- a/RGB.NET.Devices.Novation/Helper/NovationLedIdsExtension.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace RGB.NET.Devices.Novation -{ - /// - /// Offers some extensions and helper-methods for NovationLedIds related things. - /// - public static class NovationLedIdsExtension - { - #region Methods - - /// - /// Gets the status-flag associated with the id. - /// - /// The whose status-flag should be determinated. - /// The status-flag of the . - public static int GetStatus(this NovationLedIds ledId) => ((int)ledId & 0xFF00) >> 8; - - /// - /// Gets the id associated with the id. - /// - /// The whose idshould be determinated. - /// The id of the . - public static int GetId(this NovationLedIds ledId) => (int)ledId & 0x00FF; - - /// - /// Tests if the given is a grid-button. - /// - /// the to test. - /// true if is a grid-button; otherwise, false. - public static bool IsGrid(this NovationLedIds ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) < 0x08); - - /// - /// Tests if the given is a scene-button. - /// - /// the to test. - /// true if is a scene-button; otherwise, false. - public static bool IsScene(this NovationLedIds ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) == 0x09); - - /// - /// Tests if the given is custom-button. - /// - /// the to test. - /// true if is a custom-button; otherwise, false. - public static bool IsCustom(this NovationLedIds ledId) => (ledId.GetStatus() == 0xB0) && ((ledId.GetId() / 0x10) == 0x06) && ((ledId.GetId() % 0x10) > 0x07); - - #endregion - } -} diff --git a/RGB.NET.Devices.Novation/Launchpad/LaunchpadIdMapping.cs b/RGB.NET.Devices.Novation/Launchpad/LaunchpadIdMapping.cs new file mode 100644 index 0000000..8d90205 --- /dev/null +++ b/RGB.NET.Devices.Novation/Launchpad/LaunchpadIdMapping.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Novation +{ + internal static class LaunchpadIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Invalid, NovationLedId.Invalid }, + + { LedId.LedMatrix1, NovationLedId.Grid1 }, + { LedId.LedMatrix2, NovationLedId.Grid2 }, + { LedId.LedMatrix3, NovationLedId.Grid3 }, + { LedId.LedMatrix4, NovationLedId.Grid4 }, + { LedId.LedMatrix5, NovationLedId.Grid5 }, + { LedId.LedMatrix6, NovationLedId.Grid6 }, + { LedId.LedMatrix7, NovationLedId.Grid7 }, + { LedId.LedMatrix8, NovationLedId.Grid8 }, + { LedId.LedMatrix9, NovationLedId.Grid9 }, + { LedId.LedMatrix10, NovationLedId.Grid10 }, + { LedId.LedMatrix11, NovationLedId.Grid11 }, + { LedId.LedMatrix12, NovationLedId.Grid12 }, + { LedId.LedMatrix13, NovationLedId.Grid13 }, + { LedId.LedMatrix14, NovationLedId.Grid14 }, + { LedId.LedMatrix15, NovationLedId.Grid15 }, + { LedId.LedMatrix16, NovationLedId.Grid16 }, + { LedId.LedMatrix17, NovationLedId.Grid17 }, + { LedId.LedMatrix18, NovationLedId.Grid18 }, + { LedId.LedMatrix19, NovationLedId.Grid19 }, + { LedId.LedMatrix20, NovationLedId.Grid20 }, + { LedId.LedMatrix21, NovationLedId.Grid21 }, + { LedId.LedMatrix22, NovationLedId.Grid22 }, + { LedId.LedMatrix23, NovationLedId.Grid23 }, + { LedId.LedMatrix24, NovationLedId.Grid24 }, + { LedId.LedMatrix25, NovationLedId.Grid25 }, + { LedId.LedMatrix26, NovationLedId.Grid26 }, + { LedId.LedMatrix27, NovationLedId.Grid27 }, + { LedId.LedMatrix28, NovationLedId.Grid28 }, + { LedId.LedMatrix29, NovationLedId.Grid29 }, + { LedId.LedMatrix30, NovationLedId.Grid30 }, + { LedId.LedMatrix31, NovationLedId.Grid31 }, + { LedId.LedMatrix32, NovationLedId.Grid32 }, + { LedId.LedMatrix33, NovationLedId.Grid33 }, + { LedId.LedMatrix34, NovationLedId.Grid34 }, + { LedId.LedMatrix35, NovationLedId.Grid35 }, + { LedId.LedMatrix36, NovationLedId.Grid36 }, + { LedId.LedMatrix37, NovationLedId.Grid37 }, + { LedId.LedMatrix38, NovationLedId.Grid38 }, + { LedId.LedMatrix39, NovationLedId.Grid39 }, + { LedId.LedMatrix40, NovationLedId.Grid40 }, + { LedId.LedMatrix41, NovationLedId.Grid41 }, + { LedId.LedMatrix42, NovationLedId.Grid42 }, + { LedId.LedMatrix43, NovationLedId.Grid43 }, + { LedId.LedMatrix44, NovationLedId.Grid44 }, + { LedId.LedMatrix45, NovationLedId.Grid45 }, + { LedId.LedMatrix46, NovationLedId.Grid46 }, + { LedId.LedMatrix47, NovationLedId.Grid47 }, + { LedId.LedMatrix48, NovationLedId.Grid48 }, + { LedId.LedMatrix49, NovationLedId.Grid49 }, + { LedId.LedMatrix50, NovationLedId.Grid50 }, + { LedId.LedMatrix51, NovationLedId.Grid51 }, + { LedId.LedMatrix52, NovationLedId.Grid52 }, + { LedId.LedMatrix53, NovationLedId.Grid53 }, + { LedId.LedMatrix54, NovationLedId.Grid54 }, + { LedId.LedMatrix55, NovationLedId.Grid55 }, + { LedId.LedMatrix56, NovationLedId.Grid56 }, + { LedId.LedMatrix57, NovationLedId.Grid57 }, + { LedId.LedMatrix58, NovationLedId.Grid58 }, + { LedId.LedMatrix59, NovationLedId.Grid59 }, + { LedId.LedMatrix60, NovationLedId.Grid60 }, + { LedId.LedMatrix61, NovationLedId.Grid61 }, + { LedId.LedMatrix62, NovationLedId.Grid62 }, + { LedId.LedMatrix63, NovationLedId.Grid63 }, + { LedId.LedMatrix64, NovationLedId.Grid64 }, + + { LedId.Custom1, NovationLedId.Up }, + { LedId.Custom2, NovationLedId.Down }, + { LedId.Custom3, NovationLedId.Left }, + { LedId.Custom4, NovationLedId.Right }, + { LedId.Custom5, NovationLedId.Session }, + { LedId.Custom6, NovationLedId.User1 }, + { LedId.Custom7, NovationLedId.User2 }, + { LedId.Custom8, NovationLedId.Mix }, + + { LedId.Custom9, NovationLedId.Scene1 }, + { LedId.Custom10, NovationLedId.Scene2 }, + { LedId.Custom11, NovationLedId.Scene3 }, + { LedId.Custom12, NovationLedId.Scene4 }, + { LedId.Custom13, NovationLedId.Scene5 }, + { LedId.Custom14, NovationLedId.Scene6 }, + { LedId.Custom15, NovationLedId.Scene7 }, + { LedId.Custom16, NovationLedId.Scene8 }, + }; + } +} diff --git a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs index e17c4ba..50f7460 100644 --- a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using RGB.NET.Core; namespace RGB.NET.Devices.Novation @@ -27,9 +28,11 @@ namespace RGB.NET.Devices.Novation /// protected override void InitializeLayout() { + Dictionary mapping = LaunchpadIdMapping.DEFAULT.SwapKeyValue(); + //TODO DarthAffe 15.08.2017: Check if all launchpads are using the same basic layout const int BUTTON_SIZE = 20; - foreach (NovationLedIds ledId in Enum.GetValues(typeof(NovationLedIds))) + foreach (NovationLedId ledId in Enum.GetValues(typeof(NovationLedId))) { Rectangle rectangle; if (ledId.IsCustom()) @@ -40,7 +43,7 @@ namespace RGB.NET.Devices.Novation rectangle = new Rectangle(BUTTON_SIZE * ((int)ledId.GetId() % 0x10), BUTTON_SIZE * (((int)ledId.GetId() / 0x10) + 1), BUTTON_SIZE, BUTTON_SIZE); else continue; - InitializeLed(new NovationLedId(this, ledId), rectangle); + InitializeLed(mapping[ledId], rectangle); } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); @@ -48,6 +51,9 @@ namespace RGB.NET.Devices.Novation $@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads")); } + /// + protected override object CreateLedCustomData(LedId ledId) => LaunchpadIdMapping.DEFAULT[ledId]; + #endregion } } \ No newline at end of file diff --git a/RGB.NET.Devices.Novation/Layouts/Novation/Launchpads/LaunchpadS.xml b/RGB.NET.Devices.Novation/Layouts/Novation/Launchpads/LaunchpadS.xml index f9dda31..bc88904 100644 --- a/RGB.NET.Devices.Novation/Layouts/Novation/Launchpads/LaunchpadS.xml +++ b/RGB.NET.Devices.Novation/Layouts/Novation/Launchpads/LaunchpadS.xml @@ -12,50 +12,50 @@ 20 - + Circle 16 18 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm 16mm - + Circle +8 16mm @@ -63,269 +63,269 @@ - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 M0,0 L0,1 L0.75,1 L1,0.75 L1,0 Z - + +4 M0,0 L0,0.75 L0.25,1 L1,1 L1,0 Z - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 M0,0 L0,1 L1,1 L1,0.25 L0.75,0 Z - + +4 M0,0.25 L0,1 L1,1 L1,0 L0.25,0 Z - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + 14 +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + +4 - + Circle +4 40 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 16mm 16mm - + Circle ~ +8 @@ -337,88 +337,88 @@ - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index b137d3f..6fec2f3 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -53,13 +53,14 @@ - - + + - + + diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs index 36c6741..0d7c684 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs @@ -39,16 +39,19 @@ namespace RGB.NET.Devices.Razer if (LedMapping.Count == 0) for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++) - InitializeLed(new RazerLedId(this, i), new Rectangle(i * 11, 0, 10, 10)); + InitializeLed(LedId.Custom1 + i, new Rectangle(i * 11, 0, 10, 10)); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Custom1; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.CHROMALINK_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _ChromaLinkCustomEffect effectParams = new _ChromaLinkCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/Generic/RazerLedId.cs b/RGB.NET.Devices.Razer/Generic/RazerLedId.cs deleted file mode 100644 index d8fc56d..0000000 --- a/RGB.NET.Devices.Razer/Generic/RazerLedId.cs +++ /dev/null @@ -1,94 +0,0 @@ -using RGB.NET.Core; - -namespace RGB.NET.Devices.Razer -{ - /// - /// - /// Represents a Id of a on a . - /// - public class RazerLedId : ILedId - { - #region Properties & Fields - - internal int Index { get; } - - /// - public IRGBDevice Device { get; } - - /// - public bool IsValid => true; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The the belongs to. - /// The index representing the led-location in the grid. - public RazerLedId(IRGBDevice device, int index) - { - this.Device = device; - this.Index = index; - } - - #endregion - - #region Methods - - /// - /// Converts the Id of this to a human-readable string. - /// - /// A string that contains the Id of this . For example "Enter". - public override string ToString() => Index.ToString(); - - /// - /// Tests whether the specified object is a and is equivalent to this . - /// - /// The object to test. - /// true if is a equivalent to this ; otherwise, false. - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (!(obj is RazerLedId other)) return false; - - return (Index == other.Index) && Equals(Device, other.Device); - } - - /// - /// Returns a hash code for this . - /// - /// An integer value that specifies the hash code for this . - public override int GetHashCode() - { - unchecked - { - return (Index * 397) ^ (Device != null ? Device.GetHashCode() : 0); - } - } - - #endregion - - #region Operators - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(RazerLedId ledId1, RazerLedId ledId2) => ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2); - - /// - /// Returns a value that indicates whether two specified are equal. - /// - /// The first to compare. - /// The second to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(RazerLedId ledId1, RazerLedId ledId2) => !(ledId1 == ledId2); - - #endregion - } -} diff --git a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs index 66cd55c..7a73e28 100644 --- a/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Generic/RazerRGBDevice.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using RGB.NET.Core; -using RGB.NET.Core.Layout; using RGB.NET.Devices.Razer.Native; namespace RGB.NET.Devices.Razer @@ -61,45 +59,7 @@ namespace RGB.NET.Devices.Razer /// Initializes the and of the device. /// protected abstract void InitializeLayout(); - - /// - /// Applies the given layout. - /// - /// The file containing the layout. - /// The name of the layout used to get the images of the leds. - /// The path images for this device are collected in. - protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath) - { - DeviceLayout layout = DeviceLayout.Load(layoutPath); - if (layout != null) - { - LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); - - Size = new Size(layout.Width, layout.Height); - - if (layout.Leds != null) - foreach (LedLayout layoutLed in layout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out int ledIndex)) - { - if (LedMapping.TryGetValue(new RazerLedId(this, ledIndex), out Led led)) - { - led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y); - led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height); - - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - - LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); - led.Image = (!string.IsNullOrEmpty(image?.Image)) - ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) - : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute); - } - } - } - } - } - + /// protected override void UpdateLeds(IEnumerable ledsToUpdate) { diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs index a62cb07..d825a62 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs @@ -39,16 +39,19 @@ namespace RGB.NET.Devices.Razer if (LedMapping.Count == 0) for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++) - InitializeLed(new RazerLedId(this, i), new Rectangle(i * 11, 0, 10, 10)); + InitializeLed(LedId.Headset1 + i, new Rectangle(i * 11, 0, 10, 10)); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.HEADSET_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _HeadsetCustomEffect effectParams = new _HeadsetCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs index 51a7fae..2eb060c 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs @@ -38,21 +38,25 @@ namespace RGB.NET.Devices.Razer // $@"Layouts\Razer\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), // DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Razer\Keyboards")); + //TODO DarthAffe 13.12.2017: Correctly select ids if (LedMapping.Count == 0) { for (int i = 0; i < _Defines.KEYBOARD_MAX_ROW; i++) for (int j = 0; j < _Defines.KEYBOARD_MAX_COLUMN; j++) - InitializeLed(new RazerLedId(this, (i * _Defines.KEYBOARD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); + InitializeLed(LedId.Keyboard_Escape + ((i * _Defines.KEYBOARD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); } } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.KEYBOARD_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _KeyboardCustomEffect effectParams = new _KeyboardCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs index 2c528ee..f2ce8e9 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs @@ -41,17 +41,20 @@ namespace RGB.NET.Devices.Razer { for (int i = 0; i < _Defines.KEYPAD_MAX_ROW; i++) for (int j = 0; j < _Defines.KEYPAD_MAX_COLUMN; j++) - InitializeLed(new RazerLedId(this, (i * _Defines.KEYPAD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); + InitializeLed(LedId.Keypad1 + ((i * _Defines.KEYPAD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); } } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keypad1; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.KEYPAD_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _KeypadCustomEffect effectParams = new _KeypadCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs index 944d00c..a05b2aa 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs @@ -41,17 +41,20 @@ namespace RGB.NET.Devices.Razer { for (int i = 0; i < _Defines.MOUSE_MAX_ROW; i++) for (int j = 0; j < _Defines.MOUSE_MAX_COLUMN; j++) - InitializeLed(new RazerLedId(this, (i * _Defines.MOUSE_MAX_COLUMN) + j), new Rectangle(j * 11, i * 11, 10, 10)); + InitializeLed(LedId.Mouse1 + ((i * _Defines.MOUSE_MAX_COLUMN) + j), new Rectangle(j * 11, i * 11, 10, 10)); } } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.MOUSE_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _MouseCustomEffect effectParams = new _MouseCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs index e42b97d..0909e18 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs @@ -39,16 +39,19 @@ namespace RGB.NET.Devices.Razer if (LedMapping.Count == 0) for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++) - InitializeLed(new RazerLedId(this, i), new Rectangle(i * 11, 0, 10, 10)); + InitializeLed(LedId.Mousepad1 + i, new Rectangle(i * 11, 0, 10, 10)); } + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mousepad1; + /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.MOUSEPAD_MAX_LEDS]; foreach (Led led in leds) - colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); + colors[(int)led.CustomData] = new _Color(led.Color.R, led.Color.G, led.Color.B); _MousepadCustomEffect effectParams = new _MousepadCustomEffect { Color = colors }; diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 11919f7..440f0a7 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -49,7 +49,6 @@ - diff --git a/RGB.NET.Groups/Extensions/LedGroupExtension.cs b/RGB.NET.Groups/Extensions/LedGroupExtension.cs index 7a3b0c0..cd09393 100644 --- a/RGB.NET.Groups/Extensions/LedGroupExtension.cs +++ b/RGB.NET.Groups/Extensions/LedGroupExtension.cs @@ -25,21 +25,7 @@ namespace RGB.NET.Groups } return listLedGroup; } - - /// - /// Returns a new which contains all from the given excluding the specified ones. - /// - /// The base . - /// The ids of the to exclude. - /// The new . - public static ListLedGroup Exclude(this ILedGroup ledGroup, params ILedId[] ledIds) - { - ListLedGroup listLedGroup = ledGroup.ToListLedGroup(); - foreach (ILedId ledId in ledIds) - listLedGroup.RemoveLed(ledId); - return listLedGroup; - } - + /// /// Returns a new which contains all from the given excluding the specified ones. /// @@ -60,19 +46,13 @@ namespace RGB.NET.Groups /// /// The to attach. /// true if the could be attached; otherwise, false. - public static bool Attach(this ILedGroup ledGroup) - { - return RGBSurface.Instance.AttachLedGroup(ledGroup); - } + public static bool Attach(this ILedGroup ledGroup) => RGBSurface.Instance.AttachLedGroup(ledGroup); /// /// Detaches the given from the . /// /// The to attach. /// true if the could be detached; otherwise, false. - public static bool Detach(this ILedGroup ledGroup) - { - return RGBSurface.Instance.DetachLedGroup(ledGroup); - } + public static bool Detach(this ILedGroup ledGroup) => RGBSurface.Instance.DetachLedGroup(ledGroup); } } diff --git a/RGB.NET.Groups/Groups/ListLedGroup.cs b/RGB.NET.Groups/Groups/ListLedGroup.cs index f7c1143..a5fed36 100644 --- a/RGB.NET.Groups/Groups/ListLedGroup.cs +++ b/RGB.NET.Groups/Groups/ListLedGroup.cs @@ -13,7 +13,7 @@ namespace RGB.NET.Groups public class ListLedGroup : AbstractLedGroup { #region Properties & Fields - + /// /// Gets the list containing the of this . /// @@ -74,48 +74,6 @@ namespace RGB.NET.Groups AddLeds(leds); } - /// - /// - /// Initializes a new instance of the class. - /// - /// The IDs of the initial of this . - public ListLedGroup(params ILedId[] leds) - : this(true, leds) - { } - - /// - /// - /// Initializes a new instance of the class. - /// - /// The IDs of the initial of this . - public ListLedGroup(IEnumerable leds) - : this(true, leds) - { } - - /// - /// - /// Initializes a new instance of the class. - /// - /// Specifies whether this should be automatically attached or not. - /// The IDs of the initial of this . - public ListLedGroup(bool autoAttach, params ILedId[] leds) - : base(autoAttach) - { - AddLeds(leds); - } - - /// - /// - /// Initializes a new instance of the class. - /// - /// Specifies whether this should be automatically attached or not. - /// The IDs of the initial of this . - public ListLedGroup(bool autoAttach, IEnumerable leds) - : base(autoAttach) - { - AddLeds(leds); - } - #endregion #region Methods @@ -124,19 +82,7 @@ namespace RGB.NET.Groups /// Adds the given LED(s) to this . /// /// The LED(s) to add. - public void AddLed(params Led[] leds) - { - AddLeds(leds); - } - - /// - /// Adds the given LED(s) to this . - /// - /// The ID(s) of the LED(s) to add. - public void AddLed(params ILedId[] ledIds) - { - AddLeds(ledIds); - } + public void AddLed(params Led[] leds) => AddLeds(leds); /// /// Adds the given to this . @@ -151,35 +97,11 @@ namespace RGB.NET.Groups GroupLeds.Add(led); } - /// - /// Adds the given to this . - /// - /// The IDs of the to add. - public void AddLeds(IEnumerable ledIds) - { - if (ledIds == null) return; - - foreach (ILedId ledId in ledIds) - AddLed(ledId.Device[ledId]); - } - /// /// Removes the given LED(s) from this . /// /// The LED(s) to remove. - public void RemoveLed(params Led[] leds) - { - RemoveLeds(leds); - } - - /// - /// Removes the given LED(s) from this . - /// - /// The ID(s) of the LED(s) to remove. - public void RemoveLed(params ILedId[] ledIds) - { - RemoveLeds(ledIds); - } + public void RemoveLed(params Led[] leds) => RemoveLeds(leds); /// /// Removes the given from this . @@ -194,37 +116,12 @@ namespace RGB.NET.Groups GroupLeds.Remove(led); } - /// - /// Removes the given from this . - /// - /// The IDs of the to remove. - public void RemoveLeds(IEnumerable ledIds) - { - if (ledIds == null) return; - - foreach (ILedId ledId in ledIds) - RemoveLed(ledId.Device[ledId]); - } - /// /// Checks if a given LED is contained by this ledgroup. /// /// The LED which should be checked. /// true if the LED is contained by this ledgroup; otherwise, false. - public bool ContainsLed(Led led) - { - return (led != null) && GroupLeds.Contains(led); - } - - /// - /// Checks if a given LED is contained by this ledgroup. - /// - /// The ID of the LED which should be checked. - /// true if the LED is contained by this ledgroup; otherwise, false. - public bool ContainsLed(ILedId ledId) - { - return ContainsLed(ledId.Device[ledId]); - } + public bool ContainsLed(Led led) => (led != null) && GroupLeds.Contains(led); /// /// Merges the from the given ledgroup in this ledgroup. @@ -242,10 +139,7 @@ namespace RGB.NET.Groups /// Gets a list containing the from this group. /// /// The list containing the . - public override IEnumerable GetLeds() - { - return GroupLeds; - } + public override IEnumerable GetLeds() => GroupLeds; #endregion } diff --git a/RGB.NET.Groups/Groups/RectangleLedGroup.cs b/RGB.NET.Groups/Groups/RectangleLedGroup.cs index 3573d56..ac5213c 100644 --- a/RGB.NET.Groups/Groups/RectangleLedGroup.cs +++ b/RGB.NET.Groups/Groups/RectangleLedGroup.cs @@ -60,18 +60,6 @@ namespace RGB.NET.Groups #region Constructors - /// - /// - /// Initializes a new instance of the class. - /// - /// They ID of the first to calculate the of this from. - /// They ID of the second to calculate the of this from. - /// (optional) The minimal percentage overlay a must have with the to be taken into the . (default: 0.5) - /// (optional) Specifies whether this should be automatically attached or not. (default: true) - public RectangleLedGroup(ILedId fromLed, ILedId toLed, double minOverlayPercentage = 0.5, bool autoAttach = true) - : this(fromLed.Device[fromLed], toLed.Device[toLed], minOverlayPercentage, autoAttach) - { } - /// /// /// Initializes a new instance of the class.