Refactored to do everything based on LEDs.

This will adapt the devices and reduces the importance of the "special case keyboard"
This commit is contained in:
DarthAffe committed 2016-09-10 14:59:25 +02:00
1 parent bfe51add66
commit 5a018d0743
24 files changed
+847 -894

No files matched your search

+13 -64
View File
@@ -2,12 +2,9 @@
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions;
@@ -16,38 +13,15 @@ namespace CUE.NET.Devices.Mouse
/// <summary>
/// Represents the SDK for a corsair mouse.
/// </summary>
public class CorsairMouse : AbstractCueDevice, IEnumerable<CorsairLed>
public class CorsairMouse : AbstractCueDevice
{
#region Properties & Fields
#region Indexer
/// <summary>
/// Gets the <see cref="CorsairLed" /> with the specified ID.
/// </summary>
/// <param name="ledId">The ID of the LED to get.</param>
/// <returns>The LED with the specified ID.</returns>
public CorsairLed this[CorsairMouseLedId ledId]
{
get
{
CorsairLed led;
return base.Leds.TryGetValue((int)ledId, out led) ? led : null;
}
}
#endregion
/// <summary>
/// Gets specific information provided by CUE for the mouse.
/// </summary>
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
/// <summary>
/// Gets a read-only collection containing all LEDs of the mouse.
/// </summary>
public new IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(base.Leds.Values.ToList());
#endregion
#region Constructors
@@ -60,64 +34,39 @@ namespace CUE.NET.Devices.Mouse
: base(info)
{
this.MouseDeviceInfo = info;
InitializeLeds();
}
#endregion
#region Methods
private void InitializeLeds()
protected override void InitializeLeds()
{
switch (MouseDeviceInfo.PhysicalLayout)
{
case CorsairPhysicalMouseLayout.Zones1:
InitializeLed((int)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones2:
InitializeLed((int)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones3:
InitializeLed((int)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones4:
InitializeLed((int)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
InitializeLed((int)CorsairMouseLedId.B4, new RectangleF(3, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
InitializeLed((CorsairLedId)CorsairMouseLedId.B4, new RectangleF(3, 0, 1, 1));
break;
default:
throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
}
}
protected override void DeviceUpdate()
{
//DarthAffe 21.08.2016: Mice can't own brushes or groups - nothing to do here for now
}
#region IEnumerable
/// <summary>
/// Returns an enumerator that iterates over all LEDs of the mouse.
/// </summary>
/// <returns>An enumerator for all LDS of the mouse.</returns>
public IEnumerator<CorsairLed> GetEnumerator()
{
return Leds.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
#endregion
}
}