Added support for novation launchpad mk2

This commit is contained in:
DarthAffe committed 2020-09-05 23:48:46 +02:00
1 parent fd2e9a0049
commit f91d5e5060
15 files changed
+474 -272

No files matched your search

@@ -5,92 +5,180 @@ namespace RGB.NET.Devices.Novation
{
internal static class LaunchpadIdMapping
{
internal static readonly Dictionary<LedId, NovationLedId> DEFAULT = new Dictionary<LedId, NovationLedId>
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> LEGACY = new Dictionary<LedId, (byte mode, byte id, int x, int y)>
{
{ LedId.Invalid, NovationLedId.Invalid },
{ LedId.Invalid, (0x00, 0xFF, 8, 0) },
{ LedId.LedMatrix1, NovationLedId.Grid1 },
{ LedId.LedMatrix2, NovationLedId.Grid2 },
{ LedId.LedMatrix3, NovationLedId.Grid3 },
{ LedId.LedMatrix4, NovationLedId.Grid4 },
{ LedId.LedMatrix5, NovationLedId.Grid5 },
{ LedId.LedMatrix6, NovationLedId.Grid6 },
{ LedId.LedMatrix7, NovationLedId.Grid7 },
{ LedId.LedMatrix8, NovationLedId.Grid8 },
{ LedId.LedMatrix9, NovationLedId.Grid9 },
{ LedId.LedMatrix10, NovationLedId.Grid10 },
{ LedId.LedMatrix11, NovationLedId.Grid11 },
{ LedId.LedMatrix12, NovationLedId.Grid12 },
{ LedId.LedMatrix13, NovationLedId.Grid13 },
{ LedId.LedMatrix14, NovationLedId.Grid14 },
{ LedId.LedMatrix15, NovationLedId.Grid15 },
{ LedId.LedMatrix16, NovationLedId.Grid16 },
{ LedId.LedMatrix17, NovationLedId.Grid17 },
{ LedId.LedMatrix18, NovationLedId.Grid18 },
{ LedId.LedMatrix19, NovationLedId.Grid19 },
{ LedId.LedMatrix20, NovationLedId.Grid20 },
{ LedId.LedMatrix21, NovationLedId.Grid21 },
{ LedId.LedMatrix22, NovationLedId.Grid22 },
{ LedId.LedMatrix23, NovationLedId.Grid23 },
{ LedId.LedMatrix24, NovationLedId.Grid24 },
{ LedId.LedMatrix25, NovationLedId.Grid25 },
{ LedId.LedMatrix26, NovationLedId.Grid26 },
{ LedId.LedMatrix27, NovationLedId.Grid27 },
{ LedId.LedMatrix28, NovationLedId.Grid28 },
{ LedId.LedMatrix29, NovationLedId.Grid29 },
{ LedId.LedMatrix30, NovationLedId.Grid30 },
{ LedId.LedMatrix31, NovationLedId.Grid31 },
{ LedId.LedMatrix32, NovationLedId.Grid32 },
{ LedId.LedMatrix33, NovationLedId.Grid33 },
{ LedId.LedMatrix34, NovationLedId.Grid34 },
{ LedId.LedMatrix35, NovationLedId.Grid35 },
{ LedId.LedMatrix36, NovationLedId.Grid36 },
{ LedId.LedMatrix37, NovationLedId.Grid37 },
{ LedId.LedMatrix38, NovationLedId.Grid38 },
{ LedId.LedMatrix39, NovationLedId.Grid39 },
{ LedId.LedMatrix40, NovationLedId.Grid40 },
{ LedId.LedMatrix41, NovationLedId.Grid41 },
{ LedId.LedMatrix42, NovationLedId.Grid42 },
{ LedId.LedMatrix43, NovationLedId.Grid43 },
{ LedId.LedMatrix44, NovationLedId.Grid44 },
{ LedId.LedMatrix45, NovationLedId.Grid45 },
{ LedId.LedMatrix46, NovationLedId.Grid46 },
{ LedId.LedMatrix47, NovationLedId.Grid47 },
{ LedId.LedMatrix48, NovationLedId.Grid48 },
{ LedId.LedMatrix49, NovationLedId.Grid49 },
{ LedId.LedMatrix50, NovationLedId.Grid50 },
{ LedId.LedMatrix51, NovationLedId.Grid51 },
{ LedId.LedMatrix52, NovationLedId.Grid52 },
{ LedId.LedMatrix53, NovationLedId.Grid53 },
{ LedId.LedMatrix54, NovationLedId.Grid54 },
{ LedId.LedMatrix55, NovationLedId.Grid55 },
{ LedId.LedMatrix56, NovationLedId.Grid56 },
{ LedId.LedMatrix57, NovationLedId.Grid57 },
{ LedId.LedMatrix58, NovationLedId.Grid58 },
{ LedId.LedMatrix59, NovationLedId.Grid59 },
{ LedId.LedMatrix60, NovationLedId.Grid60 },
{ LedId.LedMatrix61, NovationLedId.Grid61 },
{ LedId.LedMatrix62, NovationLedId.Grid62 },
{ LedId.LedMatrix63, NovationLedId.Grid63 },
{ LedId.LedMatrix64, NovationLedId.Grid64 },
{ LedId.LedMatrix1, (0x90, 0x00, 0, 1) },
{ LedId.LedMatrix2, (0x90, 0x01, 1, 1) },
{ LedId.LedMatrix3, (0x90, 0x02, 2, 1) },
{ LedId.LedMatrix4, (0x90, 0x03, 3, 1) },
{ LedId.LedMatrix5, (0x90, 0x04, 4, 1) },
{ LedId.LedMatrix6, (0x90, 0x05, 5, 1) },
{ LedId.LedMatrix7, (0x90, 0x06, 6, 1) },
{ LedId.LedMatrix8, (0x90, 0x07, 7, 1) },
{ LedId.LedMatrix9, (0x90, 0x10, 0, 2) },
{ LedId.LedMatrix10, (0x90, 0x11, 1, 2) },
{ LedId.LedMatrix11, (0x90, 0x12, 2, 2) },
{ LedId.LedMatrix12, (0x90, 0x13, 3, 2) },
{ LedId.LedMatrix13, (0x90, 0x14, 4, 2) },
{ LedId.LedMatrix14, (0x90, 0x15, 5, 2) },
{ LedId.LedMatrix15, (0x90, 0x16, 6, 2) },
{ LedId.LedMatrix16, (0x90, 0x17, 7, 2) },
{ LedId.LedMatrix17, (0x90, 0x20, 0, 3) },
{ LedId.LedMatrix18, (0x90, 0x21, 1, 3) },
{ LedId.LedMatrix19, (0x90, 0x22, 2, 3) },
{ LedId.LedMatrix20, (0x90, 0x23, 3, 3) },
{ LedId.LedMatrix21, (0x90, 0x24, 4, 3) },
{ LedId.LedMatrix22, (0x90, 0x25, 5, 3) },
{ LedId.LedMatrix23, (0x90, 0x26, 6, 3) },
{ LedId.LedMatrix24, (0x90, 0x27, 7, 3) },
{ LedId.LedMatrix25, (0x90, 0x30, 0, 4) },
{ LedId.LedMatrix26, (0x90, 0x31, 1, 4) },
{ LedId.LedMatrix27, (0x90, 0x32, 2, 4) },
{ LedId.LedMatrix28, (0x90, 0x33, 3, 4) },
{ LedId.LedMatrix29, (0x90, 0x34, 4, 4) },
{ LedId.LedMatrix30, (0x90, 0x35, 5, 4) },
{ LedId.LedMatrix31, (0x90, 0x36, 6, 4) },
{ LedId.LedMatrix32, (0x90, 0x37, 7, 4) },
{ LedId.LedMatrix33, (0x90, 0x40, 0, 5) },
{ LedId.LedMatrix34, (0x90, 0x41, 1, 5) },
{ LedId.LedMatrix35, (0x90, 0x42, 2, 5) },
{ LedId.LedMatrix36, (0x90, 0x43, 3, 5) },
{ LedId.LedMatrix37, (0x90, 0x44, 4, 5) },
{ LedId.LedMatrix38, (0x90, 0x45, 5, 5) },
{ LedId.LedMatrix39, (0x90, 0x46, 6, 5) },
{ LedId.LedMatrix40, (0x90, 0x47, 7, 5) },
{ LedId.LedMatrix41, (0x90, 0x50, 0, 6) },
{ LedId.LedMatrix42, (0x90, 0x51, 1, 6) },
{ LedId.LedMatrix43, (0x90, 0x52, 2, 6) },
{ LedId.LedMatrix44, (0x90, 0x53, 3, 6) },
{ LedId.LedMatrix45, (0x90, 0x54, 4, 6) },
{ LedId.LedMatrix46, (0x90, 0x55, 5, 6) },
{ LedId.LedMatrix47, (0x90, 0x56, 6, 6) },
{ LedId.LedMatrix48, (0x90, 0x57, 7, 6) },
{ LedId.LedMatrix49, (0x90, 0x60, 0, 7) },
{ LedId.LedMatrix50, (0x90, 0x61, 1, 7) },
{ LedId.LedMatrix51, (0x90, 0x62, 2, 7) },
{ LedId.LedMatrix52, (0x90, 0x63, 3, 7) },
{ LedId.LedMatrix53, (0x90, 0x64, 4, 7) },
{ LedId.LedMatrix54, (0x90, 0x65, 5, 7) },
{ LedId.LedMatrix55, (0x90, 0x66, 6, 7) },
{ LedId.LedMatrix56, (0x90, 0x67, 7, 7) },
{ LedId.LedMatrix57, (0x90, 0x70, 0, 8) },
{ LedId.LedMatrix58, (0x90, 0x71, 1, 8) },
{ LedId.LedMatrix59, (0x90, 0x72, 2, 8) },
{ LedId.LedMatrix60, (0x90, 0x73, 3, 8) },
{ LedId.LedMatrix61, (0x90, 0x74, 4, 8) },
{ LedId.LedMatrix62, (0x90, 0x75, 5, 8) },
{ LedId.LedMatrix63, (0x90, 0x76, 6, 8) },
{ LedId.LedMatrix64, (0x90, 0x77, 7, 8) },
{ LedId.Custom1, NovationLedId.Up },
{ LedId.Custom2, NovationLedId.Down },
{ LedId.Custom3, NovationLedId.Left },
{ LedId.Custom4, NovationLedId.Right },
{ LedId.Custom5, NovationLedId.Session },
{ LedId.Custom6, NovationLedId.User1 },
{ LedId.Custom7, NovationLedId.User2 },
{ LedId.Custom8, NovationLedId.Mix },
{ LedId.Custom1, (0xB0, 0x68, 0, 0) }, // Up
{ LedId.Custom2, (0xB0, 0x69, 1, 0) }, // Down
{ LedId.Custom3, (0xB0, 0x6A, 2, 0) }, // Left
{ LedId.Custom4, (0xB0, 0x6B, 3, 0) }, // Right
{ LedId.Custom5, (0xB0, 0x6C, 4, 0) }, // Session
{ LedId.Custom6, (0xB0, 0x6D, 5, 0) }, // User 1
{ LedId.Custom7, (0xB0, 0x6E, 6, 0) }, // User 2
{ LedId.Custom8, (0xB0, 0x6F, 7, 0) }, // Mix
{ LedId.Custom9, NovationLedId.Scene1 },
{ LedId.Custom10, NovationLedId.Scene2 },
{ LedId.Custom11, NovationLedId.Scene3 },
{ LedId.Custom12, NovationLedId.Scene4 },
{ LedId.Custom13, NovationLedId.Scene5 },
{ LedId.Custom14, NovationLedId.Scene6 },
{ LedId.Custom15, NovationLedId.Scene7 },
{ LedId.Custom16, NovationLedId.Scene8 },
{ LedId.Custom9, (0x90, 0x08, 8, 1) }, //Scene1
{ LedId.Custom10, (0x90, 0x18, 8, 2) }, //Scene2
{ LedId.Custom11, (0x90, 0x28, 8, 3) }, //Scene3
{ LedId.Custom12, (0x90, 0x38, 8, 4) }, //Scene4
{ LedId.Custom13, (0x90, 0x48, 8, 5) }, //Scene5
{ LedId.Custom14, (0x90, 0x58, 8, 6) }, //Scene6
{ LedId.Custom15, (0x90, 0x68, 8, 7) }, //Scene7
{ LedId.Custom16, (0x90, 0x78, 8, 8) }, //Scene8
};
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> CURRENT = new Dictionary<LedId, (byte mode, byte id, int x, int y)>
{
{ LedId.Invalid, (0x00, 0xFF, 8, 0) },
{ LedId.LedMatrix1, (0x90, 81, 0, 1) },
{ LedId.LedMatrix2, (0x90, 82, 1, 1) },
{ LedId.LedMatrix3, (0x90, 83, 2, 1) },
{ LedId.LedMatrix4, (0x90, 84, 3, 1) },
{ LedId.LedMatrix5, (0x90, 85, 4, 1) },
{ LedId.LedMatrix6, (0x90, 86, 5, 1) },
{ LedId.LedMatrix7, (0x90, 87, 6, 1) },
{ LedId.LedMatrix8, (0x90, 88, 7, 1) },
{ LedId.LedMatrix9, (0x90, 71, 0, 2) },
{ LedId.LedMatrix10, (0x90, 72, 1, 2) },
{ LedId.LedMatrix11, (0x90, 73, 2, 2) },
{ LedId.LedMatrix12, (0x90, 74, 3, 2) },
{ LedId.LedMatrix13, (0x90, 75, 4, 2) },
{ LedId.LedMatrix14, (0x90, 76, 5, 2) },
{ LedId.LedMatrix15, (0x90, 77, 6, 2) },
{ LedId.LedMatrix16, (0x90, 78, 7, 2) },
{ LedId.LedMatrix17, (0x90, 61, 0, 3) },
{ LedId.LedMatrix18, (0x90, 62, 1, 3) },
{ LedId.LedMatrix19, (0x90, 63, 2, 3) },
{ LedId.LedMatrix20, (0x90, 64, 3, 3) },
{ LedId.LedMatrix21, (0x90, 65, 4, 3) },
{ LedId.LedMatrix22, (0x90, 66, 5, 3) },
{ LedId.LedMatrix23, (0x90, 67, 6, 3) },
{ LedId.LedMatrix24, (0x90, 68, 7, 3) },
{ LedId.LedMatrix25, (0x90, 51, 0, 4) },
{ LedId.LedMatrix26, (0x90, 52, 1, 4) },
{ LedId.LedMatrix27, (0x90, 53, 2, 4) },
{ LedId.LedMatrix28, (0x90, 54, 3, 4) },
{ LedId.LedMatrix29, (0x90, 55, 4, 4) },
{ LedId.LedMatrix30, (0x90, 56, 5, 4) },
{ LedId.LedMatrix31, (0x90, 57, 6, 4) },
{ LedId.LedMatrix32, (0x90, 58, 7, 4) },
{ LedId.LedMatrix33, (0x90, 41, 0, 5) },
{ LedId.LedMatrix34, (0x90, 42, 1, 5) },
{ LedId.LedMatrix35, (0x90, 43, 2, 5) },
{ LedId.LedMatrix36, (0x90, 44, 3, 5) },
{ LedId.LedMatrix37, (0x90, 45, 4, 5) },
{ LedId.LedMatrix38, (0x90, 46, 5, 5) },
{ LedId.LedMatrix39, (0x90, 47, 6, 5) },
{ LedId.LedMatrix40, (0x90, 48, 7, 5) },
{ LedId.LedMatrix41, (0x90, 31, 0, 6) },
{ LedId.LedMatrix42, (0x90, 32, 1, 6) },
{ LedId.LedMatrix43, (0x90, 33, 2, 6) },
{ LedId.LedMatrix44, (0x90, 34, 3, 6) },
{ LedId.LedMatrix45, (0x90, 35, 4, 6) },
{ LedId.LedMatrix46, (0x90, 36, 5, 6) },
{ LedId.LedMatrix47, (0x90, 37, 6, 6) },
{ LedId.LedMatrix48, (0x90, 38, 7, 6) },
{ LedId.LedMatrix49, (0x90, 21, 0, 7) },
{ LedId.LedMatrix50, (0x90, 22, 1, 7) },
{ LedId.LedMatrix51, (0x90, 23, 2, 7) },
{ LedId.LedMatrix52, (0x90, 24, 3, 7) },
{ LedId.LedMatrix53, (0x90, 25, 4, 7) },
{ LedId.LedMatrix54, (0x90, 26, 5, 7) },
{ LedId.LedMatrix55, (0x90, 27, 6, 7) },
{ LedId.LedMatrix56, (0x90, 28, 7, 7) },
{ LedId.LedMatrix57, (0x90, 11, 0, 8) },
{ LedId.LedMatrix58, (0x90, 12, 1, 8) },
{ LedId.LedMatrix59, (0x90, 13, 2, 8) },
{ LedId.LedMatrix60, (0x90, 14, 3, 8) },
{ LedId.LedMatrix61, (0x90, 15, 4, 8) },
{ LedId.LedMatrix62, (0x90, 16, 5, 8) },
{ LedId.LedMatrix63, (0x90, 17, 6, 8) },
{ LedId.LedMatrix64, (0x90, 18, 7, 8) },
{ LedId.Custom1, (0xB0, 104, 0, 0) }, // Up
{ LedId.Custom2, (0xB0, 105, 1, 0) }, // Down
{ LedId.Custom3, (0xB0, 106, 2, 0) }, // Left
{ LedId.Custom4, (0xB0, 107, 3, 0) }, // Right
{ LedId.Custom5, (0xB0, 108, 4, 0) }, // Session
{ LedId.Custom6, (0xB0, 109, 5, 0) }, // User 1
{ LedId.Custom7, (0xB0, 110, 6, 0) }, // User 2
{ LedId.Custom8, (0xB0, 111, 7, 0) }, // Mix
{ LedId.Custom9, (0x90, 89, 8, 1) }, //Scene1
{ LedId.Custom10, (0x90, 79, 8, 2) }, //Scene2
{ LedId.Custom11, (0x90, 69, 8, 3) }, //Scene3
{ LedId.Custom12, (0x90, 59, 8, 4) }, //Scene4
{ LedId.Custom13, (0x90, 49, 8, 5) }, //Scene5
{ LedId.Custom14, (0x90, 39, 8, 6) }, //Scene6
{ LedId.Custom15, (0x90, 29, 8, 7) }, //Scene7
{ LedId.Custom16, (0x90, 19, 8, 8) }, //Scene8
};
}
}
@@ -0,0 +1,8 @@
namespace RGB.NET.Devices.Novation
{
internal enum LedIdMappings
{
Current,
Legacy
}
}
@@ -28,22 +28,13 @@ namespace RGB.NET.Devices.Novation
/// <inheritdoc />
protected override void InitializeLayout()
{
Dictionary<NovationLedId, LedId> mapping = LaunchpadIdMapping.DEFAULT.SwapKeyValue();
Dictionary<LedId, (byte mode, byte id, int x, int y)> mapping = GetDeviceMapping();
//TODO DarthAffe 15.08.2017: Check if all launchpads are using the same basic layout
const int BUTTON_SIZE = 20;
foreach (NovationLedId ledId in Enum.GetValues(typeof(NovationLedId)))
foreach (LedId ledId in mapping.Keys)
{
Rectangle rectangle;
if (ledId.IsCustom())
rectangle = new Rectangle(BUTTON_SIZE * (ledId.GetId() - 0x68), 0, BUTTON_SIZE, BUTTON_SIZE);
else if (ledId.IsScene())
rectangle = new Rectangle(8 * BUTTON_SIZE, BUTTON_SIZE * (((int)ledId.GetId() / 0x10) + 1), BUTTON_SIZE, BUTTON_SIZE);
else if (ledId.IsGrid())
rectangle = new Rectangle(BUTTON_SIZE * ((int)ledId.GetId() % 0x10), BUTTON_SIZE * (((int)ledId.GetId() / 0x10) + 1), BUTTON_SIZE, BUTTON_SIZE);
else continue;
InitializeLed(mapping[ledId], rectangle);
(_, _, int x, int y) = mapping[ledId];
InitializeLed(ledId, new Point(BUTTON_SIZE * x, BUTTON_SIZE * y), new Size(BUTTON_SIZE));
}
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
@@ -51,7 +42,15 @@ namespace RGB.NET.Devices.Novation
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => LaunchpadIdMapping.DEFAULT.TryGetValue(ledId, out NovationLedId novationLedId) ? novationLedId : NovationLedId.Invalid;
protected override object CreateLedCustomData(LedId ledId) => GetDeviceMapping().TryGetValue(ledId, out (byte mode, byte id, int _, int __) data) ? (data.mode, data.id) : ((byte)0x00, (byte)0x00);
protected virtual Dictionary<LedId, (byte mode, byte id, int x, int y)> GetDeviceMapping()
=> DeviceInfo.LedIdMapping switch
{
LedIdMappings.Current => LaunchpadIdMapping.CURRENT,
LedIdMappings.Legacy => LaunchpadIdMapping.LEGACY,
_ => throw new ArgumentOutOfRangeException()
};
#endregion
}
@@ -8,6 +8,12 @@ namespace RGB.NET.Devices.Novation
/// </summary>
public class NovationLaunchpadRGBDeviceInfo : NovationRGBDeviceInfo
{
#region Properties & Fields
internal LedIdMappings LedIdMapping { get; }
#endregion
#region Constructors
/// <inheritdoc />
@@ -17,9 +23,12 @@ namespace RGB.NET.Devices.Novation
/// <param name="model">The represented device model.</param>
/// <param name="deviceId"></param>
/// <param name="colorCapabilities">The <see cref="T:RGB.NET.Devices.Novation.NovationColorCapabilities" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.</param>
internal NovationLaunchpadRGBDeviceInfo(string model, int deviceId, NovationColorCapabilities colorCapabilities)
internal NovationLaunchpadRGBDeviceInfo(string model, int deviceId, NovationColorCapabilities colorCapabilities,
LedIdMappings ledIdMapping)
: base(RGBDeviceType.LedMatrix, model, deviceId, colorCapabilities)
{ }
{
this.LedIdMapping = ledIdMapping;
}
#endregion
}