mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Added SpecialDeviceParts and implemented CorsairLightbar
This commit is contained in:
1 parent
073c4b153d
commit
3630e0f66f
7 files changed
+123
No files matched your search
@@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core.Exceptions;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
using RGB.NET.Devices.Corsair.SpecialParts;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
@@ -154,6 +155,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
case CorsairDeviceType.Keyboard:
|
||||
device = new CorsairKeyboardRGBDevice(new CorsairKeyboardRGBDeviceInfo(i, nativeDeviceInfo));
|
||||
if (device.DeviceInfo.Model.Equals("K95 RGB Platinum", StringComparison.OrdinalIgnoreCase))
|
||||
device.AddSpecialDevicePart(new LightbarSpecialPart(device));
|
||||
break;
|
||||
case CorsairDeviceType.Mouse:
|
||||
device = new CorsairMouseRGBDevice(new CorsairMouseRGBDeviceInfo(i, nativeDeviceInfo));
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Native\_CorsairProtocolDetails.cs" />
|
||||
<Compile Include="Native\_CUESDK.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SpecialParts\LightbarSpecialPart.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Layouts\DeviceLayout.xsd">
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair.SpecialParts
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a lightbar attached to a <see cref="IRGBDevice"/>
|
||||
/// </summary>
|
||||
public class LightbarSpecialPart : IRGBDeviceSpecialPart
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private List<Led> _leds;
|
||||
/// <summary>
|
||||
/// Gets a readonly collection of all <see cref="Led"/> of this <see cref="LightbarSpecialPart"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<Led> Leds => new ReadOnlyCollection<Led>(_leds);
|
||||
|
||||
private List<Led> _left;
|
||||
/// <summary>
|
||||
/// Gets a readonly collection of all <see cref="Led"/> in the left half of this <see cref="LightbarSpecialPart"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<Led> Left => new ReadOnlyCollection<Led>(_left);
|
||||
|
||||
private List<Led> _right;
|
||||
/// <summary>
|
||||
/// Gets a readonly collection of all <see cref="Led"/> in the right half of this <see cref="LightbarSpecialPart"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<Led> Right => new ReadOnlyCollection<Led>(_right);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Center <see cref="Led"/> of this <see cref="LightbarSpecialPart"/>.
|
||||
/// </summary>
|
||||
public Led Center { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LightbarSpecialPart"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The device associated with this <see cref="IRGBDeviceSpecialPart"/>.</param>
|
||||
public LightbarSpecialPart(IRGBDevice device)
|
||||
{
|
||||
_leds = device.Where(led => (((CorsairLedId)led.Id).LedId >= CorsairLedIds.Lightbar1) && (((CorsairLedId)led.Id).LedId <= CorsairLedIds.Lightbar19)).ToList();
|
||||
_left = _leds.Where(led => ((CorsairLedId)led.Id).LedId < CorsairLedIds.Lightbar10).ToList();
|
||||
_right = _leds.Where(led => ((CorsairLedId)led.Id).LedId > CorsairLedIds.Lightbar10).ToList();
|
||||
Center = _leds.FirstOrDefault(led => ((CorsairLedId)led.Id).LedId == CorsairLedIds.Lightbar10);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates over all <see cref="Led"/> of the <see cref="IRGBDeviceSpecialPart"/>.
|
||||
/// </summary>
|
||||
/// <returns>An enumerator for all <see cref="Led"/> of the <see cref="IRGBDeviceSpecialPart"/>.</returns>
|
||||
public IEnumerator<Led> GetEnumerator() => _leds.GetEnumerator();
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates over all <see cref="Led"/> of the <see cref="IRGBDeviceSpecialPart"/>.
|
||||
/// </summary>
|
||||
/// <returns>An enumerator for all <see cref="Led"/> of the <see cref="IRGBDeviceSpecialPart"/>.</returns>
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user