Rewrote Corsair device handling to use mappings

This commit is contained in:
DarthAffe committed 2021-04-18 19:33:12 +02:00
1 parent 2d0fd93b5f
commit 1e229324be
23 files changed
+284 -395

No files matched your search

@@ -1,7 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
@@ -20,51 +19,8 @@ namespace RGB.NET.Devices.Corsair
/// </summary>
/// <param name="info">The specific information provided by CUE for the mouse</param>
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, updateQueue)
{
InitializeLayout();
}
#endregion
#region Methods
private void InitializeLayout()
{
switch (DeviceInfo.PhysicalLayout)
{
case CorsairPhysicalMouseLayout.Zones1:
AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
break;
case CorsairPhysicalMouseLayout.Zones2:
AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
break;
case CorsairPhysicalMouseLayout.Zones3:
AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
AddLed(LedId.Mouse3, new Point(20, 0), new Size(10, 10));
break;
case CorsairPhysicalMouseLayout.Zones4:
AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
AddLed(LedId.Mouse3, new Point(20, 0), new Size(10, 10));
AddLed(LedId.Mouse4, new Point(30, 0), new Size(10, 10));
break;
default:
throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'");
}
}
protected override object GetLedCustomData(LedId ledId)
{
if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase))
return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
else if (string.Equals(DeviceInfo.Model, "M65 RGB ELITE", StringComparison.OrdinalIgnoreCase))
return MouseIdMapping.M65_RGB_ELITE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
else
return MouseIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
}
: base(info, LedMappings.Mouse, updateQueue)
{ }
#endregion
}
@@ -1,31 +0,0 @@
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
internal static class MouseIdMapping
{
internal static readonly Dictionary<LedId, CorsairLedId> DEFAULT = new()
{
{ LedId.Mouse1, CorsairLedId.B1 },
{ LedId.Mouse2, CorsairLedId.B2 },
{ LedId.Mouse3, CorsairLedId.B3 },
{ LedId.Mouse4, CorsairLedId.B4 },
{ LedId.Mouse5, CorsairLedId.B5 },
{ LedId.Mouse6, CorsairLedId.B6 },
};
internal static readonly Dictionary<LedId, CorsairLedId> GLAIVE = new()
{
{ LedId.Mouse1, CorsairLedId.B1 },
{ LedId.Mouse2, CorsairLedId.B2 },
{ LedId.Mouse3, CorsairLedId.B5 },
};
internal static readonly Dictionary<LedId, CorsairLedId> M65_RGB_ELITE = new()
{
{ LedId.Mouse1, CorsairLedId.B1 },
{ LedId.Mouse2, CorsairLedId.B3 },
};
}
}