using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
///
///
/// Represents a logitech zone-lightable device.
///
public class LogitechZoneRGBDevice : LogitechRGBDevice, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{
#region Constants
private static readonly Dictionary BASE_LED_MAPPING = new Dictionary
{
{RGBDeviceType.Keyboard, LedId.Keyboard_Programmable1},
{RGBDeviceType.Mouse, LedId.Mouse1},
{RGBDeviceType.Headset, LedId.Headset1},
{RGBDeviceType.Mousepad, LedId.Mousepad1},
{RGBDeviceType.Speaker, LedId.Speaker1}
};
#endregion
#region Properties & Fields
private LedId _baseLedId;
#endregion
#region Constructors
///
///
/// Initializes a new instance of the class.
///
/// The specific information provided by logitech for the zone-lightable device
internal LogitechZoneRGBDevice(LogitechRGBDeviceInfo info)
: base(info)
{
_baseLedId = BASE_LED_MAPPING.TryGetValue(info.DeviceType, out LedId id) ? id : LedId.Custom1;
}
#endregion
#region Methods
///
protected override void InitializeLayout()
{
for (int i = 0; i < DeviceInfo.Zones; i++)
InitializeLed(_baseLedId + i, new Rectangle(i * 10, 0, 10, 10));
base.InitializeLayout();
}
///
protected override object CreateLedCustomData(LedId ledId) => (int)(ledId - _baseLedId);
///
protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
#endregion
}
}