mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Added stub-novation-library for launchpad support
This commit is contained in:
parent
568a0e9b02
commit
f654f825f7
30
NuGet/RGB.NET.Devices.Novation.nuspec
Normal file
30
NuGet/RGB.NET.Devices.Novation.nuspec
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>RGB.NET.Devices.Novation</id>
|
||||
<title>RGB.NET.Devices.Novation</title>
|
||||
<version>1.0.0.0</version>
|
||||
<authors>Darth Affe</authors>
|
||||
<owners>Darth Affe</owners>
|
||||
<projectUrl>https://github.com/DarthAffe/RGB.NET</projectUrl>
|
||||
<licenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</licenseUrl>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>Novation-Device-Implementations of RGB.NET</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<summary>Novation-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</summary>
|
||||
<copyright>Copyright © Wyrez 2017</copyright>
|
||||
<language>en-US</language>
|
||||
<dependencies>
|
||||
<dependency id="RGB.NET.Core" version="1.0" />
|
||||
<dependency id="System.ValueTuple" version="4.3.1" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\bin\RGB.NET.Devices.Novation.dll" target="lib\net45\RGB.NET.Devices.Novation.dll" />
|
||||
<file src="..\bin\RGB.NET.Devices.Novation.pdb" target="lib\net45\RGB.NET.Devices.Novation.pdb" />
|
||||
<file src="..\bin\RGB.NET.Devices.Novation.xml" target="lib\net45\RGB.NET.Devices.Novation.xml" />
|
||||
<file src="..\RGB.NET.Devices.Novation\**\*.cs" target="src" exclude="..\RGB.NET.Devices.Novation\obj\**\*.*" />
|
||||
<file src="..\RGB.NET.Devices.Novation\Images\**\*.*" target="build\net45\resources\Images\" />
|
||||
<file src="..\RGB.NET.Devices.Novation\Layouts\**\*.*" target="build\net45\resources\Layouts\" />
|
||||
</files>
|
||||
</package>
|
||||
@ -33,6 +33,11 @@
|
||||
/// <summary>
|
||||
/// Represents a LED-stipe.
|
||||
/// </summary>
|
||||
LedStripe
|
||||
LedStripe,
|
||||
|
||||
/// <summary>
|
||||
/// Represents a LED-matrix
|
||||
/// </summary>
|
||||
LedMatrix
|
||||
}
|
||||
}
|
||||
|
||||
106
RGB.NET.Devices.Novation/Enum/NovationLedIds.cs
Normal file
106
RGB.NET.Devices.Novation/Enum/NovationLedIds.cs
Normal file
@ -0,0 +1,106 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains list of all LEDs available for all Novation devices.
|
||||
/// They are represented as Hex 0x[00][11] where [00] is the status flag, [1] the id of the led.
|
||||
/// </summary>
|
||||
//TODO DarthAffe 15.08.2017: Check if this is really correct for all devices
|
||||
public enum NovationLedIds
|
||||
{
|
||||
Invalid = -1,
|
||||
|
||||
Grid1 = 0x9000,
|
||||
Grid2 = 0x9001,
|
||||
Grid3 = 0x9002,
|
||||
Grid4 = 0x9003,
|
||||
Grid5 = 0x9004,
|
||||
Grid6 = 0x9005,
|
||||
Grid7 = 0x9006,
|
||||
Grid8 = 0x9007,
|
||||
|
||||
Grid9 = 0x9010,
|
||||
Grid10 = 0x9011,
|
||||
Grid11 = 0x9012,
|
||||
Grid12 = 0x9013,
|
||||
Grid13 = 0x9014,
|
||||
Grid14 = 0x9015,
|
||||
Grid15 = 0x9016,
|
||||
Grid16 = 0x9017,
|
||||
|
||||
Grid17 = 0x9020,
|
||||
Grid18 = 0x9021,
|
||||
Grid19 = 0x9022,
|
||||
Grid20 = 0x9023,
|
||||
Grid21 = 0x9024,
|
||||
Grid22 = 0x9025,
|
||||
Grid23 = 0x9026,
|
||||
Grid24 = 0x9027,
|
||||
|
||||
Grid25 = 0x9030,
|
||||
Grid26 = 0x9031,
|
||||
Grid27 = 0x9032,
|
||||
Grid28 = 0x9033,
|
||||
Grid29 = 0x9034,
|
||||
Grid30 = 0x9035,
|
||||
Grid31 = 0x9036,
|
||||
Grid32 = 0x9037,
|
||||
|
||||
Grid33 = 0x9040,
|
||||
Grid34 = 0x9041,
|
||||
Grid35 = 0x9042,
|
||||
Grid36 = 0x9043,
|
||||
Grid37 = 0x9044,
|
||||
Grid38 = 0x9045,
|
||||
Grid39 = 0x9046,
|
||||
Grid40 = 0x9047,
|
||||
|
||||
Grid41 = 0x9050,
|
||||
Grid42 = 0x9051,
|
||||
Grid43 = 0x9052,
|
||||
Grid44 = 0x9053,
|
||||
Grid45 = 0x9054,
|
||||
Grid46 = 0x9055,
|
||||
Grid47 = 0x9056,
|
||||
Grid48 = 0x9057,
|
||||
|
||||
Grid49 = 0x9060,
|
||||
Grid50 = 0x9061,
|
||||
Grid51 = 0x9062,
|
||||
Grid52 = 0x9063,
|
||||
Grid53 = 0x9064,
|
||||
Grid54 = 0x9065,
|
||||
Grid55 = 0x9066,
|
||||
Grid56 = 0x9067,
|
||||
|
||||
Grid57 = 0x9070,
|
||||
Grid58 = 0x9071,
|
||||
Grid59 = 0x9072,
|
||||
Grid60 = 0x9073,
|
||||
Grid61 = 0x9074,
|
||||
Grid62 = 0x9075,
|
||||
Grid63 = 0x9076,
|
||||
Grid64 = 0x9077,
|
||||
|
||||
Up = 0xB068,
|
||||
Down = 0xB069,
|
||||
Left = 0xB06A,
|
||||
Right = 0xB06B,
|
||||
Session = 0xB06C,
|
||||
User1 = 0xB06D,
|
||||
User2 = 0xB06E,
|
||||
Mix = 0xB06F,
|
||||
|
||||
Scene1 = 0x9009,
|
||||
Scene2 = 0x9019,
|
||||
Scene3 = 0x9029,
|
||||
Scene4 = 0x9039,
|
||||
Scene5 = 0x9049,
|
||||
Scene6 = 0x9059,
|
||||
Scene7 = 0x9069,
|
||||
Scene8 = 0x9079
|
||||
}
|
||||
}
|
||||
107
RGB.NET.Devices.Novation/Generic/NovationLedId.cs
Normal file
107
RGB.NET.Devices.Novation/Generic/NovationLedId.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using System.Diagnostics;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Id of a <see cref="Led"/> on a <see cref="NovationRGBDevice"/>.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{" + nameof(LedId) + "}")]
|
||||
public class NovationLedId : ILedId
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
internal readonly NovationLedIds LedId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRGBDevice Device { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsValid => LedId != NovationLedIds.Invalid;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NovationLedId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="IRGBDevice"/> the <see cref="ILedId"/> belongs to.</param>
|
||||
/// <param name="ledId">The <see cref="NovationLedId"/> of the represented <see cref="Led"/>.</param>
|
||||
public NovationLedId(IRGBDevice device, NovationLedIds ledId)
|
||||
{
|
||||
this.Device = device;
|
||||
this.LedId = ledId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Converts the Id of this <see cref="NovationLedId"/> to a human-readable string.
|
||||
/// </summary>
|
||||
/// <returns>A string that contains the Id of this <see cref="NovationLedId"/>. For example "Enter".</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return LedId.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="NovationLedId" /> and is equivalent to this <see cref="NovationLedId" />.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="NovationLedId" /> equivalent to this <see cref="NovationLedId" />; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
NovationLedId compareLedId = obj as NovationLedId;
|
||||
if (ReferenceEquals(compareLedId, null))
|
||||
return false;
|
||||
|
||||
if (ReferenceEquals(this, compareLedId))
|
||||
return true;
|
||||
|
||||
if (GetType() != compareLedId.GetType())
|
||||
return false;
|
||||
|
||||
return compareLedId.LedId == LedId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this <see cref="NovationLedId" />.
|
||||
/// </summary>
|
||||
/// <returns>An integer value that specifies the hash code for this <see cref="NovationLedId" />.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return LedId.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="NovationLedId" /> are equal.
|
||||
/// </summary>
|
||||
/// <param name="ledId1">The first <see cref="NovationLedId" /> to compare.</param>
|
||||
/// <param name="ledId2">The second <see cref="NovationLedId" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(NovationLedId ledId1, NovationLedId ledId2)
|
||||
{
|
||||
return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="NovationLedId" /> are equal.
|
||||
/// </summary>
|
||||
/// <param name="ledId1">The first <see cref="NovationLedId" /> to compare.</param>
|
||||
/// <param name="ledId2">The second <see cref="NovationLedId" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(NovationLedId ledId1, NovationLedId ledId2)
|
||||
{
|
||||
return !(ledId1 == ledId2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
121
RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
Normal file
121
RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core.Layout;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic Novation-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class NovationRGBDevice : AbstractRGBDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="NovationRGBDevice"/>.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NovationRGBDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by Novation for the device.</param>
|
||||
protected NovationRGBDevice(IRGBDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
if (InternalSize == null)
|
||||
{
|
||||
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||
InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
||||
/// </summary>
|
||||
protected abstract void InitializeLayout();
|
||||
|
||||
/// <summary>
|
||||
/// Applies the given layout.
|
||||
/// </summary>
|
||||
/// <param name="layoutPath">The file containing the layout.</param>
|
||||
/// <param name="imageLayout">The name of the layout used to get the images of the leds.</param>
|
||||
/// <param name="imageBasePath">The path images for this device are collected in.</param>
|
||||
protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath)
|
||||
{
|
||||
DeviceLayout layout = DeviceLayout.Load(layoutPath);
|
||||
if (layout != null)
|
||||
{
|
||||
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
InternalSize = new Size(layout.Width, layout.Height);
|
||||
|
||||
if (layout.Leds != null)
|
||||
foreach (LedLayout layoutLed in layout.Leds)
|
||||
{
|
||||
NovationLedIds ledId;
|
||||
if (Enum.TryParse(layoutLed.Id, true, out ledId))
|
||||
{
|
||||
Led led;
|
||||
if (LedMapping.TryGetValue(new NovationLedId(this, ledId), out led))
|
||||
{
|
||||
led.LedRectangle.Location.X = layoutLed.X;
|
||||
led.LedRectangle.Location.Y = layoutLed.Y;
|
||||
led.LedRectangle.Size.Width = layoutLed.Width;
|
||||
led.LedRectangle.Size.Height = layoutLed.Height;
|
||||
|
||||
led.Shape = layoutLed.Shape;
|
||||
led.ShapeData = layoutLed.ShapeData;
|
||||
|
||||
LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id);
|
||||
led.Image = (!string.IsNullOrEmpty(image?.Image))
|
||||
? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute)
|
||||
: new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
{
|
||||
List<Led> leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList();
|
||||
|
||||
if (leds.Count > 0)
|
||||
{
|
||||
//TODO DarthAffe 15.08.2017: Update Leds
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
//TODO DarthAffe 15.08.2017: Dispose
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
45
RGB.NET.Devices.Novation/Generic/NovationRGBDeviceInfo.cs
Normal file
45
RGB.NET.Devices.Novation/Generic/NovationRGBDeviceInfo.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic information for a Corsair-<see cref="IRGBDevice"/>.
|
||||
/// </summary>
|
||||
public class NovationRGBDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBDeviceType DeviceType { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Manufacturer => "Novation";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Model { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Uri Image { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="NovationRGBDeviceInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="model">The represented device model.</param>
|
||||
internal NovationRGBDeviceInfo(RGBDeviceType deviceType, string model)
|
||||
{
|
||||
this.DeviceType = deviceType;
|
||||
this.Model = model;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
47
RGB.NET.Devices.Novation/Helper/NovationLedIdsExtension.cs
Normal file
47
RGB.NET.Devices.Novation/Helper/NovationLedIdsExtension.cs
Normal file
@ -0,0 +1,47 @@
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Offers some extensions and helper-methods for NovationLedIds related things.
|
||||
/// </summary>
|
||||
public static class NovationLedIdsExtension
|
||||
{
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status-flag associated with the id.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The <see cref="NovationLedIds"/> whose status-flag should be determinated.</param>
|
||||
/// <returns>The status-flag of the <see cref="NovationLedIds"/>.</returns>
|
||||
public static int GetStatus(this NovationLedIds ledId) => ((int)ledId & 0xFF00) >> 8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id associated with the id.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The <see cref="NovationLedIds"/> whose idshould be determinated.</param>
|
||||
/// <returns>The id of the <see cref="NovationLedIds"/>.</returns>
|
||||
public static int GetId(this NovationLedIds ledId) => (int)ledId & 0x00FF;
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedIds"/> is a grid-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedIds"/> 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 NovationLedIds ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) < 0x08);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedIds"/> is a scene-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedIds"/> 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 NovationLedIds ledId) => (ledId.GetStatus() == 0x90) && ((ledId.GetId() / 0x10) < 0x08) && ((ledId.GetId() % 0x10) == 0x09);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if the given <see cref="NovationLedIds"/> is custom-button.
|
||||
/// </summary>
|
||||
/// <param name="ledId">the <see cref="NovationLedIds"/> 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 NovationLedIds ledId) => (ledId.GetStatus() == 0xB0) && ((ledId.GetId() / 0x10) == 0x06) && ((ledId.GetId() % 0x10) > 0x07);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Novation launchpad.
|
||||
/// </summary>
|
||||
public class NovationLaunchpadRGBDevice : NovationRGBDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="NovationLaunchpadRGBDevice"/>.
|
||||
/// </summary>
|
||||
public NovationLaunchpadRGBDeviceInfo LaunchpadDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NovationLaunchpadRGBDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by Novation for the launchpad</param>
|
||||
internal NovationLaunchpadRGBDevice(NovationLaunchpadRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.LaunchpadDeviceInfo = info;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 15.08.2017: Check if all launchpads are using the same basic layout
|
||||
//TODO DarthAffe 15.08.2017: Measure button size
|
||||
const int BUTTON_SIZE = 16;
|
||||
foreach (NovationLedIds ledId in Enum.GetValues(typeof(NovationLedIds)))
|
||||
{
|
||||
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(new NovationLedId(this, ledId), rectangle);
|
||||
}
|
||||
|
||||
string model = LaunchpadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
|
||||
$@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="NovationLaunchpadRGBDevice"/>.
|
||||
/// </summary>
|
||||
public class NovationLaunchpadRGBDeviceInfo : NovationRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="NovationLaunchpadRGBDeviceInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="model">The represented device model.</param>
|
||||
internal NovationLaunchpadRGBDeviceInfo(string model)
|
||||
: base(RGBDeviceType.LedMatrix, model)
|
||||
{
|
||||
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Novation\Launchpads\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
96
RGB.NET.Devices.Novation/NovationDeviceProvider.cs
Normal file
96
RGB.NET.Devices.Novation/NovationDeviceProvider.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
public class NovationDeviceProvider : IRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private static NovationDeviceProvider _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="NovationDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static NovationDeviceProvider Instance => _instance ?? new NovationDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the SDK is initialized and ready to use.
|
||||
/// </summary>
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the application has exclusive access to the SDK or not.
|
||||
/// </summary>
|
||||
public bool HasExclusiveAccess => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NovationDeviceProvider"/> class.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
private NovationDeviceProvider()
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instanc of type {nameof(NovationDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public bool Initialize(bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
|
||||
{
|
||||
IsInitialized = false;
|
||||
|
||||
try
|
||||
{
|
||||
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||
|
||||
//TODO DarthAffe 15.08.2017: Get devices
|
||||
// foreach ...
|
||||
try
|
||||
{
|
||||
NovationRGBDevice device = null;
|
||||
device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo("Launchpad S"));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (throwExceptions)
|
||||
throw;
|
||||
//else
|
||||
//continue;
|
||||
}
|
||||
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (throwExceptions)
|
||||
throw;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ResetDevices()
|
||||
{
|
||||
//TODO DarthAffe 15.08.2017: Is this possible?
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
35
RGB.NET.Devices.Novation/Properties/AssemblyInfo.cs
Normal file
35
RGB.NET.Devices.Novation/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RGB.NET.Devices.Novation")]
|
||||
[assembly: AssemblyDescription("Novation-Device-Implementations of RGB.NET")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Wyrez")]
|
||||
[assembly: AssemblyProduct("RGB.NET.Devices.Novation")]
|
||||
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("dda8c4c2-8abf-4fa0-9af9-c47ad0bfe47d")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
72
RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj
Normal file
72
RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DB2911F6-404C-4BC8-B35F-232A7450755F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RGB.NET.Devices.Novation</RootNamespace>
|
||||
<AssemblyName>RGB.NET.Devices.Novation</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\bin\RGB.NET.Devices.Novation.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\bin\RGB.NET.Devices.Novation.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enum\NovationLedIds.cs" />
|
||||
<Compile Include="Generic\NovationLedId.cs" />
|
||||
<Compile Include="Generic\NovationRGBDevice.cs" />
|
||||
<Compile Include="Generic\NovationRGBDeviceInfo.cs" />
|
||||
<Compile Include="Helper\NovationLedIdsExtension.cs" />
|
||||
<Compile Include="Launchpad\NovationLaunchpadRGBDevice.cs" />
|
||||
<Compile Include="Launchpad\NovationLaunchpadRGBDeviceInfo.cs" />
|
||||
<Compile Include="NovationDeviceProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Images\Novation\" />
|
||||
<Folder Include="Layouts\Novation\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj">
|
||||
<Project>{5a4f9a75-75fe-47cd-90e5-914d5b20d232}</Project>
|
||||
<Name>RGB.NET.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -0,0 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=launchpad/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
4
RGB.NET.Devices.Novation/packages.config
Normal file
4
RGB.NET.Devices.Novation/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{06416566
|
||||
NuGet\RGB.NET.Devices.CoolerMaster.nuspec = NuGet\RGB.NET.Devices.CoolerMaster.nuspec
|
||||
NuGet\RGB.NET.Devices.Corsair.nuspec = NuGet\RGB.NET.Devices.Corsair.nuspec
|
||||
NuGet\RGB.NET.Devices.Logitech.nuspec = NuGet\RGB.NET.Devices.Logitech.nuspec
|
||||
NuGet\RGB.NET.Devices.Novation.nuspec = NuGet\RGB.NET.Devices.Novation.nuspec
|
||||
NuGet\RGB.NET.Effects.nuspec = NuGet\RGB.NET.Effects.nuspec
|
||||
NuGet\RGB.NET.Groups.nuspec = NuGet\RGB.NET.Groups.nuspec
|
||||
NuGet\RGB.NET.Input.Corsair.nuspec = NuGet\RGB.NET.Input.Corsair.nuspec
|
||||
@ -47,6 +48,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Logitech",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.CoolerMaster", "RGB.NET.Devices.CoolerMaster\RGB.NET.Devices.CoolerMaster.csproj", "{85609427-D433-44E2-A249-CE890B66D845}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Novation", "RGB.NET.Devices.Novation\RGB.NET.Devices.Novation.csproj", "{DB2911F6-404C-4BC8-B35F-232A7450755F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -93,6 +96,10 @@ Global
|
||||
{85609427-D433-44E2-A249-CE890B66D845}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85609427-D433-44E2-A249-CE890B66D845}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85609427-D433-44E2-A249-CE890B66D845}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DB2911F6-404C-4BC8-B35F-232A7450755F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DB2911F6-404C-4BC8-B35F-232A7450755F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DB2911F6-404C-4BC8-B35F-232A7450755F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DB2911F6-404C-4BC8-B35F-232A7450755F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -107,5 +114,6 @@ Global
|
||||
{8D6C4FE6-0046-4E98-876F-4C0B87249989} = {BD7C9994-1747-4595-9C21-298E8FDCB657}
|
||||
{E7B2F174-FCC6-4FC7-9970-3138B5F4C921} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25}
|
||||
{85609427-D433-44E2-A249-CE890B66D845} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25}
|
||||
{DB2911F6-404C-4BC8-B35F-232A7450755F} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user