mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Added support for novation launchpad mk2
This commit is contained in:
1 parent
fd2e9a0049
commit
f91d5e5060
15 files changed
+474
-272
No files matched your search
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
internal static class DictionaryExtension
|
||||
{
|
||||
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary) => dictionary.ToDictionary(x => x.Value, x => x.Key);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,13 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <returns>The value of the <see cref="ColorCapabilityAttribute"/> of the source.</returns>
|
||||
internal static NovationColorCapabilities GetColorCapability(this Enum source) => source.GetAttribute<ColorCapabilityAttribute>()?.Capability ?? NovationColorCapabilities.None;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the <see cref="LedIdMappingAttribute"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">The enum value to get the description from.</param>
|
||||
/// <returns>The value of the <see cref="LedIdMappingAttribute"/> of the source.</returns>
|
||||
internal static LedIdMappings GetLedIdMapping(this Enum source) => source.GetAttribute<LedIdMappingAttribute>()?.LedIdMapping ?? LedIdMappings.Current;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attribute of type T.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Offers some extensions and helper-methods for NovationLedId related things.
|
||||
/// </summary>
|
||||
public static class NovationLedIdExtension
|
||||
{
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status-flag associated with the id.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The <see cref="NovationLedId"/> whose status-flag should be determinated.</param>
|
||||
/// <returns>The status-flag of the <see cref="NovationLedId"/>.</returns>
|
||||
public static int GetStatus(this NovationLedId ledId) => ((int)ledId & 0xFF00) >> 8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id associated with the id.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The <see cref="NovationLedId"/> whose idshould be determinated.</param>
|
||||
/// <returns>The id of the <see cref="NovationLedId"/>.</returns>
|
||||
public static int GetId(this NovationLedId ledId) => (int)ledId & 0x00FF;
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedId"/> is a grid-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedId"/> to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId" /> is a grid-button; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsGrid(this NovationLedId ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) < 0x08);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedId"/> is a scene-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedId"/> to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId" /> is a scene-button; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsScene(this NovationLedId ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) == 0x09);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedId"/> is custom-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedId"/> to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId" /> is a custom-button; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsCustom(this NovationLedId ledId) => (ledId.GetStatus() == 0xB0) && ((ledId.GetId() / 0x10) == 0x06) && ((ledId.GetId() % 0x10) > 0x07);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user