mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Added gRPC sdk client
This commit is contained in:
14 files changed
+426
-130
No files matched your search
@@ -11,6 +11,10 @@ namespace RGB.NET.Devices.Wooting.Generic;
|
||||
/// </summary>
|
||||
internal static class WootingLedMappings
|
||||
{
|
||||
|
||||
public const int ROWS = 6;
|
||||
public const int COLUMNS = 21;
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private static readonly Dictionary<LedId, (int row, int column)> TKL = new()
|
||||
|
||||
@@ -1,40 +1,47 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Wooting.Native;
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Wooting.Enum;
|
||||
|
||||
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 Constructors
|
||||
#region Properties & Fields
|
||||
|
||||
/// <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>
|
||||
/// <param name="updateQueue">The update queue used to update this device.</param>
|
||||
protected WootingRGBDevice(TDeviceInfo info, IUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{
|
||||
}
|
||||
private readonly Dictionary<LedId, (int row, int column)> _mapping;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal WootingRGBDevice(WootingDeviceType deviceType, TDeviceInfo info, IUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{
|
||||
_mapping = WootingLedMappings.Mapping[deviceType];
|
||||
InitializeLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private void InitializeLayout()
|
||||
{
|
||||
foreach (KeyValuePair<LedId, (int row, int column)> led in _mapping)
|
||||
AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object GetLedCustomData(LedId ledId) => _mapping[ledId];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
_WootingSDK.SelectDevice(DeviceInfo.WootingDeviceIndex);
|
||||
_WootingSDK.Reset();
|
||||
UpdateQueue.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Wooting.Enum;
|
||||
using RGB.NET.Devices.Wooting.Native;
|
||||
|
||||
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
|
||||
public abstract class WootingRGBDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@@ -27,37 +21,16 @@ public class WootingRGBDeviceInfo : IRGBDeviceInfo
|
||||
/// <inheritdoc />
|
||||
public object? LayoutMetadata { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Enum.WootingDeviceType"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
public WootingDeviceType WootingDeviceType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Enum.WootingLayoutType"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
public WootingLayoutType WootingLayoutType { get; }
|
||||
|
||||
public byte WootingDeviceIndex { 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="deviceInfo">The <see cref="_WootingDeviceInfo"/> of the <see cref="IRGBDevice"/>.</param>
|
||||
internal WootingRGBDeviceInfo(RGBDeviceType deviceType, _WootingDeviceInfo deviceInfo, byte deviceIndex)
|
||||
protected WootingRGBDeviceInfo(RGBDeviceType deviceType, string model, string name)
|
||||
{
|
||||
this.DeviceType = deviceType;
|
||||
this.WootingDeviceType = deviceInfo.DeviceType;
|
||||
this.WootingLayoutType = deviceInfo.LayoutType;
|
||||
this.WootingDeviceIndex = deviceIndex;
|
||||
|
||||
Model = deviceInfo.Model;
|
||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||
this.Model = model;
|
||||
this.DeviceName = name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
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 sealed class WootingUpdateQueue : UpdateQueue
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly byte _deviceid;
|
||||
|
||||
#endregion
|
||||
|
||||
#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, byte deviceId)
|
||||
: base(updateTrigger)
|
||||
{
|
||||
this._deviceid = deviceId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_WootingSDK.SdkLock)
|
||||
{
|
||||
_WootingSDK.SelectDevice(_deviceid);
|
||||
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
{
|
||||
(int row, int column) = ((int, int))key;
|
||||
_WootingSDK.ArraySetSingle((byte)row, (byte)column, color.GetR(), color.GetG(), color.GetB());
|
||||
}
|
||||
|
||||
_WootingSDK.ArrayUpdateKeyboard();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WootingDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user