1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Implemented corsair devices

This commit is contained in:
Darth Affe 2017-01-22 15:31:30 +01:00
parent 89194c4cb4
commit f3128a3dd0
31 changed files with 1731 additions and 0 deletions

View File

@ -0,0 +1,176 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Core.Exceptions;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a device provider responsible for corsair (CUE) devices.
/// </summary>
public class CorsairDeviceProvider : IDeviceProvider
{
#region Properties & Fields
/// <summary>
/// Indicates if the SDK is initialized and ready to use.
/// </summary>
public bool IsInitialized { get; private set; }
/// <summary>
/// Gets the loaded architecture (x64/x86).
/// </summary>
public string LoadedArchitecture => _CUESDK.LoadedArchitecture;
/// <summary>
/// Gets the protocol details for the current SDK-connection.
/// </summary>
public CorsairProtocolDetails ProtocolDetails { get; private set; }
/// <summary>
/// Gets whether the application has exclusive access to the SDK or not.
/// </summary>
public bool HasExclusiveAccess { get; private set; }
/// <summary>
/// Gets the last error documented by CUE.
/// </summary>
public CorsairError LastError => _CUESDK.CorsairGetLastError();
/// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; }
#endregion
#region Methods
/// <inheritdoc />
/// <exception cref="RGBDeviceException">Thrown if the SDK is already initialized or if the SDK is not compatible to CUE.</exception>
/// <exception cref="CUEException">Thrown if the CUE-SDK provides an error.</exception>
public bool Initialize(bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
{
_CUESDK.Reload();
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
CorsairError error = LastError;
if (error != CorsairError.Success)
{
Reset();
if (throwExceptions)
throw new CUEException(error);
else
return false;
}
if (ProtocolDetails.BreakingChanges)
{
Reset();
if (throwExceptions)
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})");
else
return false;
}
if (exclusiveAccessIfPossible)
{
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
{
Reset();
if (throwExceptions)
throw new CUEException(LastError);
else
return false;
}
HasExclusiveAccess = true;
}
else
HasExclusiveAccess = false;
IList<IRGBDevice> devices = new List<IRGBDevice>();
int deviceCount = _CUESDK.CorsairGetDeviceCount();
for (int i = 0; i < deviceCount; i++)
{
_CorsairDeviceInfo nativeDeviceInfo =
(_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, DeviceType.Unknown, nativeDeviceInfo);
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
continue; // Everything that doesn't support lighting control is useless
CorsairRGBDevice device;
switch (info.CorsairDeviceType)
{
case CorsairDeviceType.Keyboard:
device = new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Mouse:
device = new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Headset:
device = new CorsairHeadsetRGBDevice(new CorsairHeadsetRGBDeviceInfo(i, nativeDeviceInfo));
break;
case CorsairDeviceType.Mousemat:
device = new CorsairMousematRGBDevice(new CorsairMousematRGBDeviceInfo(i, nativeDeviceInfo));
break;
// ReSharper disable once RedundantCaseLabel
case CorsairDeviceType.Unknown:
default:
if (throwExceptions)
throw new RGBDeviceException("Unknown Device-Type");
else
continue;
}
try
{
device.Initialize();
}
catch
{
if (throwExceptions)
throw;
else
continue;
}
devices.Add(device);
error = LastError;
if (error != CorsairError.Success)
{
Reset();
if (throwExceptions)
throw new CUEException(error);
else
return false;
}
}
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
IsInitialized = true;
return true;
}
/// <inheritdoc />
public void ResetDevices()
{
if (IsInitialized)
_CUESDK.Reload();
}
private void Reset()
{
ProtocolDetails = null;
HasExclusiveAccess = false;
Devices = null;
IsInitialized = false;
}
#endregion
}
}

View File

@ -0,0 +1,15 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available SDK access modes.
/// </summary>
public enum CorsairAccessMode
{
ExclusiveLightingControl = 0
};
}

View File

