1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 08:48:30 +00:00

Added tons of xml-comments.

This commit is contained in:
Darth Affe 2015-10-17 16:57:50 +02:00
parent 57ad0f30e2
commit 6de1087c1f
23 changed files with 422 additions and 51 deletions

View File

@ -17,13 +17,42 @@ namespace CUE.NET
// ReSharper disable UnusedAutoPropertyAccessor.Global
/// <summary>
/// Gets the loaded architecture (x64/x86).
/// </summary>
public static string LoadedArchitecture => _CUESDK.LoadedArchitecture;
/// <summary>
/// Gets the protocol details for the current SDK-connection.
/// </summary>
public static CorsairProtocolDetails ProtocolDetails { get; private set; }
/// <summary>
/// Gets whether the application has exclusive access to the SDK or not.
/// </summary>
public static bool HasExclusiveAccess { get; private set; }
/// <summary>
/// Gets the last error documented by CUE.
/// </summary>
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
/// <summary>
/// Gets the managed representation of a keyboard managed by the CUE-SDK.
/// Note that currently only one connected keyboard is supported.
/// </summary>
public static CorsairKeyboard KeyboardSDK { get; private set; }
/// <summary>
/// Gets the managed representation of a mouse managed by the CUE-SDK.
/// Note that currently only one connected mouse is supported.
/// </summary>
public static CorsairMouse MouseSDK { get; private set; }
/// <summary>
/// Gets the managed representation of a headset managed by the CUE-SDK.
/// Note that currently only one connected headset is supported.
/// </summary>
public static CorsairHeadset HeadsetSDK { get; private set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
@ -32,6 +61,11 @@ namespace CUE.NET
#region Methods
/// <summary>
/// Initializes the CUE-SDK. This method should be called exactly ONE time, before anything else is done.
/// </summary>
/// <param name="exclusiveAccess">Specifies whether the application should request exclusive access or not.</param>
/// <exception cref="WrapperException">Thrown if the SDK is already initialized, the SDK is not compatible to CUE or if CUE returns unknown devices.</exception>
public static void Initialize(bool exclusiveAccess = false)
{
if (ProtocolDetails != null)

View File

@ -35,6 +35,7 @@ namespace CUE.NET.Devices.Generic
CheckUpdateLoop();
}
}
/// <summary>
/// Gets or sets the update-frequency in seconds. (Calculate by using '1f / updates per second')
/// </summary>

View File

