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

Merge pull request #106 from Hex3l/SDK/MSI

Adds support to MSI_MB device (motherboard)
This commit is contained in:
DarthAffe 2020-02-22 15:12:46 +01:00 committed by GitHub
commit 65be68f0b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 0 deletions

View File

@ -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
{
/// <inheritdoc />
/// <summary>
/// Represents a Msi mainboard.
/// </summary>
public class MsiMainboardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiMainboardRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by Asus for the mainboard.</param>
internal MsiMainboardRGBDevice(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_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);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1;
/// <inheritdoc />
public override void SyncBack()
{ }
/// <inheritdoc />
#endregion
}
}

View File

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