@ -0,0 +1,24 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
using System;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains 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
};
}

View File

@ -0,0 +1,20 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available corsair device types.
/// </summary>
public enum CorsairDeviceType
{
Unknown = 0,
Mouse = 1,
Keyboard = 2,
Headset = 3,
Mousemat = 4
};
}

View File

@ -0,0 +1,42 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace RGB.NET.Devices.Corsair
{
/// <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
};
}

View File

@ -0,0 +1,187 @@
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of all LEDs available for all corsair devices.
/// </summary>
public enum CorsairLedIds
{
Invalid = 0,
Escape = 1,
F1 = 2,
F2 = 3,
F3 = 4,
F4 = 5,
F5 = 6,
F6 = 7,
F7 = 8,
F8 = 9,
F9 = 10,
F10 = 11,
F11 = 12,
GraveAccentAndTilde = 13,
D1 = 14,
D2 = 15,
D3 = 16,
D4 = 17,
D5 = 18,
D6 = 19,
D7 = 20,
D8 = 21,
D9 = 22,
D0 = 23,
MinusAndUnderscore = 24,
Tab = 25,
Q = 26,
W = 27,
E = 28,
R = 29,
T = 30,
Y = 31,
U = 32,
I = 33,
O = 34,
P = 35,
BracketLeft = 36,
CapsLock = 37,
A = 38,
S = 39,
D = 40,
F = 41,
G = 42,
H = 43,
J = 44,
K = 45,
L = 46,
SemicolonAndColon = 47,
ApostropheAndDoubleQuote = 48,
LeftShift = 49,
NonUsBackslash = 50,
Z = 51,
X = 52,
C = 53,
V = 54,
B = 55,
N = 56,
M = 57,
CommaAndLessThan = 58,
PeriodAndBiggerThan = 59,
SlashAndQuestionMark = 60,
LeftCtrl = 61,
LeftGui = 62,
LeftAlt = 63,
Lang2 = 64,
Space = 65,
Lang1 = 66,
International2 = 67,
RightAlt = 68,
RightGui = 69,
Application = 70,
LedProgramming = 71,
Brightness = 72,
F12 = 73,
PrintScreen = 74,
ScrollLock = 75,
PauseBreak = 76,
Insert = 77,
Home = 78,
PageUp = 79,
BracketRight = 80,
Backslash = 81,
NonUsTilde = 82,
Enter = 83,
International1 = 84,
EqualsAndPlus = 85,
International3 = 86,
Backspace = 87,
Delete = 88,
End = 89,
PageDown = 90,
RightShift = 91,
RightCtrl = 92,
UpArrow = 93,
LeftArrow = 94,
DownArrow = 95,
RightArrow = 96,
WinLock = 97,
Mute = 98,
Stop = 99,
ScanPreviousTrack = 100,
PlayPause = 101,
ScanNextTrack = 102,
NumLock = 103,
KeypadSlash = 104,
KeypadAsterisk = 105,
KeypadMinus = 106,
KeypadPlus = 107,
KeypadEnter = 108,
Keypad7 = 109,
Keypad8 = 110,
Keypad9 = 111,
KeypadComma = 112,
Keypad4 = 113,
Keypad5 = 114,
Keypad6 = 115,
Keypad1 = 116,
Keypad2 = 117,
Keypad3 = 118,
Keypad0 = 119,
KeypadPeriodAndDelete = 120,
G1 = 121,
G2 = 122,
G3 = 123,
G4 = 124,
G5 = 125,
G6 = 126,
G7 = 127,
G8 = 128,
G9 = 129,
G10 = 130,
VolumeUp = 131,
VolumeDown = 132,
MR = 133,
M1 = 134,
M2 = 135,
M3 = 136,
G11 = 137,
G12 = 138,
G13 = 139,
G14 = 140,
G15 = 141,
G16 = 142,
G17 = 143,
G18 = 144,
International5 = 145,
International4 = 146,
Fn = 147,
B1 = 148,
B2 = 149,
B3 = 150,
B4 = 151,
LeftLogo = 152,
RightLogo = 153,
Logo = 154,
Zone1 = 155,
Zone2 = 156,
Zone3 = 157,
Zone4 = 158,
Zone5 = 159,
Zone6 = 160,
Zone7 = 161,
Zone8 = 162,
Zone9 = 163,
Zone10 = 164,
Zone11 = 165,
Zone12 = 166,
Zone13 = 167,
Zone14 = 168,
Zone15 = 169
}
}

