diff --git a/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs b/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs
index d36665b..0b12582 100644
--- a/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs
+++ b/RGB.NET.Devices.Msi/Exceptions/MysticLightException.cs
@@ -34,6 +34,7 @@ namespace RGB.NET.Devices.Msi.Exceptions
/// The raw error code provided by the SDK.
/// The text-description of the error.
public MysticLightException(int errorCode, string description)
+ : base($"MSI error code {errorCode} ({description})")
{
this.ErrorCode = errorCode;
this.Description = description;
diff --git a/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs
index 13caa17..cd09af0 100644
--- a/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs
@@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Msi
///
internal interface IMsiRGBDevice : IRGBDevice
{
- void Initialize(MsiDeviceUpdateQueue updateQueue);
+ void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount);
}
}
diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
index 6c83ad0..e6a5210 100644
--- a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs
@@ -46,11 +46,11 @@ namespace RGB.NET.Devices.Msi
///
/// Initializes the device.
///
- public void Initialize(MsiDeviceUpdateQueue updateQueue)
+ public void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount)
{
DeviceUpdateQueue = updateQueue;
- InitializeLayout();
+ InitializeLayout(ledCount);
if (Size == Size.Invalid)
{
@@ -62,7 +62,7 @@ namespace RGB.NET.Devices.Msi
///
/// Initializes the and of the device.
///
- protected abstract void InitializeLayout();
+ protected abstract void InitializeLayout(int ledCount);
///
protected override void UpdateLeds(IEnumerable ledsToUpdate)
diff --git a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs
index 54ab51b..ee0800a 100644
--- a/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs
@@ -25,29 +25,19 @@ namespace RGB.NET.Devices.Msi
#region Methods
///
- protected override void InitializeLayout()
+ protected override void InitializeLayout(int ledCount)
{
- // Should errors be handled?
- _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts);
-
- for (int i = 0; i < deviceTypes.Length; i++)
+ for (int i = 0; i < ledCount; 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: 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.
+ //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));
- }
- }
+ _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
+ 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?
@@ -58,7 +48,7 @@ namespace RGB.NET.Devices.Msi
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
///
- public override void SyncBack()
+ public override void SyncBack()
{ }
#endregion
diff --git a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs
index afb4f98..f80dab0 100644
--- a/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs
+++ b/RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs
@@ -25,27 +25,17 @@ namespace RGB.NET.Devices.Msi
#region Methods
///
- protected override void InitializeLayout()
+ protected override void InitializeLayout(int ledCount)
{
- // Should errors be handled?
- _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts);
-
- for (int i = 0; i < deviceTypes.Length; i++)
+ for (int i = 0; i < ledCount; i++)
{
- // DeviceInfo.MsiDeviceType = "MSI_MB"
- 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: 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";
- _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, j, LED_STYLE);
- InitializeLed(LedId.Mainboard1 + j, new Rectangle(j * 40, 0, 40, 8));
- }
- }
+ _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
+ 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?
diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs
index 703aaea..59a3980 100644
--- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs
+++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs
@@ -104,31 +104,32 @@ namespace RGB.NET.Devices.Msi
if ((errorCode = _MsiSDK.Initialize()) != 0)
ThrowMsiError(errorCode);
- if ((errorCode = _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] _)) != 0)
+ if ((errorCode = _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts)) != 0)
ThrowMsiError(errorCode);
- foreach (string deviceType in deviceTypes)
+ for (int i = 0; i < deviceTypes.Length; i++)
{
try
{
+ string deviceType = deviceTypes[i];
+ int ledCount = ledCounts[i];
+
//Hex3l: 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 (deviceType.Equals("MSI_MB"))
{
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "Msi", "Motherboard"));
- motherboard.Initialize(updateQueue);
+ motherboard.Initialize(updateQueue, ledCount);
devices.Add(motherboard);
}
-
-
- if (deviceType.Equals("MSI_VGA"))
+ else if (deviceType.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);
+ graphicscard.Initialize(updateQueue, ledCount);
devices.Add(graphicscard);
}
diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj.DotSettings b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj.DotSettings
index 1071e1b..5db6073 100644
--- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj.DotSettings
+++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj.DotSettings
@@ -1,4 +1,5 @@
True
True
+ True
True
\ No newline at end of file