mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Merge pull request #109 from DarthAffe/Development
Merge development to master
This commit is contained in:
commit
0b76199582
@ -32,7 +32,11 @@ namespace RGB.NET.Core
|
|||||||
public Point Location
|
public Point Location
|
||||||
{
|
{
|
||||||
get => _location;
|
get => _location;
|
||||||
set => SetProperty(ref _location, value);
|
set
|
||||||
|
{
|
||||||
|
if (SetProperty(ref _location, value))
|
||||||
|
UpdateActualData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Size _size = Size.Invalid;
|
private Size _size = Size.Invalid;
|
||||||
|
|||||||
@ -14,6 +14,8 @@ namespace RGB.NET.Core
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
|
private object _lock = new object();
|
||||||
|
|
||||||
private CancellationTokenSource _updateTokenSource;
|
private CancellationTokenSource _updateTokenSource;
|
||||||
private CancellationToken _updateToken;
|
private CancellationToken _updateToken;
|
||||||
private Task _updateTask;
|
private Task _updateTask;
|
||||||
@ -58,6 +60,8 @@ namespace RGB.NET.Core
|
|||||||
/// Starts the trigger if needed, causing it to performing updates.
|
/// Starts the trigger if needed, causing it to performing updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (_updateTask == null)
|
if (_updateTask == null)
|
||||||
{
|
{
|
||||||
@ -66,20 +70,25 @@ namespace RGB.NET.Core
|
|||||||
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
_updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops the trigger if running, causing it to stop performing updates.
|
/// Stops the trigger if running, causing it to stop performing updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async void Stop()
|
public void Stop()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (_updateTask != null)
|
if (_updateTask != null)
|
||||||
{
|
{
|
||||||
_updateTokenSource.Cancel();
|
_updateTokenSource.Cancel();
|
||||||
await _updateTask;
|
// ReSharper disable once MethodSupportsCancellation
|
||||||
|
_updateTask.Wait();
|
||||||
_updateTask.Dispose();
|
_updateTask.Dispose();
|
||||||
_updateTask = null;
|
_updateTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateLoop()
|
private void UpdateLoop()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,6 +62,8 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
{
|
{
|
||||||
if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase))
|
||||||
return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||||
|
else if (string.Equals(DeviceInfo.Model, "M65 RGB ELITE", StringComparison.OrdinalIgnoreCase))
|
||||||
|
return MouseIdMapping.M65_RGB_ELITE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||||
else
|
else
|
||||||
return MouseIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
return MouseIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,5 +21,11 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
{ LedId.Mouse2, CorsairLedId.B2 },
|
{ LedId.Mouse2, CorsairLedId.B2 },
|
||||||
{ LedId.Mouse3, CorsairLedId.B5 },
|
{ LedId.Mouse3, CorsairLedId.B5 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
internal static readonly Dictionary<LedId, CorsairLedId> M65_RGB_ELITE = new Dictionary<LedId, CorsairLedId>
|
||||||
|
{
|
||||||
|
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||||
|
{ LedId.Mouse2, CorsairLedId.B3 },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,10 @@ namespace RGB.NET.Devices.Logitech.HID
|
|||||||
= new List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)>
|
= new List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)>
|
||||||
{
|
{
|
||||||
("G910", RGBDeviceType.Keyboard, 0xC32B, 0, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout
|
("G910", RGBDeviceType.Keyboard, 0xC32B, 0, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout
|
||||||
|
("G910v2", RGBDeviceType.Keyboard, 0xC335, 0, "DE", @"Keyboards\G910\UK"),
|
||||||
("G810", RGBDeviceType.Keyboard, 0xC337, 0, "DE", @"Keyboards\G810\UK"),
|
("G810", RGBDeviceType.Keyboard, 0xC337, 0, "DE", @"Keyboards\G810\UK"),
|
||||||
("G610", RGBDeviceType.Keyboard, 0xC333, 0, "DE", @"Keyboards\G610\UK"),
|
("G610", RGBDeviceType.Keyboard, 0xC333, 0, "DE", @"Keyboards\G610\UK"),
|
||||||
|
("G512", RGBDeviceType.Keyboard, 0xC33C, 0, "DE", @"Keyboards\G512\UK"),
|
||||||
("G410", RGBDeviceType.Keyboard, 0xC330, 0, "DE", @"Keyboards\G410\UK"),
|
("G410", RGBDeviceType.Keyboard, 0xC330, 0, "DE", @"Keyboards\G410\UK"),
|
||||||
("G213", RGBDeviceType.Keyboard, 0xC336, 0, "DE", @"Keyboards\G213\UK"),
|
("G213", RGBDeviceType.Keyboard, 0xC336, 0, "DE", @"Keyboards\G213\UK"),
|
||||||
("Pro", RGBDeviceType.Keyboard, 0xC339, 0, "DE", @"Keyboards\Pro\UK"),
|
("Pro", RGBDeviceType.Keyboard, 0xC339, 0, "DE", @"Keyboards\Pro\UK"),
|
||||||
@ -29,8 +31,6 @@ namespace RGB.NET.Devices.Logitech.HID
|
|||||||
{
|
{
|
||||||
("G19", RGBDeviceType.Keyboard, 0xC228, 0, "DE", @"Keyboards\G19\UK"),
|
("G19", RGBDeviceType.Keyboard, 0xC228, 0, "DE", @"Keyboards\G19\UK"),
|
||||||
("G19s", RGBDeviceType.Keyboard, 0xC229, 0, "DE", @"Keyboards\G19s\UK"),
|
("G19s", RGBDeviceType.Keyboard, 0xC229, 0, "DE", @"Keyboards\G19s\UK"),
|
||||||
("G502", RGBDeviceType.Mouse, 0xC332, 0, "default", @"Mice\G502"),
|
|
||||||
("G502 HERO", RGBDeviceType.Mouse, 0xC08B, 0, "default", @"Mice\G502"),
|
|
||||||
("G600", RGBDeviceType.Mouse, 0xC24A, 0, "default", @"Mice\G600"),
|
("G600", RGBDeviceType.Mouse, 0xC24A, 0, "default", @"Mice\G600"),
|
||||||
("G300s", RGBDeviceType.Mouse, 0xC246, 0, "default", @"Mice\G300s"),
|
("G300s", RGBDeviceType.Mouse, 0xC246, 0, "default", @"Mice\G300s"),
|
||||||
("G510", RGBDeviceType.Keyboard, 0xC22D, 0, "DE", @"Keyboards\G510\UK"),
|
("G510", RGBDeviceType.Keyboard, 0xC22D, 0, "DE", @"Keyboards\G510\UK"),
|
||||||
@ -46,15 +46,19 @@ namespace RGB.NET.Devices.Logitech.HID
|
|||||||
private static readonly List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)> ZONE_DEVICES
|
private static readonly List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)> ZONE_DEVICES
|
||||||
= new List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)>
|
= new List<(string model, RGBDeviceType deviceType, int id, int zones, string imageLayout, string layoutPath)>
|
||||||
{
|
{
|
||||||
|
("G213", RGBDeviceType.Keyboard, 0xC336, 5, "default", @"Keyboards\G213"),
|
||||||
("G903", RGBDeviceType.Mouse, 0xC086, 2, "default", @"Mice\G903"),
|
("G903", RGBDeviceType.Mouse, 0xC086, 2, "default", @"Mice\G903"),
|
||||||
("G900", RGBDeviceType.Mouse, 0xC539, 2, "default", @"Mice\G900"),
|
("G900", RGBDeviceType.Mouse, 0xC539, 2, "default", @"Mice\G900"),
|
||||||
("G703", RGBDeviceType.Mouse, 0xC087, 2, "default", @"Mice\G703"),
|
("G703", RGBDeviceType.Mouse, 0xC087, 2, "default", @"Mice\G703"),
|
||||||
|
("G502 HERO", RGBDeviceType.Mouse, 0xC08B, 2, "default", @"Mice\G502"),
|
||||||
|
("G502", RGBDeviceType.Mouse, 0xC332, 2, "default", @"Mice\G502"),
|
||||||
("G403", RGBDeviceType.Mouse, 0xC083, 2, "default", @"Mice\G403"),
|
("G403", RGBDeviceType.Mouse, 0xC083, 2, "default", @"Mice\G403"),
|
||||||
("G303", RGBDeviceType.Mouse, 0xC080, 2, "default", @"Mice\G303"),
|
("G303", RGBDeviceType.Mouse, 0xC080, 2, "default", @"Mice\G303"),
|
||||||
("G203", RGBDeviceType.Mouse, 0xC084, 1, "default", @"Mice\G203"),
|
("G203", RGBDeviceType.Mouse, 0xC084, 1, "default", @"Mice\G203"),
|
||||||
("G Pro", RGBDeviceType.Mouse, 0xC085, 1, "default", @"Mice\GPro"),
|
("G Pro", RGBDeviceType.Mouse, 0xC085, 1, "default", @"Mice\GPro"),
|
||||||
("G633", RGBDeviceType.Headset, 0x0A5C, 2, "default", @"Headsets\G633"),
|
("G633", RGBDeviceType.Headset, 0x0A5C, 2, "default", @"Headsets\G633"),
|
||||||
("G933", RGBDeviceType.Headset, 0x0A5B, 2, "default", @"Headsets\G933"),
|
("G933", RGBDeviceType.Headset, 0x0A5B, 2, "default", @"Headsets\G933"),
|
||||||
|
("G935", RGBDeviceType.Headset, 0x0A87, 2, "default", @"Headsets\G935"),
|
||||||
("G560", RGBDeviceType.Speaker, 0x0A78, 4, "default", @"Speakers\G560"),
|
("G560", RGBDeviceType.Speaker, 0x0A78, 4, "default", @"Speakers\G560"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ namespace RGB.NET.Devices.Msi.Exceptions
|
|||||||
/// <param name="errorCode">The raw error code provided by the SDK.</param>
|
/// <param name="errorCode">The raw error code provided by the SDK.</param>
|
||||||
/// <param name="description">The text-description of the error.</param>
|
/// <param name="description">The text-description of the error.</param>
|
||||||
public MysticLightException(int errorCode, string description)
|
public MysticLightException(int errorCode, string description)
|
||||||
|
: base($"MSI error code {errorCode} ({description})")
|
||||||
{
|
{
|
||||||
this.ErrorCode = errorCode;
|
this.ErrorCode = errorCode;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
namespace RGB.NET.Devices.Msi
|
namespace RGB.NET.Devices.Msi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a msi RGB-device.
|
/// Represents a MSI RGB-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal interface IMsiRGBDevice : IRGBDevice
|
internal interface IMsiRGBDevice : IRGBDevice
|
||||||
{
|
{
|
||||||
void Initialize();
|
void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs
Normal file
45
RGB.NET.Devices.Msi/Generic/MsiDeviceUpdateQueue.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Msi.Native;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Msi
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the update-queue performing updates for MSI devices.
|
||||||
|
/// </summary>
|
||||||
|
public class MsiDeviceUpdateQueue : UpdateQueue
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
private string _deviceType;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MsiDeviceUpdateQueue"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="updateTrigger">The update trigger used by this queue.</param>
|
||||||
|
/// <param name="deviceType">The device-type used to identify the device.</param>
|
||||||
|
public MsiDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, string deviceType)
|
||||||
|
: base(updateTrigger)
|
||||||
|
{
|
||||||
|
this._deviceType = deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Update(Dictionary<object, Color> dataSet)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<object, Color> data in dataSet)
|
||||||
|
_MsiSDK.SetLedColor(_deviceType, (int)data.Key, data.Value.GetR(), data.Value.GetG(), data.Value.GetB());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.Msi.Native;
|
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Msi
|
namespace RGB.NET.Devices.Msi
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
|
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
|
||||||
/// <inheritdoc cref="IMsiRGBDevice" />
|
/// <inheritdoc cref="IMsiRGBDevice" />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic Msi-device. (keyboard, mouse, headset, mousepad).
|
/// Represents a generic MSI-device. (keyboard, mouse, headset, mousepad).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class MsiRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IMsiRGBDevice
|
public abstract class MsiRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IMsiRGBDevice
|
||||||
where TDeviceInfo : MsiRGBDeviceInfo
|
where TDeviceInfo : MsiRGBDeviceInfo
|
||||||
@ -21,6 +20,12 @@ namespace RGB.NET.Devices.Msi
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override TDeviceInfo DeviceInfo { get; }
|
public override TDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the update queue performing updates for this device.
|
||||||
|
/// </summary>
|
||||||
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
|
protected MsiDeviceUpdateQueue DeviceUpdateQueue { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -28,7 +33,7 @@ namespace RGB.NET.Devices.Msi
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MsiRGBDevice{TDeviceInfo}"/> class.
|
/// Initializes a new instance of the <see cref="MsiRGBDevice{TDeviceInfo}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">The generic information provided by Msi for the device.</param>
|
/// <param name="info">The generic information provided by MSI for the device.</param>
|
||||||
protected MsiRGBDevice(TDeviceInfo info)
|
protected MsiRGBDevice(TDeviceInfo info)
|
||||||
{
|
{
|
||||||
this.DeviceInfo = info;
|
this.DeviceInfo = info;
|
||||||
@ -41,9 +46,11 @@ namespace RGB.NET.Devices.Msi
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the device.
|
/// Initializes the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize()
|
public void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount)
|
||||||
{
|
{
|
||||||
InitializeLayout();
|
DeviceUpdateQueue = updateQueue;
|
||||||
|
|
||||||
|
InitializeLayout(ledCount);
|
||||||
|
|
||||||
if (Size == Size.Invalid)
|
if (Size == Size.Invalid)
|
||||||
{
|
{
|
||||||
@ -55,20 +62,11 @@ namespace RGB.NET.Devices.Msi
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void InitializeLayout();
|
protected abstract void InitializeLayout(int ledCount);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||||
{
|
=> DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is int)));
|
||||||
List<Led> leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList();
|
|
||||||
|
|
||||||
if (leds.Count > 0)
|
|
||||||
{
|
|
||||||
string deviceType = DeviceInfo.MsiDeviceType;
|
|
||||||
foreach (Led led in leds)
|
|
||||||
_MsiSDK.SetLedColor(deviceType, (int)led.CustomData, led.Color.GetR(), led.Color.GetG(), led.Color.GetB());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace RGB.NET.Devices.Msi
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic information for a Corsair-<see cref="T:RGB.NET.Core.IRGBDevice" />.
|
/// Represents a generic information for a MSI-<see cref="T:RGB.NET.Core.IRGBDevice" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MsiRGBDeviceInfo : IRGBDeviceInfo
|
public class MsiRGBDeviceInfo : IRGBDeviceInfo
|
||||||
{
|
{
|
||||||
|
|||||||
56
RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs
Normal file
56
RGB.NET.Devices.Msi/GraphicsCard/MsiGraphicsCardRGBDevice.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Msi.Native;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Msi
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents MSI VGA adapters.
|
||||||
|
/// </summary>
|
||||||
|
public class MsiGraphicsCardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiGraphicsCardRGBDevice" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The specific information provided by MSI for graphics cards.</param>
|
||||||
|
internal MsiGraphicsCardRGBDevice(MsiRGBDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void InitializeLayout(int ledCount)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ledCount; i++)
|
||||||
|
{
|
||||||
|
//Hex3l: Should it be configurable in order to provide style access?
|
||||||
|
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||||
|
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||||
|
const string LED_STYLE = "Steady";
|
||||||
|
|
||||||
|
//Hex3l: Every led is a video card adapter.
|
||||||
|
|
||||||
|
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
|
||||||
|
InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
|
||||||
|
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void SyncBack()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
54
RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs
Normal file
54
RGB.NET.Devices.Msi/Mainboard/MsiMainboardRGBDevice.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Msi.Native;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Msi
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a MSI mainboard.
|
||||||
|
/// </summary>
|
||||||
|
public class MsiMainboardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiMainboardRGBDevice" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The specific information provided by MSI for the mainboard.</param>
|
||||||
|
internal MsiMainboardRGBDevice(MsiRGBDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void InitializeLayout(int ledCount)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ledCount; i++)
|
||||||
|
{
|
||||||
|
//Hex3l: Should it be configurable in order to provide style access?
|
||||||
|
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||||
|
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||||
|
const string LED_STYLE = "Steady";
|
||||||
|
|
||||||
|
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
|
||||||
|
InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
|
||||||
|
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void SyncBack()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Msi
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device provider responsible for Cooler Master devices.
|
/// Represents a device provider responsible for MSI devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MsiDeviceProvider : IRGBDeviceProvider
|
public class MsiDeviceProvider : IRGBDeviceProvider
|
||||||
{
|
{
|
||||||
@ -62,6 +62,11 @@ namespace RGB.NET.Devices.Msi
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
|
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for corsair devices.
|
||||||
|
/// </summary>
|
||||||
|
public DeviceUpdateTrigger UpdateTrigger { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -74,6 +79,8 @@ namespace RGB.NET.Devices.Msi
|
|||||||
{
|
{
|
||||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}");
|
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}");
|
||||||
_instance = this;
|
_instance = this;
|
||||||
|
|
||||||
|
UpdateTrigger = new DeviceUpdateTrigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -87,6 +94,8 @@ namespace RGB.NET.Devices.Msi
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
UpdateTrigger?.Stop();
|
||||||
|
|
||||||
_MsiSDK.Reload();
|
_MsiSDK.Reload();
|
||||||
|
|
||||||
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||||
@ -102,11 +111,35 @@ namespace RGB.NET.Devices.Msi
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//TODO DarthAffe 11.11.2017: What is this deviceType? Find someone to try that out
|
string deviceType = deviceTypes[i];
|
||||||
|
int ledCount = ledCounts[i];
|
||||||
|
|
||||||
|
//Hex3l: MSI_MB provide access to the motherboard "leds" where a led must be intended as a led header (JRGB, JRAINBOW etc..) (Tested on MSI X570 Unify)
|
||||||
|
if (deviceType.Equals("MSI_MB"))
|
||||||
|
{
|
||||||
|
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||||
|
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "Msi", "Motherboard"));
|
||||||
|
motherboard.Initialize(updateQueue, ledCount);
|
||||||
|
devices.Add(motherboard);
|
||||||
|
}
|
||||||
|
else if (deviceType.Equals("MSI_VGA"))
|
||||||
|
{
|
||||||
|
//Hex3l: Every led under MSI_VGA should be a different graphics card. Handling all the cards together seems a good way to avoid overlapping of leds
|
||||||
|
//Hex3l: The led name is the name of the card (e.g. NVIDIA GeForce RTX 2080 Ti) we could provide it in device info.
|
||||||
|
|
||||||
|
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||||
|
IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "Msi", "GraphicsCard"));
|
||||||
|
graphicscard.Initialize(updateQueue, ledCount);
|
||||||
|
devices.Add(graphicscard);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO DarthAffe 22.02.2020: Add other devices
|
||||||
}
|
}
|
||||||
catch { if (throwExceptions) throw; }
|
catch { if (throwExceptions) throw; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTrigger?.Start();
|
||||||
|
|
||||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||||
IsInitialized = true;
|
IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
namespace RGB.NET.Devices.Msi
|
namespace RGB.NET.Devices.Msi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device provider loaded used to dynamically load msi devices into an application.
|
/// Represents a device provider loaded used to dynamically load MSI devices into an application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MsiDeviceProviderLoader : IRGBDeviceProviderLoader
|
public class MsiDeviceProviderLoader : IRGBDeviceProviderLoader
|
||||||
{
|
{
|
||||||
|
|||||||
@ -110,51 +110,104 @@ namespace RGB.NET.Devices.Msi.Native
|
|||||||
private delegate int InitializePointer();
|
private delegate int InitializePointer();
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetDeviceInfoPointer(out string[] pDevType, out int[] pLedCount);
|
private delegate int GetDeviceInfoPointer(
|
||||||
|
[Out, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pDevType,
|
||||||
|
[Out, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pLedCount);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedInfoPointer(string type, int index, out string pName, out string[] pLedStyles);
|
private delegate int GetLedInfoPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.BStr)] out string pName,
|
||||||
|
[Out, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pLedStyles);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedColorPointer(string type, int index, out int r, out int g, out int b);
|
private delegate int GetLedColorPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int r,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int g,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int b);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedStylePointer(string type, int index, out int style);
|
private delegate int GetLedStylePointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.BStr)] out string style);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedMaxBrightPointer(string type, int index, out int maxLevel);
|
private delegate int GetLedMaxBrightPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int maxLevel);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedBrightPointer(string type, int index, out int currentLevel);
|
private delegate int GetLedBrightPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int currentLevel);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedMaxSpeedPointer(string type, int index, out int maxSpeed);
|
private delegate int GetLedMaxSpeedPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int maxSpeed);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetLedSpeedPointer(string type, int index, out int currentSpeed);
|
private delegate int GetLedSpeedPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[Out, MarshalAs(UnmanagedType.I4)] out int currentSpeed);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int SetLedColorPointer(string type, int index, int r, int g, int b);
|
private delegate int SetLedColorPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int r,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int g,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int b);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int SetLedStylePointer(string type, int index, string style);
|
private delegate int SetLedStylePointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string style);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int SetLedBrightPointer(string type, int index, int level);
|
private delegate int SetLedBrightPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int level);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int SetLedSpeedPointer(string type, int index, int speed);
|
private delegate int SetLedSpeedPointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.BStr)] string type,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int index,
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int speed);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int GetErrorMessagePointer(int errorCode, out string pDesc);
|
private delegate int GetErrorMessagePointer(
|
||||||
|
[In, MarshalAs(UnmanagedType.I4)] int errorCode,
|
||||||
|
[Out, MarshalAs(UnmanagedType.BStr)] out string pDesc);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal static int Initialize() => _initializePointer();
|
internal static int Initialize() => _initializePointer();
|
||||||
internal static int GetDeviceInfo(out string[] pDevType, out int[] pLedCount) => _getDeviceInfoPointer(out pDevType, out pLedCount);
|
internal static int GetDeviceInfo(out string[] pDevType, out int[] pLedCount)
|
||||||
|
{
|
||||||
|
// HACK - SDK GetDeviceInfo returns a string[] for ledCount, so we'll parse that to int.
|
||||||
|
int result = _getDeviceInfoPointer(out pDevType, out string[] ledCount);
|
||||||
|
pLedCount = new int[ledCount.Length];
|
||||||
|
|
||||||
|
for (int i = 0; i < ledCount.Length; i++)
|
||||||
|
pLedCount[i] = int.Parse(ledCount[i]);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
internal static int GetLedInfo(string type, int index, out string pName, out string[] pLedStyles) => _getLedInfoPointer(type, index, out pName, out pLedStyles);
|
internal static int GetLedInfo(string type, int index, out string pName, out string[] pLedStyles) => _getLedInfoPointer(type, index, out pName, out pLedStyles);
|
||||||
internal static int GetLedColor(string type, int index, out int r, out int g, out int b) => _getLedColorPointer(type, index, out r, out g, out b);
|
internal static int GetLedColor(string type, int index, out int r, out int g, out int b) => _getLedColorPointer(type, index, out r, out g, out b);
|
||||||
internal static int GetLedStyle(string type, int index, out int style) => _getLedStylePointer(type, index, out style);
|
internal static int GetLedStyle(string type, int index, out string style) => _getLedStylePointer(type, index, out style);
|
||||||
internal static int GetLedMaxBright(string type, int index, out int maxLevel) => _getLedMaxBrightPointer(type, index, out maxLevel);
|
internal static int GetLedMaxBright(string type, int index, out int maxLevel) => _getLedMaxBrightPointer(type, index, out maxLevel);
|
||||||
internal static int GetLedBright(string type, int index, out int currentLevel) => _getLedBrightPointer(type, index, out currentLevel);
|
internal static int GetLedBright(string type, int index, out int currentLevel) => _getLedBrightPointer(type, index, out currentLevel);
|
||||||
internal static int GetLedMaxSpeed(string type, int index, out int maxSpeed) => _getLedMaxSpeedPointer(type, index, out maxSpeed);
|
internal static int GetLedMaxSpeed(string type, int index, out int maxSpeed) => _getLedMaxSpeedPointer(type, index, out maxSpeed);
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
|
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
|
||||||
<RepositoryType>Github</RepositoryType>
|
<RepositoryType>Github</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/DarthAffe/RGB.NET</RepositoryUrl>
|
<RepositoryUrl>https://github.com/DarthAffe/RGB.NET</RepositoryUrl>
|
||||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
|
|
||||||
<PackageReleaseNotes></PackageReleaseNotes>
|
<PackageReleaseNotes></PackageReleaseNotes>
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +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">
|
<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/=enum/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=graphicscard/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
11
RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs
Normal file
11
RGB.NET.Devices.Wooting/Enum/WootingDeviceType.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace RGB.NET.Devices.Wooting.Enum
|
||||||
|
{
|
||||||
|
public enum WootingDeviceType
|
||||||
|
{
|
||||||
|
/// 10 Keyless Keyboard. E.g. Wooting One
|
||||||
|
KeyboardTKL = 1,
|
||||||
|
|
||||||
|
/// Full Size keyboard. E.g. Wooting Two
|
||||||
|
Keyboard = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
21
RGB.NET.Devices.Wooting/Enum/WootingDevicesIndexes.cs
Normal file
21
RGB.NET.Devices.Wooting/Enum/WootingDevicesIndexes.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Enum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains a list of available device-indexes.
|
||||||
|
/// </summary>
|
||||||
|
public enum WootingDevicesIndexes
|
||||||
|
{
|
||||||
|
[Description("Wooting One")]
|
||||||
|
WootingOne = 0,
|
||||||
|
|
||||||
|
[Description("Wooting Two")]
|
||||||
|
WootingTwo = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
21
RGB.NET.Devices.Wooting/Enum/WootingLogicalKeyboardLayout.cs
Normal file
21
RGB.NET.Devices.Wooting/Enum/WootingLogicalKeyboardLayout.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Enum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available logical layouts for cooler master keyboards.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Based on what is available in the shop: https://wooting.store/collections/wooting-keyboards/products/wooting-two
|
||||||
|
/// </remarks>
|
||||||
|
public enum WootingLogicalKeyboardLayout
|
||||||
|
{
|
||||||
|
US = 0,
|
||||||
|
UK = 1,
|
||||||
|
DE = 2,
|
||||||
|
ND = 3
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Enum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available physical layouts for Wooting keyboards.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Shop states ANSI (US) and ISO (UK/German/Nodics) - https://wooting.store/collections/wooting-keyboards/products/wooting-two
|
||||||
|
/// </remarks>
|
||||||
|
public enum WootingPhysicalKeyboardLayout
|
||||||
|
{
|
||||||
|
US = 0,
|
||||||
|
UK = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
12
RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs
Normal file
12
RGB.NET.Devices.Wooting/Generic/IWootingRGBDevice.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Generic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a Wooting RGB-device.
|
||||||
|
/// </summary>
|
||||||
|
internal interface IWootingRGBDevice : IRGBDevice
|
||||||
|
{
|
||||||
|
void Initialize(IDeviceUpdateTrigger updateTrigger);
|
||||||
|
}
|
||||||
|
}
|
||||||
68
RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs
Normal file
68
RGB.NET.Devices.Wooting/Generic/WootingRGBDevice.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Generic
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
|
||||||
|
/// <inheritdoc cref="IWootingRGBDevice" />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a Wooting-device
|
||||||
|
/// </summary>
|
||||||
|
public abstract class WootingRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IWootingRGBDevice
|
||||||
|
where TDeviceInfo : WootingRGBDeviceInfo
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Gets information about the <see cref="T:RGB.NET.Devices.Wooting.WootingRGBDevice" />.
|
||||||
|
/// </summary>
|
||||||
|
public override TDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the update queue performing updates for this device.
|
||||||
|
/// </summary>
|
||||||
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
|
protected UpdateQueue UpdateQueue { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WootingRGBDevice{TDeviceInfo}"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The generic information provided by Wooting for the device.</param>
|
||||||
|
protected WootingRGBDevice(TDeviceInfo info)
|
||||||
|
{
|
||||||
|
this.DeviceInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the device.
|
||||||
|
/// </summary>
|
||||||
|
public void Initialize(IDeviceUpdateTrigger updateTrigger)
|
||||||
|
{
|
||||||
|
InitializeLayout();
|
||||||
|
|
||||||
|
if (Size == Size.Invalid)
|
||||||
|
{
|
||||||
|
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||||
|
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateQueue = new WootingUpdateQueue(updateTrigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void InitializeLayout();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
62
RGB.NET.Devices.Wooting/Generic/WootingRGBDeviceInfo.cs
Normal file
62
RGB.NET.Devices.Wooting/Generic/WootingRGBDeviceInfo.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Enum;
|
||||||
|
using RGB.NET.Devices.Wooting.Helper;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Generic
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a generic information for a Wooting-<see cref="T:RGB.NET.Core.IRGBDevice" />.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingRGBDeviceInfo : IRGBDeviceInfo
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public RGBDeviceType DeviceType { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string DeviceName { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Manufacturer => "Wooting";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Model { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Uri Image { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool SupportsSyncBack => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="WootingDevicesIndexes"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>.
|
||||||
|
/// </summary>
|
||||||
|
public WootingDevicesIndexes DeviceIndex { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal constructor of managed <see cref="WootingRGBDeviceInfo"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||||
|
/// <param name="deviceIndex">The <see cref="WootingDevicesIndexes"/> of the <see cref="IRGBDevice"/>.</param>
|
||||||
|
internal WootingRGBDeviceInfo(RGBDeviceType deviceType, WootingDevicesIndexes deviceIndex)
|
||||||
|
{
|
||||||
|
this.DeviceType = deviceType;
|
||||||
|
this.DeviceIndex = deviceIndex;
|
||||||
|
|
||||||
|
Model = deviceIndex.GetDescription();
|
||||||
|
DeviceName = $"{Manufacturer} {Model}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
42
RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs
Normal file
42
RGB.NET.Devices.Wooting/Generic/WootingUpdateQueue.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Native;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Generic
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the update-queue performing updates for cooler master devices.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingUpdateQueue : UpdateQueue
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WootingUpdateQueue"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="updateTrigger">The update trigger used by this queue.</param>
|
||||||
|
public WootingUpdateQueue(IDeviceUpdateTrigger updateTrigger)
|
||||||
|
: base(updateTrigger)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Update(Dictionary<object, Color> dataSet)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<object, Color> data in dataSet)
|
||||||
|
{
|
||||||
|
(int row, int column) = ((int, int))data.Key;
|
||||||
|
_WootingSDK.ArraySetSingle((byte)row, (byte)column, data.Value.GetR(), data.Value.GetG(), data.Value.GetB());
|
||||||
|
}
|
||||||
|
|
||||||
|
_WootingSDK.ArrayUpdateKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
41
RGB.NET.Devices.Wooting/Helper/EnumExtension.cs
Normal file
41
RGB.NET.Devices.Wooting/Helper/EnumExtension.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Reflection;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Helper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Offers some extensions and helper-methods for enum related things.
|
||||||
|
/// </summary>
|
||||||
|
internal static class EnumExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of the <see cref="DescriptionAttribute"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The enum value to get the description from.</param>
|
||||||
|
/// <typeparam name="T">The generic enum-type</typeparam>
|
||||||
|
/// <returns>The value of the <see cref="DescriptionAttribute"/> or the <see cref="Enum.ToString()" /> result of the source.</returns>
|
||||||
|
internal static string GetDescription<T>(this T source)
|
||||||
|
where T : struct
|
||||||
|
{
|
||||||
|
return source.GetAttribute<DescriptionAttribute, T>()?.Description ?? source.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the attribute of type T.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The enum value to get the attribute from</param>
|
||||||
|
/// <typeparam name="T">The generic attribute type</typeparam>
|
||||||
|
/// <typeparam name="TEnum">The generic enum-type</typeparam>
|
||||||
|
/// <returns>The <see cref="Attribute"/>.</returns>
|
||||||
|
private static T GetAttribute<T, TEnum>(this TEnum source)
|
||||||
|
where T : Attribute
|
||||||
|
where TEnum : struct
|
||||||
|
{
|
||||||
|
FieldInfo fi = source.GetType().GetField(source.ToString());
|
||||||
|
T[] attributes = (T[])fi.GetCustomAttributes(typeof(T), false);
|
||||||
|
return attributes.Length > 0 ? attributes[0] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
477
RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardLedMappings.cs
Normal file
477
RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardLedMappings.cs
Normal file
@ -0,0 +1,477 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Enum;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Keyboard
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains all the hardware-id mappings for Wooting devices.
|
||||||
|
/// </summary>
|
||||||
|
internal static class WootingKeyboardLedMappings
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
#region Wooting One
|
||||||
|
|
||||||
|
private static readonly Dictionary<LedId, (int row, int column)> WootingOne_US = new Dictionary<LedId, (int row, int column)>
|
||||||
|
{
|
||||||
|
{ LedId.Keyboard_Escape, (0,0) },
|
||||||
|
{ LedId.Keyboard_F1, (0,2) },
|
||||||
|
{ LedId.Keyboard_F2, (0,3) },
|
||||||
|
{ LedId.Keyboard_F3, (0,4) },
|
||||||
|
{ LedId.Keyboard_F4, (0,5) },
|
||||||
|
{ LedId.Keyboard_F5, (0,6) },
|
||||||
|
{ LedId.Keyboard_F6, (0,7) },
|
||||||
|
{ LedId.Keyboard_F7, (0,8) },
|
||||||
|
{ LedId.Keyboard_F8, (0,9) },
|
||||||
|
{ LedId.Keyboard_F9, (0,10) },
|
||||||
|
{ LedId.Keyboard_F10, (0,11) },
|
||||||
|
{ LedId.Keyboard_F11, (0,12) },
|
||||||
|
{ LedId.Keyboard_F12, (0,13) },
|
||||||
|
{ LedId.Keyboard_PrintScreen, (0,14) },
|
||||||
|
{ LedId.Keyboard_PauseBreak, (0,15) },
|
||||||
|
{ LedId.Keyboard_Custom1, (0,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_GraveAccentAndTilde, (1,0) },
|
||||||
|
{ LedId.Keyboard_1, (1,1) },
|
||||||
|
{ LedId.Keyboard_2, (1,2) },
|
||||||
|
{ LedId.Keyboard_3, (1,3) },
|
||||||
|
{ LedId.Keyboard_4, (1,4) },
|
||||||
|
{ LedId.Keyboard_5, (1,5) },
|
||||||
|
{ LedId.Keyboard_6, (1,6) },
|
||||||
|
{ LedId.Keyboard_7, (1,7) },
|
||||||
|
{ LedId.Keyboard_8, (1,8) },
|
||||||
|
{ LedId.Keyboard_9, (1,9) },
|
||||||
|
{ LedId.Keyboard_0, (1,10) },
|
||||||
|
{ LedId.Keyboard_MinusAndUnderscore, (1,11) },
|
||||||
|
{ LedId.Keyboard_EqualsAndPlus, (1,12) },
|
||||||
|
{ LedId.Keyboard_Backspace, (1,13) },
|
||||||
|
{ LedId.Keyboard_Insert, (1,14) },
|
||||||
|
{ LedId.Keyboard_Home, (1,15) },
|
||||||
|
{ LedId.Keyboard_PageUp, (1,16) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_Tab, (2,0) },
|
||||||
|
{ LedId.Keyboard_Q, (2,1) },
|
||||||
|
{ LedId.Keyboard_W, (2,2) },
|
||||||
|
{ LedId.Keyboard_E, (2,3) },
|
||||||
|
{ LedId.Keyboard_R, (2,4) },
|
||||||
|
{ LedId.Keyboard_T, (2,5) },
|
||||||
|
{ LedId.Keyboard_Y, (2,6) },
|
||||||
|
{ LedId.Keyboard_U, (2,7) },
|
||||||
|
{ LedId.Keyboard_I, (2,8) },
|
||||||
|
{ LedId.Keyboard_O, (2,9) },
|
||||||
|
{ LedId.Keyboard_P, (2,10) },
|
||||||
|
{ LedId.Keyboard_BracketLeft, (2,11) },
|
||||||
|
{ LedId.Keyboard_BracketRight, (2,12) },
|
||||||
|
{ LedId.Keyboard_Backslash, (2,13) },
|
||||||
|
{ LedId.Keyboard_Delete, (2,14) },
|
||||||
|
{ LedId.Keyboard_End, (2,15) },
|
||||||
|
{ LedId.Keyboard_PageDown, (2,16) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_CapsLock, (3,0) },
|
||||||
|
{ LedId.Keyboard_A, (3,1) },
|
||||||
|
{ LedId.Keyboard_S, (3,2) },
|
||||||
|
{ LedId.Keyboard_D, (3,3) },
|
||||||
|
{ LedId.Keyboard_F, (3,4) },
|
||||||
|
{ LedId.Keyboard_G, (3,5) },
|
||||||
|
{ LedId.Keyboard_H, (3,6) },
|
||||||
|
{ LedId.Keyboard_J, (3,7) },
|
||||||
|
{ LedId.Keyboard_K, (3,8) },
|
||||||
|
{ LedId.Keyboard_L, (3,9) },
|
||||||
|
{ LedId.Keyboard_SemicolonAndColon, (3,10) },
|
||||||
|
{ LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) },
|
||||||
|
{ LedId.Keyboard_Enter, (3,13) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftShift, (4,0) },
|
||||||
|
{ LedId.Keyboard_Z, (4,2) },
|
||||||
|
{ LedId.Keyboard_X, (4,3) },
|
||||||
|
{ LedId.Keyboard_C, (4,4) },
|
||||||
|
{ LedId.Keyboard_V, (4,5) },
|
||||||
|
{ LedId.Keyboard_B, (4,6) },
|
||||||
|
{ LedId.Keyboard_N, (4,7) },
|
||||||
|
{ LedId.Keyboard_M, (4,8) },
|
||||||
|
{ LedId.Keyboard_CommaAndLessThan, (4,9) },
|
||||||
|
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
|
||||||
|
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
|
||||||
|
{ LedId.Keyboard_RightShift, (4,13) },
|
||||||
|
{ LedId.Keyboard_ArrowUp, (4,15) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftCtrl, (5,0) },
|
||||||
|
{ LedId.Keyboard_LeftGui, (5,1) },
|
||||||
|
{ LedId.Keyboard_LeftAlt, (5,2) },
|
||||||
|
{ LedId.Keyboard_Space, (5,6) },
|
||||||
|
{ LedId.Keyboard_RightAlt, (5,10) },
|
||||||
|
{ LedId.Keyboard_RightGui, (5,11) },
|
||||||
|
{ LedId.Keyboard_Application, (5,12) },
|
||||||
|
{ LedId.Keyboard_RightCtrl, (5,13) },
|
||||||
|
{ LedId.Keyboard_ArrowLeft, (5,14) },
|
||||||
|
{ LedId.Keyboard_ArrowDown, (5,15) },
|
||||||
|
{ LedId.Keyboard_ArrowRight, (5,16) }
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly Dictionary<LedId, (int row, int column)> WootingOne_UK = new Dictionary<LedId, (int row, int column)>
|
||||||
|
{
|
||||||
|
{ LedId.Keyboard_Escape, (0,0) },
|
||||||
|
{ LedId.Keyboard_F1, (0,2) },
|
||||||
|
{ LedId.Keyboard_F2, (0,3) },
|
||||||
|
{ LedId.Keyboard_F3, (0,4) },
|
||||||
|
{ LedId.Keyboard_F4, (0,5) },
|
||||||
|
{ LedId.Keyboard_F5, (0,6) },
|
||||||
|
{ LedId.Keyboard_F6, (0,7) },
|
||||||
|
{ LedId.Keyboard_F7, (0,8) },
|
||||||
|
{ LedId.Keyboard_F8, (0,9) },
|
||||||
|
{ LedId.Keyboard_F9, (0,10) },
|
||||||
|
{ LedId.Keyboard_F10, (0,11) },
|
||||||
|
{ LedId.Keyboard_F11, (0,12) },
|
||||||
|
{ LedId.Keyboard_F12, (0,13) },
|
||||||
|
{ LedId.Keyboard_PrintScreen, (0,14) },
|
||||||
|
{ LedId.Keyboard_PauseBreak, (0,15) },
|
||||||
|
{ LedId.Keyboard_Custom1, (0,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_GraveAccentAndTilde, (1,0) },
|
||||||
|
{ LedId.Keyboard_1, (1,1) },
|
||||||
|
{ LedId.Keyboard_2, (1,2) },
|
||||||
|
{ LedId.Keyboard_3, (1,3) },
|
||||||
|
{ LedId.Keyboard_4, (1,4) },
|
||||||
|
{ LedId.Keyboard_5, (1,5) },
|
||||||
|
{ LedId.Keyboard_6, (1,6) },
|
||||||
|
{ LedId.Keyboard_7, (1,7) },
|
||||||
|
{ LedId.Keyboard_8, (1,8) },
|
||||||
|
{ LedId.Keyboard_9, (1,9) },
|
||||||
|
{ LedId.Keyboard_0, (1,10) },
|
||||||
|
{ LedId.Keyboard_MinusAndUnderscore, (1,11) },
|
||||||
|
{ LedId.Keyboard_EqualsAndPlus, (1,12) },
|
||||||
|
{ LedId.Keyboard_Backspace, (1,13) },
|
||||||
|
{ LedId.Keyboard_Insert, (1,14) },
|
||||||
|
{ LedId.Keyboard_Home, (1,15) },
|
||||||
|
{ LedId.Keyboard_PageUp, (1,16) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_Tab, (2,0) },
|
||||||
|
{ LedId.Keyboard_Q, (2,1) },
|
||||||
|
{ LedId.Keyboard_W, (2,2) },
|
||||||
|
{ LedId.Keyboard_E, (2,3) },
|
||||||
|
{ LedId.Keyboard_R, (2,4) },
|
||||||
|
{ LedId.Keyboard_T, (2,5) },
|
||||||
|
{ LedId.Keyboard_Y, (2,6) },
|
||||||
|
{ LedId.Keyboard_U, (2,7) },
|
||||||
|
{ LedId.Keyboard_I, (2,8) },
|
||||||
|
{ LedId.Keyboard_O, (2,9) },
|
||||||
|
{ LedId.Keyboard_P, (2,10) },
|
||||||
|
{ LedId.Keyboard_BracketLeft, (2,11) },
|
||||||
|
{ LedId.Keyboard_BracketRight, (2,12) },
|
||||||
|
{ LedId.Keyboard_Backslash, (2,13) },
|
||||||
|
{ LedId.Keyboard_Delete, (2,14) },
|
||||||
|
{ LedId.Keyboard_End, (2,15) },
|
||||||
|
{ LedId.Keyboard_PageDown, (2,16) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_CapsLock, (3,0) },
|
||||||
|
{ LedId.Keyboard_A, (3,1) },
|
||||||
|
{ LedId.Keyboard_S, (3,2) },
|
||||||
|
{ LedId.Keyboard_D, (3,3) },
|
||||||
|
{ LedId.Keyboard_F, (3,4) },
|
||||||
|
{ LedId.Keyboard_G, (3,5) },
|
||||||
|
{ LedId.Keyboard_H, (3,6) },
|
||||||
|
{ LedId.Keyboard_J, (3,7) },
|
||||||
|
{ LedId.Keyboard_K, (3,8) },
|
||||||
|
{ LedId.Keyboard_L, (3,9) },
|
||||||
|
{ LedId.Keyboard_SemicolonAndColon, (3,10) },
|
||||||
|
{ LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) },
|
||||||
|
{ LedId.Keyboard_NonUsTilde, (3,11) },
|
||||||
|
{ LedId.Keyboard_Enter, (3,13) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftShift, (4,0) },
|
||||||
|
{ LedId.Keyboard_NonUsBackslash, (4,1) },
|
||||||
|
{ LedId.Keyboard_Z, (4,2) },
|
||||||
|
{ LedId.Keyboard_X, (4,3) },
|
||||||
|
{ LedId.Keyboard_C, (4,4) },
|
||||||
|
{ LedId.Keyboard_V, (4,5) },
|
||||||
|
{ LedId.Keyboard_B, (4,6) },
|
||||||
|
{ LedId.Keyboard_N, (4,7) },
|
||||||
|
{ LedId.Keyboard_M, (4,8) },
|
||||||
|
{ LedId.Keyboard_CommaAndLessThan, (4,9) },
|
||||||
|
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
|
||||||
|
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
|
||||||
|
{ LedId.Keyboard_RightShift, (4,13) },
|
||||||
|
{ LedId.Keyboard_ArrowUp, (4,15) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftCtrl, (5,0) },
|
||||||
|
{ LedId.Keyboard_LeftGui, (5,1) },
|
||||||
|
{ LedId.Keyboard_LeftAlt, (5,2) },
|
||||||
|
{ LedId.Keyboard_Space, (5,6) },
|
||||||
|
{ LedId.Keyboard_RightAlt, (5,10) },
|
||||||
|
{ LedId.Keyboard_RightGui, (5,11) },
|
||||||
|
{ LedId.Keyboard_Application, (5,12) },
|
||||||
|
{ LedId.Keyboard_RightCtrl, (5,13) },
|
||||||
|
{ LedId.Keyboard_ArrowLeft, (5,14) },
|
||||||
|
{ LedId.Keyboard_ArrowDown, (5,15) },
|
||||||
|
{ LedId.Keyboard_ArrowRight, (5,16) }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Wooting Two
|
||||||
|
|
||||||
|
private static readonly Dictionary<LedId, (int row, int column)> WootingTwo_US = new Dictionary<LedId, (int row, int column)>
|
||||||
|
{
|
||||||
|
{ LedId.Keyboard_Escape, (0,0) },
|
||||||
|
{ LedId.Keyboard_F1, (0,2) },
|
||||||
|
{ LedId.Keyboard_F2, (0,3) },
|
||||||
|
{ LedId.Keyboard_F3, (0,4) },
|
||||||
|
{ LedId.Keyboard_F4, (0,5) },
|
||||||
|
{ LedId.Keyboard_F5, (0,6) },
|
||||||
|
{ LedId.Keyboard_F6, (0,7) },
|
||||||
|
{ LedId.Keyboard_F7, (0,8) },
|
||||||
|
{ LedId.Keyboard_F8, (0,9) },
|
||||||
|
{ LedId.Keyboard_F9, (0,10) },
|
||||||
|
{ LedId.Keyboard_F10, (0,11) },
|
||||||
|
{ LedId.Keyboard_F11, (0,12) },
|
||||||
|
{ LedId.Keyboard_F12, (0,13) },
|
||||||
|
{ LedId.Keyboard_PrintScreen, (0,14) },
|
||||||
|
{ LedId.Keyboard_PauseBreak, (0,15) },
|
||||||
|
{ LedId.Keyboard_ScrollLock, (0,16) },
|
||||||
|
{ LedId.Keyboard_Custom1, (0,17) },
|
||||||
|
{ LedId.Keyboard_Custom2, (0,18) },
|
||||||
|
{ LedId.Keyboard_Custom3, (0,19) },
|
||||||
|
{ LedId.Keyboard_Custom4, (0,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_GraveAccentAndTilde, (1,0) },
|
||||||
|
{ LedId.Keyboard_1, (1,1) },
|
||||||
|
{ LedId.Keyboard_2, (1,2) },
|
||||||
|
{ LedId.Keyboard_3, (1,3) },
|
||||||
|
{ LedId.Keyboard_4, (1,4) },
|
||||||
|
{ LedId.Keyboard_5, (1,5) },
|
||||||
|
{ LedId.Keyboard_6, (1,6) },
|
||||||
|
{ LedId.Keyboard_7, (1,7) },
|
||||||
|
{ LedId.Keyboard_8, (1,8) },
|
||||||
|
{ LedId.Keyboard_9, (1,9) },
|
||||||
|
{ LedId.Keyboard_0, (1,10) },
|
||||||
|
{ LedId.Keyboard_MinusAndUnderscore, (1,11) },
|
||||||
|
{ LedId.Keyboard_EqualsAndPlus, (1,12) },
|
||||||
|
{ LedId.Keyboard_Backspace, (1,13) },
|
||||||
|
{ LedId.Keyboard_Insert, (1,14) },
|
||||||
|
{ LedId.Keyboard_Home, (1,15) },
|
||||||
|
{ LedId.Keyboard_PageUp, (1,16) },
|
||||||
|
{ LedId.Keyboard_NumLock, (1,17) },
|
||||||
|
{ LedId.Keyboard_NumSlash, (1,18) },
|
||||||
|
{ LedId.Keyboard_NumAsterisk, (1,19) },
|
||||||
|
{ LedId.Keyboard_NumMinus, (1,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_Tab, (2,0) },
|
||||||
|
{ LedId.Keyboard_Q, (2,1) },
|
||||||
|
{ LedId.Keyboard_W, (2,2) },
|
||||||
|
{ LedId.Keyboard_E, (2,3) },
|
||||||
|
{ LedId.Keyboard_R, (2,4) },
|
||||||
|
{ LedId.Keyboard_T, (2,5) },
|
||||||
|
{ LedId.Keyboard_Y, (2,6) },
|
||||||
|
{ LedId.Keyboard_U, (2,7) },
|
||||||
|
{ LedId.Keyboard_I, (2,8) },
|
||||||
|
{ LedId.Keyboard_O, (2,9) },
|
||||||
|
{ LedId.Keyboard_P, (2,10) },
|
||||||
|
{ LedId.Keyboard_BracketLeft, (2,11) },
|
||||||
|
{ LedId.Keyboard_BracketRight, (2,12) },
|
||||||
|
{ LedId.Keyboard_Backslash, (2,13) },
|
||||||
|
{ LedId.Keyboard_Delete, (2,14) },
|
||||||
|
{ LedId.Keyboard_End, (2,15) },
|
||||||
|
{ LedId.Keyboard_PageDown, (2,16) },
|
||||||
|
{ LedId.Keyboard_Num7, (2,17) },
|
||||||
|
{ LedId.Keyboard_Num8, (2,18) },
|
||||||
|
{ LedId.Keyboard_Num9, (2,19) },
|
||||||
|
{ LedId.Keyboard_NumPlus, (2,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_CapsLock, (3,0) },
|
||||||
|
{ LedId.Keyboard_A, (3,1) },
|
||||||
|
{ LedId.Keyboard_S, (3,2) },
|
||||||
|
{ LedId.Keyboard_D, (3,3) },
|
||||||
|
{ LedId.Keyboard_F, (3,4) },
|
||||||
|
{ LedId.Keyboard_G, (3,5) },
|
||||||
|
{ LedId.Keyboard_H, (3,6) },
|
||||||
|
{ LedId.Keyboard_J, (3,7) },
|
||||||
|
{ LedId.Keyboard_K, (3,8) },
|
||||||
|
{ LedId.Keyboard_L, (3,9) },
|
||||||
|
{ LedId.Keyboard_SemicolonAndColon, (3,10) },
|
||||||
|
{ LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) },
|
||||||
|
{ LedId.Keyboard_Enter, (3,13) },
|
||||||
|
{ LedId.Keyboard_Num4, (3,17) },
|
||||||
|
{ LedId.Keyboard_Num5, (3,18) },
|
||||||
|
{ LedId.Keyboard_Num6, (3,19) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftShift, (4,0) },
|
||||||
|
{ LedId.Keyboard_Z, (4,2) },
|
||||||
|
{ LedId.Keyboard_X, (4,3) },
|
||||||
|
{ LedId.Keyboard_C, (4,4) },
|
||||||
|
{ LedId.Keyboard_V, (4,5) },
|
||||||
|
{ LedId.Keyboard_B, (4,6) },
|
||||||
|
{ LedId.Keyboard_N, (4,7) },
|
||||||
|
{ LedId.Keyboard_M, (4,8) },
|
||||||
|
{ LedId.Keyboard_CommaAndLessThan, (4,9) },
|
||||||
|
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
|
||||||
|
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
|
||||||
|
{ LedId.Keyboard_RightShift, (4,13) },
|
||||||
|
{ LedId.Keyboard_ArrowUp, (4,15) },
|
||||||
|
{ LedId.Keyboard_Num1, (4,17) },
|
||||||
|
{ LedId.Keyboard_Num2, (4,18) },
|
||||||
|
{ LedId.Keyboard_Num3, (4,19) },
|
||||||
|
{ LedId.Keyboard_NumEnter, (4,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftCtrl, (5,0) },
|
||||||
|
{ LedId.Keyboard_LeftGui, (5,1) },
|
||||||
|
{ LedId.Keyboard_LeftAlt, (5,2) },
|
||||||
|
{ LedId.Keyboard_Space, (5,6) },
|
||||||
|
{ LedId.Keyboard_RightAlt, (5,10) },
|
||||||
|
{ LedId.Keyboard_RightGui, (5,11) },
|
||||||
|
{ LedId.Keyboard_Application, (5,12) },
|
||||||
|
{ LedId.Keyboard_RightCtrl, (5,13) },
|
||||||
|
{ LedId.Keyboard_ArrowLeft, (5,14) },
|
||||||
|
{ LedId.Keyboard_ArrowDown, (5,15) },
|
||||||
|
{ LedId.Keyboard_ArrowRight, (5,16) },
|
||||||
|
{ LedId.Keyboard_Num0, (5,18) },
|
||||||
|
{ LedId.Keyboard_NumPeriodAndDelete, (5,19) }
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly Dictionary<LedId, (int row, int column)> WootingTwo_UK = new Dictionary<LedId, (int row, int column)>
|
||||||
|
{
|
||||||
|
{ LedId.Keyboard_Escape, (0,0) },
|
||||||
|
{ LedId.Keyboard_F1, (0,2) },
|
||||||
|
{ LedId.Keyboard_F2, (0,3) },
|
||||||
|
{ LedId.Keyboard_F3, (0,4) },
|
||||||
|
{ LedId.Keyboard_F4, (0,5) },
|
||||||
|
{ LedId.Keyboard_F5, (0,6) },
|
||||||
|
{ LedId.Keyboard_F6, (0,7) },
|
||||||
|
{ LedId.Keyboard_F7, (0,8) },
|
||||||
|
{ LedId.Keyboard_F8, (0,9) },
|
||||||
|
{ LedId.Keyboard_F9, (0,10) },
|
||||||
|
{ LedId.Keyboard_F10, (0,11) },
|
||||||
|
{ LedId.Keyboard_F11, (0,12) },
|
||||||
|
{ LedId.Keyboard_F12, (0,13) },
|
||||||
|
{ LedId.Keyboard_PrintScreen, (0,14) },
|
||||||
|
{ LedId.Keyboard_PauseBreak, (0,15) },
|
||||||
|
{ LedId.Keyboard_ScrollLock, (0,16) },
|
||||||
|
{ LedId.Keyboard_Custom1, (0,17) },
|
||||||
|
{ LedId.Keyboard_Custom2, (0,18) },
|
||||||
|
{ LedId.Keyboard_Custom3, (0,19) },
|
||||||
|
{ LedId.Keyboard_Custom4, (0,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_GraveAccentAndTilde, (1,0) },
|
||||||
|
{ LedId.Keyboard_1, (1,1) },
|
||||||
|
{ LedId.Keyboard_2, (1,2) },
|
||||||
|
{ LedId.Keyboard_3, (1,3) },
|
||||||
|
{ LedId.Keyboard_4, (1,4) },
|
||||||
|
{ LedId.Keyboard_5, (1,5) },
|
||||||
|
{ LedId.Keyboard_6, (1,6) },
|
||||||
|
{ LedId.Keyboard_7, (1,7) },
|
||||||
|
{ LedId.Keyboard_8, (1,8) },
|
||||||
|
{ LedId.Keyboard_9, (1,9) },
|
||||||
|
{ LedId.Keyboard_0, (1,10) },
|
||||||
|
{ LedId.Keyboard_MinusAndUnderscore, (1,11) },
|
||||||
|
{ LedId.Keyboard_EqualsAndPlus, (1,12) },
|
||||||
|
{ LedId.Keyboard_Backspace, (1,13) },
|
||||||
|
{ LedId.Keyboard_Insert, (1,14) },
|
||||||
|
{ LedId.Keyboard_Home, (1,15) },
|
||||||
|
{ LedId.Keyboard_PageUp, (1,16) },
|
||||||
|
{ LedId.Keyboard_NumLock, (1,17) },
|
||||||
|
{ LedId.Keyboard_NumSlash, (1,18) },
|
||||||
|
{ LedId.Keyboard_NumAsterisk, (1,19) },
|
||||||
|
{ LedId.Keyboard_NumMinus, (1,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_Tab, (2,0) },
|
||||||
|
{ LedId.Keyboard_Q, (2,1) },
|
||||||
|
{ LedId.Keyboard_W, (2,2) },
|
||||||
|
{ LedId.Keyboard_E, (2,3) },
|
||||||
|
{ LedId.Keyboard_R, (2,4) },
|
||||||
|
{ LedId.Keyboard_T, (2,5) },
|
||||||
|
{ LedId.Keyboard_Y, (2,6) },
|
||||||
|
{ LedId.Keyboard_U, (2,7) },
|
||||||
|
{ LedId.Keyboard_I, (2,8) },
|
||||||
|
{ LedId.Keyboard_O, (2,9) },
|
||||||
|
{ LedId.Keyboard_P, (2,10) },
|
||||||
|
{ LedId.Keyboard_BracketLeft, (2,11) },
|
||||||
|
{ LedId.Keyboard_BracketRight, (2,12) },
|
||||||
|
{ LedId.Keyboard_Backslash, (2,13) },
|
||||||
|
{ LedId.Keyboard_Delete, (2,14) },
|
||||||
|
{ LedId.Keyboard_End, (2,15) },
|
||||||
|
{ LedId.Keyboard_PageDown, (2,16) },
|
||||||
|
{ LedId.Keyboard_Num7, (2,17) },
|
||||||
|
{ LedId.Keyboard_Num8, (2,18) },
|
||||||
|
{ LedId.Keyboard_Num9, (2,19) },
|
||||||
|
{ LedId.Keyboard_NumPlus, (2,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_CapsLock, (3,0) },
|
||||||
|
{ LedId.Keyboard_A, (3,1) },
|
||||||
|
{ LedId.Keyboard_S, (3,2) },
|
||||||
|
{ LedId.Keyboard_D, (3,3) },
|
||||||
|
{ LedId.Keyboard_F, (3,4) },
|
||||||
|
{ LedId.Keyboard_G, (3,5) },
|
||||||
|
{ LedId.Keyboard_H, (3,6) },
|
||||||
|
{ LedId.Keyboard_J, (3,7) },
|
||||||
|
{ LedId.Keyboard_K, (3,8) },
|
||||||
|
{ LedId.Keyboard_L, (3,9) },
|
||||||
|
{ LedId.Keyboard_SemicolonAndColon, (3,10) },
|
||||||
|
{ LedId.Keyboard_ApostropheAndDoubleQuote, (3,11) },
|
||||||
|
{ LedId.Keyboard_NonUsTilde, (3,12) },
|
||||||
|
{ LedId.Keyboard_Enter, (3,13) },
|
||||||
|
{ LedId.Keyboard_Num4, (3,17) },
|
||||||
|
{ LedId.Keyboard_Num5, (3,18) },
|
||||||
|
{ LedId.Keyboard_Num6, (3,19) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftShift, (4,0) },
|
||||||
|
{ LedId.Keyboard_NonUsBackslash, (4,1) },
|
||||||
|
{ LedId.Keyboard_Z, (4,2) },
|
||||||
|
{ LedId.Keyboard_X, (4,3) },
|
||||||
|
{ LedId.Keyboard_C, (4,4) },
|
||||||
|
{ LedId.Keyboard_V, (4,5) },
|
||||||
|
{ LedId.Keyboard_B, (4,6) },
|
||||||
|
{ LedId.Keyboard_N, (4,7) },
|
||||||
|
{ LedId.Keyboard_M, (4,8) },
|
||||||
|
{ LedId.Keyboard_CommaAndLessThan, (4,9) },
|
||||||
|
{ LedId.Keyboard_PeriodAndBiggerThan, (4,10) },
|
||||||
|
{ LedId.Keyboard_SlashAndQuestionMark, (4,11) },
|
||||||
|
{ LedId.Keyboard_RightShift, (4,13) },
|
||||||
|
{ LedId.Keyboard_ArrowUp, (4,15) },
|
||||||
|
{ LedId.Keyboard_Num1, (4,17) },
|
||||||
|
{ LedId.Keyboard_Num2, (4,18) },
|
||||||
|
{ LedId.Keyboard_Num3, (4,19) },
|
||||||
|
{ LedId.Keyboard_NumEnter, (4,20) },
|
||||||
|
|
||||||
|
{ LedId.Keyboard_LeftCtrl, (5,0) },
|
||||||
|
{ LedId.Keyboard_LeftGui, (5,1) },
|
||||||
|
{ LedId.Keyboard_LeftAlt, (5,2) },
|
||||||
|
{ LedId.Keyboard_Space, (5,6) },
|
||||||
|
{ LedId.Keyboard_RightAlt, (5,10) },
|
||||||
|
{ LedId.Keyboard_RightGui, (5,11) },
|
||||||
|
{ LedId.Keyboard_Application, (5,12) },
|
||||||
|
{ LedId.Keyboard_RightCtrl, (5,13) },
|
||||||
|
{ LedId.Keyboard_ArrowLeft, (5,14) },
|
||||||
|
{ LedId.Keyboard_ArrowDown, (5,15) },
|
||||||
|
{ LedId.Keyboard_ArrowRight, (5,16) },
|
||||||
|
{ LedId.Keyboard_Num0, (5,18) },
|
||||||
|
{ LedId.Keyboard_NumPeriodAndDelete, (5,19) }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains all the hardware-id mappings for Wooting devices.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly Dictionary<WootingDevicesIndexes, Dictionary<WootingPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>> Mapping =
|
||||||
|
new Dictionary<WootingDevicesIndexes, Dictionary<WootingPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>>
|
||||||
|
{
|
||||||
|
{ WootingDevicesIndexes.WootingOne, new Dictionary<WootingPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>
|
||||||
|
{
|
||||||
|
{ WootingPhysicalKeyboardLayout.US, WootingOne_US },
|
||||||
|
{ WootingPhysicalKeyboardLayout.UK, WootingOne_UK }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{ WootingDevicesIndexes.WootingTwo, new Dictionary<WootingPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>>
|
||||||
|
{
|
||||||
|
{ WootingPhysicalKeyboardLayout.US, WootingTwo_US },
|
||||||
|
{ WootingPhysicalKeyboardLayout.UK, WootingTwo_UK }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
53
RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs
Normal file
53
RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Generic;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Keyboard
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a Wooting keyboard.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingKeyboardRGBDevice : WootingRGBDevice<WootingKeyboardRGBDeviceInfo>
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Wooting.Keyboard.WootingKeyboardRGBDevice" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The specific information provided by Wooting for the keyboard</param>
|
||||||
|
internal WootingKeyboardRGBDevice(WootingKeyboardRGBDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void InitializeLayout()
|
||||||
|
{
|
||||||
|
|
||||||
|
Dictionary<LedId, (int row, int column)> mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout];
|
||||||
|
|
||||||
|
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
|
||||||
|
{
|
||||||
|
InitializeLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19,19));
|
||||||
|
}
|
||||||
|
|
||||||
|
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||||
|
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Wooting\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||||
|
DeviceInfo.LogicalLayout.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override object CreateLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Enum;
|
||||||
|
using RGB.NET.Devices.Wooting.Generic;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Keyboard
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Wooting.Keyboard.WootingKeyboardRGBDevice" />.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="WootingPhysicalKeyboardLayout"/> of the <see cref="WootingKeyboardRGBDevice"/>.
|
||||||
|
/// </summary>
|
||||||
|
public WootingPhysicalKeyboardLayout PhysicalLayout { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="WootingLogicalKeyboardLayout"/> of the <see cref="WootingKeyboardRGBDevice"/>.
|
||||||
|
/// </summary>
|
||||||
|
public WootingLogicalKeyboardLayout LogicalLayout { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDeviceInfo" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDevice" />.</param>
|
||||||
|
/// <param name="physicalKeyboardLayout">The <see cref="T:RGB.NET.Devices.Wooting.WootingPhysicalKeyboardLayout" /> of the <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDevice" />.</param>
|
||||||
|
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using</param>
|
||||||
|
internal WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes deviceIndex, WootingPhysicalKeyboardLayout physicalKeyboardLayout,
|
||||||
|
CultureInfo culture)
|
||||||
|
: base(RGBDeviceType.Keyboard, deviceIndex)
|
||||||
|
{
|
||||||
|
this.PhysicalLayout = physicalKeyboardLayout;
|
||||||
|
|
||||||
|
DetermineLogicalLayout(culture.KeyboardLayoutId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DetermineLogicalLayout(int keyboardLayoutId)
|
||||||
|
{
|
||||||
|
switch (keyboardLayoutId)
|
||||||
|
{
|
||||||
|
// TODO SpoinkyNL 15-12-2019: There doesn't seem to be an accurate way to determine this, perhaps it should be a configurable thing..
|
||||||
|
// I'm using US International and it's reporting nl-NL's 1043. Also you can after all just swap your keycaps
|
||||||
|
default:
|
||||||
|
if (PhysicalLayout == WootingPhysicalKeyboardLayout.US)
|
||||||
|
LogicalLayout = WootingLogicalKeyboardLayout.US;
|
||||||
|
else
|
||||||
|
LogicalLayout = WootingLogicalKeyboardLayout.UK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
21
RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs
Normal file
21
RGB.NET.Devices.Wooting/Native/_WootingDeviceInfo.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using RGB.NET.Devices.Wooting.Enum;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Native
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct _WootingDeviceInfo
|
||||||
|
{
|
||||||
|
public bool Connected { get; private set; }
|
||||||
|
|
||||||
|
public string Model { get; private set; }
|
||||||
|
|
||||||
|
public byte MaxRows { get; private set; }
|
||||||
|
|
||||||
|
public byte MaxColumns { get; private set; }
|
||||||
|
|
||||||
|
public byte KeycodeLimit { get; private set; }
|
||||||
|
|
||||||
|
public WootingDeviceType DeviceType { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
117
RGB.NET.Devices.Wooting/Native/_WootingSDK.cs
Normal file
117
RGB.NET.Devices.Wooting/Native/_WootingSDK.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
// ReSharper disable UnusedMethodReturnValue.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
public class _WootingSDK
|
||||||
|
{
|
||||||
|
#region Library management
|
||||||
|
|
||||||
|
private static IntPtr _dllHandle = IntPtr.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the loaded architecture (x64/x86).
|
||||||
|
/// </summary>
|
||||||
|
internal static string LoadedArchitecture { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reloads the SDK.
|
||||||
|
/// </summary>
|
||||||
|
internal static void Reload()
|
||||||
|
{
|
||||||
|
UnloadWootingSDK();
|
||||||
|
LoadWootingSDK();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LoadWootingSDK()
|
||||||
|
{
|
||||||
|
if (_dllHandle != IntPtr.Zero) return;
|
||||||
|
|
||||||
|
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||||
|
List<string> possiblePathList = Environment.Is64BitProcess ? WootingDeviceProvider.PossibleX64NativePaths : WootingDeviceProvider.PossibleX86NativePaths;
|
||||||
|
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||||
|
if (dllPath == null) throw new RGBDeviceException($"Can't find the Wooting-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||||
|
|
||||||
|
SetDllDirectory(Path.GetDirectoryName(Path.GetFullPath(dllPath)));
|
||||||
|
|
||||||
|
_dllHandle = LoadLibrary(dllPath);
|
||||||
|
|
||||||
|
_getDeviceInfoPointer = (GetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_device_info"), typeof(GetDeviceInfoPointer));
|
||||||
|
_keyboardConnectedPointer = (KeyboardConnectedPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_kbd_connected"), typeof(KeyboardConnectedPointer));
|
||||||
|
_resetPointer = (ResetPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_reset"), typeof(ResetPointer));
|
||||||
|
_arrayUpdateKeyboardPointer = (ArrayUpdateKeyboardPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_array_update_keyboard"), typeof(ArrayUpdateKeyboardPointer));
|
||||||
|
_arraySetSinglePointer = (ArraySetSinglePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_array_set_single"), typeof(ArraySetSinglePointer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UnloadWootingSDK()
|
||||||
|
{
|
||||||
|
if (_dllHandle == IntPtr.Zero) return;
|
||||||
|
|
||||||
|
// ReSharper disable once EmptyEmbeddedStatement - DarthAffe 20.02.2016: We might need to reduce the internal reference counter more than once to set the library free
|
||||||
|
while (FreeLibrary(_dllHandle)) ;
|
||||||
|
_dllHandle = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool SetDllDirectory(string lpPathName);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern IntPtr LoadLibrary(string dllToLoad);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool FreeLibrary(IntPtr dllHandle);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SDK-METHODS
|
||||||
|
|
||||||
|
#region Pointers
|
||||||
|
|
||||||
|
private static GetDeviceInfoPointer _getDeviceInfoPointer;
|
||||||
|
private static KeyboardConnectedPointer _keyboardConnectedPointer;
|
||||||
|
private static ResetPointer _resetPointer;
|
||||||
|
private static ArrayUpdateKeyboardPointer _arrayUpdateKeyboardPointer;
|
||||||
|
private static ArraySetSinglePointer _arraySetSinglePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Delegates
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate IntPtr GetDeviceInfoPointer();
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate bool KeyboardConnectedPointer();
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate bool ResetPointer();
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate bool ArrayUpdateKeyboardPointer();
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate bool ArraySetSinglePointer(byte row, byte column, byte red, byte green, byte blue);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal static IntPtr GetDeviceInfo() => _getDeviceInfoPointer();
|
||||||
|
internal static bool KeyboardConnected() => _keyboardConnectedPointer();
|
||||||
|
internal static bool Reset() => _resetPointer();
|
||||||
|
internal static bool ArrayUpdateKeyboard() => _arrayUpdateKeyboardPointer();
|
||||||
|
internal static bool ArraySetSingle(byte row, byte column, byte red, byte green, byte blue) => _arraySetSinglePointer(row, column, red, green, blue);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
68
RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj
Normal file
68
RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
|
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
|
||||||
|
|
||||||
|
<Authors>Darth Affe</Authors>
|
||||||
|
<Company>Wyrez</Company>
|
||||||
|
<Language>en-US</Language>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<Title>RGB.NET.Devices.Wooting</Title>
|
||||||
|
<AssemblyName>RGB.NET.Devices.Wooting</AssemblyName>
|
||||||
|
<AssemblyTitle>RGB.NET.Devices.Wooting</AssemblyTitle>
|
||||||
|
<PackageId>RGB.NET.Devices.Wooting</PackageId>
|
||||||
|
<RootNamespace>RGB.NET.Devices.Wooting</RootNamespace>
|
||||||
|
<Description>Wooting-Device-Implementations of RGB.NET</Description>
|
||||||
|
<Summary>Wooting-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
|
||||||
|
<Copyright>Copyright © Wyrez 2017</Copyright>
|
||||||
|
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
|
||||||
|
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
|
||||||
|
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
|
||||||
|
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
|
||||||
|
<RepositoryType>Github</RepositoryType>
|
||||||
|
<RepositoryUrl>https://github.com/DarthAffe/RGB.NET</RepositoryUrl>
|
||||||
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
|
|
||||||
|
<PackageReleaseNotes></PackageReleaseNotes>
|
||||||
|
|
||||||
|
<Version>0.0.1</Version>
|
||||||
|
<AssemblyVersion>0.0.1</AssemblyVersion>
|
||||||
|
<FileVersion>0.0.1</FileVersion>
|
||||||
|
|
||||||
|
<OutputPath>..\bin\</OutputPath>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<IncludeSource>True</IncludeSource>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||||
|
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||||
|
<DefineConstants>NET45;NETFULL</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
|
||||||
|
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||||
|
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
154
RGB.NET.Devices.Wooting/WootingDeviceProvider.cs
Normal file
154
RGB.NET.Devices.Wooting/WootingDeviceProvider.cs
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
using RGB.NET.Devices.Wooting.Enum;
|
||||||
|
using RGB.NET.Devices.Wooting.Generic;
|
||||||
|
using RGB.NET.Devices.Wooting.Keyboard;
|
||||||
|
using RGB.NET.Devices.Wooting.Native;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a device provider responsible for Wooting devices.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingDeviceProvider : IRGBDeviceProvider
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
private static WootingDeviceProvider _instance;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the singleton <see cref="WootingDeviceProvider"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
public static WootingDeviceProvider Instance => _instance ?? new WootingDeviceProvider();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||||
|
/// The first match will be used.
|
||||||
|
/// </summary>
|
||||||
|
public static List<string> PossibleX86NativePaths { get; } = new List<string> {"x86/wooting-rgb-sdk.dll"};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||||
|
/// The first match will be used.
|
||||||
|
/// </summary>
|
||||||
|
public static List<string> PossibleX64NativePaths { get; } = new List<string> {"x64/wooting-rgb-sdk64.dll"};
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the SDK is initialized and ready to use.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsInitialized { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the loaded architecture (x64/x86).
|
||||||
|
/// </summary>
|
||||||
|
public string LoadedArchitecture => _WootingSDK.LoadedArchitecture;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <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; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for cooler master devices.
|
||||||
|
/// </summary>
|
||||||
|
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WootingDeviceProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||||
|
public WootingDeviceProvider()
|
||||||
|
{
|
||||||
|
if (_instance != null)
|
||||||
|
throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}");
|
||||||
|
_instance = this;
|
||||||
|
|
||||||
|
UpdateTrigger = new DeviceUpdateTrigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <exception cref="RGBDeviceException">Thrown if the SDK failed to initialize</exception>
|
||||||
|
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false,
|
||||||
|
bool throwExceptions = false)
|
||||||
|
{
|
||||||
|
IsInitialized = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UpdateTrigger?.Stop();
|
||||||
|
|
||||||
|
_WootingSDK.Reload();
|
||||||
|
|
||||||
|
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||||
|
if (_WootingSDK.KeyboardConnected())
|
||||||
|
{
|
||||||
|
_WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo));
|
||||||
|
IWootingRGBDevice device;
|
||||||
|
// TODO: Find an accurate way to determine physical and logical layouts
|
||||||
|
if (nativeDeviceInfo.Model == "Wooting two")
|
||||||
|
{
|
||||||
|
device = new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingTwo,
|
||||||
|
WootingPhysicalKeyboardLayout.US,
|
||||||
|
CultureHelper.GetCurrentCulture()));
|
||||||
|
}
|
||||||
|
else if (nativeDeviceInfo.Model == "Wooting one")
|
||||||
|
{
|
||||||
|
device = new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingOne,
|
||||||
|
WootingPhysicalKeyboardLayout.US,
|
||||||
|
CultureHelper.GetCurrentCulture()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new RGBDeviceException("No supported Wooting keyboard connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
device.Initialize(UpdateTrigger);
|
||||||
|
devices.Add(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateTrigger?.Start();
|
||||||
|
|
||||||
|
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||||
|
IsInitialized = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (throwExceptions) throw;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void ResetDevices()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
try { _WootingSDK.Reset(); }
|
||||||
|
catch
|
||||||
|
{ /* Unlucky.. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
24
RGB.NET.Devices.Wooting/WootingDeviceProviderLoader.cs
Normal file
24
RGB.NET.Devices.Wooting/WootingDeviceProviderLoader.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace RGB.NET.Devices.Wooting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a device provider loaded used to dynamically load Wooting devices into an application.
|
||||||
|
/// </summary>
|
||||||
|
public class WootingDeviceProviderLoader : IRGBDeviceProviderLoader
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool RequiresInitialization => false;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IRGBDeviceProvider GetDeviceProvider() => WootingDeviceProvider.Instance;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
11
RGB.NET.sln
11
RGB.NET.sln
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.27703.2035
|
VisualStudioVersion = 16.0.29424.173
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devices", "Devices", "{D13032C6-432E-4F43-8A32-071133C22B16}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devices", "Devices", "{D13032C6-432E-4F43-8A32-071133C22B16}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Core.Tests", "Tests
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Asus", "RGB.NET.Devices.Asus\RGB.NET.Devices.Asus.csproj", "{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Asus", "RGB.NET.Devices.Asus\RGB.NET.Devices.Asus.csproj", "{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Wooting", "RGB.NET.Devices.Wooting\RGB.NET.Devices.Wooting.csproj", "{DD46DB2D-85BE-4962-86AE-E38C9053A548}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -129,6 +131,10 @@ Global
|
|||||||
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DD46DB2D-85BE-4962-86AE-E38C9053A548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DD46DB2D-85BE-4962-86AE-E38C9053A548}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DD46DB2D-85BE-4962-86AE-E38C9053A548}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DD46DB2D-85BE-4962-86AE-E38C9053A548}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -152,6 +158,7 @@ Global
|
|||||||
{FFDE4387-60F2-47B6-9704-3A57D02B8C64} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
{FFDE4387-60F2-47B6-9704-3A57D02B8C64} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||||
{A3FD5AD7-040A-47CA-A278-53493A25FF8A} = {92D7C263-D4C9-4D26-93E2-93C1F9C2CD16}
|
{A3FD5AD7-040A-47CA-A278-53493A25FF8A} = {92D7C263-D4C9-4D26-93E2-93C1F9C2CD16}
|
||||||
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
{E0732B34-3F96-4DD9-AFD5-0E34B833AD6D} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||||
|
{DD46DB2D-85BE-4962-86AE-E38C9053A548} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {7F222AD4-1F9E-4AAB-9D69-D62372D4C1BA}
|
SolutionGuid = {7F222AD4-1F9E-4AAB-9D69-D62372D4C1BA}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user