View File

@ -0,0 +1,32 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains 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
};
}

View File

@ -0,0 +1,36 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains 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
}
}

View File

@ -0,0 +1,28 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains 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
}
}

View File

@ -0,0 +1,35 @@
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
using System;
namespace RGB.NET.Devices.Corsair
{
/// <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
/// <summary>
/// Initializes a new instance of the <see cref="CUEException"/> class.
/// </summary>
/// <param name="error">The <see cref="CorsairError" /> provided by CUE, which leads to this exception.</param>
public CUEException(CorsairError error)
{
this.Error = error;
}
#endregion
}
}

View File

@ -0,0 +1,102 @@
using System.Diagnostics;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a Id of a <see cref="Led"/> on a <see cref="CorsairRGBDevice"/>.
/// </summary>
[DebuggerDisplay("{_ledId}")]
public class CorsairLedId : ILedId
{
#region Properties & Fields
private readonly CorsairLedIds _ledId;
/// <inheritdoc />
public bool IsValid => _ledId != CorsairLedIds.Invalid;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairLedId"/> class.
/// </summary>
/// <param name="ledId">The corsair-id of the represented <see cref="Led"/>.</param>
public CorsairLedId(CorsairLedIds ledId)
{
this._ledId = ledId;
}
#endregion
#region Methods
/// <summary>
/// Converts the Id of this <see cref="CorsairLedId"/> to a human-readable string.
/// </summary>
/// <returns>A string that contains the Id of this <see cref="CorsairLedId"/>. For example "Enter".</returns>
public override string ToString()
{
return _ledId.ToString();
}
/// <summary>
/// Tests whether the specified object is a <see cref="CorsairLedId" /> and is equivalent to this <see cref="CorsairLedId" />.
/// </summary>
/// <param name="obj">The object to test.</param>
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="CorsairLedId" /> equivalent to this <see cref="CorsairLedId" />; otherwise, <c>false</c>.</returns>
public override bool Equals(object obj)
{
CorsairLedId compareLedId = obj as CorsairLedId;
if (ReferenceEquals(compareLedId, null))
return false;
if (ReferenceEquals(this, compareLedId))
return true;
if (GetType() != compareLedId.GetType())
return false;
return compareLedId._ledId == _ledId;
}
/// <summary>
/// Returns a hash code for this <see cref="CorsairLedId" />.
/// </summary>
/// <returns>An integer value that specifies the hash code for this <see cref="CorsairLedId" />.</returns>
public override int GetHashCode()
{
return _ledId.GetHashCode();
}
#endregion
#region Operators
/// <summary>
/// Returns a value that indicates whether two specified <see cref="CorsairLedId" /> are equal.
/// </summary>
/// <param name="ledId1">The first <see cref="CorsairLedId" /> to compare.</param>
/// <param name="ledId2">The second <see cref="CorsairLedId" /> to compare.</param>
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are equal; otherwise, <c>false</c>.</returns>
public static bool operator ==(CorsairLedId ledId1, CorsairLedId ledId2)
{
return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2);
}
/// <summary>
/// Returns a value that indicates whether two specified <see cref="CorsairLedId" /> are equal.
/// </summary>
/// <param name="ledId1">The first <see cref="CorsairLedId" /> to compare.</param>
/// <param name="ledId2">The second <see cref="CorsairLedId" /> to compare.</param>
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are not equal; otherwise, <c>false</c>.</returns>
public static bool operator !=(CorsairLedId ledId1, CorsairLedId ledId2)
{
return !(ledId1 == ledId2);
}
#endregion
}
}

