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

Merge pull request #125 from Hex3l/SDK/MSI

Adds MSI Mouse support
This commit is contained in:
DarthAffe 2020-05-07 01:05:47 +02:00 committed by GitHub
commit 4580a5dff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 3 deletions

View File

@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Msi
/// <param name="msiDeviceType">The internal type of the <see cref="IRGBDevice"/>.</param>
/// <param name="manufacturer">The manufacturer-name of the <see cref="IRGBDevice"/>.</param>
/// <param name="model">The model-name of the <see cref="IRGBDevice"/>.</param>
internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "Msi", string model = "Generic Msi-Device")
internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "MSI", string model = "Generic Msi-Device")
{
this.DeviceType = deviceType;
this.MsiDeviceType = msiDeviceType;

View File

@ -0,0 +1,54 @@
using RGB.NET.Core;
using RGB.NET.Devices.Msi.Native;
namespace RGB.NET.Devices.Msi
{
/// <inheritdoc />
/// <summary>
/// Represents a MSI mouse.
/// </summary>
public class MsiMouseRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiMouseRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by MSI for the mouse.</param>
internal MsiMouseRGBDevice(MsiRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeLayout(int ledCount)
{
for (int i = 0; i < ledCount; i++)
{
//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, i, LED_STYLE);
InitializeLed(LedId.Mouse1 + 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?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

View File

@ -118,7 +118,7 @@ namespace RGB.NET.Devices.Msi
if (deviceType.Equals("MSI_MB"))
{
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "Msi", "Motherboard"));
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "MSI", "Motherboard"));
motherboard.Initialize(updateQueue, ledCount);
devices.Add(motherboard);
}
@ -128,10 +128,20 @@ namespace RGB.NET.Devices.Msi
//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"));
IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "MSI", "GraphicsCard"));
graphicscard.Initialize(updateQueue, ledCount);
devices.Add(graphicscard);
}
else if (deviceType.Equals("MSI_MOUSE"))
{
//Hex3l: Every led under MSI_MOUSE should be a different mouse. Handling all the mouses together seems a good way to avoid overlapping of leds
//Hex3l: The led name is the name of the mouse (e.g. msi CLUTCH GM11) we could provide it in device info.
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
IMsiRGBDevice mouses = new MsiMouseRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mouse, deviceType, "MSI", "Mouse"));
mouses.Initialize(updateQueue, ledCount);
devices.Add(mouses);
}
//TODO DarthAffe 22.02.2020: Add other devices
}