1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Adds MSI VGA support

This commit is contained in:
Hex3l 2020-02-22 20:13:41 +01:00
parent 18887a048e
commit 7fea5fbde5
2 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,66 @@
using RGB.NET.Core;
using RGB.NET.Devices.Msi.Native;
namespace RGB.NET.Devices.Msi
{
/// <inheritdoc />
/// <summary>
/// Represents MSI VGA adapters.
/// </summary>
public class MsiGraphicsCardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiGraphicsCardRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by MSI for graphics cards.</param>
internal MsiGraphicsCardRGBDevice(MsiRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
/// <inheritdoc />
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);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

View File

@ -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; }