From b92f121379bee5b51ecdf56bf1cc38c4f7a22d89 Mon Sep 17 00:00:00 2001 From: Hex3l Date: Sat, 15 Feb 2020 17:28:08 +0100 Subject: [PATCH] Adds support to MSI_MB device (motherboard) --- .../Mainboard/MsiMainboardRGBDevice.cs | 68 +++++++++++++++++++ RGB.NET.Devices.Msi/MsiDeviceProvider.cs | 10 +++ 2 files changed, 78 insertions(+) create mode 100644 RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs diff --git a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs new file mode 100644 index 0000000..7901ffb --- /dev/null +++ b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs @@ -0,0 +1,68 @@ +using System; +using RGB.NET.Core; +using RGB.NET.Devices.Msi.Native; +using RGB.NET.Devices.Msi.Exceptions; + +namespace RGB.NET.Devices.Msi +{ + /// + /// + /// Represents a Msi mainboard. + /// + public class MsiMainboardRGBDevice : MsiRGBDevice + { + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by Asus for the mainboard. + internal MsiMainboardRGBDevice(MsiRGBDeviceInfo info) + : base(info) + { } + + #endregion + + #region Methods + + /// + protected override void InitializeLayout() + { + // Should errors be handled? + _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts); + + for (int i = 0; i < deviceTypes.Length; i++) + { + // DeviceInfo.MsiDeviceType = "MSI_MB" + if (deviceTypes[i].Equals(DeviceInfo.MsiDeviceType)) + { + for (int j = 0; j < ledCounts[i]; j++) + { + // Should it be configurable in order to provide style access? + // Sets led style to "Steady" in order to have a solid color output therefore a controllable led color + // This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present + string style = "Steady"; + + _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, j, style); + InitializeLed(LedId.Mainboard1 + j, new Rectangle(j * 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); + } + + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1; + + /// + public override void SyncBack() + { } + + /// + + #endregion + } +} diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index 2eba9a0..2d1e377 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -103,6 +103,16 @@ namespace RGB.NET.Devices.Msi try { //TODO DarthAffe 11.11.2017: What is this deviceType? Find someone to try that out + + // MSI_MB provide access to the motherboard "leds" where a led must be intended as a led header (JRGB, JRAINBOW etc..) (Tested on MSI X570 Unify) + if (deviceTypes[i].Equals("MSI_MB")) + { + IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceTypes[i], "Msi", "Motherboard")); + motherboard.Initialize(); + devices.Add(motherboard); + } + + // Other devices? } catch { if (throwExceptions) throw; } }