diff --git a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs new file mode 100644 index 0000000..54ab51b --- /dev/null +++ b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs @@ -0,0 +1,66 @@ +using RGB.NET.Core; +using RGB.NET.Devices.Msi.Native; + +namespace RGB.NET.Devices.Msi +{ + /// + /// + /// Represents MSI VGA adapters. + /// + public class MsiGraphicsCardRGBDevice : MsiRGBDevice + { + #region Constructors + + /// + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by MSI for graphics cards. + internal MsiGraphicsCardRGBDevice(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_VGA" + if (deviceTypes[i].Equals(DeviceInfo.MsiDeviceType)) + { + for (int j = 0; j < ledCounts[i]; j++) + { + //Hex3l: Should it be configurable in order to provide style access? + //Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color + //Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present + const string LED_STYLE = "Steady"; + + //Hex3l: Every led is a video card adapter. + + _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, j, LED_STYLE); + InitializeLed(LedId.GraphicsCard1 + j, new Rectangle(j * 10, 0, 10, 10)); + } + } + } + + //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + } + + /// + protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1; + + /// + public override void SyncBack() + { } + + #endregion + } +} diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index f233857..591050a 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -120,6 +120,18 @@ namespace RGB.NET.Devices.Msi devices.Add(motherboard); } + + if (deviceTypes.Equals("MSI_VGA")) + { + //Hex3l: Every led under MSI_VGA should be a different graphics card. Handling all the cards together seems a good way to avoid overlapping of leds + //Hex3l: The led name is the name of the card (e.g. NVIDIA GeForce RTX 2080 Ti) we could provide it in device info. + + MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType); + IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "Msi", "GraphicsCard")); + graphicscard.Initialize(updateQueue); + devices.Add(graphicscard); + } + //TODO DarthAffe 22.02.2020: Add other devices } catch { if (throwExceptions) throw; }