using System;
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.Novation
{
///
///
/// Represents a Novation launchpad.
///
public class NovationLaunchpadRGBDevice : NovationRGBDevice, ILedMatrix
{
#region Constructors
///
///
/// Initializes a new instance of the class.
///
/// The specific information provided by Novation for the launchpad
internal NovationLaunchpadRGBDevice(NovationLaunchpadRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
///
protected override void InitializeLayout()
{
Dictionary mapping = GetDeviceMapping();
const int BUTTON_SIZE = 20;
foreach (LedId ledId in mapping.Keys)
{
(_, _, int x, int y) = mapping[ledId];
AddLed(ledId, new Point(BUTTON_SIZE * x, BUTTON_SIZE * y), new Size(BUTTON_SIZE));
}
}
///
protected override object GetLedCustomData(LedId ledId) => GetDeviceMapping().TryGetValue(ledId, out (byte mode, byte id, int _, int __) data) ? (data.mode, data.id) : ((byte)0x00, (byte)0x00);
protected virtual Dictionary GetDeviceMapping()
=> DeviceInfo.LedIdMapping switch
{
LedIdMappings.Current => LaunchpadIdMapping.CURRENT,
LedIdMappings.Legacy => LaunchpadIdMapping.LEGACY,
_ => throw new ArgumentOutOfRangeException()
};
#endregion
}
}