From 0f402a6ecdec3a10252848f40180cd82cc798172 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 14 Oct 2015 20:32:01 +0200 Subject: [PATCH] Added some xml-comments --- Devices/Generic/AbstractCueDevice.cs | 42 ++++++++++++++++++++- Devices/Generic/CorsairLed.cs | 21 ++++++++++- Devices/Generic/Enums/UpdateMode.cs | 15 ++++++++ Devices/Generic/GenericDeviceInfo.cs | 8 ++-- Devices/Generic/OnExceptionEventArgs.cs | 10 +++++ Devices/Headset/CorsairHeadset.cs | 3 ++ Devices/Headset/CorsairHeadsetDeviceInfo.cs | 3 ++ Devices/ICueDevice.cs | 1 - Devices/Mouse/CorsairMouse.cs | 3 ++ Devices/Mouse/CorsairMouseDeviceInfo.cs | 3 ++ 10 files changed, 101 insertions(+), 8 deletions(-) diff --git a/Devices/Generic/AbstractCueDevice.cs b/Devices/Generic/AbstractCueDevice.cs index 918ecf9..d7ec4e9 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,16 @@ 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(); + /// + /// Indicates if the device has an active effect to deal with. + /// protected abstract bool HasEffect { get; } private CancellationTokenSource _updateTokenSource; @@ -41,12 +55,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 +79,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 +92,9 @@ namespace CUE.NET.Devices.Generic return Leds[ledId]; } + /// + /// Checks if automatic updates should occur and starts/stops the update-loop if needed. + /// protected async void CheckUpdateLoop() { bool shouldRun; @@ -111,6 +140,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 +181,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 0d70704..06f17ec 100644 --- a/Devices/Generic/GenericDeviceInfo.cs +++ b/Devices/Generic/GenericDeviceInfo.cs @@ -10,17 +10,17 @@ namespace CUE.NET.Devices.Generic #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; } diff --git a/Devices/Generic/OnExceptionEventArgs.cs b/Devices/Generic/OnExceptionEventArgs.cs index d53b86f..27fd53a 100644 --- a/Devices/Generic/OnExceptionEventArgs.cs +++ b/Devices/Generic/OnExceptionEventArgs.cs @@ -2,16 +2,26 @@ 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..d27a728 100644 --- a/Devices/Headset/CorsairHeadset.cs +++ b/Devices/Headset/CorsairHeadset.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Headset { //TODO DarthAffe 20.09.2015: Find someone to test this + /// + /// Stub for planned headset-support. + /// public class CorsairHeadset : AbstractCueDevice { #region Properties & Fields diff --git a/Devices/Headset/CorsairHeadsetDeviceInfo.cs b/Devices/Headset/CorsairHeadsetDeviceInfo.cs index d01f424..b94b2f9 100644 --- a/Devices/Headset/CorsairHeadsetDeviceInfo.cs +++ b/Devices/Headset/CorsairHeadsetDeviceInfo.cs @@ -3,6 +3,9 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Headset { + /// + /// Stub for planned headset-support. + /// public class CorsairHeadsetDeviceInfo : GenericDeviceInfo { internal CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo) diff --git a/Devices/ICueDevice.cs b/Devices/ICueDevice.cs index ff62eab..4a1c2fa 100644 --- a/Devices/ICueDevice.cs +++ b/Devices/ICueDevice.cs @@ -7,7 +7,6 @@ namespace CUE.NET.Devices public interface ICueDevice { - IDeviceInfo DeviceInfo { get; } UpdateMode UpdateMode { get; set; } diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs index e770e91..012c7cb 100644 --- a/Devices/Mouse/CorsairMouse.cs +++ b/Devices/Mouse/CorsairMouse.cs @@ -3,6 +3,9 @@ namespace CUE.NET.Devices.Mouse { //TODO DarthAffe 20.09.2015: Find someone to test this + /// + /// Stub for planned headset-support. + /// public class CorsairMouse : AbstractCueDevice { #region Properties & Fields diff --git a/Devices/Mouse/CorsairMouseDeviceInfo.cs b/Devices/Mouse/CorsairMouseDeviceInfo.cs index 9972fc7..2290e02 100644 --- a/Devices/Mouse/CorsairMouseDeviceInfo.cs +++ b/Devices/Mouse/CorsairMouseDeviceInfo.cs @@ -7,6 +7,9 @@ using CUE.NET.Native; namespace CUE.NET.Devices.Mouse { + /// + /// Stub for planned headset-support. + /// public class CorsairMouseDeviceInfo : GenericDeviceInfo { #region Properties & Fields