View File

@ -0,0 +1,66 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
using System;
using System.Runtime.InteropServices;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <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
}
}

View File

@ -0,0 +1,56 @@
using System.Linq;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic CUE-device. (keyboard, mouse, headset, mousmat).
/// </summary>
public abstract class CorsairRGBDevice : AbstractRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="CorsairRGBDevice"/>.
/// </summary>
public override IRGBDeviceInfo DeviceInfo { get; }
private Rectangle _deviceRectangle;
/// <inheritdoc />
public override Rectangle DeviceRectangle => _deviceRectangle;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairRGBDevice"/> class.
/// </summary>
/// <param name="info">The generic information provided by CUE for the device.</param>
protected CorsairRGBDevice(IRGBDeviceInfo info)
{
this.DeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the device.
/// </summary>
internal void Initialize()
{
InitializeLeds();
_deviceRectangle = new Rectangle(this.Select(x => x.LedRectangle));
}
/// <summary>
/// Initializes the <see cref="Led"/> of the device.
/// </summary>
protected abstract void InitializeLeds();
#endregion
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic information for a Corsair-<see cref="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"/>.
/// </summary>
public int CorsairDeviceIndex { get; }
/// <inheritdoc />
public DeviceType DeviceType { get; }
/// <inheritdoc />
public string Manufacturer => "Corsair";
/// <inheritdoc />
public string Model { get; }
/// <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"/>.</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, DeviceType deviceType, _CorsairDeviceInfo nativeInfo)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = nativeInfo.model == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeInfo.model);
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
}
#endregion
}
}

View File

@ -0,0 +1,46 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a corsair headset.
/// </summary>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="CorsairHeadsetRGBDevice"/>.
/// </summary>
public CorsairHeadsetRGBDeviceInfo HeadsetDeviceInfo { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairHeadsetRGBDevice"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the headset</param>
internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info)
: base(info)
{
this.HeadsetDeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the <see cref="Led"/> of the headset.
/// </summary>
protected override void InitializeLeds()
{
InitializeLed(new CorsairLedId(CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10));
}
#endregion
}
}

View File

@ -0,0 +1,23 @@
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic information for a <see cref="CorsairHeadsetRGBDevice"/>.
/// </summary>
public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairHeadsetRGBDeviceInfo"/>.
/// </summary>
/// <param name="deviceIndex">The index of the <see cref="CorsairHeadsetRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Headset, nativeInfo)
{ }
#endregion
}
}

View File

@ -0,0 +1,63 @@
using System;
using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a corsair keyboard.
/// </summary>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="CorsairKeyboardRGBDevice"/>.
/// </summary>
public CorsairKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairKeyboardRGBDevice"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the keyboard</param>
internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info)
: base(info)
{
this.KeyboardDeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the <see cref="Led"/> of the keyboard.
/// </summary>
protected override void InitializeLeds()
{
_CorsairLedPositions nativeLedPositions =
(_CorsairLedPositions)
Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(KeyboardDeviceInfo.CorsairDeviceIndex),
typeof(_CorsairLedPositions));
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));
InitializeLed(new CorsairLedId(ledPosition.ledId),
new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
ptr = new IntPtr(ptr.ToInt64() + structSize);
}
}
#endregion
}
}

View File

@ -0,0 +1,40 @@
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic information for a <see cref="CorsairKeyboardRGBDevice"/>.
/// </summary>
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Properties & Fields
/// <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
/// <summary>
/// Internal constructor of managed <see cref="CorsairKeyboardRGBDeviceInfo"/>.
/// </summary>
/// <param name="deviceIndex">The index of the <see cref="CorsairKeyboardRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Keyboard, nativeInfo)
{
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
}
#endregion
}
}

