Changed logitech devices to better fit the sdk-design. This allows to easily plug in new devices as soon as the hid-id is known

This commit is contained in:
DarthAffe committed 2017-11-14 22:41:30 +01:00
1 parent 4f48c63ae2
commit c3edd506cb
14 files changed
+241 -207

No files matched your search

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Devices.Logitech.Native;
namespace RGB.NET.Devices.Logitech.PerDevice
{
/// <inheritdoc />
/// <summary>
/// Represents a logitech per-device-lightable device.
/// </summary>
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="LogitechPerDeviceRGBDevice"/>.
/// </summary>
public LogitechRGBDeviceInfo PerDeviceDeviceInfo { get; }
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Logitech.LogitechPerDeviceRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by logitech for the per-device-lightable device</param>
internal LogitechPerDeviceRGBDevice(LogitechRGBDeviceInfo info)
: base(info)
{
this.PerDeviceDeviceInfo = info;
}
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeLayout()
{
base.InitializeLayout();
if (LedMapping.Count == 0)
InitializeLed(new LogitechLedId(this, LogitechLedIds.DEVICE), new Rectangle(0, 0, 1, 1));
}
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
{
Led led = ledsToUpdate.FirstOrDefault(x => x.Color.A > 0);
if (led == null) return;
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB);
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(led.Color.RPercent * 100),
(int)Math.Round(led.Color.GPercent * 100),
(int)Math.Round(led.Color.BPercent * 100));
}
#endregion
}
}