mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Added some xml-comments
This commit is contained in:
parent
9c57e3257f
commit
0f402a6ecd
@ -10,14 +10,22 @@ using CUE.NET.Native;
|
||||
|
||||
namespace CUE.NET.Devices.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic CUE-device. (keyboard, mouse, headset, ...)
|
||||
/// </summary>
|
||||
public abstract class AbstractCueDevice : ICueDevice
|
||||
{
|
||||
private UpdateMode _updateMode = UpdateMode.AutoOnEffect;
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets generic information provided by CUE for the device.
|
||||
/// </summary>
|
||||
public IDeviceInfo DeviceInfo { get; }
|
||||
|
||||
private UpdateMode _updateMode = UpdateMode.AutoOnEffect;
|
||||
/// <summary>
|
||||
/// Gets or sets the update-mode for the device.
|
||||
/// </summary>
|
||||
public UpdateMode UpdateMode
|
||||
{
|
||||
get { return _updateMode; }
|
||||
@ -27,10 +35,16 @@ namespace CUE.NET.Devices.Generic
|
||||
CheckUpdateLoop();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the update-frequency in seconds. (Calculate by using '1f / updates per second')
|
||||
/// </summary>
|
||||
public float UpdateFrequency { get; set; } = 1f / 30f;
|
||||
|
||||
private Dictionary<int, CorsairLed> Leds { get; } = new Dictionary<int, CorsairLed>();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the device has an active effect to deal with.
|
||||
/// </summary>
|
||||
protected abstract bool HasEffect { get; }
|
||||
|
||||
private CancellationTokenSource _updateTokenSource;
|
||||
@ -41,12 +55,19 @@ namespace CUE.NET.Devices.Generic
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a catched exception is thrown inside the device.
|
||||
/// </summary>
|
||||
public event OnExceptionEventHandler OnException;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbstractCueDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by CUE for the device.</param>
|
||||
protected AbstractCueDevice(IDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
@ -58,6 +79,11 @@ namespace CUE.NET.Devices.Generic
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LED-Object with the specified id.
|
||||
/// </summary>
|
||||
/// <param name="ledId">The LED-Id to look for.</param>
|
||||
/// <returns></returns>
|
||||
protected CorsairLed GetLed(int ledId)
|
||||
{
|
||||
if (!Leds.ContainsKey(ledId))
|
||||
@ -66,6 +92,9 @@ namespace CUE.NET.Devices.Generic
|
||||
return Leds[ledId];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if automatic updates should occur and starts/stops the update-loop if needed.
|
||||
/// </summary>
|
||||
protected async void CheckUpdateLoop()
|
||||
{
|
||||
bool shouldRun;
|
||||
@ -111,6 +140,10 @@ namespace CUE.NET.Devices.Generic
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public virtual void Update(bool flushLeds = false)
|
||||
{
|
||||
IList<KeyValuePair<int, CorsairLed>> ledsToUpdate = (flushLeds ? Leds : Leds.Where(x => x.Value.IsDirty)).ToList();
|
||||
@ -148,6 +181,11 @@ namespace CUE.NET.Devices.Generic
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the needed event-calls for an exception.
|
||||
/// </summary>
|
||||
/// <param name="ex"></param>
|
||||
/// <exception cref="Exception">A delegate callback throws an exception.</exception>
|
||||
protected void ManageException(Exception ex)
|
||||
{
|
||||
OnException?.Invoke(this, new OnExceptionEventArgs(ex));
|
||||
|
||||
@ -7,16 +7,32 @@ using CUE.NET.Helper;
|
||||
|
||||
namespace CUE.NET.Devices.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single LED of a CUE-device.
|
||||
/// </summary>
|
||||
public class CorsairLed
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the LED has changed an internal state.
|
||||
/// </summary>
|
||||
public bool IsDirty => RequestedColor != _color;
|
||||
|
||||
/// <summary>
|
||||
/// Indicate whether the Color of the LED was set since the last update.
|
||||
/// </summary>
|
||||
public bool IsUpdated { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Color the LED should be set to on the next update.
|
||||
/// </summary>
|
||||
public Color RequestedColor { get; private set; } = Color.Transparent;
|
||||
|
||||
private Color _color = Color.Transparent;
|
||||
/// <summary>
|
||||
/// Gets the current color of the LED. Sets the <see cref="RequestedColor" /> for the next update and mark the LED as <see cref="IsUpdated" />.
|
||||
/// </summary>
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
@ -30,12 +46,15 @@ namespace CUE.NET.Devices.Generic
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the color of this LED can be changed.
|
||||
/// </summary>
|
||||
public bool IsLocked { get; set; } = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
|
||||
internal CorsairLed() { }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,9 +1,24 @@
|
||||
namespace CUE.NET.Devices.Generic.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains list of available update modes.
|
||||
/// </summary>
|
||||
public enum UpdateMode
|
||||
{
|
||||
/// <summary>
|
||||
/// The device will not perform automatic updates. Updates will only occur if <see cref="CUE.NET.Devices.ICueDevice.Update" /> is called.
|
||||
/// </summary>
|
||||
Manual,
|
||||
|
||||
/// <summary>
|
||||
/// The device will perform automatic updates at the rate set in <see cref="CUE.NET.Devices.ICueDevice.UpdateFrequency" />
|
||||
/// as long as an <see cref="CUE.NET.Devices.Keyboard.Effects.IEffect" /> is attached.
|
||||
/// </summary>
|
||||
AutoOnEffect,
|
||||
|
||||
/// <summary>
|
||||
/// The device will perform automatic updates at the rate set in <see cref="CUE.NET.Devices.ICueDevice.UpdateFrequency" />.
|
||||
/// </summary>
|
||||
Continuous
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,17 +10,17 @@ namespace CUE.NET.Devices.Generic
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Device type.
|
||||
/// Gets the device type. (<see cref="CUE.NET.Devices.Generic.Enums.CorsairDeviceType" />)
|
||||
/// </summary>
|
||||
public CorsairDeviceType Type { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Device model (like “K95RGB”).
|
||||
/// Gets the device model (like “K95RGB”).
|
||||
/// </summary>
|
||||
public string Model { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Flags that describes device capabilities
|
||||
/// Get a flag that describes device capabilities. (<see cref="CUE.NET.Devices.Generic.Enums.CorsairDeviceCaps" />)
|
||||
/// </summary>
|
||||
public CorsairDeviceCaps CapsMask { get; }
|
||||
|
||||
|
||||
@ -2,16 +2,26 @@
|
||||
|
||||
namespace CUE.NET.Devices.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the information supplied with an OnException-event.
|
||||
/// </summary>
|
||||
public class OnExceptionEventArgs : EventArgs
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception which is responsible for the event-call.
|
||||
/// </summary>
|
||||
public Exception Exception { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OnExceptionEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception which is responsible for the event-call.</param>
|
||||
public OnExceptionEventArgs(Exception exception)
|
||||
{
|
||||
this.Exception = exception;
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
namespace CUE.NET.Devices.Headset
|
||||
{
|
||||
//TODO DarthAffe 20.09.2015: Find someone to test this
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairHeadset : AbstractCueDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@ -3,6 +3,9 @@ using CUE.NET.Native;
|
||||
|
||||
namespace CUE.NET.Devices.Headset
|
||||
{
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetDeviceInfo : GenericDeviceInfo
|
||||
{
|
||||
internal CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo)
|
||||
|
||||
@ -7,7 +7,6 @@ namespace CUE.NET.Devices
|
||||
|
||||
public interface ICueDevice
|
||||
{
|
||||
|
||||
IDeviceInfo DeviceInfo { get; }
|
||||
|
||||
UpdateMode UpdateMode { get; set; }
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
namespace CUE.NET.Devices.Mouse
|
||||
{
|
||||
//TODO DarthAffe 20.09.2015: Find someone to test this
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairMouse : AbstractCueDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@ -7,6 +7,9 @@ using CUE.NET.Native;
|
||||
|
||||
namespace CUE.NET.Devices.Mouse
|
||||
{
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairMouseDeviceInfo : GenericDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user