Changed update-Pprameter away from dictionary

This commit is contained in:
DarthAffe committed 2021-03-03 23:06:22 +01:00
1 parent 9c8d67740d
commit 2222808c23
27 files changed
+133 -149

No files matched your search

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Devices.Logitech.Native;
@@ -27,9 +25,9 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
Color color = dataSet.Values.First();
Color color = dataSet[0].color;
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.DeviceRGB);
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100),
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using RGB.NET.Core;
using RGB.NET.Devices.Logitech.Native;
@@ -33,27 +32,27 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB);
Array.Clear(_bitmap, 0, _bitmap.Length);
bool usesBitmap = false;
foreach (KeyValuePair<object, Color> data in dataSet)
foreach ((object key, Color color) in dataSet)
{
(LedId id, LogitechLedId customData) = ((LedId, LogitechLedId))data.Key;
(LedId id, LogitechLedId customData) = ((LedId, LogitechLedId))key;
// DarthAffe 26.03.2017: This is only needed since update by name doesn't work as expected for all keys ...
if (BitmapMapping.BitmapOffset.TryGetValue(id, out int bitmapOffset))
{
BitmapMapping.SetColor(_bitmap, bitmapOffset, data.Value);
BitmapMapping.SetColor(_bitmap, bitmapOffset, color);
usesBitmap = true;
}
else
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)customData,
(int)Math.Round(data.Value.R * 100),
(int)Math.Round(data.Value.G * 100),
(int)Math.Round(data.Value.B * 100));
(int)MathF.Round(color.R * 100),
(int)MathF.Round(color.G * 100),
(int)MathF.Round(color.B * 100));
}
if (usesBitmap)
@@ -13,12 +13,12 @@ namespace RGB.NET.Devices.Logitech
#region Constants
private static readonly Dictionary<RGBDeviceType, LogitechDeviceType> DEVICE_TYPE_MAPPING = new()
{
{RGBDeviceType.Keyboard, LogitechDeviceType.Keyboard},
{RGBDeviceType.Mouse, LogitechDeviceType.Mouse},
{RGBDeviceType.Headset, LogitechDeviceType.Headset},
{RGBDeviceType.Mousepad, LogitechDeviceType.Mousemat},
{RGBDeviceType.Speaker, LogitechDeviceType.Speaker}
{
{ RGBDeviceType.Keyboard, LogitechDeviceType.Keyboard },
{ RGBDeviceType.Mouse, LogitechDeviceType.Mouse },
{ RGBDeviceType.Headset, LogitechDeviceType.Headset },
{ RGBDeviceType.Mousepad, LogitechDeviceType.Mousemat },
{ RGBDeviceType.Speaker, LogitechDeviceType.Speaker }
};
#endregion
@@ -48,17 +48,17 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All);
foreach (KeyValuePair<object, Color> data in dataSet)
foreach ((object key, Color color) in dataSet)
{
int zone = (int)data.Key;
int zone = (int)key;
_LogitechGSDK.LogiLedSetLightingForTargetZone(_deviceType, zone,
(int)Math.Round(data.Value.R * 100),
(int)Math.Round(data.Value.G * 100),
(int)Math.Round(data.Value.B * 100));
(int)MathF.Round(color.R * 100),
(int)MathF.Round(color.G * 100),
(int)MathF.Round(color.B * 100));
}
}