View File

@ -0,0 +1,68 @@
using RGB.NET.Core;
using RGB.NET.Core.Exceptions;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a corsair mouse.
/// </summary>
public class CorsairMouseRGBDevice : CorsairRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="CorsairMouseRGBDevice"/>.
/// </summary>
public CorsairMouseRGBDeviceInfo MouseDeviceInfo { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairMouseRGBDevice"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the mouse</param>
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info)
: base(info)
{
this.MouseDeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the <see cref="Led"/> of the mouse.
/// </summary>
protected override void InitializeLeds()
{
switch (MouseDeviceInfo.PhysicalLayout)
{
case CorsairPhysicalMouseLayout.Zones1:
InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10));
break;
case CorsairPhysicalMouseLayout.Zones2:
InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10));
break;
case CorsairPhysicalMouseLayout.Zones3:
InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B3), new Rectangle(20, 0, 10, 10));
break;
case CorsairPhysicalMouseLayout.Zones4:
InitializeLed(new CorsairLedId(CorsairLedIds.B1), new Rectangle(0, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B2), new Rectangle(10, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B3), new Rectangle(20, 0, 10, 10));
InitializeLed(new CorsairLedId(CorsairLedIds.B4), new Rectangle(30, 0, 10, 10));
break;
default:
throw new RGBDeviceException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
}
}
#endregion
}
}

View File

@ -0,0 +1,34 @@
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic information for a <see cref="CorsairMouseRGBDevice"/>.
/// </summary>
public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Properties & Fields
/// <summary>
/// Gets the physical layout of the mouse.
/// </summary>
public CorsairPhysicalMouseLayout PhysicalLayout { get; private set; }
#endregion
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairMouseRGBDeviceInfo"/>.
/// </summary>
/// <param name="deviceIndex">The index of the <see cref="CorsairMouseRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Mouse, nativeInfo)
{
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
}
#endregion
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a corsair mousemat.
/// </summary>
public class CorsairMousematRGBDevice : CorsairRGBDevice
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="CorsairMousematRGBDevice"/>.
/// </summary>
public CorsairMousematRGBDeviceInfo MousematDeviceInfo { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairMousematRGBDevice"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the mousemat</param>
internal CorsairMousematRGBDevice(CorsairMousematRGBDeviceInfo info)
: base(info)
{
this.MousematDeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the <see cref="Led"/> of the mousemat.
/// </summary>
protected override void InitializeLeds()
{
_CorsairLedPositions nativeLedPositions =
(_CorsairLedPositions)
Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(MousematDeviceInfo.CorsairDeviceIndex),
typeof(_CorsairLedPositions));
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition;
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
ptr = new IntPtr(ptr.ToInt64() + structSize);
positions.Add(ledPosition);
}
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
InitializeLed(new CorsairLedId(ledPosition.ledId),
new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
}
#endregion
}
}

View File

@ -0,0 +1,23 @@
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Represents a generic information for a <see cref="CorsairMousematRGBDevice"/>.
/// </summary>
public class CorsairMousematRGBDeviceInfo : CorsairRGBDeviceInfo
{
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairMousematRGBDeviceInfo"/>.
/// </summary>
/// <param name="deviceIndex">The index if the <see cref="CorsairMousematRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Mousemat, nativeInfo)
{ }
#endregion
}
}

View File

