mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Merge branch 'Development' of https://github.com/DarthAffe/RGB.NET into asus-remove-system-management
This commit is contained in:
commit
cadf96634e
@ -20,8 +20,13 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <inheritdoc />
|
||||
public bool ThrowsExceptions { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of devices managed by this device-provider.
|
||||
/// </summary>
|
||||
protected List<IRGBDevice> InternalDevices { get; } = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEnumerable<IRGBDevice> Devices { get; protected set; } = Enumerable.Empty<IRGBDevice>();
|
||||
public virtual IReadOnlyList<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(InternalDevices);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dictionary containing the registered update triggers.
|
||||
@ -39,6 +44,9 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<ExceptionEventArgs>? Exception;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<DevicesChangedEventArgs>? DevicesChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -67,7 +75,8 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
|
||||
InitializeSDK();
|
||||
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(GetLoadedDevices(loadFilter).ToList());
|
||||
foreach (IRGBDevice device in GetLoadedDevices(loadFilter))
|
||||
AddDevice(device);
|
||||
|
||||
foreach (IDeviceUpdateTrigger updateTrigger in UpdateTriggerMapping.Values)
|
||||
updateTrigger.Start();
|
||||
@ -168,11 +177,43 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
foreach (IRGBDevice device in Devices)
|
||||
device.Dispose();
|
||||
|
||||
Devices = Enumerable.Empty<IRGBDevice>();
|
||||
List<IRGBDevice> devices = new(InternalDevices);
|
||||
foreach (IRGBDevice device in devices)
|
||||
RemoveDevice(device);
|
||||
|
||||
UpdateTriggerMapping.Clear();
|
||||
IsInitialized = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the provided device to the list of managed devices.
|
||||
/// </summary>
|
||||
/// <param name="device">The device to add.</param>
|
||||
/// <returns><c>true</c> if the device was added successfully; otherwise <c>false</c>.</returns>
|
||||
protected virtual bool AddDevice(IRGBDevice device)
|
||||
{
|
||||
if (InternalDevices.Contains(device)) return false;
|
||||
|
||||
InternalDevices.Add(device);
|
||||
try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesAddedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the provided device from the list of managed devices.
|
||||
/// </summary>
|
||||
/// <param name="device">The device to remove.</param>
|
||||
/// <returns><c>true</c> if the device was removed successfully; otherwise <c>false</c>.</returns>
|
||||
protected virtual bool RemoveDevice(IRGBDevice device)
|
||||
{
|
||||
if (!InternalDevices.Remove(device)) return false;
|
||||
|
||||
try { OnDevicesChanged(DevicesChangedEventArgs.CreateDevicesRemovedArgs(device)); } catch { /* we don't want to throw due to bad event handlers */ }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the <see cref="Exception"/>-event and throws the specified exception if <see cref="ThrowsExceptions"/> is true and it is not overriden in the event.
|
||||
/// </summary>
|
||||
@ -188,11 +229,17 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws the <see cref="Exception"/> event.
|
||||
/// Throws the <see cref="Exception"/>.event.
|
||||
/// </summary>
|
||||
/// <param name="args">The parameters passed to the event.</param>
|
||||
protected virtual void OnException(ExceptionEventArgs args) => Exception?.Invoke(this, args);
|
||||
|
||||
/// <summary>
|
||||
/// Throws the <see cref="DevicesChanged"/>-event.
|
||||
/// </summary>
|
||||
/// <param name="args">The parameters passed to the event.</param>
|
||||
protected virtual void OnDevicesChanged(DevicesChangedEventArgs args) => DevicesChanged?.Invoke(this, args);
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Dispose()
|
||||
{
|
||||
|
||||
@ -29,7 +29,7 @@ public interface IRGBDeviceProvider : IDisposable
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="IRGBDevice"/> loaded by this <see cref="IRGBDeviceProvider"/>.
|
||||
/// </summary>
|
||||
IEnumerable<IRGBDevice> Devices { get; }
|
||||
IReadOnlyList<IRGBDevice> Devices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection <see cref="IDeviceUpdateTrigger"/> registered to this device provider.
|
||||
@ -45,6 +45,11 @@ public interface IRGBDeviceProvider : IDisposable
|
||||
/// </summary>
|
||||
event EventHandler<ExceptionEventArgs>? Exception;
|
||||
|
||||
/// <summary>
|
||||
/// Occures when the devices provided by this device provider changed.
|
||||
/// </summary>
|
||||
event EventHandler<DevicesChangedEventArgs>? DevicesChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
36
RGB.NET.Core/Events/DevicesChangedEventArgs.cs
Normal file
36
RGB.NET.Core/Events/DevicesChangedEventArgs.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Core;
|
||||
|
||||
public sealed class DevicesChangedEventArgs : EventArgs
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public IRGBDevice Device { get; }
|
||||
public DevicesChangedAction Action { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public DevicesChangedEventArgs(IRGBDevice device, DevicesChangedAction action)
|
||||
{
|
||||
this.Device = device;
|
||||
this.Action = action;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public static DevicesChangedEventArgs CreateDevicesAddedArgs(IRGBDevice addedDevice) => new(addedDevice, DevicesChangedAction.Added);
|
||||
public static DevicesChangedEventArgs CreateDevicesRemovedArgs(IRGBDevice removedDevice) => new(removedDevice, DevicesChangedAction.Removed);
|
||||
|
||||
#endregion
|
||||
|
||||
public enum DevicesChangedAction
|
||||
{
|
||||
Added,
|
||||
Removed
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
@ -58,6 +58,21 @@ public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceI
|
||||
Rectangle rectangle = ledPosition.ToRectangle();
|
||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||
}
|
||||
|
||||
if (DeviceInfo.LedOffset > 0)
|
||||
FixOffsetDeviceLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fixes the locations for devices split by offset by aligning them to the top left.
|
||||
/// </summary>
|
||||
protected virtual void FixOffsetDeviceLayout()
|
||||
{
|
||||
float minX = this.Min(x => x.Location.X);
|
||||
float minY = this.Min(x => x.Location.Y);
|
||||
|
||||
foreach (Led led in this)
|
||||
led.Location = led.Location.Translate(-minX, -minY);
|
||||
}
|
||||
|
||||
protected abstract LedMapping<CorsairLedId> CreateMapping(IEnumerable<CorsairLedId> ids);
|
||||
|
||||
213
RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs
Normal file
213
RGB.NET.Devices.Corsair_Legacy/CorsairLegacyDeviceProvider.cs
Normal file
@ -0,0 +1,213 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a device provider responsible for corsair (CUE) devices.
|
||||
/// </summary>
|
||||
public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private static CorsairLegacyDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CorsairLegacyDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CorsairLegacyDeviceProvider Instance => _instance ?? new CorsairLegacyDeviceProvider();
|
||||
|
||||
/// <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() { "x86/CUESDK.dll", "x86/CUESDK_2019.dll", "x86/CUESDK_2017.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.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() { "x64/CUESDK.dll", "x64/CUESDK.x64_2019.dll", "x64/CUESDK.x64_2017.dll", "x64/CUESDK_2019.dll", "x64/CUESDK_2017.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets the protocol details for the current SDK-connection.
|
||||
/// </summary>
|
||||
public CorsairProtocolDetails? ProtocolDetails { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last error documented by CUE.
|
||||
/// </summary>
|
||||
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairLegacyDeviceProvider"/> class.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CorsairLegacyDeviceProvider()
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeSDK()
|
||||
{
|
||||
_CUESDK.Reload();
|
||||
|
||||
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
|
||||
|
||||
CorsairError error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(new CUEException(error), true);
|
||||
|
||||
if (ProtocolDetails.BreakingChanges)
|
||||
Throw(new RGBDeviceException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||
+ $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n"
|
||||
+ $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})"), true);
|
||||
|
||||
// DarthAffe 02.02.2021: 127 is iCUE
|
||||
if (!_CUESDK.CorsairSetLayerPriority(128))
|
||||
Throw(new CUEException(LastError));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IEnumerable<IRGBDevice> LoadDevices()
|
||||
{
|
||||
foreach (ICorsairRGBDevice corsairDevice in LoadCorsairDevices())
|
||||
{
|
||||
corsairDevice.Initialize();
|
||||
yield return corsairDevice;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<ICorsairRGBDevice> LoadCorsairDevices()
|
||||
{
|
||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||
for (int i = 0; i < deviceCount; i++)
|
||||
{
|
||||
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo))!;
|
||||
if (!((CorsairDeviceCaps)nativeDeviceInfo.capsMask).HasFlag(CorsairDeviceCaps.Lighting))
|
||||
continue; // Everything that doesn't support lighting control is useless
|
||||
|
||||
CorsairDeviceUpdateQueue updateQueue = new(GetUpdateTrigger(), i);
|
||||
switch (nativeDeviceInfo.type)
|
||||
{
|
||||
case CorsairDeviceType.Keyboard:
|
||||
yield return new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Mouse:
|
||||
yield return new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Headset:
|
||||
yield return new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Mousepad:
|
||||
yield return new CorsairMousepadRGBDevice(new CorsairMousepadRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.HeadsetStand:
|
||||
yield return new CorsairHeadsetStandRGBDevice(new CorsairHeadsetStandRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.MemoryModule:
|
||||
yield return new CorsairMemoryRGBDevice(new CorsairMemoryRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Mainboard:
|
||||
yield return new CorsairMainboardRGBDevice(new CorsairMainboardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.GraphicsCard:
|
||||
yield return new CorsairGraphicsCardRGBDevice(new CorsairGraphicsCardRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Touchbar:
|
||||
yield return new CorsairTouchbarRGBDevice(new CorsairTouchbarRGBDeviceInfo(i, nativeDeviceInfo), updateQueue);
|
||||
break;
|
||||
|
||||
case CorsairDeviceType.Cooler:
|
||||
case CorsairDeviceType.CommanderPro:
|
||||
case CorsairDeviceType.LightningNodePro:
|
||||
List<_CorsairChannelInfo> channels = GetChannels(nativeDeviceInfo).ToList();
|
||||
int channelsLedCount = channels.Sum(x => x.totalLedsCount);
|
||||
int deviceLedCount = nativeDeviceInfo.ledsCount - channelsLedCount;
|
||||
|
||||
if (deviceLedCount > 0)
|
||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, deviceLedCount), updateQueue);
|
||||
|
||||
int ledOffset = deviceLedCount;
|
||||
foreach (_CorsairChannelInfo channelInfo in channels)
|
||||
{
|
||||
int channelDeviceInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelDeviceInfo));
|
||||
IntPtr channelDeviceInfoPtr = channelInfo.devices;
|
||||
for (int device = 0; (device < channelInfo.devicesCount) && (ledOffset < nativeDeviceInfo.ledsCount); device++)
|
||||
{
|
||||
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo))!;
|
||||
|
||||
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(i, nativeDeviceInfo, channelDeviceInfo, ledOffset), updateQueue);
|
||||
|
||||
ledOffset += channelDeviceInfo.deviceLedCount;
|
||||
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Throw(new RGBDeviceException("Unknown Device-Type"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<_CorsairChannelInfo> GetChannels(_CorsairDeviceInfo deviceInfo)
|
||||
{
|
||||
_CorsairChannelsInfo? channelsInfo = deviceInfo.channels;
|
||||
if (channelsInfo == null) yield break;
|
||||
|
||||
IntPtr channelInfoPtr = channelsInfo.channels;
|
||||
for (int channel = 0; channel < channelsInfo.channelsCount; channel++)
|
||||
{
|
||||
yield return (_CorsairChannelInfo)Marshal.PtrToStructure(channelInfoPtr, typeof(_CorsairChannelInfo))!;
|
||||
|
||||
int channelInfoStructSize = Marshal.SizeOf(typeof(_CorsairChannelInfo));
|
||||
channelInfoPtr = new IntPtr(channelInfoPtr.ToInt64() + channelInfoStructSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Reset()
|
||||
{
|
||||
ProtocolDetails = null;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair custom.
|
||||
/// </summary>
|
||||
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>, IUnknownDevice
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairCustomRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, new LedMapping<CorsairLedId>(), updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
Mapping.Clear();
|
||||
|
||||
_CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
|
||||
if (nativeLedPositions == null) return;
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
IntPtr ptr = new(nativeLedPositions.pLedPosition.ToInt64() + (structSize * DeviceInfo.LedOffset));
|
||||
|
||||
LedId referenceLedId = GetReferenceLed(DeviceInfo.DeviceType);
|
||||
for (int i = 0; i < DeviceInfo.LedCount; i++)
|
||||
{
|
||||
LedId ledId = referenceLedId + i;
|
||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||
if (ledPosition == null)
|
||||
{
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
Mapping.Add(ledId, ledPosition.LedId);
|
||||
|
||||
Rectangle rectangle = ledPosition.ToRectangle();
|
||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
}
|
||||
|
||||
if (DeviceInfo.LedOffset > 0)
|
||||
FixOffsetDeviceLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fixes the locations for devices split by offset by aligning them to the top left.
|
||||
/// </summary>
|
||||
protected virtual void FixOffsetDeviceLayout()
|
||||
{
|
||||
float minX = this.Min(x => x.Location.X);
|
||||
float minY = this.Min(x => x.Location.Y);
|
||||
|
||||
foreach (Led led in this)
|
||||
led.Location = led.Location.Translate(-minX, -minY);
|
||||
}
|
||||
|
||||
private static LedId GetReferenceLed(RGBDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
RGBDeviceType.LedStripe => LedId.LedStripe1,
|
||||
RGBDeviceType.Fan => LedId.Fan1,
|
||||
RGBDeviceType.Cooler => LedId.Cooler1,
|
||||
_ => LedId.Custom1
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairCustomRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairCustomRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of LEDs this device contains.
|
||||
/// </summary>
|
||||
public int LedCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the offset used to access the LEDs of this device.
|
||||
/// </summary>
|
||||
internal int LedOffset { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair._CorsairChannelDeviceInfo" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
|
||||
/// <param name="channelDeviceInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairChannelDeviceInfo"/> representing this device.</param>
|
||||
/// <param name="ledOffset">The offset used to find the LEDs of this device.</param>
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, int ledOffset)
|
||||
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
|
||||
GetModelName(nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo))
|
||||
{
|
||||
this.LedOffset = ledOffset;
|
||||
|
||||
LedCount = channelDeviceInfo.deviceLedCount;
|
||||
}
|
||||
|
||||
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, int ledCount)
|
||||
: base(deviceIndex, GetDeviceType(nativeInfo.type), nativeInfo)
|
||||
{
|
||||
this.LedCount = ledCount;
|
||||
|
||||
LedOffset = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown,
|
||||
CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanML => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.DAP => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.EightLedSeriesFan => RGBDeviceType.Fan,
|
||||
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
|
||||
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
|
||||
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static RGBDeviceType GetDeviceType(CorsairDeviceType deviceType)
|
||||
=> deviceType switch
|
||||
{
|
||||
CorsairDeviceType.Unknown => RGBDeviceType.Unknown,
|
||||
CorsairDeviceType.Mouse => RGBDeviceType.Mouse,
|
||||
CorsairDeviceType.Keyboard => RGBDeviceType.Keyboard,
|
||||
CorsairDeviceType.Headset => RGBDeviceType.Headset,
|
||||
CorsairDeviceType.Mousepad => RGBDeviceType.Mousepad,
|
||||
CorsairDeviceType.HeadsetStand => RGBDeviceType.HeadsetStand,
|
||||
CorsairDeviceType.CommanderPro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.LightningNodePro => RGBDeviceType.LedController,
|
||||
CorsairDeviceType.MemoryModule => RGBDeviceType.DRAM,
|
||||
CorsairDeviceType.Cooler => RGBDeviceType.Cooler,
|
||||
CorsairDeviceType.Mainboard => RGBDeviceType.Mainboard,
|
||||
CorsairDeviceType.GraphicsCard => RGBDeviceType.GraphicsCard,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
|
||||
};
|
||||
|
||||
private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo)
|
||||
{
|
||||
switch (channelDeviceInfo.type)
|
||||
{
|
||||
case CorsairChannelDeviceType.Invalid:
|
||||
return model;
|
||||
|
||||
case CorsairChannelDeviceType.FanHD:
|
||||
return "HD Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanSP:
|
||||
return "SP Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanLL:
|
||||
return "LL Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanML:
|
||||
return "ML Fan";
|
||||
|
||||
case CorsairChannelDeviceType.FanQL:
|
||||
return "QL Fan";
|
||||
|
||||
case CorsairChannelDeviceType.EightLedSeriesFan:
|
||||
return "8-Led-Series Fan Fan";
|
||||
|
||||
case CorsairChannelDeviceType.Strip:
|
||||
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
|
||||
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138))
|
||||
return "LS100 LED Strip (dual monitor)";
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84))
|
||||
return "LS100 LED Strip (single monitor)";
|
||||
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15))
|
||||
return "LS100 LED Strip (short)";
|
||||
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27))
|
||||
return "LS100 LED Strip (long)";
|
||||
// Device model is "Commander Pro" for regular LED strips
|
||||
else
|
||||
return "LED Strip";
|
||||
|
||||
case CorsairChannelDeviceType.DAP:
|
||||
return "DAP Fan";
|
||||
|
||||
case CorsairChannelDeviceType.WaterBlock:
|
||||
return "Water Block";
|
||||
|
||||
case CorsairChannelDeviceType.Pump:
|
||||
return "Pump";
|
||||
|
||||
default:
|
||||
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
|
||||
throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null);
|
||||
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
14
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs
Normal file
14
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairAccessMode.cs
Normal file
@ -0,0 +1,14 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an SDK access mode.
|
||||
/// </summary>
|
||||
public enum CorsairAccessMode
|
||||
{
|
||||
ExclusiveLightingControl = 0
|
||||
};
|
||||
@ -0,0 +1,25 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available corsair channel device types.
|
||||
/// </summary>
|
||||
public enum CorsairChannelDeviceType
|
||||
{
|
||||
Invalid = 0,
|
||||
FanHD = 1,
|
||||
FanSP = 2,
|
||||
FanLL = 3,
|
||||
FanML = 4,
|
||||
Strip = 5,
|
||||
DAP = 6,
|
||||
Pump = 7,
|
||||
FanQL = 8,
|
||||
WaterBlock = 9,
|
||||
EightLedSeriesFan = 10 // Previously called FanSPPRO
|
||||
};
|
||||
28
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs
Normal file
28
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceCaps.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of corsair device capabilities.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum CorsairDeviceCaps
|
||||
{
|
||||
/// <summary>
|
||||
/// For devices that do not support any SDK functions.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// For devices that has controlled lighting.
|
||||
/// </summary>
|
||||
Lighting = 1,
|
||||
|
||||
/// <summary>
|
||||
/// For devices that provide current state through set of properties.
|
||||
/// </summary>
|
||||
PropertyLookup = 2
|
||||
};
|
||||
27
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs
Normal file
27
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairDeviceType.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available corsair device types.
|
||||
/// </summary>
|
||||
public enum CorsairDeviceType
|
||||
{
|
||||
Unknown = 0,
|
||||
Mouse = 1,
|
||||
Keyboard = 2,
|
||||
Headset = 3,
|
||||
Mousepad = 4,
|
||||
HeadsetStand = 5,
|
||||
CommanderPro = 6,
|
||||
LightningNodePro = 7,
|
||||
MemoryModule = 8,
|
||||
Cooler = 9,
|
||||
Mainboard = 10,
|
||||
GraphicsCard = 11,
|
||||
Touchbar = 12
|
||||
};
|
||||
41
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs
Normal file
41
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairError.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Shared list of all errors which could happen during calling of Corsair* functions.
|
||||
/// </summary>
|
||||
public enum CorsairError
|
||||
{
|
||||
/// <summary>
|
||||
/// If previously called function completed successfully.
|
||||
/// </summary>
|
||||
Success,
|
||||
|
||||
/// <summary>
|
||||
/// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error)
|
||||
/// </summary>
|
||||
ServerNotFound,
|
||||
|
||||
/// <summary>
|
||||
/// If some other client has or took over exclusive control. (runtime error)
|
||||
/// </summary>
|
||||
NoControl,
|
||||
|
||||
/// <summary>
|
||||
/// If developer did not perform protocol handshake. (developer error)
|
||||
/// </summary>
|
||||
ProtocolHandshakeMissing,
|
||||
|
||||
/// <summary>
|
||||
/// If developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old.
|
||||
/// Check CorsairProtocolDetails for details). (developer error)
|
||||
/// </summary>
|
||||
IncompatibleProtocol,
|
||||
|
||||
/// <summary>
|
||||
/// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error)
|
||||
/// </summary>
|
||||
InvalidArguments
|
||||
};
|
||||
1742
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs
Normal file
1742
RGB.NET.Devices.Corsair_Legacy/Enum/CorsairLedId.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available logical layouts for corsair keyboards.
|
||||
/// </summary>
|
||||
public enum CorsairLogicalKeyboardLayout
|
||||
{
|
||||
US_Int = 1,
|
||||
NA = 2,
|
||||
EU = 3,
|
||||
UK = 4,
|
||||
BE = 5,
|
||||
BR = 6,
|
||||
CH = 7,
|
||||
CN = 8,
|
||||
DE = 9,
|
||||
ES = 10,
|
||||
FR = 11,
|
||||
IT = 12,
|
||||
ND = 13,
|
||||
RU = 14,
|
||||
JP = 15,
|
||||
KR = 16,
|
||||
TW = 17,
|
||||
MEX = 18
|
||||
};
|
||||
@ -0,0 +1,35 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available physical layouts for corsair keyboards.
|
||||
/// </summary>
|
||||
public enum CorsairPhysicalKeyboardLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// US-Keyboard
|
||||
/// </summary>
|
||||
US = 1,
|
||||
|
||||
/// <summary>
|
||||
/// UK-Keyboard
|
||||
/// </summary>
|
||||
UK = 2,
|
||||
|
||||
/// <summary>
|
||||
/// BR-Keyboard
|
||||
/// </summary>
|
||||
BR = 3,
|
||||
|
||||
/// <summary>
|
||||
/// JP-Keyboard
|
||||
/// </summary>
|
||||
JP = 4,
|
||||
|
||||
/// <summary>
|
||||
/// KR-Keyboard
|
||||
/// </summary>
|
||||
KR = 5
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains a list of available physical layouts for mice.
|
||||
/// </summary>
|
||||
public enum CorsairPhysicalMouseLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// Zone1-Mouse
|
||||
/// </summary>
|
||||
Zones1 = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Zone2-Mouse
|
||||
/// </summary>
|
||||
Zones2 = 7,
|
||||
|
||||
/// <summary>
|
||||
/// Zone3-Mouse
|
||||
/// </summary>
|
||||
Zones3 = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Zone4-Mouse
|
||||
/// </summary>
|
||||
Zones4 = 9,
|
||||
|
||||
/// <summary>
|
||||
/// Zone5-Mouse
|
||||
/// </summary>
|
||||
Zones5 = 101,
|
||||
|
||||
/// <summary>
|
||||
/// Zone6-Mouse
|
||||
/// </summary>
|
||||
Zones6 = 11,
|
||||
|
||||
/// <summary>
|
||||
/// Zone7-Mouse
|
||||
/// </summary>
|
||||
Zones7 = 12,
|
||||
|
||||
/// <summary>
|
||||
/// Zone8-Mouse
|
||||
/// </summary>
|
||||
Zones8 = 13,
|
||||
|
||||
/// <summary>
|
||||
/// Zone9-Mouse
|
||||
/// </summary>
|
||||
Zones9 = 14,
|
||||
|
||||
/// <summary>
|
||||
/// Zone10-Mouse
|
||||
/// </summary>
|
||||
Zones10 = 15,
|
||||
|
||||
/// <summary>
|
||||
/// Zone11-Mouse
|
||||
/// </summary>
|
||||
Zones11 = 16,
|
||||
|
||||
/// <summary>
|
||||
/// Zone12-Mouse
|
||||
/// </summary>
|
||||
Zones12 = 17,
|
||||
|
||||
/// <summary>
|
||||
/// Zone13-Mouse
|
||||
/// </summary>
|
||||
Zones13 = 18,
|
||||
|
||||
/// <summary>
|
||||
/// Zone14-Mouse
|
||||
/// </summary>
|
||||
Zones14 = 19,
|
||||
|
||||
/// <summary>
|
||||
/// Zone15-Mouse
|
||||
/// </summary>
|
||||
Zones15 = 20,
|
||||
|
||||
/// <summary>
|
||||
/// Zone16-Mouse
|
||||
/// </summary>
|
||||
Zones16 = 21,
|
||||
|
||||
/// <summary>
|
||||
/// Zone17-Mouse
|
||||
/// </summary>
|
||||
Zones17 = 22,
|
||||
|
||||
/// <summary>
|
||||
/// Zone18-Mouse
|
||||
/// </summary>
|
||||
Zones18 = 23,
|
||||
|
||||
/// <summary>
|
||||
/// Zone19-Mouse
|
||||
/// </summary>
|
||||
Zones19 = 24,
|
||||
|
||||
/// <summary>
|
||||
/// Zone20-Mouse
|
||||
/// </summary>
|
||||
Zones20 = 25
|
||||
}
|
||||
36
RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs
Normal file
36
RGB.NET.Devices.Corsair_Legacy/Exceptions/CUEException.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents an exception thrown by the CUE.
|
||||
/// </summary>
|
||||
public class CUEException : ApplicationException
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CorsairError" /> provided by CUE.
|
||||
/// </summary>
|
||||
public CorsairError Error { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CUEException" /> class.
|
||||
/// </summary>
|
||||
/// <param name="error">The <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairError" /> provided by CUE, which leads to this exception.</param>
|
||||
public CUEException(CorsairError error)
|
||||
{
|
||||
this.Error = error;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents the update-queue performing updates for corsair devices.
|
||||
/// </summary>
|
||||
public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private int _deviceIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairDeviceUpdateQueue"/> class.
|
||||
/// </summary>
|
||||
/// <param name="updateTrigger">The update trigger used by this queue.</param>
|
||||
/// <param name="deviceIndex">The index used to identify the device.</param>
|
||||
public CorsairDeviceUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceIndex)
|
||||
: base(updateTrigger)
|
||||
{
|
||||
this._deviceIndex = deviceIndex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * dataSet.Length);
|
||||
IntPtr addPtr = new(ptr.ToInt64());
|
||||
try
|
||||
{
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
{
|
||||
_CorsairLedColor corsairColor = new()
|
||||
{
|
||||
ledId = (int)key,
|
||||
r = color.GetR(),
|
||||
g = color.GetG(),
|
||||
b = color.GetB()
|
||||
};
|
||||
|
||||
Marshal.StructureToPtr(corsairColor, addPtr, false);
|
||||
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
||||
}
|
||||
|
||||
_CUESDK.CorsairSetLedsColorsBufferByDeviceIndex(_deviceIndex, dataSet.Length, ptr);
|
||||
_CUESDK.CorsairSetLedsColorsFlushBuffer();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CorsairLegacyDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Managed wrapper for CorsairProtocolDetails.
|
||||
/// </summary>
|
||||
public class CorsairProtocolDetails
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// String containing version of SDK(like "1.0.0.1").
|
||||
/// Always contains valid value even if there was no CUE found.
|
||||
/// </summary>
|
||||
public string? SdkVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// String containing version of CUE(like "1.0.0.1") or NULL if CUE was not found.
|
||||
/// </summary>
|
||||
public string? ServerVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Integer that specifies version of protocol that is implemented by current SDK.
|
||||
/// Numbering starts from 1.
|
||||
/// Always contains valid value even if there was no CUE found.
|
||||
/// </summary>
|
||||
public int SdkProtocolVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Integer that specifies version of protocol that is implemented by CUE.
|
||||
/// Numbering starts from 1.
|
||||
/// If CUE was not found then this value will be 0.
|
||||
/// </summary>
|
||||
public int ServerProtocolVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client.
|
||||
/// </summary>
|
||||
public bool BreakingChanges { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed CorsairProtocolDetails.
|
||||
/// </summary>
|
||||
/// <param name="nativeDetails">The native CorsairProtocolDetails-struct</param>
|
||||
internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails)
|
||||
{
|
||||
this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.sdkVersion);
|
||||
this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeDetails.serverVersion);
|
||||
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
|
||||
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
|
||||
this.BreakingChanges = nativeDetails.breakingChanges != 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
76
RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs
Normal file
76
RGB.NET.Devices.Corsair_Legacy/Generic/CorsairRGBDevice.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ICorsairRGBDevice
|
||||
where TDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping of <see cref="LedId"/> to <see cref="CorsairLedId"/> used to update the LEDs of this device.
|
||||
/// </summary>
|
||||
protected LedMapping<CorsairLedId> Mapping { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by CUE for the device.</param>
|
||||
/// <param name="mapping">The mapping <see cref="LedId"/> to <see cref="CorsairLedId"/> used to update the LEDs of this device.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
protected CorsairRGBDevice(TDeviceInfo info, LedMapping<CorsairLedId> mapping, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{
|
||||
this.Mapping = mapping;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
void ICorsairRGBDevice.Initialize() => InitializeLayout();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the LEDs of the device based on the data provided by the SDK.
|
||||
/// </summary>
|
||||
protected virtual void InitializeLayout()
|
||||
{
|
||||
_CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
|
||||
if (nativeLedPositions == null) return;
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
IntPtr ptr = nativeLedPositions.pLedPosition;
|
||||
|
||||
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
||||
{
|
||||
_CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||
if (ledPosition == null)
|
||||
{
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
LedId ledId = Mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
|
||||
Rectangle rectangle = ledPosition.ToRectangle();
|
||||
AddLed(ledId, rectangle.Location, rectangle.Size);
|
||||
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object GetLedCustomData(LedId ledId) => Mapping.TryGetValue(ledId, out CorsairLedId corsairLedId) ? corsairLedId : CorsairLedId.Invalid;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a Corsair-<see cref="T:RGB.NET.Core.IRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairRGBDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the corsair specific device type.
|
||||
/// </summary>
|
||||
public CorsairDeviceType CorsairDeviceType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
public int CorsairDeviceIndex { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBDeviceType DeviceType { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DeviceName { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Manufacturer => "Corsair";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Model { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the unique ID provided by the Corsair-SDK.
|
||||
/// Returns string.Empty for Custom devices.
|
||||
/// </summary>
|
||||
public string DeviceId { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public object? LayoutMetadata { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
|
||||
/// </summary>
|
||||
public CorsairDeviceCaps CapsMask { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.</param>
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
|
||||
{
|
||||
this.CorsairDeviceIndex = deviceIndex;
|
||||
this.DeviceType = deviceType;
|
||||
this.CorsairDeviceType = nativeInfo.type;
|
||||
this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
|
||||
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
||||
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
||||
|
||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.</param>
|
||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
/// <param name="modelName">The name of the device-model (overwrites the one provided with the device info).</param>
|
||||
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName)
|
||||
{
|
||||
this.CorsairDeviceIndex = deviceIndex;
|
||||
this.DeviceType = deviceType;
|
||||
this.CorsairDeviceType = nativeInfo.type;
|
||||
this.Model = modelName;
|
||||
this.DeviceId = nativeInfo.deviceId ?? string.Empty;
|
||||
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
|
||||
|
||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
11
RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs
Normal file
11
RGB.NET.Devices.Corsair_Legacy/Generic/ICorsairRGBDevice.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a corsair RGB-device.
|
||||
/// </summary>
|
||||
public interface ICorsairRGBDevice : IRGBDevice
|
||||
{
|
||||
internal void Initialize();
|
||||
}
|
||||
302
RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs
Normal file
302
RGB.NET.Devices.Corsair_Legacy/Generic/LedMappings.cs
Normal file
@ -0,0 +1,302 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Contains mappings for <see cref="LedId"/> to <see cref="CorsairLedId"/>.
|
||||
/// </summary>
|
||||
public static class LedMappings
|
||||
{
|
||||
static LedMappings()
|
||||
{
|
||||
for (int i = 0; i <= (CorsairLedId.GPU50 - CorsairLedId.GPU1); i++)
|
||||
GraphicsCard.Add(LedId.GraphicsCard1 + i, CorsairLedId.GPU1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.HeadsetStandZone9 - CorsairLedId.HeadsetStandZone1); i++)
|
||||
HeadsetStand.Add(LedId.HeadsetStand1 + i, CorsairLedId.HeadsetStandZone1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.Mainboard100 - CorsairLedId.Mainboard1); i++)
|
||||
Mainboard.Add(LedId.Mainboard1 + i, CorsairLedId.Mainboard1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.DRAM12 - CorsairLedId.DRAM1); i++)
|
||||
Memory.Add(LedId.DRAM1 + i, CorsairLedId.DRAM1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.Zone15 - CorsairLedId.Zone1); i++)
|
||||
Mousepad.Add(LedId.Mousepad1 + i, CorsairLedId.Zone1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.OemLed100 - CorsairLedId.OemLed1); i++)
|
||||
Keyboard.Add(LedId.Custom1 + i, CorsairLedId.OemLed1 + i);
|
||||
|
||||
for (int i = 0; i <= (CorsairLedId.OemLed250 - CorsairLedId.OemLed101); i++)
|
||||
Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for graphics cards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> GraphicsCard { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for headsets.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> HeadsetStand { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mainboards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mainboard { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for memory.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Memory { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mousepads.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mousepad { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for headsets.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Headset { get; } = new()
|
||||
{
|
||||
{ LedId.Headset1, CorsairLedId.LeftLogo },
|
||||
{ LedId.Headset2, CorsairLedId.RightLogo },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mice.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Mouse { get; } = new()
|
||||
{
|
||||
{ LedId.Mouse1, CorsairLedId.B1 },
|
||||
{ LedId.Mouse2, CorsairLedId.B2 },
|
||||
{ LedId.Mouse3, CorsairLedId.B3 },
|
||||
{ LedId.Mouse4, CorsairLedId.B4 },
|
||||
{ LedId.Mouse5, CorsairLedId.B5 },
|
||||
{ LedId.Mouse6, CorsairLedId.B6 },
|
||||
{ LedId.Mouse7, CorsairLedId.B7 },
|
||||
{ LedId.Mouse8, CorsairLedId.B8 },
|
||||
{ LedId.Mouse9, CorsairLedId.B9 },
|
||||
{ LedId.Mouse10, CorsairLedId.B10 },
|
||||
{ LedId.Mouse11, CorsairLedId.B11 },
|
||||
{ LedId.Mouse12, CorsairLedId.B12 },
|
||||
{ LedId.Mouse13, CorsairLedId.B13 },
|
||||
{ LedId.Mouse14, CorsairLedId.B14 },
|
||||
{ LedId.Mouse15, CorsairLedId.B15 },
|
||||
{ LedId.Mouse16, CorsairLedId.B16 },
|
||||
{ LedId.Mouse17, CorsairLedId.B17 },
|
||||
{ LedId.Mouse18, CorsairLedId.B18 },
|
||||
{ LedId.Mouse19, CorsairLedId.B19 },
|
||||
{ LedId.Mouse20, CorsairLedId.B20 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for keyboards.
|
||||
/// </summary>
|
||||
public static LedMapping<CorsairLedId> Keyboard { get; } = new()
|
||||
{
|
||||
{ LedId.Invalid, CorsairLedId.Invalid },
|
||||
{ LedId.Logo, CorsairLedId.Logo },
|
||||
{ LedId.Keyboard_Escape, CorsairLedId.Escape },
|
||||
{ LedId.Keyboard_F1, CorsairLedId.F1 },
|
||||
{ LedId.Keyboard_F2, CorsairLedId.F2 },
|
||||
{ LedId.Keyboard_F3, CorsairLedId.F3 },
|
||||
{ LedId.Keyboard_F4, CorsairLedId.F4 },
|
||||
{ LedId.Keyboard_F5, CorsairLedId.F5 },
|
||||
{ LedId.Keyboard_F6, CorsairLedId.F6 },
|
||||
{ LedId.Keyboard_F7, CorsairLedId.F7 },
|
||||
{ LedId.Keyboard_F8, CorsairLedId.F8 },
|
||||
{ LedId.Keyboard_F9, CorsairLedId.F9 },
|
||||
{ LedId.Keyboard_F10, CorsairLedId.F10 },
|
||||
{ LedId.Keyboard_F11, CorsairLedId.F11 },
|
||||
{ LedId.Keyboard_GraveAccentAndTilde, CorsairLedId.GraveAccentAndTilde },
|
||||
{ LedId.Keyboard_1, CorsairLedId.D1 },
|
||||
{ LedId.Keyboard_2, CorsairLedId.D2 },
|
||||
{ LedId.Keyboard_3, CorsairLedId.D3 },
|
||||
{ LedId.Keyboard_4, CorsairLedId.D4 },
|
||||
{ LedId.Keyboard_5, CorsairLedId.D5 },
|
||||
{ LedId.Keyboard_6, CorsairLedId.D6 },
|
||||
{ LedId.Keyboard_7, CorsairLedId.D7 },
|
||||
{ LedId.Keyboard_8, CorsairLedId.D8 },
|
||||
{ LedId.Keyboard_9, CorsairLedId.D9 },
|
||||
{ LedId.Keyboard_0, CorsairLedId.D0 },
|
||||
{ LedId.Keyboard_MinusAndUnderscore, CorsairLedId.MinusAndUnderscore },
|
||||
{ LedId.Keyboard_Tab, CorsairLedId.Tab },
|
||||
{ LedId.Keyboard_Q, CorsairLedId.Q },
|
||||
{ LedId.Keyboard_W, CorsairLedId.W },
|
||||
{ LedId.Keyboard_E, CorsairLedId.E },
|
||||
{ LedId.Keyboard_R, CorsairLedId.R },
|
||||
{ LedId.Keyboard_T, CorsairLedId.T },
|
||||
{ LedId.Keyboard_Y, CorsairLedId.Y },
|
||||
{ LedId.Keyboard_U, CorsairLedId.U },
|
||||
{ LedId.Keyboard_I, CorsairLedId.I },
|
||||
{ LedId.Keyboard_O, CorsairLedId.O },
|
||||
{ LedId.Keyboard_P, CorsairLedId.P },
|
||||
{ LedId.Keyboard_BracketLeft, CorsairLedId.BracketLeft },
|
||||
{ LedId.Keyboard_CapsLock, CorsairLedId.CapsLock },
|
||||
{ LedId.Keyboard_A, CorsairLedId.A },
|
||||
{ LedId.Keyboard_S, CorsairLedId.S },
|
||||
{ LedId.Keyboard_D, CorsairLedId.D },
|
||||
{ LedId.Keyboard_F, CorsairLedId.F },
|
||||
{ LedId.Keyboard_G, CorsairLedId.G },
|
||||
{ LedId.Keyboard_H, CorsairLedId.H },
|
||||
{ LedId.Keyboard_J, CorsairLedId.J },
|
||||
{ LedId.Keyboard_K, CorsairLedId.K },
|
||||
{ LedId.Keyboard_L, CorsairLedId.L },
|
||||
{ LedId.Keyboard_SemicolonAndColon, CorsairLedId.SemicolonAndColon },
|
||||
{ LedId.Keyboard_ApostropheAndDoubleQuote, CorsairLedId.ApostropheAndDoubleQuote },
|
||||
{ LedId.Keyboard_LeftShift, CorsairLedId.LeftShift },
|
||||
{ LedId.Keyboard_NonUsBackslash, CorsairLedId.NonUsBackslash },
|
||||
{ LedId.Keyboard_Z, CorsairLedId.Z },
|
||||
{ LedId.Keyboard_X, CorsairLedId.X },
|
||||
{ LedId.Keyboard_C, CorsairLedId.C },
|
||||
{ LedId.Keyboard_V, CorsairLedId.V },
|
||||
{ LedId.Keyboard_B, CorsairLedId.B },
|
||||
{ LedId.Keyboard_N, CorsairLedId.N },
|
||||
{ LedId.Keyboard_M, CorsairLedId.M },
|
||||
{ LedId.Keyboard_CommaAndLessThan, CorsairLedId.CommaAndLessThan },
|
||||
{ LedId.Keyboard_PeriodAndBiggerThan, CorsairLedId.PeriodAndBiggerThan },
|
||||
{ LedId.Keyboard_SlashAndQuestionMark, CorsairLedId.SlashAndQuestionMark },
|
||||
{ LedId.Keyboard_LeftCtrl, CorsairLedId.LeftCtrl },
|
||||
{ LedId.Keyboard_LeftGui, CorsairLedId.LeftGui },
|
||||
{ LedId.Keyboard_LeftAlt, CorsairLedId.LeftAlt },
|
||||
{ LedId.Keyboard_Lang2, CorsairLedId.Lang2 },
|
||||
{ LedId.Keyboard_Space, CorsairLedId.Space },
|
||||
{ LedId.Keyboard_Lang1, CorsairLedId.Lang1 },
|
||||
{ LedId.Keyboard_International2, CorsairLedId.International2 },
|
||||
{ LedId.Keyboard_RightAlt, CorsairLedId.RightAlt },
|
||||
{ LedId.Keyboard_RightGui, CorsairLedId.RightGui },
|
||||
{ LedId.Keyboard_Application, CorsairLedId.Application },
|
||||
{ LedId.Keyboard_Brightness, CorsairLedId.Brightness },
|
||||
{ LedId.Keyboard_F12, CorsairLedId.F12 },
|
||||
{ LedId.Keyboard_PrintScreen, CorsairLedId.PrintScreen },
|
||||
{ LedId.Keyboard_ScrollLock, CorsairLedId.ScrollLock },
|
||||
{ LedId.Keyboard_PauseBreak, CorsairLedId.PauseBreak },
|
||||
{ LedId.Keyboard_Insert, CorsairLedId.Insert },
|
||||
{ LedId.Keyboard_Home, CorsairLedId.Home },
|
||||
{ LedId.Keyboard_PageUp, CorsairLedId.PageUp },
|
||||
{ LedId.Keyboard_BracketRight, CorsairLedId.BracketRight },
|
||||
{ LedId.Keyboard_Backslash, CorsairLedId.Backslash },
|
||||
{ LedId.Keyboard_NonUsTilde, CorsairLedId.NonUsTilde },
|
||||
{ LedId.Keyboard_Enter, CorsairLedId.Enter },
|
||||
{ LedId.Keyboard_International1, CorsairLedId.International1 },
|
||||
{ LedId.Keyboard_EqualsAndPlus, CorsairLedId.EqualsAndPlus },
|
||||
{ LedId.Keyboard_International3, CorsairLedId.International3 },
|
||||
{ LedId.Keyboard_Backspace, CorsairLedId.Backspace },
|
||||
{ LedId.Keyboard_Delete, CorsairLedId.Delete },
|
||||
{ LedId.Keyboard_End, CorsairLedId.End },
|
||||
{ LedId.Keyboard_PageDown, CorsairLedId.PageDown },
|
||||
{ LedId.Keyboard_RightShift, CorsairLedId.RightShift },
|
||||
{ LedId.Keyboard_RightCtrl, CorsairLedId.RightCtrl },
|
||||
{ LedId.Keyboard_ArrowUp, CorsairLedId.UpArrow },
|
||||
{ LedId.Keyboard_ArrowLeft, CorsairLedId.LeftArrow },
|
||||
{ LedId.Keyboard_ArrowDown, CorsairLedId.DownArrow },
|
||||
{ LedId.Keyboard_ArrowRight, CorsairLedId.RightArrow },
|
||||
{ LedId.Keyboard_WinLock, CorsairLedId.WinLock },
|
||||
{ LedId.Keyboard_MediaMute, CorsairLedId.Mute },
|
||||
{ LedId.Keyboard_MediaStop, CorsairLedId.Stop },
|
||||
{ LedId.Keyboard_MediaPreviousTrack, CorsairLedId.ScanPreviousTrack },
|
||||
{ LedId.Keyboard_MediaPlay, CorsairLedId.PlayPause },
|
||||
{ LedId.Keyboard_MediaNextTrack, CorsairLedId.ScanNextTrack },
|
||||
{ LedId.Keyboard_NumLock, CorsairLedId.NumLock },
|
||||
{ LedId.Keyboard_NumSlash, CorsairLedId.KeypadSlash },
|
||||
{ LedId.Keyboard_NumAsterisk, CorsairLedId.KeypadAsterisk },
|
||||
{ LedId.Keyboard_NumMinus, CorsairLedId.KeypadMinus },
|
||||
{ LedId.Keyboard_NumPlus, CorsairLedId.KeypadPlus },
|
||||
{ LedId.Keyboard_NumEnter, CorsairLedId.KeypadEnter },
|
||||
{ LedId.Keyboard_Num7, CorsairLedId.Keypad7 },
|
||||
{ LedId.Keyboard_Num8, CorsairLedId.Keypad8 },
|
||||
{ LedId.Keyboard_Num9, CorsairLedId.Keypad9 },
|
||||
{ LedId.Keyboard_NumComma, CorsairLedId.KeypadComma },
|
||||
{ LedId.Keyboard_Num4, CorsairLedId.Keypad4 },
|
||||
{ LedId.Keyboard_Num5, CorsairLedId.Keypad5 },
|
||||
{ LedId.Keyboard_Num6, CorsairLedId.Keypad6 },
|
||||
{ LedId.Keyboard_Num1, CorsairLedId.Keypad1 },
|
||||
{ LedId.Keyboard_Num2, CorsairLedId.Keypad2 },
|
||||
{ LedId.Keyboard_Num3, CorsairLedId.Keypad3 },
|
||||
{ LedId.Keyboard_Num0, CorsairLedId.Keypad0 },
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, CorsairLedId.KeypadPeriodAndDelete },
|
||||
{ LedId.Keyboard_Programmable1, CorsairLedId.G1 },
|
||||
{ LedId.Keyboard_Programmable2, CorsairLedId.G2 },
|
||||
{ LedId.Keyboard_Programmable3, CorsairLedId.G3 },
|
||||
{ LedId.Keyboard_Programmable4, CorsairLedId.G4 },
|
||||
{ LedId.Keyboard_Programmable5, CorsairLedId.G5 },
|
||||
{ LedId.Keyboard_Programmable6, CorsairLedId.G6 },
|
||||
{ LedId.Keyboard_Programmable7, CorsairLedId.G7 },
|
||||
{ LedId.Keyboard_Programmable8, CorsairLedId.G8 },
|
||||
{ LedId.Keyboard_Programmable9, CorsairLedId.G9 },
|
||||
{ LedId.Keyboard_Programmable10, CorsairLedId.G10 },
|
||||
{ LedId.Keyboard_MediaVolumeUp, CorsairLedId.VolumeUp },
|
||||
{ LedId.Keyboard_MediaVolumeDown, CorsairLedId.VolumeDown },
|
||||
{ LedId.Keyboard_MacroRecording, CorsairLedId.MR },
|
||||
{ LedId.Keyboard_Macro1, CorsairLedId.M1 },
|
||||
{ LedId.Keyboard_Macro2, CorsairLedId.M2 },
|
||||
{ LedId.Keyboard_Macro3, CorsairLedId.M3 },
|
||||
{ LedId.Keyboard_Programmable11, CorsairLedId.G11 },
|
||||
{ LedId.Keyboard_Programmable12, CorsairLedId.G12 },
|
||||
{ LedId.Keyboard_Programmable13, CorsairLedId.G13 },
|
||||
{ LedId.Keyboard_Programmable14, CorsairLedId.G14 },
|
||||
{ LedId.Keyboard_Programmable15, CorsairLedId.G15 },
|
||||
{ LedId.Keyboard_Programmable16, CorsairLedId.G16 },
|
||||
{ LedId.Keyboard_Programmable17, CorsairLedId.G17 },
|
||||
{ LedId.Keyboard_Programmable18, CorsairLedId.G18 },
|
||||
{ LedId.Keyboard_International5, CorsairLedId.International5 },
|
||||
{ LedId.Keyboard_International4, CorsairLedId.International4 },
|
||||
{ LedId.Keyboard_Profile, CorsairLedId.Profile },
|
||||
{ LedId.Keyboard_LedProgramming, CorsairLedId.LedProgramming },
|
||||
{ LedId.Keyboard_Function, CorsairLedId.Fn },
|
||||
|
||||
{ LedId.LedStripe1, CorsairLedId.Lightbar1 },
|
||||
{ LedId.LedStripe2, CorsairLedId.Lightbar2 },
|
||||
{ LedId.LedStripe3, CorsairLedId.Lightbar3 },
|
||||
{ LedId.LedStripe4, CorsairLedId.Lightbar4 },
|
||||
{ LedId.LedStripe5, CorsairLedId.Lightbar5 },
|
||||
{ LedId.LedStripe6, CorsairLedId.Lightbar6 },
|
||||
{ LedId.LedStripe7, CorsairLedId.Lightbar7 },
|
||||
{ LedId.LedStripe8, CorsairLedId.Lightbar8 },
|
||||
{ LedId.LedStripe9, CorsairLedId.Lightbar9 },
|
||||
{ LedId.LedStripe10, CorsairLedId.Lightbar10 },
|
||||
{ LedId.LedStripe11, CorsairLedId.Lightbar11 },
|
||||
{ LedId.LedStripe12, CorsairLedId.Lightbar12 },
|
||||
{ LedId.LedStripe13, CorsairLedId.Lightbar13 },
|
||||
{ LedId.LedStripe14, CorsairLedId.Lightbar14 },
|
||||
{ LedId.LedStripe15, CorsairLedId.Lightbar15 },
|
||||
{ LedId.LedStripe16, CorsairLedId.Lightbar16 },
|
||||
{ LedId.LedStripe17, CorsairLedId.Lightbar17 },
|
||||
{ LedId.LedStripe18, CorsairLedId.Lightbar18 },
|
||||
{ LedId.LedStripe19, CorsairLedId.Lightbar19 },
|
||||
{ LedId.LedStripe20, CorsairLedId.Lightbar20 },
|
||||
{ LedId.LedStripe21, CorsairLedId.Lightbar21 },
|
||||
{ LedId.LedStripe22, CorsairLedId.Lightbar22 },
|
||||
{ LedId.LedStripe23, CorsairLedId.Lightbar23 },
|
||||
{ LedId.LedStripe24, CorsairLedId.Lightbar24 },
|
||||
{ LedId.LedStripe25, CorsairLedId.Lightbar25 },
|
||||
{ LedId.LedStripe26, CorsairLedId.Lightbar26 },
|
||||
{ LedId.LedStripe27, CorsairLedId.Lightbar27 },
|
||||
{ LedId.LedStripe28, CorsairLedId.Lightbar28 },
|
||||
{ LedId.LedStripe29, CorsairLedId.Lightbar29 },
|
||||
{ LedId.LedStripe30, CorsairLedId.Lightbar30 },
|
||||
{ LedId.LedStripe31, CorsairLedId.Lightbar31 },
|
||||
{ LedId.LedStripe32, CorsairLedId.Lightbar32 },
|
||||
{ LedId.LedStripe33, CorsairLedId.Lightbar33 },
|
||||
{ LedId.LedStripe34, CorsairLedId.Lightbar34 },
|
||||
{ LedId.LedStripe35, CorsairLedId.Lightbar35 },
|
||||
{ LedId.LedStripe36, CorsairLedId.Lightbar36 },
|
||||
{ LedId.LedStripe37, CorsairLedId.Lightbar37 },
|
||||
{ LedId.LedStripe38, CorsairLedId.Lightbar38 },
|
||||
{ LedId.LedStripe39, CorsairLedId.Lightbar39 },
|
||||
{ LedId.LedStripe40, CorsairLedId.Lightbar40 },
|
||||
{ LedId.LedStripe41, CorsairLedId.Lightbar41 },
|
||||
{ LedId.LedStripe42, CorsairLedId.Lightbar42 },
|
||||
{ LedId.LedStripe43, CorsairLedId.Lightbar43 },
|
||||
{ LedId.LedStripe44, CorsairLedId.Lightbar44 },
|
||||
{ LedId.LedStripe45, CorsairLedId.Lightbar45 },
|
||||
{ LedId.LedStripe46, CorsairLedId.Lightbar46 },
|
||||
{ LedId.LedStripe47, CorsairLedId.Lightbar47 },
|
||||
{ LedId.LedStripe48, CorsairLedId.Lightbar48 },
|
||||
{ LedId.LedStripe49, CorsairLedId.Lightbar49 },
|
||||
{ LedId.LedStripe50, CorsairLedId.Lightbar50 },
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair graphics card.
|
||||
/// </summary>
|
||||
public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCardRGBDeviceInfo>, IGraphicsCard
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairGraphicsCardRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the graphics card.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.GraphicsCard, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairGraphicsCardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairGraphicsCardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairGraphicsCardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairGraphicsCardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.GraphicsCard, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair headset.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the headset</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Headset, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Headset, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair headset stand.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetStandRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the headset stand</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.HeadsetStand, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetStandRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetStandRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairHeadsetStandRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairHeadsetStandRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.HeadsetStand, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
12
RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs
Normal file
12
RGB.NET.Devices.Corsair_Legacy/Helper/DictionaryExtension.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
internal static class DictionaryExtension
|
||||
{
|
||||
public static Dictionary<TValue, TKey> SwapKeyValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary)
|
||||
where TKey : notnull
|
||||
where TValue : notnull
|
||||
=> dictionary.ToDictionary(x => x.Value, x => x.Key);
|
||||
}
|
||||
18
RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs
Normal file
18
RGB.NET.Devices.Corsair_Legacy/Helper/NativeExtensions.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
internal static class NativeExtensions
|
||||
{
|
||||
internal static Rectangle ToRectangle(this _CorsairLedPosition position)
|
||||
{
|
||||
//HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0.
|
||||
float width = position.width < 0.5f ? 10 : (float)position.width;
|
||||
float height = position.height < 0.5f ? 10 : (float)position.height;
|
||||
float posX = (float)position.left;
|
||||
float posY = (float)position.top;
|
||||
|
||||
return new Rectangle(posX, posY, width, height);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair keyboard.
|
||||
/// </summary>
|
||||
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairKeyboardRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the keyboard.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Keyboard, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical layout of the keyboard.
|
||||
/// </summary>
|
||||
public CorsairPhysicalKeyboardLayout PhysicalLayout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logical layout of the keyboard as set in CUE settings.
|
||||
/// </summary>
|
||||
public CorsairLogicalKeyboardLayout LogicalLayout { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairKeyboardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairKeyboardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Keyboard, nativeInfo)
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
||||
this.Layout = PhysicalLayout switch
|
||||
{
|
||||
CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.ANSI,
|
||||
CorsairPhysicalKeyboardLayout.UK => KeyboardLayoutType.ISO,
|
||||
CorsairPhysicalKeyboardLayout.BR => KeyboardLayoutType.ABNT,
|
||||
CorsairPhysicalKeyboardLayout.JP => KeyboardLayoutType.JIS,
|
||||
CorsairPhysicalKeyboardLayout.KR => KeyboardLayoutType.KS,
|
||||
_ => KeyboardLayoutType.Unknown
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair memory.
|
||||
/// </summary>
|
||||
public class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDeviceInfo>, IMainboard
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMainboardRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the memory.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mainboard, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMainboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMainboardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMainboardRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMainboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mainboard, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair memory.
|
||||
/// </summary>
|
||||
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMemoryRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the memory.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Memory, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMemoryRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMemoryRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMemoryRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMemoryRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.DRAM, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair mouse.
|
||||
/// </summary>
|
||||
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMouseRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the mouse</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mouse, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMouseRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical layout of the mouse.
|
||||
/// </summary>
|
||||
public CorsairPhysicalMouseLayout PhysicalLayout { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMouseRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMouseRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mouse, nativeInfo)
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair mousepad.
|
||||
/// </summary>
|
||||
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMousepadRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the mousepad</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Mousepad, updateQueue)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMousepadRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMousepadRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index if the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairMousepadRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
193
RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs
Normal file
193
RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs
Normal file
@ -0,0 +1,193 @@
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// 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 RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal static class _CUESDK
|
||||
{
|
||||
#region Libary Management
|
||||
|
||||
private static IntPtr _handle = IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the SDK.
|
||||
/// </summary>
|
||||
internal static void Reload()
|
||||
{
|
||||
UnloadCUESDK();
|
||||
LoadCUESDK();
|
||||
}
|
||||
|
||||
private static void LoadCUESDK()
|
||||
{
|
||||
if (_handle != IntPtr.Zero) return;
|
||||
|
||||
List<string> possiblePathList = GetPossibleLibraryPaths().ToList();
|
||||
|
||||
string? dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
if (!NativeLibrary.TryLoad(dllPath, out _handle))
|
||||
#if NET6_0
|
||||
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
|
||||
#else
|
||||
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||
#endif
|
||||
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsBufferByDeviceIndex", out _corsairSetLedsColorsBufferByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsBufferByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsFlushBuffer", out _corsairSetLedsColorsFlushBufferPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsFlushBuffer'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedsColorsByDeviceIndex", out _corsairGetLedsColorsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedsColorsByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLayerPriority", out _corsairSetLayerPriorityPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLayerPriority'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceCount", out _corsairGetDeviceCountPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceCount'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetDeviceInfo", out _corsairGetDeviceInfoPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetDeviceInfo'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedIdForKeyName", out _corsairGetLedIdForKeyNamePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedIdForKeyName'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLedPositionsByDeviceIndex", out _corsairGetLedPositionsByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLedPositionsByDeviceIndex'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairRequestControl", out _corsairRequestControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairRequestControl'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairReleaseControl", out _corsairReleaseControlPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairReleaseControl'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairPerformProtocolHandshake", out _corsairPerformProtocolHandshakePointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairPerformProtocolHandshake'");
|
||||
if (!NativeLibrary.TryGetExport(_handle, "CorsairGetLastError", out _corsairGetLastErrorPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairGetLastError'");
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetPossibleLibraryPaths()
|
||||
{
|
||||
IEnumerable<string> possibleLibraryPaths;
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths;
|
||||
else
|
||||
possibleLibraryPaths = Enumerable.Empty<string>();
|
||||
|
||||
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
|
||||
}
|
||||
|
||||
internal static void UnloadCUESDK()
|
||||
{
|
||||
if (_handle == IntPtr.Zero) return;
|
||||
|
||||
_corsairSetLedsColorsBufferByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairSetLedsColorsFlushBufferPointer = IntPtr.Zero;
|
||||
_corsairGetLedsColorsByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairSetLayerPriorityPointer = IntPtr.Zero;
|
||||
_corsairGetDeviceCountPointer = IntPtr.Zero;
|
||||
_corsairGetDeviceInfoPointer = IntPtr.Zero;
|
||||
_corsairGetLedIdForKeyNamePointer = IntPtr.Zero;
|
||||
_corsairGetLedPositionsByDeviceIndexPointer = IntPtr.Zero;
|
||||
_corsairRequestControlPointer = IntPtr.Zero;
|
||||
_corsairReleaseControlPointer = IntPtr.Zero;
|
||||
_corsairPerformProtocolHandshakePointer = IntPtr.Zero;
|
||||
_corsairGetLastErrorPointer = IntPtr.Zero;
|
||||
|
||||
NativeLibrary.Free(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SDK-METHODS
|
||||
|
||||
#region Pointers
|
||||
|
||||
private static IntPtr _corsairSetLedsColorsBufferByDeviceIndexPointer;
|
||||
private static IntPtr _corsairSetLedsColorsFlushBufferPointer;
|
||||
private static IntPtr _corsairGetLedsColorsByDeviceIndexPointer;
|
||||
private static IntPtr _corsairSetLayerPriorityPointer;
|
||||
private static IntPtr _corsairGetDeviceCountPointer;
|
||||
private static IntPtr _corsairGetDeviceInfoPointer;
|
||||
private static IntPtr _corsairGetLedIdForKeyNamePointer;
|
||||
private static IntPtr _corsairGetLedPositionsByDeviceIndexPointer;
|
||||
private static IntPtr _corsairRequestControlPointer;
|
||||
private static IntPtr _corsairReleaseControlPointer;
|
||||
private static IntPtr _corsairPerformProtocolHandshakePointer;
|
||||
private static IntPtr _corsairGetLastErrorPointer;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: set specified LEDs to some colors.
|
||||
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
|
||||
/// Typical usecase is next: CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync is called to write LEDs colors to the device
|
||||
/// and follows after one or more calls of CorsairSetLedsColorsBufferByDeviceIndex to set the LEDs buffer.
|
||||
/// This function does not take logical layout into account.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairSetLedsColorsBufferByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_corsairSetLedsColorsBufferByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: writes to the devices LEDs colors buffer which is previously filled by the CorsairSetLedsColorsBufferByDeviceIndex function.
|
||||
/// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairSetLedsColorsFlushBuffer() => ((delegate* unmanaged[Cdecl]<bool>)ThrowIfZero(_corsairSetLedsColorsFlushBufferPointer))();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: get current color for the list of requested LEDs.
|
||||
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
|
||||
/// This function works for keyboard, mouse, mousemat, headset, headset stand and DIY-devices.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairGetLedsColorsByDeviceIndex(int deviceIndex, int size, IntPtr ledsColors)
|
||||
=> ((delegate* unmanaged[Cdecl]<int, int, IntPtr, bool>)ThrowIfZero(_corsairGetLedsColorsByDeviceIndexPointer))(deviceIndex, size, ledsColors);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: set layer priority for this shared client.
|
||||
/// By default CUE has priority of 127 and all shared clients have priority of 128 if they don’t call this function.
|
||||
/// Layers with higher priority value are shown on top of layers with lower priority.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairSetLayerPriority(int priority) => ((delegate* unmanaged[Cdecl]<int, bool>)ThrowIfZero(_corsairSetLayerPriorityPointer))(priority);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
||||
/// </summary>
|
||||
internal static unsafe int CorsairGetDeviceCount() => ((delegate* unmanaged[Cdecl]<int>)ThrowIfZero(_corsairGetDeviceCountPointer))();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns information about device at provided index.
|
||||
/// </summary>
|
||||
internal static unsafe IntPtr CorsairGetDeviceInfo(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetDeviceInfoPointer))(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
|
||||
/// </summary>
|
||||
internal static unsafe IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex) => ((delegate* unmanaged[Cdecl]<int, IntPtr>)ThrowIfZero(_corsairGetLedPositionsByDeviceIndexPointer))(deviceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
|
||||
/// </summary>
|
||||
internal static unsafe CorsairLedId CorsairGetLedIdForKeyName(char keyName) => ((delegate* unmanaged[Cdecl]<char, CorsairLedId>)ThrowIfZero(_corsairGetLedIdForKeyNamePointer))(keyName);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: requestes control using specified access mode.
|
||||
/// By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairRequestControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl]<CorsairAccessMode, bool>)ThrowIfZero(_corsairRequestControlPointer))(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: releases previously requested control for specified access mode.
|
||||
/// </summary>
|
||||
internal static unsafe bool CorsairReleaseControl(CorsairAccessMode accessMode) => ((delegate* unmanaged[Cdecl]<CorsairAccessMode, bool>)ThrowIfZero(_corsairReleaseControlPointer))(accessMode);
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE.
|
||||
/// </summary>
|
||||
internal static unsafe _CorsairProtocolDetails CorsairPerformProtocolHandshake() => ((delegate* unmanaged[Cdecl]<_CorsairProtocolDetails>)ThrowIfZero(_corsairPerformProtocolHandshakePointer))();
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
|
||||
/// </summary>
|
||||
internal static unsafe CorsairError CorsairGetLastError() => ((delegate* unmanaged[Cdecl]<CorsairError>)ThrowIfZero(_corsairGetLastErrorPointer))();
|
||||
|
||||
private static IntPtr ThrowIfZero(IntPtr ptr)
|
||||
{
|
||||
if (ptr == IntPtr.Zero) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about separate LED-device connected to the channel controlled by the DIY-device.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
internal class _CorsairChannelDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: type of the LED-device
|
||||
/// </summary>
|
||||
internal CorsairChannelDeviceType type;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of LEDs controlled by LED-device.
|
||||
/// </summary>
|
||||
internal int deviceLedCount;
|
||||
}
|
||||
33
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs
Normal file
33
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairChannelInfo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about separate channel of the DIY-device.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairChannelInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: total number of LEDs connected to the channel;
|
||||
/// </summary>
|
||||
internal int totalLedsCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of LED-devices (fans, strips, etc.) connected to the channel which is controlled by the DIY device
|
||||
/// </summary>
|
||||
internal int devicesCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: array containing information about each separate LED-device connected to the channel controlled by the DIY device.
|
||||
/// Index of the LED-device in array is same as the index of the LED-device connected to the DIY-device.
|
||||
/// </summary>
|
||||
internal IntPtr devices;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about channels of the DIY-devices.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairChannelsInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of channels controlled by the device
|
||||
/// </summary>
|
||||
internal int channelsCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: array containing information about each separate channel of the DIY-device.
|
||||
/// Index of the channel in the array is same as index of the channel on the DIY-device.
|
||||
/// </summary>
|
||||
internal IntPtr channels;
|
||||
}
|
||||
58
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs
Normal file
58
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairDeviceInfo.cs
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about device
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing device type
|
||||
/// </summary>
|
||||
internal CorsairDeviceType type;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated device model(like “K95RGB”)
|
||||
/// </summary>
|
||||
internal IntPtr model;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing physical layout of the keyboard or mouse
|
||||
/// </summary>
|
||||
internal int physicalLayout;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings
|
||||
/// </summary>
|
||||
internal int logicalLayout;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
|
||||
/// </summary>
|
||||
internal int capsMask;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: number of controllable LEDs on the device
|
||||
/// </summary>
|
||||
internal int ledsCount;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: structure that describes channels of the DIY-devices
|
||||
/// </summary>
|
||||
internal _CorsairChannelsInfo? channels;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null-terminated string that contains unique device identifier that uniquely identifies device at least within session
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
internal string? deviceId;
|
||||
}
|
||||
37
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs
Normal file
37
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedColor.cs
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
// ReSharper disable NotAccessedField.Global
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about led and its color
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedColor
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: identifier of LED to set
|
||||
/// </summary>
|
||||
internal int ledId;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: red brightness[0..255]
|
||||
/// </summary>
|
||||
internal int r;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: green brightness[0..255]
|
||||
/// </summary>
|
||||
internal int g;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: blue brightness[0..255]
|
||||
/// </summary>
|
||||
internal int b;
|
||||
};
|
||||
42
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs
Normal file
42
RGB.NET.Devices.Corsair_Legacy/Native/_CorsairLedPosition.cs
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains led id and position of led rectangle.Most of the keys are rectangular.
|
||||
/// In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: identifier of led
|
||||
/// </summary>
|
||||
internal CorsairLedId LedId;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double top;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double left;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double height;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: values in mm
|
||||
/// </summary>
|
||||
internal double width;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains number of leds and arrays with their positions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class _CorsairLedPositions
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer value.Number of elements in following array
|
||||
/// </summary>
|
||||
internal int numberOfLed;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: array of led positions
|
||||
/// </summary>
|
||||
internal IntPtr pLedPosition;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
#pragma warning disable 169 // Field 'x' is never used
|
||||
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||
#pragma warning disable 649 // Field 'x' is never assigned
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// CUE-SDK: contains information about SDK and CUE versions
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct _CorsairProtocolDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found
|
||||
/// </summary>
|
||||
internal IntPtr sdkVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found.
|
||||
/// </summary>
|
||||
internal IntPtr serverVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer number that specifies version of protocol that is implemented by current SDK.
|
||||
/// Numbering starts from 1. Always contains valid value even if there was no CUE found
|
||||
/// </summary>
|
||||
internal int sdkProtocolVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: integer number that specifies version of protocol that is implemented by CUE.
|
||||
/// Numbering starts from 1. If CUE was not found then this value will be 0
|
||||
/// </summary>
|
||||
internal int serverProtocolVersion;
|
||||
|
||||
/// <summary>
|
||||
/// CUE-SDK: boolean value that specifies if there were breaking changes between version of protocol implemented by server and client
|
||||
/// </summary>
|
||||
internal byte breakingChanges;
|
||||
};
|
||||
24
RGB.NET.Devices.Corsair_Legacy/README.md
Normal file
24
RGB.NET.Devices.Corsair_Legacy/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
[RGB.NET](https://github.com/DarthAffe/RGB.NET) Device-Provider-Package for Corsair-Devices.
|
||||
|
||||
## Usage
|
||||
This provider follows the default pattern and does not require additional setup.
|
||||
|
||||
```csharp
|
||||
surface.Load(CorsairDeviceProvider.Instance);
|
||||
```
|
||||
|
||||
# Required SDK
|
||||
This providers requires native SDK-dlls. (version < 4.x)
|
||||
You can get them directly from Corsair at [https://github.com/CorsairOfficial/cue-sdk/releases](https://github.com/CorsairOfficial/cue-sdk/releases)
|
||||
|
||||
Since the SDK-dlls are native it's important to use the correct architecture you're building your application for. (If in doubt you can always include both.)
|
||||
|
||||
### x64
|
||||
`redist\x64\CUESDK.x64_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x64\CUESDK.x64_2019.dll` (or simply named `CUESDK.dll`)
|
||||
|
||||
You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX64NativePaths`.
|
||||
|
||||
### x86
|
||||
`redist\i386\CUESDK_2019.dll` from the SDK-zip needs to be distributed as `<application-directory>\x86\CUESDK_2019.dll` (or simply named `CUESDK.dll`)
|
||||
|
||||
You can use other, custom paths by adding them to `CorsairDeviceProvider.PossibleX86NativePaths`.
|
||||
@ -0,0 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<Authors>Darth Affe</Authors>
|
||||
<Company>Wyrez</Company>
|
||||
<Language>en-US</Language>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<Title>RGB.NET.Devices.CorsairLegacy</Title>
|
||||
<AssemblyName>RGB.NET.Devices.CorsairLegacy</AssemblyName>
|
||||
<AssemblyTitle>RGB.NET.Devices.CorsairLegacy</AssemblyTitle>
|
||||
<PackageId>RGB.NET.Devices.CorsairLegacy</PackageId>
|
||||
<RootNamespace>RGB.NET.Devices.CorsairLegacy</RootNamespace>
|
||||
<Description>Corsair-Device-Implementations of RGB.NET using the old SDK</Description>
|
||||
<Summary>Corsair-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
|
||||
<Copyright>Copyright © Darth Affe 2023</Copyright>
|
||||
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
|
||||
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||
<RepositoryType>Github</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/DarthAffe/RGB.NET</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>True</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>
|
||||
<DebugType>portable</DebugType>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
|
||||
<DefineConstants>RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,22 @@
|
||||
<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/=generic_005Cupdate/@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/=headsetstand/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=libs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=memory/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mousepad/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=native/@EntryIndexedValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mousmat/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mouse/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=headset/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=keyboard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=custom/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@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/=specialparts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=targets/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=touchbar/@EntryIndexedValue">True</s:Boolean>
|
||||
</wpf:ResourceDictionary>
|
||||
@ -0,0 +1,27 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a corsair touchbar.
|
||||
/// </summary>
|
||||
public class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDeviceInfo>, IDRAM
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairTouchbarRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the touchbar.</param>
|
||||
/// <param name="updateQueue">The queue used to update this device.</param>
|
||||
internal CorsairTouchbarRGBDevice(CorsairTouchbarRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
|
||||
: base(info, LedMappings.Keyboard, updateQueue) //TODO DarthAffe 17.07.2022: Find someone with such a device and check which LedIds are actually used
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CorsairLegacy.Native;
|
||||
|
||||
namespace RGB.NET.Devices.CorsairLegacy;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairTouchbarRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairTouchbarRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CorsairLegacy.CorsairTouchbarRGBDevice" />.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.CorsairLegacy.Native._CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairTouchbarRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, RGBDeviceType.Keypad, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -161,7 +161,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_clients.Clear();
|
||||
DeviceDefinitions.Clear();
|
||||
Devices = Enumerable.Empty<IRGBDevice>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -160,6 +160,137 @@ public static class LedMappings
|
||||
//Row 7 is also empty
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for Blade keyboards.
|
||||
/// </summary>
|
||||
public static LedMapping<int> Blade { get; } = new()
|
||||
{
|
||||
//Row 0 is empty
|
||||
|
||||
#region Row 1
|
||||
|
||||
[LedId.Keyboard_Escape] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 2,
|
||||
[LedId.Keyboard_F1] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 3,
|
||||
[LedId.Keyboard_F2] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 4,
|
||||
[LedId.Keyboard_F3] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 5,
|
||||
[LedId.Keyboard_F4] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 6,
|
||||
[LedId.Keyboard_F5] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 7,
|
||||
[LedId.Keyboard_F6] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 8,
|
||||
[LedId.Keyboard_F7] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 9,
|
||||
[LedId.Keyboard_F8] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 10,
|
||||
[LedId.Keyboard_F9] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 11,
|
||||
[LedId.Keyboard_F10] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 12,
|
||||
[LedId.Keyboard_F11] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 13,
|
||||
[LedId.Keyboard_F12] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 14,
|
||||
[LedId.Keyboard_PrintScreen] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 15,
|
||||
[LedId.Keyboard_ScrollLock] = (_Defines.KEYBOARD_MAX_COLUMN * 1) + 16,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row 2
|
||||
|
||||
[LedId.Keyboard_GraveAccentAndTilde] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 2,
|
||||
[LedId.Keyboard_1] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 3,
|
||||
[LedId.Keyboard_2] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 4,
|
||||
[LedId.Keyboard_3] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 5,
|
||||
[LedId.Keyboard_4] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 6,
|
||||
[LedId.Keyboard_5] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 7,
|
||||
[LedId.Keyboard_6] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 8,
|
||||
[LedId.Keyboard_7] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 9,
|
||||
[LedId.Keyboard_8] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 10,
|
||||
[LedId.Keyboard_9] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 11,
|
||||
[LedId.Keyboard_0] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 12,
|
||||
[LedId.Keyboard_MinusAndUnderscore] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 13,
|
||||
[LedId.Keyboard_EqualsAndPlus] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 14,
|
||||
[LedId.Keyboard_Backspace] = (_Defines.KEYBOARD_MAX_COLUMN * 2) + 16,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row 3
|
||||
|
||||
[LedId.Keyboard_Tab] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 2,
|
||||
[LedId.Keyboard_Q] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 3,
|
||||
[LedId.Keyboard_W] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 4,
|
||||
[LedId.Keyboard_E] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 5,
|
||||
[LedId.Keyboard_R] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 6,
|
||||
[LedId.Keyboard_T] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 7,
|
||||
[LedId.Keyboard_Y] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 8,
|
||||
[LedId.Keyboard_U] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 9,
|
||||
[LedId.Keyboard_I] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 10,
|
||||
[LedId.Keyboard_O] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 11,
|
||||
[LedId.Keyboard_P] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 12,
|
||||
[LedId.Keyboard_BracketLeft] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 13,
|
||||
[LedId.Keyboard_BracketRight] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 14,
|
||||
[LedId.Keyboard_Backslash] = (_Defines.KEYBOARD_MAX_COLUMN * 3) + 16,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row 4
|
||||
|
||||
[LedId.Keyboard_CapsLock] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 2,
|
||||
[LedId.Keyboard_A] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 3,
|
||||
[LedId.Keyboard_S] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 4,
|
||||
[LedId.Keyboard_D] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 5,
|
||||
[LedId.Keyboard_F] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 6,
|
||||
[LedId.Keyboard_G] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 7,
|
||||
[LedId.Keyboard_H] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 8,
|
||||
[LedId.Keyboard_J] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 9,
|
||||
[LedId.Keyboard_K] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 10,
|
||||
[LedId.Keyboard_L] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 11,
|
||||
[LedId.Keyboard_SemicolonAndColon] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 12,
|
||||
[LedId.Keyboard_ApostropheAndDoubleQuote] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 13,
|
||||
[LedId.Keyboard_NonUsTilde] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 14,
|
||||
[LedId.Keyboard_Enter] = (_Defines.KEYBOARD_MAX_COLUMN * 4) + 16,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row 5
|
||||
|
||||
[LedId.Keyboard_LeftShift] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 2,
|
||||
[LedId.Keyboard_NonUsBackslash] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 3,
|
||||
[LedId.Keyboard_Z] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 4,
|
||||
[LedId.Keyboard_X] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 5,
|
||||
[LedId.Keyboard_C] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 6,
|
||||
[LedId.Keyboard_V] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 7,
|
||||
[LedId.Keyboard_B] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 8,
|
||||
[LedId.Keyboard_N] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 9,
|
||||
[LedId.Keyboard_M] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 10,
|
||||
[LedId.Keyboard_CommaAndLessThan] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 11,
|
||||
[LedId.Keyboard_PeriodAndBiggerThan] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 12,
|
||||
[LedId.Keyboard_SlashAndQuestionMark] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 13,
|
||||
[LedId.Keyboard_RightShift] = (_Defines.KEYBOARD_MAX_COLUMN * 5) + 16,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row 6
|
||||
|
||||
[LedId.Keyboard_LeftCtrl] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 2,
|
||||
// left gui lights left fn key
|
||||
[LedId.Keyboard_LeftGui] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 3,
|
||||
// left alt lights left gui key
|
||||
[LedId.Keyboard_LeftAlt] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 4,
|
||||
// space lights left alt key
|
||||
[LedId.Keyboard_Space] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 6,
|
||||
// see comment bellow
|
||||
[LedId.Keyboard_RightAlt] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 10,
|
||||
// right gui lights right fn key (this one (11) seems to light both right alt and right fn, but 8, 9 and 10 don't light anything)
|
||||
[LedId.Keyboard_RightGui] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 11,
|
||||
// application key lights right control to make room for up/down keys stacked in 1 key spot
|
||||
[LedId.Keyboard_Application] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 12,
|
||||
// right ctrl lights left arrow key
|
||||
[LedId.Keyboard_RightCtrl] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 13,
|
||||
// arrow left lights up arrow key
|
||||
[LedId.Keyboard_ArrowLeft] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 14,
|
||||
// these arrows appear to be flipped
|
||||
[LedId.Keyboard_ArrowDown] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 16,
|
||||
[LedId.Keyboard_ArrowRight] = (_Defines.KEYBOARD_MAX_COLUMN * 6) + 15,
|
||||
|
||||
#endregion
|
||||
|
||||
//Row 7 is also empty
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapping for mice.
|
||||
/// </summary>
|
||||
|
||||
@ -55,6 +55,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x010F, RGBDeviceType.Keyboard, "Anansi", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x011A, RGBDeviceType.Keyboard, "BlackWidow Ultimate 2013", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x011B, RGBDeviceType.Keyboard, "BlackWidow Stealth", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x011C, RGBDeviceType.Keyboard, "BlackWidow Tournament Edition 2014", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0202, RGBDeviceType.Keyboard, "DeathStalker Expert", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0203, RGBDeviceType.Keyboard, "BlackWidow Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0204, RGBDeviceType.Keyboard, "DeathStalker Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
@ -77,6 +78,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0227, RGBDeviceType.Keyboard, "Huntsman", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0228, RGBDeviceType.Keyboard, "BlackWidow Elite", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x022A, RGBDeviceType.Keyboard, "Cynosa Chroma", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x022C, RGBDeviceType.Keyboard, "Cynosa Chroma Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x022D, RGBDeviceType.Keyboard, "Blade Stealth (Mid 2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x022F, RGBDeviceType.Keyboard, "Blade Pro FullHD (2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x0232, RGBDeviceType.Keyboard, "Blade Stealth (Late 2017)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
@ -100,37 +102,41 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0252, RGBDeviceType.Keyboard, "Blade Stealth (Early 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x0253, RGBDeviceType.Keyboard, "Blade 15 Advanced (2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x0255, RGBDeviceType.Keyboard, "Blade 15 (Early 2020) Base", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x0256, RGBDeviceType.Keyboard, "Blade Blade Pro (Early 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x0257, RGBDeviceType.Keyboard, "Huntsman Mini", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0258, RGBDeviceType.Keyboard, "BlackWidow V3 Mini", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0259, RGBDeviceType.Keyboard, "Blade Stealth (Late 2020)", LedMappings.Keyboard, RazerEndpointType.LaptopKeyboard },
|
||||
{ 0x25A, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The keyboard, only present when connected with cable
|
||||
{ 0x25C, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The dongle, may not be present when connected with cable
|
||||
{ 0x025A, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The keyboard, only present when connected with cable
|
||||
{ 0x025C, RGBDeviceType.Keyboard, "BlackWidow V3 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // The dongle, may not be present when connected with cable
|
||||
{ 0x025D, RGBDeviceType.Keyboard, "Ornata Chroma V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x025E, RGBDeviceType.Keyboard, "Cynosa V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0266, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x029F, RGBDeviceType.Keyboard, "Blade 16 (2023)", LedMappings.Blade, RazerEndpointType.Keyboard },
|
||||
{ 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
|
||||
// Mice
|
||||
{ 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
@ -138,6 +144,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0020, RGBDeviceType.Mouse, "Abyssus 1800", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0024, RGBDeviceType.Mouse, "Mamba 2012 (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0025, RGBDeviceType.Mouse, "Mamba 2012 (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0029, RGBDeviceType.Mouse, "DeathAdder V3 5G", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x002E, RGBDeviceType.Mouse, "Naga 2012", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x002F, RGBDeviceType.Mouse, "Imperator 2012", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0032, RGBDeviceType.Mouse, "Ouroboros 2012", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
@ -167,6 +174,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0060, RGBDeviceType.Mouse, "Lancehead Tournament Edition", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0062, RGBDeviceType.Mouse, "Atheris (Receiver)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0064, RGBDeviceType.Mouse, "Basilisk", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0065, RGBDeviceType.Mouse, "Basilisk Essential", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0067, RGBDeviceType.Mouse, "Naga Trinity", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x006A, RGBDeviceType.Mouse, "Abyssus Elite (D.Va Edition)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x006B, RGBDeviceType.Mouse, "Abyssus Essential", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
@ -177,24 +185,38 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x0071, RGBDeviceType.Mouse, "DeathAdder Essential (White Edition)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0072, RGBDeviceType.Mouse, "Mamba Wireless (Receiver)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0073, RGBDeviceType.Mouse, "Mamba Wireless (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0077, RGBDeviceType.Mouse, "Pro Click (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0078, RGBDeviceType.Mouse, "Viper", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x007A, RGBDeviceType.Mouse, "Viper Ultimate (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x007B, RGBDeviceType.Mouse, "Viper Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x007C, RGBDeviceType.Mouse, "DeathAdder V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x007D, RGBDeviceType.Mouse, "DeathAdder V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0080, RGBDeviceType.Mouse, "Pro Click (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0083, RGBDeviceType.Mouse, "Basilisk X HyperSpeed", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0085, RGBDeviceType.Mouse, "Basilisk V2", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0088, RGBDeviceType.Mouse, "Basilisk Ultimate", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0084, RGBDeviceType.Mouse, "DeathAdder V2", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0085, RGBDeviceType.Mouse, "Basilisk V2", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0086, RGBDeviceType.Mouse, "Basilisk Ultimate (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0088, RGBDeviceType.Mouse, "Basilisk Ultimate", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x008A, RGBDeviceType.Mouse, "Viper Mini", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x008C, RGBDeviceType.Mouse, "DeathAdder V2 Mini", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x008D, RGBDeviceType.Mouse, "Naga Left Handed Edition", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x008F, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via usb connection
|
||||
{ 0x0090, RGBDeviceType.Mouse, "Naga Pro", LedMappings.Mouse, RazerEndpointType.Mouse }, //this is via bluetooth connection
|
||||
{ 0x0091, RGBDeviceType.Mouse, "Viper 8khz", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0094, RGBDeviceType.Mouse, "Orochi V2", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0096, RGBDeviceType.Mouse, "Naga X", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x0099, RGBDeviceType.Mouse, "Basilisk v3", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x009A, RGBDeviceType.Mouse, "Pro Click Mini (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x009C, RGBDeviceType.Mouse, "DeathAdder V2 X Hyperspeed", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00A1, RGBDeviceType.Mouse, "DeathAdder V2 Lite", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00A5, RGBDeviceType.Mouse, "Viper V2 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00A6, RGBDeviceType.Mouse, "Viper V2 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00A8, RGBDeviceType.Mouse, "Naga V2 Pro", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
|
||||
{ 0x00AA, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00AB, RGBDeviceType.Mouse, "Basilisk V3 Pro (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00B6, RGBDeviceType.Mouse, "DeathAdder V3 (Wired)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
{ 0x00B7, RGBDeviceType.Mouse, "DeathAdder V3 (Wireless)", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
|
||||
// Mousepads
|
||||
{ 0x0068, RGBDeviceType.Mousepad, "Firefly Hyperflux", LedMappings.Mousepad, RazerEndpointType.Mousepad },
|
||||
{ 0x0C00, RGBDeviceType.Mousepad, "Firefly", LedMappings.Mousepad, RazerEndpointType.Mousepad },
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
@ -118,20 +118,16 @@ public class DeviceLayout : IDeviceLayout
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeviceLayout"/> from the specified xml.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the xml file.</param>
|
||||
/// <param name="stream">The stream that contains the layout to be loaded.</param>
|
||||
/// <param name="customDeviceDataType">The type of the custom data.</param>
|
||||
/// <param name="customLedDataType">The type of the custom data of the leds.</param>
|
||||
/// <returns>The deserialized <see cref="DeviceLayout"/>.</returns>
|
||||
public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null)
|
||||
public static DeviceLayout? Load(Stream stream, Type? customDeviceDataType = null, Type? customLedDataType = null)
|
||||
{
|
||||
if (!File.Exists(path)) return null;
|
||||
|
||||
try
|
||||
{
|
||||
XmlSerializer serializer = new(typeof(DeviceLayout));
|
||||
using StreamReader reader = new(path);
|
||||
|
||||
DeviceLayout? layout = serializer.Deserialize(reader) as DeviceLayout;
|
||||
DeviceLayout? layout = serializer.Deserialize(stream) as DeviceLayout;
|
||||
if (layout != null)
|
||||
layout.CustomData = layout.GetCustomData(layout.InternalCustomData, customDeviceDataType);
|
||||
|
||||
@ -155,6 +151,21 @@ public class DeviceLayout : IDeviceLayout
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeviceLayout"/> from the specified xml.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the xml file.</param>
|
||||
/// <param name="customDeviceDataType">The type of the custom data.</param>
|
||||
/// <param name="customLedDataType">The type of the custom data of the leds.</param>
|
||||
/// <returns>The deserialized <see cref="DeviceLayout"/>.</returns>
|
||||
public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null)
|
||||
{
|
||||
if (!File.Exists(path)) return null;
|
||||
|
||||
using Stream stream = File.OpenRead(path);
|
||||
return Load(stream, customDeviceDataType, customLedDataType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the deserialized custom data.
|
||||
/// </summary>
|
||||
@ -177,4 +188,4 @@ public class DeviceLayout : IDeviceLayout
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Presets.Tests", "Te
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.OpenRGB", "RGB.NET.Devices.OpenRGB\RGB.NET.Devices.OpenRGB.csproj", "{F29A96E5-CDD0-469F-A871-A35A7519BC49}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Corsair_Legacy", "RGB.NET.Devices.Corsair_Legacy\RGB.NET.Devices.Corsair_Legacy.csproj", "{66AF690C-27A1-4097-AC53-57C0ED89E286}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -133,6 +135,10 @@ Global
|
||||
{F29A96E5-CDD0-469F-A871-A35A7519BC49}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F29A96E5-CDD0-469F-A871-A35A7519BC49}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F29A96E5-CDD0-469F-A871-A35A7519BC49}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{66AF690C-27A1-4097-AC53-57C0ED89E286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{66AF690C-27A1-4097-AC53-57C0ED89E286}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{66AF690C-27A1-4097-AC53-57C0ED89E286}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{66AF690C-27A1-4097-AC53-57C0ED89E286}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -154,6 +160,7 @@ Global
|
||||
{7FC5C7A8-7B27-46E7-A8E8-DB80568F49C5} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||
{EDBA49D6-AE96-4E96-9E6A-30154D93BD5F} = {92D7C263-D4C9-4D26-93E2-93C1F9C2CD16}
|
||||
{F29A96E5-CDD0-469F-A871-A35A7519BC49} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||
{66AF690C-27A1-4097-AC53-57C0ED89E286} = {D13032C6-432E-4F43-8A32-071133C22B16}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7F222AD4-1F9E-4AAB-9D69-D62372D4C1BA}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user