@ -5,6 +5,9 @@ using CUE.NET.Native;
namespace CUE.NET.Devices.Generic
{
/// <summary>
/// Represents generic information about a CUE device.
/// </summary>
public class GenericDeviceInfo : IDeviceInfo
{
#region Properties & Fields
@ -29,9 +32,9 @@ namespace CUE.NET.Devices.Generic
#region Constructors
/// <summary>
/// Internal constructor of managed CorsairDeviceInfo.
/// Internal constructor of managed <see cref="GenericDeviceInfo"/>.
/// </summary>
/// <param name="nativeInfo">The native CorsairDeviceInfo-struct</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal GenericDeviceInfo(_CorsairDeviceInfo nativeInfo)
{
this.Type = nativeInfo.type;

View File

@ -1,4 +1,7 @@
using System;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
using System;
namespace CUE.NET.Devices.Generic
{

View File

@ -1,4 +1,7 @@
using System.Collections;
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@ -7,12 +10,21 @@ using CUE.NET.Devices.Headset.Enums;
namespace CUE.NET.Devices.Headset
{
/// <summary>
/// Represents the SDK for a corsair headset.
/// </summary>
public class CorsairHeadset : AbstractCueDevice, IEnumerable<CorsairLed>
{
#region Properties & Fields
#region Indexer
/// <summary>
/// Gets the <see cref="CorsairLed" /> with the specified ID.
/// </summary>
/// <param name="ledId">The ID of the LED to get.</param>
/// <returns>The LED with the specified ID.</returns>
/// <exception cref="System.ArgumentNullException" accessor="get"><paramref name="ledId" /> is null.</exception>
public CorsairLed this[CorsairHeadsetLedId ledId]
{
get
@ -24,16 +36,29 @@ namespace CUE.NET.Devices.Headset
#endregion
/// <summary>
/// Gets specific information provided by CUE for the headset.
/// </summary>
public CorsairHeadsetDeviceInfo HeadsetDeviceInfo { get; }
/// <summary>
/// Indicates if the headset has an active effect to deal with.
/// </summary>
protected override bool HasEffect => false;
/// <summary>
/// Gets a read-only collection containing all LEDs of the headset.
/// </summary>
public new IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(base.Leds.Values.ToList());
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairHeadset"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the headset</param>
internal CorsairHeadset(CorsairHeadsetDeviceInfo info)
: base(info)
{
@ -53,6 +78,10 @@ namespace CUE.NET.Devices.Headset
#region IEnumerable
/// <summary>
/// Returns an enumerator that iterates over all LEDs of the headset.
/// </summary>
/// <returns>An enumerator for all LDS of the headset.</returns>
public IEnumerator<CorsairLed> GetEnumerator()
{
return Leds.GetEnumerator();

View File

@ -4,10 +4,14 @@ using CUE.NET.Native;
namespace CUE.NET.Devices.Headset
{
/// <summary>
/// Stub for planned headset-support.
/// Represents specific information for a CUE headset.
/// </summary>
public class CorsairHeadsetDeviceInfo : GenericDeviceInfo
{
/// <summary>
/// Internal constructor of managed <see cref="CorsairHeadsetDeviceInfo" />.
/// </summary>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo)
: base(nativeInfo)
{ }

View File

@ -3,6 +3,9 @@
namespace CUE.NET.Devices.Headset.Enums
{
/// <summary>
/// Contains list of all LEDs available for corsair headsets.
/// </summary>
public enum CorsairHeadsetLedId
{
Invalid = 0,

View File

@ -3,18 +3,42 @@ using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices
{
/// <summary>
/// Represents the event-handler of the OnException-event.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="args">The arguments provided by the event.</param>
public delegate void OnExceptionEventHandler(object sender, OnExceptionEventArgs args);
/// <summary>
/// Represents a generic cue device.
/// </summary>
public interface ICueDevice
{
/// <summary>
/// Gets generic information provided by CUE for the device.
/// </summary>
IDeviceInfo DeviceInfo { get; }
/// <summary>
/// Gets or sets the update-mode for the device.
/// </summary>
UpdateMode UpdateMode { get; set; }
/// <summary>
/// Gets or sets the update-frequency in seconds. (Calculate by using '1f / updates per second')
/// </summary>
float UpdateFrequency { get; set; }
/// <summary>
/// Occurs when a catched exception is thrown inside the device.
/// </summary>
event OnExceptionEventHandler OnException;
/// <summary>
/// Perform an update for all dirty keys, or all keys if flushLeds is set to true.
/// </summary>
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
void Update(bool flushLeds = false);
}
}

View File

@ -5,17 +5,17 @@ namespace CUE.NET.Devices
public interface IDeviceInfo
{
/// <summary>
/// Device type
/// Gets the device type.
/// </summary>
CorsairDeviceType Type { get; }
/// <summary>
/// Device model (like “K95RGB”).
/// Gets the device model (like “K95RGB”).
/// </summary>
string Model { get; }
/// <summary>
/// Flags that describes device capabilities
/// Gets flags, which describe device capabilities.
/// </summary>
CorsairDeviceCaps CapsMask { get; }
}

View File

@ -12,12 +12,21 @@ using CUE.NET.Exceptions;
namespace CUE.NET.Devices.Mouse
{
/// <summary>
/// Represents the SDK for a corsair mouse.
/// </summary>
public class CorsairMouse : AbstractCueDevice, IEnumerable<CorsairLed>
{
#region Properties & Fields
#region Indexer
/// <summary>
/// Gets the <see cref="CorsairLed" /> with the specified ID.
/// </summary>
/// <param name="ledId">The ID of the LED to get.</param>
/// <returns>The LED with the specified ID.</returns>
/// <exception cref="System.ArgumentNullException" accessor="get"><paramref name="ledId" /> is null.</exception>
public CorsairLed this[CorsairMouseLedId ledId]
{
get
@ -29,16 +38,29 @@ namespace CUE.NET.Devices.Mouse
#endregion
/// <summary>
/// Gets specific information provided by CUE for the mouse.
/// </summary>
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
/// <summary>
/// Indicates if the mouse has an active effect to deal with.
/// </summary>
protected override bool HasEffect => false;
/// <summary>
/// Gets a read-only collection containing all LEDs of the mouse.
/// </summary>
public new IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(base.Leds.Values.ToList());
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairMouse"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the mouse</param>
internal CorsairMouse(CorsairMouseDeviceInfo info)
: base(info)
{
@ -80,6 +102,10 @@ namespace CUE.NET.Devices.Mouse
#region IEnumerable
/// <summary>
/// Returns an enumerator that iterates over all LEDs of the mouse.
/// </summary>
/// <returns>An enumerator for all LDS of the mouse.</returns>
public IEnumerator<CorsairLed> GetEnumerator()
{
return Leds.GetEnumerator();

View File

@ -8,7 +8,7 @@ using CUE.NET.Native;
namespace CUE.NET.Devices.Mouse
{
/// <summary>
/// Stub for planned headset-support.
/// Represents specific information for a CUE mouse.
/// </summary>
public class CorsairMouseDeviceInfo : GenericDeviceInfo
{
@ -24,9 +24,9 @@ namespace CUE.NET.Devices.Mouse
#region Constructors
/// <summary>
/// Internal constructor of managed CorsairDeviceInfo.
/// Internal constructor of managed <see cref="CorsairMouseDeviceInfo" />.
/// </summary>
/// <param name="nativeInfo">The native CorsairDeviceInfo-struct</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairMouseDeviceInfo(_CorsairDeviceInfo nativeInfo)
: base(nativeInfo)
{

View File

@ -3,6 +3,9 @@
namespace CUE.NET.Devices.Mouse.Enums
{
/// <summary>
/// Contains list of all LEDs available for corsair mice.
/// </summary>
public enum CorsairMouseLedId
{
Invalid = 0,

View File

@ -6,16 +6,26 @@ using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Exceptions
{
/// <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;

View File

@ -2,10 +2,18 @@
namespace CUE.NET.Exceptions
{
/// <summary>
/// Represents an exception thrown by this SDK-Wrapper.
/// </summary>
public class WrapperException : ApplicationException
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="WrapperException"/> class.
/// </summary>
/// <param name="message">The message which describes the reason of throwing this exception.</param>
/// <param name="innerException">Optional inner exception, which lead to this exception.</param>
public WrapperException(string message, Exception innerException = null)
: base(message, innerException)
{ }

View File

@ -5,32 +5,64 @@ using System.Drawing;
namespace CUE.NET.Helper
{
/// <summary>
/// Offers some extensions and helper-methods for color related things.
/// </summary>
public static class ColorHelper
{
#region byte/float conversion
/// <summary>
/// Converts the alpha-value of the <see cref="Color"/> to an float value int the range [0..1].
/// </summary>
/// <param name="color">The color to take the alpha-value from.</param>
/// <returns>The float-value in the range of [0..1]</returns>
public static float GetFloatA(this Color color)
{
return color.A / 255f;
}
/// <summary>
/// Converts the red-value of the <see cref="Color"/> to an float value int the range [0..1].
/// </summary>
/// <param name="color">The color to take the red-value from.</param>
/// <returns>The float-value in the range of [0..1]</returns>
public static float GetFloatR(this Color color)
{
return color.R / 255f;
}
/// <summary>
/// Converts the green-value of the <see cref="Color"/> to an float value int the range [0..1].
/// </summary>
/// <param name="color">The color to take the green-value from.</param>
/// <returns>The float-value in the range of [0..1]</returns>
public static float GetFloatG(this Color color)
{
return color.G / 255f;
}
/// <summary>
/// Converts the blue-value of the <see cref="Color"/> to an float value int the range [0..1].
/// </summary>
/// <param name="color">The color to take the blue-value from.</param>
/// <returns>The float-value in the range of [0..1]</returns>
public static float GetFloatB(this Color color)
{
return color.B / 255f;
}
/// <summary>
/// Creates a <see cref="Color"/> object from the respective rgb-float-values in the range [0..1].
/// </summary>
/// <param name="a">The alpha-value in the range [0..1].</param>
/// <param name="r">The red-value in the range [0..1].</param>
/// <param name="g">The green-value in the range [0..1].</param>
/// <param name="b">The blue-value in the range [0..1].</param>
/// <returns>The color-object created representing the given values.</returns>
public static Color CreateColorFromFloat(float a, float r, float g, float b)
{
// ReSharper disable once ExceptionNotDocumentedOptional
return Color.FromArgb(GetIntColorFromFloat(a), GetIntColorFromFloat(r), GetIntColorFromFloat(g), GetIntColorFromFloat(b));
}
@ -45,6 +77,12 @@ namespace CUE.NET.Helper
#region Blending
/// <summary>
/// Blends two colors.
/// </summary>
/// <param name="bg">The background-color.</param>
/// <param name="fg">The foreground-color</param>
/// <returns>The resulting color.</returns>
public static Color Blend(this Color bg, Color fg)
{
if (fg.A == 255)
@ -65,6 +103,11 @@ namespace CUE.NET.Helper
#region RGB/HSV conversion
// https://en.wikipedia.org/wiki/HSL_and_HSV
/// <summary>
/// Gets the saturation-value (HSV-color space) of the color.
/// </summary>
/// <param name="color">The color to take the saturation from.</param>
/// <returns>The saturation-value (HSV-color space) of the color.</returns>
public static float GetHSVSaturation(this Color color)
{
int max = Math.Max(color.R, Math.Max(color.G, color.B));
@ -75,12 +118,25 @@ namespace CUE.NET.Helper
// ReSharper restore RedundantCast
}
/// <summary>
/// Gets the value-value (HSV-color space) of the color.
/// </summary>
/// <param name="color">The color to take the value from.</param>
/// <returns>The value-value (HSV-color space) of the color.</returns>
public static float GetHSVValue(this Color color)
{
return Math.Max(color.R, Math.Max(color.G, color.B)) / 255f;
}
// Based on http://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb-in-range-0-255-for-both/6930407#6930407 as of 27.09.2015
/// <summary>
/// Creates a <see cref="Color"/> object from the respective hsv-float-values in the range [0..1].
/// </summary>
/// <param name="hue">The hue of the color.</param>
/// <param name="saturation">The saturation of the color.</param>
/// <param name="value">The value of the color.</param>
/// <param name="alpha">The alpha of the color.</param>
/// <returns>The color-object created representing the given values.</returns>
public static Color ColorFromHSV(float hue, float saturation, float value, byte alpha = 255)
{
if (saturation <= 0.0)

View File

@ -5,9 +5,19 @@ using System.Drawing;
namespace CUE.NET.Helper
{
/// <summary>
/// Offers some extensions and helper-methods for gradient related things.
/// </summary>
public static class GradientHelper
{
// Based on https://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/
/// <summary>
/// Calculates the offset of an given point on an gradient.
/// </summary>
/// <param name="startPoint">The start point of the gradient.</param>
/// <param name="endPoint">The end point of the gradient.</param>
/// <param name="point">The point on the gradient to which the offset is calculated.</param>
/// <returns>The offset of the point on the gradient.</returns>
public static float CalculateLinearGradientOffset(PointF startPoint, PointF endPoint, PointF point)
{
PointF intersectingPoint;
@ -17,7 +27,7 @@ namespace CUE.NET.Helper
else if (startPoint.X.Equals(endPoint.X)) // Vertical case
intersectingPoint = new PointF(startPoint.X, point.Y);
else // Diagnonal case
else // Diagonal case
{
float slope = (endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
float orthogonalSlope = -1 / slope;
@ -39,8 +49,12 @@ namespace CUE.NET.Helper
// Based on https://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/
/// <summary>
/// Returns the signed magnitude of a point on a vector
/// Returns the signed magnitude of a point on a vector.
/// </summary>
/// <param name="point">The point on the vector of which the magnitude should be calculated.</param>
/// <param name="origin">The origin of the vector.</param>
/// <param name="direction">The direction of the vector.</param>
/// <returns>The signed magnitude of a point on a vector.</returns>
public static float CalculateDistance(PointF point, PointF origin, PointF direction)
{
float distance = CalculateDistance(point, origin);
@ -52,6 +66,12 @@ namespace CUE.NET.Helper
? -distance : distance;
}
/// <summary>
/// Calculated the distance between two points.
/// </summary>
/// <param name="point1">The first point.</param>
/// <param name="point2">The second point.</param>
/// <returns>The distance between the two points.</returns>
public static float CalculateDistance(PointF point1, PointF point2)
{
return (float)Math.Sqrt((point1.Y - point2.Y) * (point1.Y - point2.Y) + (point1.X - point2.X) * (point1.X - point2.X));

View File

@ -4,13 +4,27 @@ using System.Drawing;
namespace CUE.NET.Helper
{
/// <summary>
/// Offers some extensions and helper-methods for rectangle related things.
/// </summary>
public static class RectangleHelper
{
/// <summary>
/// Calculates the center-point of a rectangle.
/// </summary>
/// <param name="rectangle">The rectangle.</param>
/// <returns>The center point of the rectangle.</returns>
public static PointF GetCenter(this RectangleF rectangle)
{
return new PointF(rectangle.Left + rectangle.Width / 2f, rectangle.Top + rectangle.Height / 2f);
}
/// <summary>
/// Creates a rectangle from two corner points.
/// </summary>
/// <param name="point1">The first point.</param>
/// <param name="point2">The second points.</param>
/// <returns>The rectangle created from the two points.</returns>
public static RectangleF CreateRectangleFromPoints(PointF point1, PointF point2)
{
float posX = Math.Min(point1.X, point2.X);
@ -21,16 +35,27 @@ namespace CUE.NET.Helper
return new RectangleF(posX, posY, width, height);
}
public static RectangleF CreateRectangleFromRectangles(RectangleF point1, RectangleF point2)
/// <summary>
/// Creates a rectangle containing two other rectangles.
/// </summary>
/// <param name="rectangle1">The first rectangle.</param>
/// <param name="rectangle2">The second rectangle.</param>
/// <returns>The rectangle created from the two rectangles.</returns>
public static RectangleF CreateRectangleFromRectangles(RectangleF rectangle1, RectangleF rectangle2)
{
float posX = Math.Min(point1.X, point2.X);
float posY = Math.Min(point1.Y, point2.Y);
float width = Math.Max(point1.X + point1.Width, point2.X + point2.Width) - posX;
float height = Math.Max(point1.Y + point1.Height, point2.Y + point2.Height) - posY;
float posX = Math.Min(rectangle1.X, rectangle2.X);
float posY = Math.Min(rectangle1.Y, rectangle2.Y);
float width = Math.Max(rectangle1.X + rectangle1.Width, rectangle2.X + rectangle2.Width) - posX;
float height = Math.Max(rectangle1.Y + rectangle1.Height, rectangle2.Y + rectangle2.Height) - posY;
return new RectangleF(posX, posY, width, height);
}
/// <summary>
/// Creates a rectangle containing n other rectangles.
/// </summary>
/// <param name="rectangles">The list of rectangles.</param>
/// <returns>The rectangle created from the rectangles.</returns>
public static RectangleF CreateRectangleFromRectangles(IEnumerable<RectangleF> rectangles)
{
float posX = float.MaxValue;
@ -49,6 +74,12 @@ namespace CUE.NET.Helper
return CreateRectangleFromPoints(new PointF(posX, posY), new PointF(posX2, posY2));
}
/// <summary>
/// Calculates the percentage of the intersection of two rectangles.
/// </summary>
/// <param name="rect">The rectangle from which the percentage should be calculated.</param>
/// <param name="referenceRect">The intersecting rectangle.</param>
/// <returns>The percentage of the intersection.</returns>
public static float CalculateIntersectPercentage(RectangleF rect, RectangleF referenceRect)
{
if (rect.IsEmpty || referenceRect.IsEmpty) return 0;

View File

@ -10,6 +10,9 @@ namespace CUE.NET.Native
{
#region Libary Management
/// <summary>
/// Gets the loaded architecture (x64/x86).
/// </summary>
internal static string LoadedArchitecture { get; private set; }
static _CUESDK()
@ -25,8 +28,10 @@ namespace CUE.NET.Native
#region SDK-IMPORTS
/// <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>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account
internal static extern bool CorsairSetLedsColors(int size, IntPtr ledsColors);
//#if WIN64
@ -36,32 +41,47 @@ namespace CUE.NET.Native
//#endif
//internal static extern bool CorsairSetLedsColorsAsync(int size, CorsairLedColor* ledsColors, void(*CallbackType)(void*, bool, CorsairError), void* context);
/// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
/// </summary>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// returns number of connected Corsair devices that support lighting control.
internal static extern int CorsairGetDeviceCount();
/// <summary>
/// CUE-SDK: returns information about device at provided index
/// </summary>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// returns information about device at provided index
internal static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
/// <summary>
/// CUE-SDK: provides list of keyboard LEDs with their physical positions.
/// </summary>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// provides list of keyboard LEDs with their physical positions.
internal static extern IntPtr CorsairGetLedPositions();
/// <summary>
/// CUE-SDK: retrieves led id for key name taking logical layout into account.
/// </summary>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// retrieves led id for key name taking logical layout into account.
internal static extern CorsairKeyboardKeyId CorsairGetLedIdForKeyName(char 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>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// 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
internal static extern bool CorsairRequestControl(CorsairAccessMode 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>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE
internal static extern _CorsairProtocolDetails CorsairPerformProtocolHandshake();
/// <summary>
/// CUE-SDK: returns last error that occured while using any of Corsair* functions
/// </summary>
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
// returns last error that occured while using any of Corsair* functions
internal static extern CorsairError CorsairGetLastError();
#endregion

View File

@ -9,13 +9,35 @@ using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about device
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairDeviceInfo // contains information about device
internal class _CorsairDeviceInfo
{
internal CorsairDeviceType type; // enum describing device type
internal IntPtr model; // null - terminated device model(like “K95RGB”)
internal int physicalLayout; // enum describing physical layout of the keyboard or mouse
internal int logicalLayout; // enum describing logical layout of the keyboard as set in CUE settings
internal int capsMask; // mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
/// <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;
}
}

View File

@ -6,14 +6,31 @@ using System.Runtime.InteropServices;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about led and its color
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedColor // contains information about led and its color
internal class _CorsairLedColor
{
/// <summary>
/// CUE-SDK: identifier of LED to set
/// </summary>
internal int ledId;
internal int ledId; // identifier of LED to set
internal int r; // red brightness[0..255]
internal int g; // green brightness[0..255]
internal int b; // blue brightness[0..255]
/// <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

@ -8,13 +8,36 @@ using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.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 // 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
internal class _CorsairLedPosition
{
internal CorsairKeyboardKeyId ledId; // identifier of led
/// <summary>
/// CUE-SDK: identifier of led
/// </summary>
internal CorsairKeyboardKeyId 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;
internal double width; // values in mm
/// <summary>
/// CUE-SDK: values in mm
/// </summary>
internal double width;
}
}

View File

@ -8,10 +8,20 @@ using System.Runtime.InteropServices;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains number of leds and arrays with their positions
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedPositions // contains number of leds and arrays with their positions
internal class _CorsairLedPositions
{
internal int numberOfLed; // integer value.Number of elements in following array
internal IntPtr pLedPosition; // array of led positions
/// <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

@ -8,13 +8,37 @@ using System.Runtime.InteropServices;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
/// <summary>
/// CUE-SDK: contains information about SDK and CUE versions
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct _CorsairProtocolDetails // contains information about SDK and CUE versions
internal struct _CorsairProtocolDetails
{
internal IntPtr sdkVersion; // null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found
internal IntPtr serverVersion; // null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found.
internal int sdkProtocolVersion; // 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
internal int serverProtocolVersion; // 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
internal byte breakingChanges; // boolean value that specifies if there were breaking changes between version of protocol implemented by server and client
/// <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;
};
}