@ -0,0 +1,242 @@
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
using System.IO;
using System.Runtime.InteropServices;
using RGB.NET.Core.Exceptions;
namespace RGB.NET.Devices.Corsair.Native
{
// ReSharper disable once InconsistentNaming
internal static class _CUESDK
{
#region Libary Management
private static IntPtr _dllHandle = IntPtr.Zero;
/// <summary>
/// Gets the loaded architecture (x64/x86).
/// </summary>
internal static string LoadedArchitecture { get; private set; }
/// <summary>
/// Reloads the SDK.
/// </summary>
internal static void Reload()
{
UnloadCUESDK();
LoadCUESDK();
}
private static void LoadCUESDK()
{
if (_dllHandle != IntPtr.Zero) return;
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CUESDK_2015.dll";
if (!File.Exists(dllPath))
throw new RGBDeviceException($"Can't find the CUE-SDK at the expected location '{Path.GetFullPath(dllPath)}'");
_dllHandle = LoadLibrary(dllPath);
_corsairSetLedsColorsPointer =
(CorsairSetLedsColorsPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"),
typeof(CorsairSetLedsColorsPointer));
_corsairGetDeviceCountPointer =
(CorsairGetDeviceCountPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"),
typeof(CorsairGetDeviceCountPointer));
_corsairGetDeviceInfoPointer =
(CorsairGetDeviceInfoPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"),
typeof(CorsairGetDeviceInfoPointer));
_corsairGetLedPositionsPointer =
(CorsairGetLedPositionsPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"),
typeof(CorsairGetLedPositionsPointer));
_corsairGetLedPositionsByDeviceIndexPointer =
(CorsairGetLedPositionsByDeviceIndexPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositionsByDeviceIndex"),
typeof(CorsairGetLedPositionsByDeviceIndexPointer));
_corsairGetLedIdForKeyNamePointer =
(CorsairGetLedIdForKeyNamePointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedIdForKeyName"),
typeof(CorsairGetLedIdForKeyNamePointer));
_corsairRequestControlPointer =
(CorsairRequestControlPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRequestControl"),
typeof(CorsairRequestControlPointer));
_corsairReleaseControlPointer =
(CorsairReleaseControlPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"),
typeof(CorsairReleaseControlPointer));
_corsairPerformProtocolHandshakePointer =
(CorsairPerformProtocolHandshakePointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"),
typeof(CorsairPerformProtocolHandshakePointer));
_corsairGetLastErrorPointer =
(CorsairGetLastErrorPointer)
Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
}
private static void UnloadCUESDK()
{
if (_dllHandle == IntPtr.Zero) return;
// ReSharper disable once EmptyEmbeddedStatement - DarthAffe 20.02.2016: We might need to reduce the internal reference counter more than once to set the library free
while (FreeLibrary(_dllHandle)) ;
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion
#region SDK-METHODS
#region Pointers
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
private static CorsairGetLedIdForKeyNamePointer _corsairGetLedIdForKeyNamePointer;
private static CorsairGetLedPositionsByDeviceIndexPointer _corsairGetLedPositionsByDeviceIndexPointer;
private static CorsairRequestControlPointer _corsairRequestControlPointer;
private static CorsairReleaseControlPointer _corsairReleaseControlPointer;
private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer;
private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer;
#endregion
#region Delegates
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetDeviceInfoPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate IntPtr CorsairGetLedPositionsByDeviceIndexPointer(int deviceIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairLedIds CorsairGetLedIdForKeyNamePointer(char keyName);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairRequestControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairReleaseControlPointer(CorsairAccessMode accessMode);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate _CorsairProtocolDetails CorsairPerformProtocolHandshakePointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairError CorsairGetLastErrorPointer();
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account.
/// </summary>
internal static bool CorsairSetLedsColors(int size, IntPtr ledsColors)
{
return _corsairSetLedsColorsPointer(size, ledsColors);
}
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
/// </summary>
internal static int CorsairGetDeviceCount()
{
return _corsairGetDeviceCountPointer();
}
/// <summary>
/// CUE-SDK: returns information about device at provided index.
/// </summary>
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex)
{
return _corsairGetDeviceInfoPointer(deviceIndex);
}
/// <summary>
/// CUE-SDK: provides list of keyboard LEDs with their physical positions.
/// </summary>
internal static IntPtr CorsairGetLedPositions()
{
return _corsairGetLedPositionsPointer();
}
/// <summary>
/// CUE-SDK: provides list of keyboard or mousemat LEDs with their physical positions.
/// </summary>
internal static IntPtr CorsairGetLedPositionsByDeviceIndex(int deviceIndex)
{
return _corsairGetLedPositionsByDeviceIndexPointer(deviceIndex);
}
/// <summary>
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
/// </summary>
internal static CorsairLedIds CorsairGetLedIdForKeyName(char keyName)
{
return _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 bool CorsairRequestControl(CorsairAccessMode accessMode)
{
return _corsairRequestControlPointer(accessMode);
}
/// <summary>
/// CUE-SDK: releases previously requested control for specified access mode.
/// </summary>
internal static bool CorsairReleaseControl(CorsairAccessMode accessMode)
{
return _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 _CorsairProtocolDetails CorsairPerformProtocolHandshake()
{
return _corsairPerformProtocolHandshakePointer();
}
/// <summary>
/// CUE-SDK: returns last error that occured while using any of Corsair* functions.
/// </summary>
internal static CorsairError CorsairGetLastError()
{
return _corsairGetLastErrorPointer();
}
// ReSharper restore EventExceptionNotDocumented
#endregion
}
}

View File

@ -0,0 +1,47 @@
#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.Corsair.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;
}
}

View File

@ -0,0 +1,36 @@
#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.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.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;
};
}

