mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Added support for mouse and headset devices. This *should* work out of the box but needs to be tested.
This commit is contained in:
parent
0f402a6ecd
commit
57ad0f30e2
@ -40,7 +40,10 @@ namespace CUE.NET.Devices.Generic
|
||||
/// </summary>
|
||||
public float UpdateFrequency { get; set; } = 1f / 30f;
|
||||
|
||||
private Dictionary<int, CorsairLed> Leds { get; } = new Dictionary<int, CorsairLed>();
|
||||
/// <summary>
|
||||
/// Gets a dictionary containing all LEDs of the device.
|
||||
/// </summary>
|
||||
protected Dictionary<int, CorsairLed> Leds { get; } = new Dictionary<int, CorsairLed>();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the device has an active effect to deal with.
|
||||
|
||||
@ -1,29 +1,70 @@
|
||||
using CUE.NET.Devices.Generic;
|
||||
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
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairHeadset : AbstractCueDevice
|
||||
public class CorsairHeadset : AbstractCueDevice, IEnumerable<CorsairLed>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
#region Indexer
|
||||
|
||||
public CorsairLed this[CorsairHeadsetLedId ledId]
|
||||
{
|
||||
get
|
||||
{
|
||||
CorsairLed led;
|
||||
return base.Leds.TryGetValue((int)ledId, out led) ? led : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public CorsairHeadsetDeviceInfo HeadsetDeviceInfo { get; }
|
||||
|
||||
protected override bool HasEffect => false;
|
||||
|
||||
public new IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(base.Leds.Values.ToList());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
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
|
||||
|
||||
public IEnumerator<CorsairLed> GetEnumerator()
|
||||
{
|
||||
return Leds.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,40 @@
|
||||
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
|
||||
/// <summary>
|
||||
/// Stub for planned headset-support.
|
||||
/// </summary>
|
||||
public class CorsairMouse : AbstractCueDevice
|
||||
public class CorsairMouse : AbstractCueDevice, IEnumerable<CorsairLed>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
#region Indexer
|
||||
|
||||
public CorsairLed this[CorsairMouseLedId ledId]
|
||||
{
|
||||
get
|
||||
{
|
||||
CorsairLed led;
|
||||
return base.Leds.TryGetValue((int)ledId, out led) ? led : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
|
||||
|
||||
protected override bool HasEffect => false;
|
||||
|
||||
public new IEnumerable<CorsairLed> Leds => new ReadOnlyCollection<CorsairLed>(base.Leds.Values.ToList());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -22,12 +43,55 @@ namespace CUE.NET.Devices.Mouse
|
||||
: 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
|
||||
|
||||
public IEnumerator<CorsairLed> GetEnumerator()
|
||||
{
|
||||
return Leds.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user