diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index dde9077..8a9f81c 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -201,6 +201,11 @@ namespace RGB.NET.Devices.Corsair yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo, modelCounter)); break; + case CorsairDeviceType.MemoryModule: + yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo, modelCounter)); + break; + + case CorsairDeviceType.Cooler: case CorsairDeviceType.CommanderPro: case CorsairDeviceType.LightningNodePro: _CorsairChannelsInfo channelsInfo = nativeDeviceInfo.channels; diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs index fe2a6e8..8a67c26 100644 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDeviceInfo.cs @@ -34,7 +34,7 @@ namespace RGB.NET.Devices.Corsair /// The id of the first led of this device. internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, CorsairLedId referenceCorsairLed, Dictionary modelCounter) - : base(deviceIndex, channelDeviceInfo.type == CorsairChannelDeviceType.Strip ? RGBDeviceType.LedStripe : RGBDeviceType.Fan, nativeInfo, + : base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo, GetModelName(channelDeviceInfo.type), modelCounter) { this.ReferenceCorsairLed = referenceCorsairLed; @@ -46,6 +46,31 @@ namespace RGB.NET.Devices.Corsair #region Methods + private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType) + { + switch (deviceType) + { + case CorsairChannelDeviceType.Invalid: + return RGBDeviceType.Unknown; + + case CorsairChannelDeviceType.FanHD: + case CorsairChannelDeviceType.FanSP: + case CorsairChannelDeviceType.FanLL: + case CorsairChannelDeviceType.FanML: + case CorsairChannelDeviceType.DAP: + return RGBDeviceType.Fan; + + case CorsairChannelDeviceType.Strip: + return RGBDeviceType.LedStripe; + + case CorsairChannelDeviceType.Pump: + return RGBDeviceType.Cooler; + + default: + throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null); + } + } + private static string GetModelName(CorsairChannelDeviceType deviceType) { switch (deviceType) @@ -71,6 +96,9 @@ namespace RGB.NET.Devices.Corsair case CorsairChannelDeviceType.DAP: return "DAP Fan"; + case CorsairChannelDeviceType.Pump: + return "Pump"; + default: throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null); } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs index d834044..b20a2d1 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairChannelDeviceType.cs @@ -18,5 +18,6 @@ namespace RGB.NET.Devices.Corsair FanML = 4, Strip = 5, DAP = 6, + Pump = 7 }; } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs index 1693b85..4d49626 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceCaps.cs @@ -19,6 +19,11 @@ namespace RGB.NET.Devices.Corsair /// /// For devices that has controlled lighting. /// - Lighting = 1 + Lighting = 1, + + /// + /// For devices that provide current state through set of properties. + /// + PropertyLookup = 2 }; } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs index 8548bdd..966dbfb 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairDeviceType.cs @@ -18,6 +18,8 @@ namespace RGB.NET.Devices.Corsair Mousepad = 4, HeadsetStand = 5, CommanderPro = 6, - LightningNodePro = 7 + LightningNodePro = 7, + MemoryModule = 8, + Cooler = 9 }; } diff --git a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs index 4dd7ffb..2277367 100644 --- a/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs +++ b/RGB.NET.Devices.Corsair/Enum/CorsairLedId.cs @@ -517,5 +517,270 @@ namespace RGB.NET.Devices.Corsair CustomDeviceChannel2Led148 = 497, CustomDeviceChannel2Led149 = 498, CustomDeviceChannel2Led150 = 499, + + OemLed1 = 500, + OemLed2 = 501, + OemLed3 = 502, + OemLed4 = 503, + OemLed5 = 504, + OemLed6 = 505, + OemLed7 = 506, + OemLed8 = 507, + OemLed9 = 508, + OemLed10 = 509, + OemLed11 = 510, + OemLed12 = 511, + OemLed13 = 512, + OemLed14 = 513, + OemLed15 = 514, + OemLed16 = 515, + OemLed17 = 516, + OemLed18 = 517, + OemLed19 = 518, + OemLed20 = 519, + OemLed21 = 520, + OemLed22 = 521, + OemLed23 = 522, + OemLed24 = 523, + OemLed25 = 524, + OemLed26 = 525, + OemLed27 = 526, + OemLed28 = 527, + OemLed29 = 528, + OemLed30 = 529, + OemLed31 = 530, + OemLed32 = 531, + OemLed33 = 532, + OemLed34 = 533, + OemLed35 = 534, + OemLed36 = 535, + OemLed37 = 536, + OemLed38 = 537, + OemLed39 = 538, + OemLed40 = 539, + OemLed41 = 540, + OemLed42 = 541, + OemLed43 = 542, + OemLed44 = 543, + OemLed45 = 544, + OemLed46 = 545, + OemLed47 = 546, + OemLed48 = 547, + OemLed49 = 548, + OemLed50 = 549, + OemLed51 = 550, + OemLed52 = 551, + OemLed53 = 552, + OemLed54 = 553, + OemLed55 = 554, + OemLed56 = 555, + OemLed57 = 556, + OemLed58 = 557, + OemLed59 = 558, + OemLed60 = 559, + OemLed61 = 560, + OemLed62 = 561, + OemLed63 = 562, + OemLed64 = 563, + OemLed65 = 564, + OemLed66 = 565, + OemLed67 = 566, + OemLed68 = 567, + OemLed69 = 568, + OemLed70 = 569, + OemLed71 = 570, + OemLed72 = 571, + OemLed73 = 572, + OemLed74 = 573, + OemLed75 = 574, + OemLed76 = 575, + OemLed77 = 576, + OemLed78 = 577, + OemLed79 = 578, + OemLed80 = 579, + OemLed81 = 580, + OemLed82 = 581, + OemLed83 = 582, + OemLed84 = 583, + OemLed85 = 584, + OemLed86 = 585, + OemLed87 = 586, + OemLed88 = 587, + OemLed89 = 588, + OemLed90 = 589, + OemLed91 = 590, + OemLed92 = 591, + OemLed93 = 592, + OemLed94 = 593, + OemLed95 = 594, + OemLed96 = 595, + OemLed97 = 596, + OemLed98 = 597, + OemLed99 = 598, + OemLed100 = 599, + + DRAM1 = 600, + DRAM2 = 601, + DRAM3 = 602, + DRAM4 = 603, + DRAM5 = 604, + DRAM6 = 605, + DRAM7 = 606, + DRAM8 = 607, + DRAM9 = 608, + DRAM10 = 609, + DRAM11 = 610, + DRAM12 = 611, + + CustomDeviceChannel3Led1 = 612, + CustomDeviceChannel3Led2 = 613, + CustomDeviceChannel3Led3 = 614, + CustomDeviceChannel3Led4 = 615, + CustomDeviceChannel3Led5 = 616, + CustomDeviceChannel3Led6 = 617, + CustomDeviceChannel3Led7 = 618, + CustomDeviceChannel3Led8 = 619, + CustomDeviceChannel3Led9 = 620, + CustomDeviceChannel3Led10 = 621, + CustomDeviceChannel3Led11 = 622, + CustomDeviceChannel3Led12 = 623, + CustomDeviceChannel3Led13 = 624, + CustomDeviceChannel3Led14 = 625, + CustomDeviceChannel3Led15 = 626, + CustomDeviceChannel3Led16 = 627, + CustomDeviceChannel3Led17 = 628, + CustomDeviceChannel3Led18 = 629, + CustomDeviceChannel3Led19 = 630, + CustomDeviceChannel3Led20 = 631, + CustomDeviceChannel3Led21 = 632, + CustomDeviceChannel3Led22 = 633, + CustomDeviceChannel3Led23 = 634, + CustomDeviceChannel3Led24 = 635, + CustomDeviceChannel3Led25 = 636, + CustomDeviceChannel3Led26 = 637, + CustomDeviceChannel3Led27 = 638, + CustomDeviceChannel3Led28 = 639, + CustomDeviceChannel3Led29 = 640, + CustomDeviceChannel3Led30 = 641, + CustomDeviceChannel3Led31 = 642, + CustomDeviceChannel3Led32 = 643, + CustomDeviceChannel3Led33 = 644, + CustomDeviceChannel3Led34 = 645, + CustomDeviceChannel3Led35 = 646, + CustomDeviceChannel3Led36 = 647, + CustomDeviceChannel3Led37 = 648, + CustomDeviceChannel3Led38 = 649, + CustomDeviceChannel3Led39 = 650, + CustomDeviceChannel3Led40 = 651, + CustomDeviceChannel3Led41 = 652, + CustomDeviceChannel3Led42 = 653, + CustomDeviceChannel3Led43 = 654, + CustomDeviceChannel3Led44 = 655, + CustomDeviceChannel3Led45 = 656, + CustomDeviceChannel3Led46 = 657, + CustomDeviceChannel3Led47 = 658, + CustomDeviceChannel3Led48 = 659, + CustomDeviceChannel3Led49 = 660, + CustomDeviceChannel3Led50 = 661, + CustomDeviceChannel3Led51 = 662, + CustomDeviceChannel3Led52 = 663, + CustomDeviceChannel3Led53 = 664, + CustomDeviceChannel3Led54 = 665, + CustomDeviceChannel3Led55 = 666, + CustomDeviceChannel3Led56 = 667, + CustomDeviceChannel3Led57 = 668, + CustomDeviceChannel3Led58 = 669, + CustomDeviceChannel3Led59 = 670, + CustomDeviceChannel3Led60 = 671, + CustomDeviceChannel3Led61 = 672, + CustomDeviceChannel3Led62 = 673, + CustomDeviceChannel3Led63 = 674, + CustomDeviceChannel3Led64 = 675, + CustomDeviceChannel3Led65 = 676, + CustomDeviceChannel3Led66 = 677, + CustomDeviceChannel3Led67 = 678, + CustomDeviceChannel3Led68 = 679, + CustomDeviceChannel3Led69 = 680, + CustomDeviceChannel3Led70 = 681, + CustomDeviceChannel3Led71 = 682, + CustomDeviceChannel3Led72 = 683, + CustomDeviceChannel3Led73 = 684, + CustomDeviceChannel3Led74 = 685, + CustomDeviceChannel3Led75 = 686, + CustomDeviceChannel3Led76 = 687, + CustomDeviceChannel3Led77 = 688, + CustomDeviceChannel3Led78 = 689, + CustomDeviceChannel3Led79 = 690, + CustomDeviceChannel3Led80 = 691, + CustomDeviceChannel3Led81 = 692, + CustomDeviceChannel3Led82 = 693, + CustomDeviceChannel3Led83 = 694, + CustomDeviceChannel3Led84 = 695, + CustomDeviceChannel3Led85 = 696, + CustomDeviceChannel3Led86 = 697, + CustomDeviceChannel3Led87 = 698, + CustomDeviceChannel3Led88 = 699, + CustomDeviceChannel3Led89 = 700, + CustomDeviceChannel3Led90 = 701, + CustomDeviceChannel3Led91 = 702, + CustomDeviceChannel3Led92 = 703, + CustomDeviceChannel3Led93 = 704, + CustomDeviceChannel3Led94 = 705, + CustomDeviceChannel3Led95 = 706, + CustomDeviceChannel3Led96 = 707, + CustomDeviceChannel3Led97 = 708, + CustomDeviceChannel3Led98 = 709, + CustomDeviceChannel3Led99 = 710, + CustomDeviceChannel3Led100 = 711, + CustomDeviceChannel3Led101 = 712, + CustomDeviceChannel3Led102 = 713, + CustomDeviceChannel3Led103 = 714, + CustomDeviceChannel3Led104 = 715, + CustomDeviceChannel3Led105 = 716, + CustomDeviceChannel3Led106 = 717, + CustomDeviceChannel3Led107 = 718, + CustomDeviceChannel3Led108 = 719, + CustomDeviceChannel3Led109 = 720, + CustomDeviceChannel3Led110 = 721, + CustomDeviceChannel3Led111 = 722, + CustomDeviceChannel3Led112 = 723, + CustomDeviceChannel3Led113 = 724, + CustomDeviceChannel3Led114 = 725, + CustomDeviceChannel3Led115 = 726, + CustomDeviceChannel3Led116 = 727, + CustomDeviceChannel3Led117 = 728, + CustomDeviceChannel3Led118 = 729, + CustomDeviceChannel3Led119 = 730, + CustomDeviceChannel3Led120 = 731, + CustomDeviceChannel3Led121 = 732, + CustomDeviceChannel3Led122 = 733, + CustomDeviceChannel3Led123 = 734, + CustomDeviceChannel3Led124 = 735, + CustomDeviceChannel3Led125 = 736, + CustomDeviceChannel3Led126 = 737, + CustomDeviceChannel3Led127 = 738, + CustomDeviceChannel3Led128 = 739, + CustomDeviceChannel3Led129 = 740, + CustomDeviceChannel3Led130 = 741, + CustomDeviceChannel3Led131 = 742, + CustomDeviceChannel3Led132 = 743, + CustomDeviceChannel3Led133 = 744, + CustomDeviceChannel3Led134 = 745, + CustomDeviceChannel3Led135 = 746, + CustomDeviceChannel3Led136 = 747, + CustomDeviceChannel3Led137 = 748, + CustomDeviceChannel3Led138 = 749, + CustomDeviceChannel3Led139 = 750, + CustomDeviceChannel3Led140 = 751, + CustomDeviceChannel3Led141 = 752, + CustomDeviceChannel3Led142 = 753, + CustomDeviceChannel3Led143 = 754, + CustomDeviceChannel3Led144 = 755, + CustomDeviceChannel3Led145 = 756, + CustomDeviceChannel3Led146 = 757, + CustomDeviceChannel3Led147 = 758, + CustomDeviceChannel3Led148 = 759, + CustomDeviceChannel3Led149 = 760, + CustomDeviceChannel3Led150 = 761, } } diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs new file mode 100644 index 0000000..d9bb202 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs @@ -0,0 +1,59 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair +{ + /// + /// + /// Represents a corsair memory. + /// + public class CorsairMemoryRGBDevice : CorsairRGBDevice + { + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the memory. + internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info) + : base(info) + { } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); + + int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); + IntPtr ptr = nativeLedPositions.pLedPosition; + + Dictionary mapping = MemoryIdMapping.DEFAULT.SwapKeyValue(); + for (int i = 0; i < nativeLedPositions.numberOfLed; i++) + { + _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); + InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); + + ptr = new IntPtr(ptr.ToInt64() + structSize); + } + + string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Memory\{model}.xml"), null); + } + + /// + protected override object CreateLedCustomData(LedId ledId) => MemoryIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; + + #endregion + } +} diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs new file mode 100644 index 0000000..544757a --- /dev/null +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDeviceInfo.cs @@ -0,0 +1,31 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System.Collections.Generic; +using RGB.NET.Core; +using RGB.NET.Devices.Corsair.Native; + +namespace RGB.NET.Devices.Corsair +{ + /// + /// + /// Represents a generic information for a . + /// + public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo + { + #region Constructors + + /// + /// + /// Internal constructor of managed . + /// + /// The index of the . + /// The native -struct + /// A dictionary containing counters to create unique names for equal devices models. + internal CorsairMemoryRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, Dictionary modelCounter) + : base(deviceIndex, RGBDeviceType.DRAM, nativeInfo, modelCounter) + { } + + #endregion + } +} diff --git a/RGB.NET.Devices.Corsair/Memory/MemoryIdMapping.cs b/RGB.NET.Devices.Corsair/Memory/MemoryIdMapping.cs new file mode 100644 index 0000000..b7d7db4 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Memory/MemoryIdMapping.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + internal static class MemoryIdMapping + { + internal static readonly Dictionary DEFAULT = new Dictionary + { + { LedId.Invalid, CorsairLedId.Invalid }, + { LedId.DRAM1, CorsairLedId.DRAM1 }, + { LedId.DRAM2, CorsairLedId.DRAM2 }, + { LedId.DRAM3, CorsairLedId.DRAM3 }, + { LedId.DRAM4, CorsairLedId.DRAM4 }, + { LedId.DRAM5, CorsairLedId.DRAM5 }, + { LedId.DRAM6, CorsairLedId.DRAM6 }, + { LedId.DRAM7, CorsairLedId.DRAM7 }, + { LedId.DRAM8, CorsairLedId.DRAM8 }, + { LedId.DRAM9, CorsairLedId.DRAM9 }, + { LedId.DRAM10, CorsairLedId.DRAM10 }, + { LedId.DRAM11, CorsairLedId.DRAM11 }, + { LedId.DRAM12, CorsairLedId.DRAM12 }, + }; + } +} 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 f85c0ca..704d9f9 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj.DotSettings @@ -3,6 +3,7 @@ True True True + True True False True