View 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
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.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 CorsairLedIds 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;
}
}

View File

@ -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
using System;
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Corsair.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;
}
}

View File

@ -0,0 +1,44 @@
#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.Corsair.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;
};
}

View File

@ -31,6 +31,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="RGB.NET.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RGB.NET.Core.1.0.0\lib\net45\RGB.NET.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@ -41,8 +45,40 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CorsairDeviceProvider.cs" />
<Compile Include="Enum\CorsairAccessMode.cs" />
<Compile Include="Enum\CorsairDeviceCaps.cs" />
<Compile Include="Enum\CorsairDeviceType.cs" />
<Compile Include="Enum\CorsairError.cs" />
<Compile Include="Enum\CorsairLedIds.cs" />
<Compile Include="Enum\CorsairLogicalKeyboardLayout.cs" />
<Compile Include="Enum\CorsairPhysicalKeyboardLayout.cs" />
<Compile Include="Enum\CorsairPhysicalMouseLayout.cs" />
<Compile Include="Exceptions\CUEException.cs" />
<Compile Include="Generic\CorsairLedId.cs" />
<Compile Include="Generic\CorsairProtocolDetails.cs" />
<Compile Include="Generic\CorsairRGBDeviceInfo.cs" />
<Compile Include="Generic\CorsairRGBDevice.cs" />
<Compile Include="Headset\CorsairHeadsetRGBDevice.cs" />
<Compile Include="Headset\CorsairHeadsetRGBDeviceInfo.cs" />
<Compile Include="Keyboard\CorsairKeyboardRGBDevice.cs" />
<Compile Include="Keyboard\CorsairKeyboardRGBDeviceInfo.cs" />
<Compile Include="Mouse\CorsairMouseRGBDevice.cs" />
<Compile Include="Mouse\CorsairMouseRGBDeviceInfo.cs" />
<Compile Include="Mousmat\CorsairMousematRGBDevice.cs" />
<Compile Include="Mousmat\CorsairMousematRGBDeviceInfo.cs" />
<Compile Include="Native\_CorsairDeviceInfo.cs" />
<Compile Include="Native\_CorsairLedColor.cs" />
<Compile Include="Native\_CorsairLedPosition.cs" />
<Compile Include="Native\_CorsairLedPositions.cs" />
<Compile Include="Native\_CorsairProtocolDetails.cs" />
<Compile Include="Native\_CUESDK.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -0,0 +1,9 @@
<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/=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/=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></wpf:ResourceDictionary>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RGB.NET.Core" version="1.0.0" targetFramework="net45" />
</packages>