diff --git a/CueSDK.cs b/CueSDK.cs index c3c2679..c6c48b7 100644 --- a/CueSDK.cs +++ b/CueSDK.cs @@ -17,13 +17,42 @@ namespace CUE.NET // ReSharper disable UnusedAutoPropertyAccessor.Global + /// + /// Gets the loaded architecture (x64/x86). + /// public static string LoadedArchitecture => _CUESDK.LoadedArchitecture; + + /// + /// Gets the protocol details for the current SDK-connection. + /// public static CorsairProtocolDetails ProtocolDetails { get; private set; } + + /// + /// Gets whether the application has exclusive access to the SDK or not. + /// public static bool HasExclusiveAccess { get; private set; } + + /// + /// Gets the last error documented by CUE. + /// public static CorsairError LastError => _CUESDK.CorsairGetLastError(); + /// + /// Gets the managed representation of a keyboard managed by the CUE-SDK. + /// Note that currently only one connected keyboard is supported. + /// public static CorsairKeyboard KeyboardSDK { get; private set; } + + /// + /// Gets the managed representation of a mouse managed by the CUE-SDK. + /// Note that currently only one connected mouse is supported. + /// public static CorsairMouse MouseSDK { get; private set; } + + /// + /// Gets the managed representation of a headset managed by the CUE-SDK. + /// Note that currently only one connected headset is supported. + /// public static CorsairHeadset HeadsetSDK { get; private set; } // ReSharper restore UnusedAutoPropertyAccessor.Global @@ -32,6 +61,11 @@ namespace CUE.NET #region Methods + /// + /// Initializes the CUE-SDK. This method should be called exactly ONE time, before anything else is done. + /// + /// Specifies whether the application should request exclusive access or not. + /// Thrown if the SDK is already initialized, the SDK is not compatible to CUE or if CUE returns unknown devices. public static void Initialize(bool exclusiveAccess = false) { if (ProtocolDetails != null) diff --git a/Devices/Generic/AbstractCueDevice.cs b/Devices/Generic/AbstractCueDevice.cs index 918ecf9..6a9fbc3 100644 --- a/Devices/Generic/AbstractCueDevice.cs +++ b/Devices/Generic/AbstractCueDevice.cs @@ -10,14 +10,22 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Generic { + /// + /// Represents a generic CUE-device. (keyboard, mouse, headset, ...) + /// public abstract class AbstractCueDevice : ICueDevice { - private UpdateMode _updateMode = UpdateMode.AutoOnEffect; - #region Properties & Fields + /// + /// Gets generic information provided by CUE for the device. + /// public IDeviceInfo DeviceInfo { get; } + private UpdateMode _updateMode = UpdateMode.AutoOnEffect; + /// + /// Gets or sets the update-mode for the device. + /// public UpdateMode UpdateMode { get { return _updateMode; } @@ -27,10 +35,20 @@ namespace CUE.NET.Devices.Generic CheckUpdateLoop(); } } + + /// + /// Gets or sets the update-frequency in seconds. (Calculate by using '1f / updates per second') + /// public float UpdateFrequency { get; set; } = 1f / 30f; - private Dictionary Leds { get; } = new Dictionary(); + /// + /// Gets a dictionary containing all LEDs of the device. + /// + protected Dictionary Leds { get; } = new Dictionary(); + /// + /// Indicates if the device has an active effect to deal with. + /// protected abstract bool HasEffect { get; } private CancellationTokenSource _updateTokenSource; @@ -41,12 +59,19 @@ namespace CUE.NET.Devices.Generic #region Events + /// + /// Occurs when a catched exception is thrown inside the device. + /// public event OnExceptionEventHandler OnException; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The generic information provided by CUE for the device. protected AbstractCueDevice(IDeviceInfo info) { this.DeviceInfo = info; @@ -58,6 +83,11 @@ namespace CUE.NET.Devices.Generic #region Methods + /// + /// Gets the LED-Object with the specified id. + /// + /// The LED-Id to look for. + /// protected CorsairLed GetLed(int ledId) { if (!Leds.ContainsKey(ledId)) @@ -66,6 +96,10 @@ namespace CUE.NET.Devices.Generic return Leds[ledId]; } + /// + /// Checks if automatic updates should occur and starts/stops the update-loop if needed. + /// + /// Thrown if the requested update-mode is not available. protected async void CheckUpdateLoop() { bool shouldRun; @@ -111,6 +145,10 @@ namespace CUE.NET.Devices.Generic } } + /// + /// Perform an update for all dirty keys, or all keys if flushLeds is set to true. + /// + /// Specifies whether all keys (including clean ones) should be updated. public virtual void Update(bool flushLeds = false) { IList> ledsToUpdate = (flushLeds ? Leds : Leds.Where(x => x.Value.IsDirty)).ToList(); @@ -148,6 +186,11 @@ namespace CUE.NET.Devices.Generic Marshal.FreeHGlobal(ptr); } + /// + /// Handles the needed event-calls for an exception. + /// + /// + /// A delegate callback throws an exception. protected void ManageException(Exception ex) { OnException?.Invoke(this, new OnExceptionEventArgs(ex)); diff --git a/Devices/Generic/CorsairLed.cs b/Devices/Generic/CorsairLed.cs index c07dc18..9c3e3fe 100644 --- a/Devices/Generic/CorsairLed.cs +++ b/Devices/Generic/CorsairLed.cs @@ -7,16 +7,32 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Generic { + /// + /// Represents a single LED of a CUE-device. + /// public class CorsairLed { #region Properties & Fields + /// + /// Indicates whether the LED has changed an internal state. + /// public bool IsDirty => RequestedColor != _color; + + /// + /// Indicate whether the Color of the LED was set since the last update. + /// public bool IsUpdated { get; private set; } + /// + /// Gets the Color the LED should be set to on the next update. + /// public Color RequestedColor { get; private set; } = Color.Transparent; private Color _color = Color.Transparent; + /// + /// Gets the current color of the LED. Sets the for the next update and mark the LED as . + /// public Color Color { get { return _color; } @@ -30,12 +46,15 @@ namespace CUE.NET.Devices.Generic } } + /// + /// Gets or sets if the color of this LED can be changed. + /// public bool IsLocked { get; set; } = false; #endregion #region Constructors - + internal CorsairLed() { } #endregion diff --git a/Devices/Generic/Enums/UpdateMode.cs b/Devices/Generic/Enums/UpdateMode.cs index 8ce44ab..c61c57d 100644 --- a/Devices/Generic/Enums/UpdateMode.cs +++ b/Devices/Generic/Enums/UpdateMode.cs @@ -1,9 +1,24 @@ namespace CUE.NET.Devices.Generic.Enums { + /// + /// Contains list of available update modes. + /// public enum UpdateMode { + /// + /// The device will not perform automatic updates. Updates will only occur if is called. + /// Manual, + + /// + /// The device will perform automatic updates at the rate set in + /// as long as an is attached. + /// AutoOnEffect, + + /// + /// The device will perform automatic updates at the rate set in . + /// Continuous } } diff --git a/Devices/Generic/GenericDeviceInfo.cs b/Devices/Generic/GenericDeviceInfo.cs index d72f917..a9d9cce 100644 --- a/Devices/Generic/GenericDeviceInfo.cs +++ b/Devices/Generic/GenericDeviceInfo.cs @@ -5,22 +5,25 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Generic { + /// + /// Represents generic information about a CUE device. + /// public class GenericDeviceInfo : IDeviceInfo { #region Properties & Fields /// - /// Device type. + /// Gets the device type. () /// public CorsairDeviceType Type { get; } - + /// - /// Device model (like “K95RGB”). + /// Gets the device model (like “K95RGB”). /// public string Model { get; } /// - /// Flags that describes device capabilities + /// Get a flag that describes device capabilities. () /// public CorsairDeviceCaps CapsMask { get; } @@ -29,9 +32,9 @@ namespace CUE.NET.Devices.Generic #region Constructors /// - /// Internal constructor of managed CorsairDeviceInfo. + /// Internal constructor of managed . /// - /// The native CorsairDeviceInfo-struct + /// The native -struct internal GenericDeviceInfo(_CorsairDeviceInfo nativeInfo) { this.Type = nativeInfo.type; diff --git a/Devices/Generic/OnExceptionEventArgs.cs b/Devices/Generic/OnExceptionEventArgs.cs index d53b86f..ecb3325 100644 --- a/Devices/Generic/OnExceptionEventArgs.cs +++ b/Devices/Generic/OnExceptionEventArgs.cs @@ -1,17 +1,30 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global + +using System; namespace CUE.NET.Devices.Generic { + /// + /// Represents the information supplied with an OnException-event. + /// public class OnExceptionEventArgs : EventArgs { #region Properties & Fields + /// + /// Gets the exception which is responsible for the event-call. + /// public Exception Exception { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The exception which is responsible for the event-call. public OnExceptionEventArgs(Exception exception) { this.Exception = exception; diff --git a/Devices/Headset/CorsairHeadset.cs b/Devices/Headset/CorsairHeadset.cs index a976a64..9e4f826 100644 --- a/Devices/Headset/CorsairHeadset.cs +++ b/Devices/Headset/CorsairHeadset.cs @@ -1,26 +1,98 @@ -using CUE.NET.Devices.Generic; +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable MemberCanBePrivate.Global + +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using CUE.NET.Devices.Generic; +using CUE.NET.Devices.Headset.Enums; namespace CUE.NET.Devices.Headset { - //TODO DarthAffe 20.09.2015: Find someone to test this - public class CorsairHeadset : AbstractCueDevice + /// + /// Represents the SDK for a corsair headset. + /// + public class CorsairHeadset : AbstractCueDevice, IEnumerable { #region Properties & Fields + #region Indexer + + /// + /// Gets the with the specified ID. + /// + /// The ID of the LED to get. + /// The LED with the specified ID. + public CorsairLed this[CorsairHeadsetLedId ledId] + { + get + { + CorsairLed led; + return base.Leds.TryGetValue((int)ledId, out led) ? led : null; + } + } + + #endregion + + /// + /// Gets specific information provided by CUE for the headset. + /// + public CorsairHeadsetDeviceInfo HeadsetDeviceInfo { get; } + + /// + /// Gets a value indicating if the headset has an active effect to deal with or not. + /// protected override bool HasEffect => false; + /// + /// Gets a read-only collection containing all LEDs of the headset. + /// + public new IEnumerable Leds => new ReadOnlyCollection(base.Leds.Values.ToList()); + #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the headset internal CorsairHeadset(CorsairHeadsetDeviceInfo info) : base(info) - { } + { + this.HeadsetDeviceInfo = info; + InitializeLeds(); + } #endregion #region Methods + private void InitializeLeds() + { + GetLed((int)CorsairHeadsetLedId.LeftLogo); + GetLed((int)CorsairHeadsetLedId.RightLogo); + } + + #region IEnumerable + + /// + /// Returns an enumerator that iterates over all LEDs of the headset. + /// + /// An enumerator for all LDS of the headset. + public IEnumerator GetEnumerator() + { + return Leds.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + #endregion } } diff --git a/Devices/Headset/CorsairHeadsetDeviceInfo.cs b/Devices/Headset/CorsairHeadsetDeviceInfo.cs index d01f424..344bfb2 100644 --- a/Devices/Headset/CorsairHeadsetDeviceInfo.cs +++ b/Devices/Headset/CorsairHeadsetDeviceInfo.cs @@ -3,8 +3,15 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Headset { + /// + /// Represents specific information for a CUE headset. + /// public class CorsairHeadsetDeviceInfo : GenericDeviceInfo { + /// + /// Internal constructor of managed . + /// + /// The native -struct internal CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo) : base(nativeInfo) { } diff --git a/Devices/Headset/Enums/CorsairHeadsetLedId.cs b/Devices/Headset/Enums/CorsairHeadsetLedId.cs index 8a27111..84e551a 100644 --- a/Devices/Headset/Enums/CorsairHeadsetLedId.cs +++ b/Devices/Headset/Enums/CorsairHeadsetLedId.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Headset.Enums { + /// + /// Contains list of all LEDs available for corsair headsets. + /// public enum CorsairHeadsetLedId { Invalid = 0, diff --git a/Devices/ICueDevice.cs b/Devices/ICueDevice.cs index ff62eab..2ad8a14 100644 --- a/Devices/ICueDevice.cs +++ b/Devices/ICueDevice.cs @@ -3,19 +3,43 @@ using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Devices { + /// + /// Represents the event-handler of the OnException-event. + /// + /// The sender of the event. + /// The arguments provided by the event. public delegate void OnExceptionEventHandler(object sender, OnExceptionEventArgs args); + /// + /// Represents a generic cue device. + /// public interface ICueDevice { - + /// + /// Gets generic information provided by CUE for the device. + /// IDeviceInfo DeviceInfo { get; } + /// + /// Gets or sets the update-mode for the device. + /// UpdateMode UpdateMode { get; set; } + /// + /// Gets or sets the update-frequency in seconds. (Calculate by using '1f / updates per second') + /// float UpdateFrequency { get; set; } + // ReSharper disable once EventNeverSubscribedTo.Global + /// + /// Occurs when a catched exception is thrown inside the device. + /// event OnExceptionEventHandler OnException; + /// + /// Perform an update for all dirty keys, or all keys if flushLeds is set to true. + /// + /// Specifies whether all keys (including clean ones) should be updated. void Update(bool flushLeds = false); } } diff --git a/Devices/IDeviceInfo.cs b/Devices/IDeviceInfo.cs index 75ff15a..4034ae8 100644 --- a/Devices/IDeviceInfo.cs +++ b/Devices/IDeviceInfo.cs @@ -2,20 +2,23 @@ namespace CUE.NET.Devices { + /// + /// Represents generic device information. + /// public interface IDeviceInfo { /// - /// Device type + /// Gets the device type. /// CorsairDeviceType Type { get; } - + /// - /// Device model (like “K95RGB”). + /// Gets the device model (like “K95RGB”). /// string Model { get; } /// - /// Flags that describes device capabilities + /// Gets flags, which describe device capabilities. /// CorsairDeviceCaps CapsMask { get; } } diff --git a/Devices/Keyboard/Brushes/AbstractBrush.cs b/Devices/Keyboard/Brushes/AbstractBrush.cs index 40daba7..300fbc5 100644 --- a/Devices/Keyboard/Brushes/AbstractBrush.cs +++ b/Devices/Keyboard/Brushes/AbstractBrush.cs @@ -3,17 +3,32 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a basic brush. + /// public abstract class AbstractBrush : IBrush { #region Properties & Fields + /// + /// Gets or sets the overall percentage brightness of the brush. + /// public float Brightness { get; set; } + + /// + /// Gets or sets the overall percentage opacity of the brush. + /// public float Opacity { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The overall percentage brightness of the brush. (default: 1f) + /// The overall percentage opacity of the brush. (default: 1f) protected AbstractBrush(float brightness = 1f, float opacity = 1f) { this.Brightness = brightness; @@ -24,8 +39,20 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public abstract Color GetColorAtPoint(RectangleF rectangle, PointF point); + /// + /// Finalizes the color by appliing the overall brightness and opacity.
+ /// This method should always be the last call of a implementation. + ///
+ /// The color to finalize. + /// The finalized color. protected virtual Color FinalizeColor(Color color) { // Since we use HSV to calculate there is no way to make a color 'brighter' than 100% diff --git a/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs b/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs index cb1bd64..f6e429b 100644 --- a/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/AbstractGradient.cs @@ -6,19 +6,32 @@ using System.Linq; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a basic gradient. + /// public abstract class AbstractGradient : IGradient { #region Properties & Fields + /// + /// Gets a list of the stops used by this gradient. + /// public IList GradientStops { get; } = new List(); #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// protected AbstractGradient() { } + /// + /// Initializes a new instance of the class. + /// + /// The stops with which the gradient should be initialized. protected AbstractGradient(params GradientStop[] gradientStops) { foreach (GradientStop gradientStop in gradientStops) @@ -29,6 +42,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #region Methods + /// + /// Clips the offset and ensures, that it is inside the bounds of the stop list. + /// + /// + /// protected float ClipOffset(float offset) { float max = GradientStops.Max(n => n.Offset); @@ -42,6 +60,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient return offset; } + /// + /// Gets the color of the gradient on the specified offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public abstract Color GetColor(float offset); #endregion diff --git a/Devices/Keyboard/Brushes/Gradient/GradientStop.cs b/Devices/Keyboard/Brushes/Gradient/GradientStop.cs index 8ddd9db..06ade36 100644 --- a/Devices/Keyboard/Brushes/Gradient/GradientStop.cs +++ b/Devices/Keyboard/Brushes/Gradient/GradientStop.cs @@ -5,18 +5,32 @@ using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a stop on a gradient. + /// public class GradientStop { #region Properties & Fields + /// + /// Gets or sets the percentage offset to place this stop. This should be inside the range of [0..1] but it's not necessary. + /// public float Offset { get; set; } + /// + /// Gets or sets the color of the stop. + /// public Color Color { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The percentage offset to place this stop. + /// The color of the stop. public GradientStop(float offset, Color color) { this.Offset = offset; diff --git a/Devices/Keyboard/Brushes/Gradient/IGradient.cs b/Devices/Keyboard/Brushes/Gradient/IGradient.cs index b5cc9ff..c30c8ec 100644 --- a/Devices/Keyboard/Brushes/Gradient/IGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/IGradient.cs @@ -2,8 +2,16 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a basic gradient. + /// public interface IGradient { + /// + /// Gets the color of the gradient on the specified offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. Color GetColor(float offset); } } diff --git a/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs b/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs index 5af52db..2057e01 100644 --- a/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/LinearGradient.cs @@ -3,13 +3,23 @@ using System.Linq; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a linear interpolated gradient with n stops. + /// public class LinearGradient : AbstractGradient { #region Constructors + /// + /// Initializes a new instance of the class. + /// public LinearGradient() { } + /// + /// Initializes a new instance of the class. + /// + /// The stops with which the gradient should be initialized. public LinearGradient(params GradientStop[] gradientStops) : base(gradientStops) { } @@ -18,6 +28,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #region Methods + /// + /// Gets the linear interpolated color at the given offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public override Color GetColor(float offset) { if (!GradientStops.Any()) return Color.Transparent; diff --git a/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs b/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs index b777955..dd86986 100644 --- a/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs +++ b/Devices/Keyboard/Brushes/Gradient/RainbowGradient.cs @@ -5,17 +5,33 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes.Gradient { + /// + /// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.
+ /// See as reference + ///
public class RainbowGradient : IGradient { #region Properties & Fields + /// + /// Gets or sets the hue (in degrees) to start from. + /// public float StartHue { get; set; } + + /// + /// Gets or sets the hue (in degrees) to end the with. + /// public float EndHue { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The hue (in degrees) to start from (default: 0) + /// The hue (in degrees) to end with (default: 360) public RainbowGradient(float startHue = 0f, float endHue = 360f) { this.StartHue = startHue; @@ -28,6 +44,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient #endregion + /// + /// Gets the color on the rainbow at the given offset. + /// + /// The percentage offset to take the color from. + /// The color at the specific offset. public Color GetColor(float offset) { float range = EndHue - StartHue; diff --git a/Devices/Keyboard/Brushes/IBrush.cs b/Devices/Keyboard/Brushes/IBrush.cs index de0bcd4..4e3bf98 100644 --- a/Devices/Keyboard/Brushes/IBrush.cs +++ b/Devices/Keyboard/Brushes/IBrush.cs @@ -2,11 +2,27 @@ using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a basic brush. + /// public interface IBrush { + /// + /// Gets or sets the overall percentage brightness of the brush. + /// float Brightness { get; set; } + + /// + /// Gets or sets the overall percentage opacity of the brush. + /// float Opacity { get; set; } + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. Color GetColorAtPoint(RectangleF rectangle, PointF point); } } \ No newline at end of file diff --git a/Devices/Keyboard/Brushes/LinearGradientBrush.cs b/Devices/Keyboard/Brushes/LinearGradientBrush.cs index 741d4e6..a7bde7f 100644 --- a/Devices/Keyboard/Brushes/LinearGradientBrush.cs +++ b/Devices/Keyboard/Brushes/LinearGradientBrush.cs @@ -9,26 +9,52 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing a linear gradient. + /// public class LinearGradientBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the start point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0f, 0.5f) + /// public PointF StartPoint { get; set; } = new PointF(0f, 0.5f); + + /// + /// Gets or sets the end point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 1f, 0.5f) + /// public PointF EndPoint { get; set; } = new PointF(1f, 0.5f); + + /// + /// Gets or sets the gradient drawn by the brush. If null it will default to full transparent. + /// public IGradient Gradient { get; set; } #endregion #region Constructor + /// + /// Initializes a new instance of the class. + /// public LinearGradientBrush() { } + /// + /// Initializes a new instance of the class. + /// + /// The gradient drawn by the brush. public LinearGradientBrush(IGradient gradient) { this.Gradient = gradient; } - + /// + /// Initializes a new instance of the class. + /// + /// The start point (as percentage in the range [0..1]). + /// The end point (as percentage in the range [0..1]). + /// The gradient drawn by the brush. public LinearGradientBrush(PointF startPoint, PointF endPoint, IGradient gradient) { this.StartPoint = startPoint; @@ -40,6 +66,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { if (Gradient == null) return Color.Transparent; diff --git a/Devices/Keyboard/Brushes/RadialGradientBrush.cs b/Devices/Keyboard/Brushes/RadialGradientBrush.cs index c284d0a..b5a0225 100644 --- a/Devices/Keyboard/Brushes/RadialGradientBrush.cs +++ b/Devices/Keyboard/Brushes/RadialGradientBrush.cs @@ -8,25 +8,47 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing a radial gradient around a center point. + /// public class RadialGradientBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the center point (as percentage in the range [0..1]) around which the brush should be drawn. + /// public PointF Center { get; set; } = new PointF(0.5f, 0.5f); + + /// + /// Gets or sets the gradient drawn by the brush. If null it will default to full transparent. + /// public IGradient Gradient { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// public RadialGradientBrush() { } + /// + /// Initializes a new instance of the class. + /// + /// The gradient drawn by the brush. public RadialGradientBrush(IGradient gradient) { this.Gradient = gradient; } + /// + /// Initializes a new instance of the class. + /// + /// The center point (as percentage in the range [0..1]). + /// The gradient drawn by the brush. public RadialGradientBrush(PointF center, IGradient gradient) { this.Center = center; @@ -37,6 +59,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. + /// + /// The rectangle in which the brush should be drawn. + /// The point from which the color should be taken. + /// The color at the specified point. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { PointF centerPoint = new PointF(rectangle.X + rectangle.Width * Center.X, rectangle.Y + rectangle.Height * Center.Y); diff --git a/Devices/Keyboard/Brushes/RandomColorBrush.cs b/Devices/Keyboard/Brushes/RandomColorBrush.cs index c8ff304..09f4fc4 100644 --- a/Devices/Keyboard/Brushes/RandomColorBrush.cs +++ b/Devices/Keyboard/Brushes/RandomColorBrush.cs @@ -5,6 +5,10 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Brushes { //TODO DarthAffe 30.09.2015: Like this the brush seems kinda useless. Think about making it cool. + + /// + /// Represents a brush drawing random colors. + /// public class RandomColorBrush : AbstractBrush { #region Properties & Fields @@ -15,6 +19,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Gets a random color. + /// + /// This value isn't used. + /// This value isn't used. + /// A random color. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { return FinalizeColor(ColorHelper.ColorFromHSV((float)_random.NextDouble() * 360f, 1, 1)); diff --git a/Devices/Keyboard/Brushes/SolidColorBrush.cs b/Devices/Keyboard/Brushes/SolidColorBrush.cs index 79899b3..2a2c7a4 100644 --- a/Devices/Keyboard/Brushes/SolidColorBrush.cs +++ b/Devices/Keyboard/Brushes/SolidColorBrush.cs @@ -1,19 +1,30 @@ // ReSharper disable MemberCanBePrivate.Global +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global using System.Drawing; namespace CUE.NET.Devices.Keyboard.Brushes { + /// + /// Represents a brush drawing only a single color. + /// public class SolidColorBrush : AbstractBrush { #region Properties & Fields + /// + /// Gets or sets the color drawn by the brush. + /// public Color Color { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The color drawn by the brush. public SolidColorBrush(Color color) { this.Color = color; @@ -23,6 +34,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes #region Methods + /// + /// Returns the of the brush. + /// + /// This value isn't used. + /// This value isn't used. + /// The of the brush. public override Color GetColorAtPoint(RectangleF rectangle, PointF point) { return FinalizeColor(Color); diff --git a/Devices/Keyboard/CorsairKeyboard.cs b/Devices/Keyboard/CorsairKeyboard.cs index a48dc75..642c239 100644 --- a/Devices/Keyboard/CorsairKeyboard.cs +++ b/Devices/Keyboard/CorsairKeyboard.cs @@ -19,12 +19,20 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Keyboard { + /// + /// Represents the SDK for a corsair keyboard. + /// public class CorsairKeyboard : AbstractCueDevice, IEnumerable, IKeyGroup { #region Properties & Fields #region Indexer + /// + /// Gets the with the specified ID. + /// + /// The ID of the key to get. + /// The key with the specified ID or null if no key is found. public CorsairKey this[CorsairKeyboardKeyId keyId] { get @@ -34,10 +42,35 @@ namespace CUE.NET.Devices.Keyboard } } - public CorsairKey this[char key] => this[_CUESDK.CorsairGetLedIdForKeyName(key)]; + /// + /// Gets the representing the given character by calling the SDK-method 'CorsairGetLedIdForKeyName'.
+ /// Note that this currently only works for letters. + ///
+ /// The character of the key. + /// The key representing the given character or null if no key is found. + public CorsairKey this[char key] + { + get + { + CorsairKeyboardKeyId keyId = _CUESDK.CorsairGetLedIdForKeyName(key); + CorsairKey cKey; + return _keys.TryGetValue(keyId, out cKey) ? cKey : null; + } + } + /// + /// Gets the at the given physical location. + /// + /// The point to get the key from. + /// The key at the given point or null if no key is found. public CorsairKey this[PointF location] => _keys.Values.FirstOrDefault(x => x.KeyRectangle.Contains(location)); + /// + /// Gets a list of inside the given rectangle. + /// + /// The rectangle to check. + /// The minimal percentage overlay a key must have with the to be taken into the list. + /// public IEnumerable this[RectangleF referenceRect, float minOverlayPercentage = 0.5f] => _keys.Values.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, referenceRect) >= minOverlayPercentage); #endregion @@ -46,13 +79,36 @@ namespace CUE.NET.Devices.Keyboard private readonly LinkedList _effects = new LinkedList(); private Dictionary _keys = new Dictionary(); + + /// + /// Gets a read-only collection containing the keys of the keyboard. + /// public IEnumerable Keys => new ReadOnlyCollection(_keys.Values.ToList()); + /// + /// Gets specific information provided by CUE for the keyboard. + /// public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; } + + /// + /// Gets the rectangle containing all keys of the keyboard. + /// public RectangleF KeyboardRectangle { get; private set; } + + /// + /// Gets or sets the background brush of the keyboard. + /// public IBrush Brush { get; set; } + + /// + /// Gets or sets the z-index of the background brush of the keyboard.
+ /// This value has absolutely no effect. + ///
public int ZIndex { get; set; } = 0; + /// + /// Gets a value indicating if the keyboard has an active effect to deal with or not. + /// protected override bool HasEffect { get @@ -66,6 +122,10 @@ namespace CUE.NET.Devices.Keyboard #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the keyboard internal CorsairKeyboard(CorsairKeyboardDeviceInfo info) : base(info) { @@ -81,6 +141,10 @@ namespace CUE.NET.Devices.Keyboard #region Update + /// + /// Updates all groups and effects and perform an update for all dirty keys, or all keys if flushLeds is set to true. + /// + /// Specifies whether all keys (including clean ones) should be updated. public override void Update(bool flushLeds = false) { UpdateKeyGroups(); @@ -153,6 +217,11 @@ namespace CUE.NET.Devices.Keyboard #endregion + /// + /// Attaches the given keygroup. + /// + /// The keygroup to attach. + /// true if the keygroup could be attached; otherwise, false. public bool AttachKeyGroup(IKeyGroup keyGroup) { lock (_keyGroups) @@ -164,6 +233,11 @@ namespace CUE.NET.Devices.Keyboard } } + /// + /// Detaches the given keygroup. + /// + /// The keygroup to detached. + /// true if the keygroup could be detached; otherwise, false. public bool DetachKeyGroup(IKeyGroup keyGroup) { lock (_keyGroups) @@ -178,6 +252,11 @@ namespace CUE.NET.Devices.Keyboard } } + /// + /// Attaches the given effect. + /// + /// The effect to attach. + /// true if the effect could be attached; otherwise, false. public bool AttachEffect(IEffect effect) { bool retVal = false; @@ -195,6 +274,11 @@ namespace CUE.NET.Devices.Keyboard return retVal; } + /// + /// Detaches the given effect. + /// + /// The effect to detached. + /// true if the effect could be detached; otherwise, false. public bool DetachEffect(IEffect effect) { bool retVal = false; @@ -233,6 +317,10 @@ namespace CUE.NET.Devices.Keyboard #region IEnumerable + /// + /// Returns an enumerator that iterates over all keys of the keyboard. + /// + /// An enumerator for all keys of the keyboard. public IEnumerator GetEnumerator() { return _keys.Values.GetEnumerator(); diff --git a/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs b/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs index 19adc41..b52af96 100644 --- a/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs +++ b/Devices/Keyboard/CorsairKeyboardDeviceInfo.cs @@ -7,17 +7,20 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Keyboard { + /// + /// Represents specific information for a CUE keyboard. + /// public class CorsairKeyboardDeviceInfo : GenericDeviceInfo { #region Properties & Fields /// - /// Physical layout of the keyboard. + /// Gets the physical layout of the keyboard. /// public CorsairPhysicalKeyboardLayout PhysicalLayout { get; private set; } /// - /// Logical layout of the keyboard as set in CUE settings. + /// Gets the logical layout of the keyboard as set in CUE settings. /// public CorsairLogicalKeyboardLayout LogicalLayout { get; private set; } diff --git a/Devices/Keyboard/Effects/AbstractEffect.cs b/Devices/Keyboard/Effects/AbstractEffect.cs index ebc8bf7..51569e5 100644 --- a/Devices/Keyboard/Effects/AbstractEffect.cs +++ b/Devices/Keyboard/Effects/AbstractEffect.cs @@ -7,32 +7,61 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a basic effect. + /// public abstract class AbstractEffect : IEffect { #region Properties & Fields + /// + /// Gets or sets the list of keys to which the effect applies. + /// public IEnumerable KeyList { get; protected set; } + /// + /// Gets the brush which is drawn by the effect. + /// public abstract IBrush EffectBrush { get; } + /// + /// Gets or sets the z-index of the brush to allow ordering them before drawing. (lowest first) (default: 0) + /// public int ZIndex { get; set; } = 0; + /// + /// Gets or sets if this effect has finished all of his work. + /// public bool IsDone { get; protected set; } #endregion #region Methods + /// + /// Sets the list of keys to which the effect applies. + /// + /// public void SetTarget(IKeyGroup keyGroup) { KeyList = keyGroup.Keys.ToList(); } + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. public abstract void Update(float deltaTime); + /// + /// Hook which is called when the effect is attached to a keyboard. + /// public virtual void OnAttach() { } + /// + /// Hook which is called when the effect is detached from a keyboard. + /// public virtual void OnDetach() { } diff --git a/Devices/Keyboard/Effects/EffectTimeContainer.cs b/Devices/Keyboard/Effects/EffectTimeContainer.cs index 643d9f3..9a2a963 100644 --- a/Devices/Keyboard/Effects/EffectTimeContainer.cs +++ b/Devices/Keyboard/Effects/EffectTimeContainer.cs @@ -3,20 +3,37 @@ namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a wrapped effect with additional time information. + /// internal class EffectTimeContainer { #region Properties & Fields + /// + /// Gets or sets the wrapped effect. + /// internal IEffect Effect { get; set; } + /// + /// Gets or sets the tick-count from the last time the effect was updated. + /// internal long TicksAtLastUpdate { get; set; } + /// + /// Gets the z-index of the effect. + /// internal int ZIndex => Effect?.ZIndex ?? 0; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The wrapped effect. + /// The tick-count from the last time the effect was updated. internal EffectTimeContainer(IEffect effect, long ticksAtLastUpdate) { this.Effect = effect; diff --git a/Devices/Keyboard/Effects/FlashEffect.cs b/Devices/Keyboard/Effects/FlashEffect.cs index 3a538db..93d6a7d 100644 --- a/Devices/Keyboard/Effects/FlashEffect.cs +++ b/Devices/Keyboard/Effects/FlashEffect.cs @@ -7,23 +7,61 @@ using CUE.NET.Devices.Keyboard.Brushes; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents an effect which allows to flash an brush by modifying his opacity. + /// public class FlashEffect : AbstractEffect { #region Properties & Fields + /// + /// Gets the brush which is drawn by the effect. + /// public override IBrush EffectBrush { get; } - // Settings are close to a synthesizer envelope (sustain is different for consequent naming): https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope + /// + /// Gets or sets the attack-time (in seconds) of the effect. (default: 0.2f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Attack { get; set; } = 0.2f; + + /// + /// Gets or sets the decay-time (in seconds) of the effect. (default: 0f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Decay { get; set; } = 0f; + + /// + /// Gets or sets the sustain-time (in seconds) of the effect. (default: 0.3f)
+ /// This is close to a synthesizer envelope. (See as reference)
+ /// Note that this value for naming reasons represents the time NOT the level. + ///
public float Sustain { get; set; } = 0.3f; + + /// + /// Gets or sets the release-time (in seconds) of the effect. (default: 0.2f)
+ /// This is close to a synthesizer envelope. (See as reference) + ///
public float Release { get; set; } = 0.2f; - public float SustainValue { get; set; } = 1f; + /// + /// Gets or sets the level to which the oppacity (percentage) should raise in the attack-cycle. (default: 1f); + /// public float AttackValue { get; set; } = 1f; + /// + /// Gets or sets the level at which the oppacity (percentage) should stay in the sustain-cycle. (default: 1f); + /// + public float SustainValue { get; set; } = 1f; + + /// + /// Gets or sets the interval (in seconds) in which the effect should repeat (if repetition is enabled). (default: 1f) + /// public float Interval { get; set; } = 1f; + /// + /// Gets or sets the amount of repetitions the effect should do until it's finished. Zero means infinite. (default: 0f) + /// public int Repetitions { get; set; } = 0; private ADSRPhase _currentPhase; @@ -34,10 +72,18 @@ namespace CUE.NET.Devices.Keyboard.Effects #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The color from which a should be created and used by this effect. public FlashEffect(Color flashColor) : this(new SolidColorBrush(flashColor)) { } + /// + /// Initializes a new instance of the class. + /// + /// The brush which should be used by this effect, public FlashEffect(IBrush effectBrush) { this.EffectBrush = effectBrush; @@ -47,6 +93,10 @@ namespace CUE.NET.Devices.Keyboard.Effects #region Methods + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. public override void Update(float deltaTime) { _currentPhaseValue -= deltaTime; @@ -101,6 +151,9 @@ namespace CUE.NET.Devices.Keyboard.Effects } } + /// + /// Resets the effect. + /// public override void OnAttach() { base.OnAttach(); diff --git a/Devices/Keyboard/Effects/IEffect.cs b/Devices/Keyboard/Effects/IEffect.cs index 1805ba6..8cf4a6a 100644 --- a/Devices/Keyboard/Effects/IEffect.cs +++ b/Devices/Keyboard/Effects/IEffect.cs @@ -4,26 +4,51 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Effects { + /// + /// Represents a basic effect. + /// public interface IEffect { #region Properties & Fields + /// + /// Gets or sets the list of keys to which the effect applies. + /// IEnumerable KeyList { get; } + /// + /// Gets the brush which is drawn by the effect. + /// IBrush EffectBrush { get; } + /// + /// Gets or sets the z-index of the effect to allow ordering them before drawing. (lowest first) (default: 0) + /// int ZIndex { get; set; } + /// + /// Gets or sets if this effect has finished all of his work. + /// bool IsDone { get; } #endregion #region Methods - + + /// + /// Updates the effect. + /// + /// The elapsed time (in seconds) since the last update. void Update(float deltaTime); + /// + /// Hook which is called when the effect is attached to a keyboard. + /// void OnAttach(); + /// + /// Hook which is called when the effect is detached from a keyboard. + /// void OnDetach(); #endregion diff --git a/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs b/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs index 63d7677..dd04a60 100644 --- a/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs +++ b/Devices/Keyboard/Enums/CorsairKeyboardKeyId.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Keyboard.Enums { + /// + /// Contains list of all LEDs available for corsair keyboards. + /// public enum CorsairKeyboardKeyId { Invalid = 0, diff --git a/Devices/Keyboard/Extensions/KeyGroupExtension.cs b/Devices/Keyboard/Extensions/KeyGroupExtension.cs index 73abff3..e1f5976 100644 --- a/Devices/Keyboard/Extensions/KeyGroupExtension.cs +++ b/Devices/Keyboard/Extensions/KeyGroupExtension.cs @@ -6,8 +6,16 @@ using CUE.NET.Devices.Keyboard.Keys; namespace CUE.NET.Devices.Keyboard.Extensions { + /// + /// Offers some extensions and helper-methods for keygroup related things. + /// public static class KeyGroupExtension { + /// + /// Converts the given to a . + /// + /// The to convert. + /// The converted . public static ListKeyGroup ToSimpleKeyGroup(this BaseKeyGroup keyGroup) { ListKeyGroup simpleKeyGroup = keyGroup as ListKeyGroup; @@ -19,6 +27,12 @@ namespace CUE.NET.Devices.Keyboard.Extensions return simpleKeyGroup; } + /// + /// Returns a new which contains all keys from the given keygroup excluding the specified ones. + /// + /// The base keygroup. + /// The ids of the keys to exclude. + /// The new . public static ListKeyGroup Exclude(this BaseKeyGroup keyGroup, params CorsairKeyboardKeyId[] keyIds) { ListKeyGroup simpleKeyGroup = keyGroup.ToSimpleKeyGroup(); @@ -27,6 +41,12 @@ namespace CUE.NET.Devices.Keyboard.Extensions return simpleKeyGroup; } + /// + /// Returns a new which contains all keys from the given keygroup excluding the specified ones. + /// + /// The base keygroup. + /// The keys to exclude. + /// The new . public static ListKeyGroup Exclude(this BaseKeyGroup keyGroup, params CorsairKey[] keyIds) { ListKeyGroup simpleKeyGroup = keyGroup.ToSimpleKeyGroup(); @@ -36,11 +56,21 @@ namespace CUE.NET.Devices.Keyboard.Extensions } // ReSharper disable once UnusedMethodReturnValue.Global + /// + /// Attaches the given keygroup to the keyboard. + /// + /// The keygroup to attach. + /// true if the keygroup could be attached; otherwise, false. public static bool Attach(this BaseKeyGroup keyGroup) { return keyGroup.Keyboard?.AttachKeyGroup(keyGroup) ?? false; } + /// + /// Detaches the given keygroup from the keyboard. + /// + /// The keygroup to attach. + /// true if the keygroup could be detached; otherwise, false. public static bool Detach(this BaseKeyGroup keyGroup) { return keyGroup.Keyboard?.DetachKeyGroup(keyGroup) ?? false; diff --git a/Devices/Keyboard/Keys/BaseKeyGroup.cs b/Devices/Keyboard/Keys/BaseKeyGroup.cs index 6e8eb70..b968e40 100644 --- a/Devices/Keyboard/Keys/BaseKeyGroup.cs +++ b/Devices/Keyboard/Keys/BaseKeyGroup.cs @@ -5,22 +5,42 @@ using CUE.NET.Devices.Keyboard.Extensions; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a basic keygroup. + /// public abstract class BaseKeyGroup : IKeyGroup { #region Properties & Fields + /// + /// Gets the keyboard this keygroup belongs to. + /// internal CorsairKeyboard Keyboard { get; } + /// + /// Gets a read-only collection containing the keys from this group. + /// public IEnumerable Keys => new ReadOnlyCollection(GetGroupKeys()); + /// + /// Gets or sets the brush which should be drawn over this group. + /// public IBrush Brush { get; set; } + /// + /// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) + /// public int ZIndex { get; set; } = 0; #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this group should be automatically attached or not. protected BaseKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true) { this.Keyboard = keyboard; @@ -29,6 +49,10 @@ namespace CUE.NET.Devices.Keyboard.Keys this.Attach(); } + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected abstract IList GetGroupKeys(); #endregion diff --git a/Devices/Keyboard/Keys/CorsairKey.cs b/Devices/Keyboard/Keys/CorsairKey.cs index aaa6705..1cb799f 100644 --- a/Devices/Keyboard/Keys/CorsairKey.cs +++ b/Devices/Keyboard/Keys/CorsairKey.cs @@ -7,18 +7,38 @@ using CUE.NET.Devices.Keyboard.Enums; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a key of a corsair keyboard. + /// public class CorsairKey { #region Properties & Fields + /// + /// Gets the key-ID of the key. + /// public CorsairKeyboardKeyId KeyId { get; } + + /// + /// Gets the LED of the key. + /// public CorsairLed Led { get; } + + /// + /// Gets a rectangle representing the physical location of the key. + /// public RectangleF KeyRectangle { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The key-ID of the key. + /// The LED of the key. + /// The rectangle representing the physical location of the key. internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led, RectangleF keyRectangle) { this.KeyId = keyId; @@ -27,9 +47,5 @@ namespace CUE.NET.Devices.Keyboard.Keys } #endregion - - #region Methods - - #endregion } } diff --git a/Devices/Keyboard/Keys/IKeyGroup.cs b/Devices/Keyboard/Keys/IKeyGroup.cs index eb270e9..ff23029 100644 --- a/Devices/Keyboard/Keys/IKeyGroup.cs +++ b/Devices/Keyboard/Keys/IKeyGroup.cs @@ -5,10 +5,19 @@ namespace CUE.NET.Devices.Keyboard.Keys { public interface IKeyGroup { + /// + /// Gets a read-only collection containing the keys from this group. + /// IEnumerable Keys { get; } + /// + /// Gets or sets the brush which should be drawn over this group. + /// IBrush Brush { get; set; } + /// + /// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0) + /// int ZIndex { get; set; } } } diff --git a/Devices/Keyboard/Keys/ListKeyGroup.cs b/Devices/Keyboard/Keys/ListKeyGroup.cs index 5d95aae..bafae08 100644 --- a/Devices/Keyboard/Keys/ListKeyGroup.cs +++ b/Devices/Keyboard/Keys/ListKeyGroup.cs @@ -5,34 +5,67 @@ using CUE.NET.Devices.Keyboard.Enums; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a keygroup containing arbitrary keys. + /// public class ListKeyGroup : BaseKeyGroup { #region Properties & Fields + /// + /// Gets the list containing the keys of this keygroup. + /// protected IList GroupKeys { get; } = new List(); #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach = true) : base(keyboard, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKey[] keys) : this(keyboard, true, keys) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. + /// The initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKey[] keys) : base(keyboard, autoAttach) { AddKey(keys); } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The IDs of the initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, params CorsairKeyboardKeyId[] keys) : this(keyboard, true, keys) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// Specifies whether this keygroup should be automatically attached or not. + /// The IDs of the initial keys of this keygroup. public ListKeyGroup(CorsairKeyboard keyboard, bool autoAttach, params CorsairKeyboardKeyId[] keys) : base(keyboard, autoAttach) { @@ -43,6 +76,10 @@ namespace CUE.NET.Devices.Keyboard.Keys #region Methods + /// + /// Adds the given key(s) to the keygroup. + /// + /// The key(s) to add. public void AddKey(params CorsairKey[] keys) { if (keys != null) @@ -52,6 +89,10 @@ namespace CUE.NET.Devices.Keyboard.Keys } + /// + /// Adds the given key(s) to the keygroup. + /// + /// The ID(s) of the key(s) to add. public void AddKey(params CorsairKeyboardKeyId[] keyIds) { if (keyIds != null) @@ -59,6 +100,10 @@ namespace CUE.NET.Devices.Keyboard.Keys AddKey(Keyboard[keyId]); } + /// + /// Removes the given key(s) from the keygroup. + /// + /// The key(s) to remove. public void RemoveKey(params CorsairKey[] keys) { if (keys != null) @@ -67,6 +112,10 @@ namespace CUE.NET.Devices.Keyboard.Keys GroupKeys.Remove(key); } + /// + /// Removes the given key(s) from the keygroup. + /// + /// The ID(s) of the key(s) to remove. public void RemoveKey(params CorsairKeyboardKeyId[] keyIds) { if (keyIds != null) @@ -74,16 +123,30 @@ namespace CUE.NET.Devices.Keyboard.Keys RemoveKey(Keyboard[keyId]); } + /// + /// Checks if a given key is contained by this keygroup. + /// + /// The key which should be checked. + /// true if the key is contained by this keygroup; otherwise, false. public bool ContainsKey(CorsairKey key) { return key != null && GroupKeys.Contains(key); } + /// + /// Checks if a given key is contained by this keygroup. + /// + /// The ID of the key which should be checked. + /// true if the key is contained by this keygroup; otherwise, false. public bool ContainsKey(CorsairKeyboardKeyId keyId) { return ContainsKey(Keyboard[keyId]); } + /// + /// Merges the keys from the given keygroup in this keygroup. + /// + /// The keygroup to merge. public void MergeKeys(IKeyGroup groupToMerge) { foreach (CorsairKey key in groupToMerge.Keys) @@ -91,7 +154,10 @@ namespace CUE.NET.Devices.Keyboard.Keys GroupKeys.Add(key); } - + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected override IList GetGroupKeys() { return GroupKeys; diff --git a/Devices/Keyboard/Keys/RectangleKeyGroup.cs b/Devices/Keyboard/Keys/RectangleKeyGroup.cs index f29708f..2d187dd 100644 --- a/Devices/Keyboard/Keys/RectangleKeyGroup.cs +++ b/Devices/Keyboard/Keys/RectangleKeyGroup.cs @@ -9,29 +9,70 @@ using CUE.NET.Helper; namespace CUE.NET.Devices.Keyboard.Keys { + /// + /// Represents a keygroup containing keys which physically lay inside a rectangle. + /// public class RectangleKeyGroup : BaseKeyGroup { #region Properties & Fields + /// + /// Gets or sets the rectangle the keys should be taken from. + /// public RectangleF Rectangle { get; set; } + + /// + /// Gets or sets the minimal percentage overlay a key must have with the to be taken into the keygroup. + /// public float MinOverlayPercentage { get; set; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They ID of the first key to calculate the rectangle of this keygroup from. + /// They ID of the second key to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, CorsairKeyboardKeyId fromKey, CorsairKeyboardKeyId toKey, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(keyboard, keyboard[fromKey], keyboard[toKey], minOverlayPercentage, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They first key to calculate the rectangle of this keygroup from. + /// They second key to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, CorsairKey fromKey, CorsairKey toKey, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(keyboard, RectangleHelper.CreateRectangleFromRectangles(fromKey.KeyRectangle, toKey.KeyRectangle), minOverlayPercentage, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// They first point to calculate the rectangle of this keygroup from. + /// They second point to calculate the rectangle of this keygroup from. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, PointF fromPoint, PointF toPoint, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(keyboard, RectangleHelper.CreateRectangleFromPoints(fromPoint, toPoint), minOverlayPercentage, autoAttach) { } + /// + /// Initializes a new instance of the class. + /// + /// The keyboard this keygroup belongs to. + /// The rectangle of this keygroup. + /// (optional) The minimal percentage overlay a key must have with the to be taken into the keygroup. (default: 0.5f) + /// (optional) Specifies whether this group should be automatically attached or not. (default: true) public RectangleKeyGroup(CorsairKeyboard keyboard, RectangleF rectangle, float minOverlayPercentage = 0.5f, bool autoAttach = true) : base(keyboard, autoAttach) { @@ -43,6 +84,10 @@ namespace CUE.NET.Devices.Keyboard.Keys #region Methods + /// + /// Gets a list containing the keys from this group. + /// + /// The list containing the keys. protected override IList GetGroupKeys() { return Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, Rectangle) >= MinOverlayPercentage).ToList(); diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs index e770e91..944b769 100644 --- a/Devices/Mouse/CorsairMouse.cs +++ b/Devices/Mouse/CorsairMouse.cs @@ -1,30 +1,122 @@ -using CUE.NET.Devices.Generic; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable UnusedMember.Global + +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using CUE.NET.Devices.Generic; +using CUE.NET.Devices.Mouse.Enums; +using CUE.NET.Exceptions; namespace CUE.NET.Devices.Mouse { - //TODO DarthAffe 20.09.2015: Find someone to test this - public class CorsairMouse : AbstractCueDevice + /// + /// Represents the SDK for a corsair mouse. + /// + public class CorsairMouse : AbstractCueDevice, IEnumerable { #region Properties & Fields + #region Indexer + + /// + /// Gets the with the specified ID. + /// + /// The ID of the LED to get. + /// The LED with the specified ID. + public CorsairLed this[CorsairMouseLedId ledId] + { + get + { + CorsairLed led; + return base.Leds.TryGetValue((int)ledId, out led) ? led : null; + } + } + + #endregion + + /// + /// Gets specific information provided by CUE for the mouse. + /// public CorsairMouseDeviceInfo MouseDeviceInfo { get; } + /// + /// Gets a value indicating if the mouse has an active effect to deal with or not. + /// protected override bool HasEffect => false; + /// + /// Gets a read-only collection containing all LEDs of the mouse. + /// + public new IEnumerable Leds => new ReadOnlyCollection(base.Leds.Values.ToList()); + #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The specific information provided by CUE for the mouse internal CorsairMouse(CorsairMouseDeviceInfo info) : base(info) { this.MouseDeviceInfo = info; + + InitializeLeds(); } #endregion #region Methods + private void InitializeLeds() + { + switch (MouseDeviceInfo.PhysicalLayout) + { + case CorsairPhysicalMouseLayout.Zones1: + GetLed((int)CorsairMouseLedId.B1); + break; + case CorsairPhysicalMouseLayout.Zones2: + GetLed((int)CorsairMouseLedId.B1); + GetLed((int)CorsairMouseLedId.B2); + break; + case CorsairPhysicalMouseLayout.Zones3: + GetLed((int)CorsairMouseLedId.B1); + GetLed((int)CorsairMouseLedId.B2); + GetLed((int)CorsairMouseLedId.B3); + break; + case CorsairPhysicalMouseLayout.Zones4: + GetLed((int)CorsairMouseLedId.B1); + GetLed((int)CorsairMouseLedId.B2); + GetLed((int)CorsairMouseLedId.B3); + GetLed((int)CorsairMouseLedId.B4); + break; + default: + throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'"); + } + } + + #region IEnumerable + + /// + /// Returns an enumerator that iterates over all LEDs of the mouse. + /// + /// An enumerator for all LDS of the mouse. + public IEnumerator GetEnumerator() + { + return Leds.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + #endregion } } diff --git a/Devices/Mouse/CorsairMouseDeviceInfo.cs b/Devices/Mouse/CorsairMouseDeviceInfo.cs index 9972fc7..fe5a55e 100644 --- a/Devices/Mouse/CorsairMouseDeviceInfo.cs +++ b/Devices/Mouse/CorsairMouseDeviceInfo.cs @@ -7,12 +7,15 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Mouse { + /// + /// Represents specific information for a CUE mouse. + /// public class CorsairMouseDeviceInfo : GenericDeviceInfo { #region Properties & Fields /// - /// Physical layout of the mouse. + /// Gets the physical layout of the mouse. /// public CorsairPhysicalMouseLayout PhysicalLayout { get; private set; } @@ -21,9 +24,9 @@ namespace CUE.NET.Devices.Mouse #region Constructors /// - /// Internal constructor of managed CorsairDeviceInfo. + /// Internal constructor of managed . /// - /// The native CorsairDeviceInfo-struct + /// The native -struct internal CorsairMouseDeviceInfo(_CorsairDeviceInfo nativeInfo) : base(nativeInfo) { diff --git a/Devices/Mouse/Enums/CorsairMouseButtonId.cs b/Devices/Mouse/Enums/CorsairMouseButtonId.cs index 99494da..47c7288 100644 --- a/Devices/Mouse/Enums/CorsairMouseButtonId.cs +++ b/Devices/Mouse/Enums/CorsairMouseButtonId.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Mouse.Enums { + /// + /// Contains list of all LEDs available for corsair mice. + /// public enum CorsairMouseLedId { Invalid = 0, diff --git a/Exceptions/CUEException.cs b/Exceptions/CUEException.cs index bf09654..52824b7 100644 --- a/Exceptions/CUEException.cs +++ b/Exceptions/CUEException.cs @@ -6,16 +6,26 @@ using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Exceptions { + /// + /// Represents an exception thrown by the CUE. + /// public class CUEException : ApplicationException { #region Properties & Fields + /// + /// Gets the provided by CUE. + /// public CorsairError Error { get; } #endregion #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The provided by CUE, which leads to this exception. public CUEException(CorsairError error) { this.Error = error; diff --git a/Exceptions/WrapperException.cs b/Exceptions/WrapperException.cs index 5fca300..2eaa7b1 100644 --- a/Exceptions/WrapperException.cs +++ b/Exceptions/WrapperException.cs @@ -2,10 +2,18 @@ namespace CUE.NET.Exceptions { + /// + /// Represents an exception thrown by this SDK-Wrapper. + /// public class WrapperException : ApplicationException { #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// The message which describes the reason of throwing this exception. + /// Optional inner exception, which lead to this exception. public WrapperException(string message, Exception innerException = null) : base(message, innerException) { } diff --git a/Helper/ColorHelper.cs b/Helper/ColorHelper.cs index b4cbc7e..3825ca3 100644 --- a/Helper/ColorHelper.cs +++ b/Helper/ColorHelper.cs @@ -5,32 +5,64 @@ using System.Drawing; namespace CUE.NET.Helper { + /// + /// Offers some extensions and helper-methods for color related things. + /// public static class ColorHelper { #region byte/float conversion + /// + /// Converts the alpha-value of the to an float value int the range [0..1]. + /// + /// The color to take the alpha-value from. + /// The float-value in the range of [0..1] public static float GetFloatA(this Color color) { return color.A / 255f; } + /// + /// Converts the red-value of the to an float value int the range [0..1]. + /// + /// The color to take the red-value from. + /// The float-value in the range of [0..1] public static float GetFloatR(this Color color) { return color.R / 255f; } + /// + /// Converts the green-value of the to an float value int the range [0..1]. + /// + /// The color to take the green-value from. + /// The float-value in the range of [0..1] public static float GetFloatG(this Color color) { return color.G / 255f; } + /// + /// Converts the blue-value of the to an float value int the range [0..1]. + /// + /// The color to take the blue-value from. + /// The float-value in the range of [0..1] public static float GetFloatB(this Color color) { return color.B / 255f; } + /// + /// Creates a object from the respective rgb-float-values in the range [0..1]. + /// + /// The alpha-value in the range [0..1]. + /// The red-value in the range [0..1]. + /// The green-value in the range [0..1]. + /// The blue-value in the range [0..1]. + /// The color-object created representing the given values. 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 + /// + /// Blends two colors. + /// + /// The background-color. + /// The foreground-color + /// The resulting color. 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 + /// + /// Gets the saturation-value (HSV-color space) of the color. + /// + /// The color to take the saturation from. + /// The saturation-value (HSV-color space) of the color. 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 } + /// + /// Gets the value-value (HSV-color space) of the color. + /// + /// The color to take the value from. + /// The value-value (HSV-color space) of the color. 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 + /// + /// Creates a object from the respective hsv-float-values in the range [0..1]. + /// + /// The hue of the color. + /// The saturation of the color. + /// The value of the color. + /// The alpha of the color. + /// The color-object created representing the given values. public static Color ColorFromHSV(float hue, float saturation, float value, byte alpha = 255) { if (saturation <= 0.0) diff --git a/Helper/GradientHelper.cs b/Helper/GradientHelper.cs index 54dac67..2ba2f4d 100644 --- a/Helper/GradientHelper.cs +++ b/Helper/GradientHelper.cs @@ -5,9 +5,19 @@ using System.Drawing; namespace CUE.NET.Helper { + /// + /// Offers some extensions and helper-methods for gradient related things. + /// public static class GradientHelper { // Based on https://dotupdate.wordpress.com/2008/01/28/find-the-color-of-a-point-in-a-lineargradientbrush/ + /// + /// Calculates the offset of an given point on an gradient. + /// + /// The start point of the gradient. + /// The end point of the gradient. + /// The point on the gradient to which the offset is calculated. + /// The offset of the point on the gradient. 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/ /// - /// Returns the signed magnitude of a point on a vector + /// Returns the signed magnitude of a point on a vector. /// + /// The point on the vector of which the magnitude should be calculated. + /// The origin of the vector. + /// The direction of the vector. + /// The signed magnitude of a point on a vector. 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; } + /// + /// Calculated the distance between two points. + /// + /// The first point. + /// The second point. + /// The distance between the two points. 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)); diff --git a/Helper/RectangleHelper.cs b/Helper/RectangleHelper.cs index 3082fbd..dc1faea 100644 --- a/Helper/RectangleHelper.cs +++ b/Helper/RectangleHelper.cs @@ -4,13 +4,27 @@ using System.Drawing; namespace CUE.NET.Helper { + /// + /// Offers some extensions and helper-methods for rectangle related things. + /// public static class RectangleHelper { + /// + /// Calculates the center-point of a rectangle. + /// + /// The rectangle. + /// The center point of the rectangle. public static PointF GetCenter(this RectangleF rectangle) { return new PointF(rectangle.Left + rectangle.Width / 2f, rectangle.Top + rectangle.Height / 2f); } + /// + /// Creates a rectangle from two corner points. + /// + /// The first point. + /// The second points. + /// The rectangle created from the two points. 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) + /// + /// Creates a rectangle containing two other rectangles. + /// + /// The first rectangle. + /// The second rectangle. + /// The rectangle created from the two rectangles. + 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); } + /// + /// Creates a rectangle containing n other rectangles. + /// + /// The list of rectangles. + /// The rectangle created from the rectangles. public static RectangleF CreateRectangleFromRectangles(IEnumerable rectangles) { float posX = float.MaxValue; @@ -49,6 +74,12 @@ namespace CUE.NET.Helper return CreateRectangleFromPoints(new PointF(posX, posY), new PointF(posX2, posY2)); } + /// + /// Calculates the percentage of the intersection of two rectangles. + /// + /// The rectangle from which the percentage should be calculated. + /// The intersecting rectangle. + /// The percentage of the intersection. public static float CalculateIntersectPercentage(RectangleF rect, RectangleF referenceRect) { if (rect.IsEmpty || referenceRect.IsEmpty) return 0; diff --git a/Native/_CUESDK.cs b/Native/_CUESDK.cs index 094c253..87c6bf8 100644 --- a/Native/_CUESDK.cs +++ b/Native/_CUESDK.cs @@ -10,6 +10,9 @@ namespace CUE.NET.Native { #region Libary Management + /// + /// Gets the loaded architecture (x64/x86). + /// internal static string LoadedArchitecture { get; private set; } static _CUESDK() @@ -25,8 +28,10 @@ namespace CUE.NET.Native #region SDK-IMPORTS + /// + /// 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 + /// [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); + /// + /// CUE-SDK: returns number of connected Corsair devices that support lighting control. + /// [DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)] - // returns number of connected Corsair devices that support lighting control. internal static extern int CorsairGetDeviceCount(); + /// + /// CUE-SDK: returns information about device at provided index + /// [DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)] - // returns information about device at provided index internal static extern IntPtr CorsairGetDeviceInfo(int deviceIndex); + /// + /// CUE-SDK: provides list of keyboard LEDs with their physical positions. + /// [DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)] - // provides list of keyboard LEDs with their physical positions. internal static extern IntPtr CorsairGetLedPositions(); + /// + /// CUE-SDK: retrieves led id for key name taking logical layout into account. + /// [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); + /// + /// 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 + /// [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); + /// + /// CUE-SDK: checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE + /// [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(); + /// + /// CUE-SDK: returns last error that occured while using any of Corsair* functions + /// [DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)] - // returns last error that occured while using any of Corsair* functions internal static extern CorsairError CorsairGetLastError(); #endregion diff --git a/Native/_CorsairDeviceInfo.cs b/Native/_CorsairDeviceInfo.cs index 846e240..fe41dfe 100644 --- a/Native/_CorsairDeviceInfo.cs +++ b/Native/_CorsairDeviceInfo.cs @@ -9,13 +9,35 @@ using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Native { // ReSharper disable once InconsistentNaming + /// + /// CUE-SDK: contains information about device + /// [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 + /// + /// CUE-SDK: enum describing device type + /// + internal CorsairDeviceType type; + + /// + /// CUE-SDK: null - terminated device model(like “K95RGB”) + /// + internal IntPtr model; + + /// + /// CUE-SDK: enum describing physical layout of the keyboard or mouse + /// + internal int physicalLayout; + + /// + /// CUE-SDK: enum describing logical layout of the keyboard as set in CUE settings + /// + internal int logicalLayout; + + /// + /// CUE-SDK: mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values + /// + internal int capsMask; } } diff --git a/Native/_CorsairLedColor.cs b/Native/_CorsairLedColor.cs index 489589a..00a5e27 100644 --- a/Native/_CorsairLedColor.cs +++ b/Native/_CorsairLedColor.cs @@ -6,14 +6,31 @@ using System.Runtime.InteropServices; namespace CUE.NET.Native { - // ReSharper disable once InconsistentNaming + // ReSharper disable once InconsistentNaming + /// + /// CUE-SDK: contains information about led and its color + /// [StructLayout(LayoutKind.Sequential)] - internal class _CorsairLedColor // contains information about led and its color + internal class _CorsairLedColor { + /// + /// CUE-SDK: identifier of LED to set + /// + 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] + /// + /// CUE-SDK: red brightness[0..255] + /// + internal int r; + + /// + /// CUE-SDK: green brightness[0..255] + /// + internal int g; + + /// + /// CUE-SDK: blue brightness[0..255] + /// + internal int b; }; } diff --git a/Native/_CorsairLedPosition.cs b/Native/_CorsairLedPosition.cs index ebd29e2..bb0cc96 100644 --- a/Native/_CorsairLedPosition.cs +++ b/Native/_CorsairLedPosition.cs @@ -8,13 +8,36 @@ using CUE.NET.Devices.Keyboard.Enums; namespace CUE.NET.Native { // ReSharper disable once InconsistentNaming + /// + /// 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 + /// [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 + /// + /// CUE-SDK: identifier of led + /// + internal CorsairKeyboardKeyId ledId; + + /// + /// CUE-SDK: values in mm + /// internal double top; + + /// + /// CUE-SDK: values in mm + /// internal double left; + + /// + /// CUE-SDK: values in mm + /// internal double height; - internal double width; // values in mm + + /// + /// CUE-SDK: values in mm + /// + internal double width; } } diff --git a/Native/_CorsairLedPositions.cs b/Native/_CorsairLedPositions.cs index 9bcfd9e..109fdcb 100644 --- a/Native/_CorsairLedPositions.cs +++ b/Native/_CorsairLedPositions.cs @@ -8,10 +8,20 @@ using System.Runtime.InteropServices; namespace CUE.NET.Native { // ReSharper disable once InconsistentNaming + /// + /// CUE-SDK: contains number of leds and arrays with their positions + /// [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 + /// + /// CUE-SDK: integer value.Number of elements in following array + /// + internal int numberOfLed; + + /// + /// CUE-SDK: array of led positions + /// + internal IntPtr pLedPosition; } } diff --git a/Native/_CorsairProtocolDetails.cs b/Native/_CorsairProtocolDetails.cs index 92fa888..f521388 100644 --- a/Native/_CorsairProtocolDetails.cs +++ b/Native/_CorsairProtocolDetails.cs @@ -8,13 +8,37 @@ using System.Runtime.InteropServices; namespace CUE.NET.Native { // ReSharper disable once InconsistentNaming + /// + /// CUE-SDK: contains information about SDK and CUE versions + /// [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 + /// + /// 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 + /// + internal IntPtr sdkVersion; + + /// + /// CUE-SDK: null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found. + /// + internal IntPtr serverVersion; + + /// + /// 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 + /// + internal int sdkProtocolVersion; + + /// + /// 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 + /// + internal int serverProtocolVersion; + + /// + /// CUE-SDK: boolean value that specifies if there were breaking changes between version of protocol implemented by server and client + /// + internal byte breakingChanges; }; }