Applied code-formatting

This commit is contained in:
DarthAffe committed 2022-09-26 14:35:03 +02:00
1 parent 7954b876ef
commit d345de2c40
9 files changed
+304 -275

No files matched your search

+135 -135
View File
@@ -5,141 +5,141 @@ namespace RGB.NET.Devices.OpenRGB;
internal static class LedMappings
{
public static readonly Dictionary<string, LedId> Default = new()
public static readonly Dictionary<string, LedId> DEFAULT = new()
{
["Key: A" ] = LedId.Keyboard_A ,
["Key: B" ] = LedId.Keyboard_B ,
["Key: C" ] = LedId.Keyboard_C ,
["Key: D" ] = LedId.Keyboard_D ,
["Key: E" ] = LedId.Keyboard_E ,
["Key: F" ] = LedId.Keyboard_F ,
["Key: G" ] = LedId.Keyboard_G ,
["Key: H" ] = LedId.Keyboard_H ,
["Key: I" ] = LedId.Keyboard_I ,
["Key: J" ] = LedId.Keyboard_J ,
["Key: K" ] = LedId.Keyboard_K ,
["Key: L" ] = LedId.Keyboard_L ,
["Key: M" ] = LedId.Keyboard_M ,
["Key: N" ] = LedId.Keyboard_N ,
["Key: O" ] = LedId.Keyboard_O ,
["Key: P" ] = LedId.Keyboard_P ,
["Key: Q" ] = LedId.Keyboard_Q ,
["Key: R" ] = LedId.Keyboard_R ,
["Key: S" ] = LedId.Keyboard_S ,
["Key: T" ] = LedId.Keyboard_T ,
["Key: U" ] = LedId.Keyboard_U ,
["Key: V" ] = LedId.Keyboard_V ,
["Key: W" ] = LedId.Keyboard_W ,
["Key: X" ] = LedId.Keyboard_X ,
["Key: Y" ] = LedId.Keyboard_Y ,
["Key: Z" ] = LedId.Keyboard_Z ,
["Key: 1" ] = LedId.Keyboard_1 ,
["Key: 2" ] = LedId.Keyboard_2 ,
["Key: 3" ] = LedId.Keyboard_3 ,
["Key: 4" ] = LedId.Keyboard_4 ,
["Key: 5" ] = LedId.Keyboard_5 ,
["Key: 6" ] = LedId.Keyboard_6 ,
["Key: 7" ] = LedId.Keyboard_7 ,
["Key: 8" ] = LedId.Keyboard_8 ,
["Key: 9" ] = LedId.Keyboard_9 ,
["Key: 0" ] = LedId.Keyboard_0 ,
["Key: Enter" ] = LedId.Keyboard_Enter ,
["Key: Enter (ISO)" ] = LedId.Keyboard_Enter ,
["Key: Escape" ] = LedId.Keyboard_Escape ,
["Key: Backspace" ] = LedId.Keyboard_Backspace ,
["Key: Tab" ] = LedId.Keyboard_Tab ,
["Key: Space" ] = LedId.Keyboard_Space ,
["Key: -" ] = LedId.Keyboard_MinusAndUnderscore ,
["Key: =" ] = LedId.Keyboard_EqualsAndPlus ,
["Key: [" ] = LedId.Keyboard_BracketLeft ,
["Key: ]" ] = LedId.Keyboard_BracketRight ,
["Key: \\ (ANSI)" ] = LedId.Keyboard_Backslash ,
["Key: #" ] = LedId.Keyboard_NonUsTilde ,
["Key: ;" ] = LedId.Keyboard_SemicolonAndColon ,
["Key: '" ] = LedId.Keyboard_ApostropheAndDoubleQuote,
["Key: `" ] = LedId.Keyboard_GraveAccentAndTilde ,
["Key: ," ] = LedId.Keyboard_CommaAndLessThan ,
["Key: ." ] = LedId.Keyboard_PeriodAndBiggerThan ,
["Key: /" ] = LedId.Keyboard_SlashAndQuestionMark ,
["Key: Caps Lock" ] = LedId.Keyboard_CapsLock ,
["Key: F1" ] = LedId.Keyboard_F1 ,
["Key: F2" ] = LedId.Keyboard_F2 ,
["Key: F3" ] = LedId.Keyboard_F3 ,
["Key: F4" ] = LedId.Keyboard_F4 ,
["Key: F5" ] = LedId.Keyboard_F5 ,
["Key: F6" ] = LedId.Keyboard_F6 ,
["Key: F7" ] = LedId.Keyboard_F7 ,
["Key: F8" ] = LedId.Keyboard_F8 ,
["Key: F9" ] = LedId.Keyboard_F9 ,
["Key: F10" ] = LedId.Keyboard_F10 ,
["Key: F11" ] = LedId.Keyboard_F11 ,
["Key: F12" ] = LedId.Keyboard_F12 ,
["Key: Print Screen" ] = LedId.Keyboard_PrintScreen ,
["Key: Scroll Lock" ] = LedId.Keyboard_ScrollLock ,
["Key: Pause/Break" ] = LedId.Keyboard_PauseBreak ,
["Key: Insert" ] = LedId.Keyboard_Insert ,
["Key: Home" ] = LedId.Keyboard_Home ,
["Key: Page Up" ] = LedId.Keyboard_PageUp ,
["Key: Delete" ] = LedId.Keyboard_Delete ,
["Key: End" ] = LedId.Keyboard_End ,
["Key: Page Down" ] = LedId.Keyboard_PageDown ,
["Key: Right Arrow" ] = LedId.Keyboard_ArrowRight ,
["Key: Left Arrow" ] = LedId.Keyboard_ArrowLeft ,
["Key: Down Arrow" ] = LedId.Keyboard_ArrowDown ,
["Key: Up Arrow" ] = LedId.Keyboard_ArrowUp ,
["Key: Num Lock" ] = LedId.Keyboard_NumLock ,
["Key: Number Pad /" ] = LedId.Keyboard_NumSlash ,
["Key: Number Pad *" ] = LedId.Keyboard_NumAsterisk ,
["Key: Number Pad -" ] = LedId.Keyboard_NumMinus ,
["Key: Number Pad +" ] = LedId.Keyboard_NumPlus ,
["Key: Number Pad Enter"] = LedId.Keyboard_NumEnter ,
["Key: Number Pad 1" ] = LedId.Keyboard_Num1 ,
["Key: Number Pad 2" ] = LedId.Keyboard_Num2 ,
["Key: Number Pad 3" ] = LedId.Keyboard_Num3 ,
["Key: Number Pad 4" ] = LedId.Keyboard_Num4 ,
["Key: Number Pad 5" ] = LedId.Keyboard_Num5 ,
["Key: Number Pad 6" ] = LedId.Keyboard_Num6 ,
["Key: Number Pad 7" ] = LedId.Keyboard_Num7 ,
["Key: Number Pad 8" ] = LedId.Keyboard_Num8 ,
["Key: Number Pad 9" ] = LedId.Keyboard_Num9 ,
["Key: Number Pad 0" ] = LedId.Keyboard_Num0 ,
["Key: Number Pad ." ] = LedId.Keyboard_NumPeriodAndDelete ,
["Key: Left Fn" ] = LedId.Keyboard_Function ,
["Key: Right Fn" ] = LedId.Keyboard_Function ,
["Key: \\ (ISO)" ] = LedId.Keyboard_NonUsBackslash ,
["Key: Menu" ] = LedId.Keyboard_Application ,
["Key: Left Control" ] = LedId.Keyboard_LeftCtrl ,
["Key: Left Shift" ] = LedId.Keyboard_LeftShift ,
["Key: Left Alt" ] = LedId.Keyboard_LeftAlt ,
["Key: Left Windows" ] = LedId.Keyboard_LeftGui ,
["Key: Right Control" ] = LedId.Keyboard_RightCtrl ,
["Key: Right Shift" ] = LedId.Keyboard_RightShift ,
["Key: Right Alt" ] = LedId.Keyboard_RightAlt ,
["Key: Right Windows" ] = LedId.Keyboard_RightGui ,
["Key: Media Next" ] = LedId.Keyboard_MediaNextTrack ,
["Key: Media Previous" ] = LedId.Keyboard_MediaPreviousTrack ,
["Key: Media Stop" ] = LedId.Keyboard_MediaStop ,
["Key: Media Pause" ] = LedId.Keyboard_MediaPlay ,
["Key: Media Play" ] = LedId.Keyboard_MediaPlay ,
["Key: Media Play/Pause"] = LedId.Keyboard_MediaPlay ,
["Key: Media Mute" ] = LedId.Keyboard_MediaMute ,
["Logo" ] = LedId.Logo ,
["Key: Brightness" ] = LedId.Keyboard_Brightness ,
["Key: M1" ] = LedId.Keyboard_Macro1 ,
["Key: M2" ] = LedId.Keyboard_Macro2 ,
["Key: M3" ] = LedId.Keyboard_Macro3 ,
["Key: M4" ] = LedId.Keyboard_Macro4 ,
["Key: M5" ] = LedId.Keyboard_Macro5 ,
["Key: G1" ] = LedId.Keyboard_Programmable1 ,
["Key: G2" ] = LedId.Keyboard_Programmable2 ,
["Key: G3" ] = LedId.Keyboard_Programmable3 ,
["Key: G4" ] = LedId.Keyboard_Programmable4 ,
["Key: G5" ] = LedId.Keyboard_Programmable5 ,
["Key: G6" ] = LedId.Keyboard_Programmable6 ,
["Key: G7" ] = LedId.Keyboard_Programmable7 ,
["Key: G8" ] = LedId.Keyboard_Programmable8 ,
["Key: G9" ] = LedId.Keyboard_Programmable9 ,
["Lighting" ] = LedId.Keyboard_Brightness ,
["Game Mode" ] = LedId.Keyboard_WinLock ,
["Key: A"] = LedId.Keyboard_A,
["Key: B"] = LedId.Keyboard_B,
["Key: C"] = LedId.Keyboard_C,
["Key: D"] = LedId.Keyboard_D,
["Key: E"] = LedId.Keyboard_E,
["Key: F"] = LedId.Keyboard_F,
["Key: G"] = LedId.Keyboard_G,
["Key: H"] = LedId.Keyboard_H,
["Key: I"] = LedId.Keyboard_I,
["Key: J"] = LedId.Keyboard_J,
["Key: K"] = LedId.Keyboard_K,
["Key: L"] = LedId.Keyboard_L,
["Key: M"] = LedId.Keyboard_M,
["Key: N"] = LedId.Keyboard_N,
["Key: O"] = LedId.Keyboard_O,
["Key: P"] = LedId.Keyboard_P,
["Key: Q"] = LedId.Keyboard_Q,
["Key: R"] = LedId.Keyboard_R,
["Key: S"] = LedId.Keyboard_S,
["Key: T"] = LedId.Keyboard_T,
["Key: U"] = LedId.Keyboard_U,
["Key: V"] = LedId.Keyboard_V,
["Key: W"] = LedId.Keyboard_W,
["Key: X"] = LedId.Keyboard_X,
["Key: Y"] = LedId.Keyboard_Y,
["Key: Z"] = LedId.Keyboard_Z,
["Key: 1"] = LedId.Keyboard_1,
["Key: 2"] = LedId.Keyboard_2,
["Key: 3"] = LedId.Keyboard_3,
["Key: 4"] = LedId.Keyboard_4,
["Key: 5"] = LedId.Keyboard_5,
["Key: 6"] = LedId.Keyboard_6,
["Key: 7"] = LedId.Keyboard_7,
["Key: 8"] = LedId.Keyboard_8,
["Key: 9"] = LedId.Keyboard_9,
["Key: 0"] = LedId.Keyboard_0,
["Key: Enter"] = LedId.Keyboard_Enter,
["Key: Enter (ISO)"] = LedId.Keyboard_Enter,
["Key: Escape"] = LedId.Keyboard_Escape,
["Key: Backspace"] = LedId.Keyboard_Backspace,
["Key: Tab"] = LedId.Keyboard_Tab,
["Key: Space"] = LedId.Keyboard_Space,
["Key: -"] = LedId.Keyboard_MinusAndUnderscore,
["Key: ="] = LedId.Keyboard_EqualsAndPlus,
["Key: ["] = LedId.Keyboard_BracketLeft,
["Key: ]"] = LedId.Keyboard_BracketRight,
["Key: \\ (ANSI)"] = LedId.Keyboard_Backslash,
["Key: #"] = LedId.Keyboard_NonUsTilde,
["Key: ;"] = LedId.Keyboard_SemicolonAndColon,
["Key: '"] = LedId.Keyboard_ApostropheAndDoubleQuote,
["Key: `"] = LedId.Keyboard_GraveAccentAndTilde,
["Key: ,"] = LedId.Keyboard_CommaAndLessThan,
["Key: ."] = LedId.Keyboard_PeriodAndBiggerThan,
["Key: /"] = LedId.Keyboard_SlashAndQuestionMark,
["Key: Caps Lock"] = LedId.Keyboard_CapsLock,
["Key: F1"] = LedId.Keyboard_F1,
["Key: F2"] = LedId.Keyboard_F2,
["Key: F3"] = LedId.Keyboard_F3,
["Key: F4"] = LedId.Keyboard_F4,
["Key: F5"] = LedId.Keyboard_F5,
["Key: F6"] = LedId.Keyboard_F6,
["Key: F7"] = LedId.Keyboard_F7,
["Key: F8"] = LedId.Keyboard_F8,
["Key: F9"] = LedId.Keyboard_F9,
["Key: F10"] = LedId.Keyboard_F10,
["Key: F11"] = LedId.Keyboard_F11,
["Key: F12"] = LedId.Keyboard_F12,
["Key: Print Screen"] = LedId.Keyboard_PrintScreen,
["Key: Scroll Lock"] = LedId.Keyboard_ScrollLock,
["Key: Pause/Break"] = LedId.Keyboard_PauseBreak,
["Key: Insert"] = LedId.Keyboard_Insert,
["Key: Home"] = LedId.Keyboard_Home,
["Key: Page Up"] = LedId.Keyboard_PageUp,
["Key: Delete"] = LedId.Keyboard_Delete,
["Key: End"] = LedId.Keyboard_End,
["Key: Page Down"] = LedId.Keyboard_PageDown,
["Key: Right Arrow"] = LedId.Keyboard_ArrowRight,
["Key: Left Arrow"] = LedId.Keyboard_ArrowLeft,
["Key: Down Arrow"] = LedId.Keyboard_ArrowDown,
["Key: Up Arrow"] = LedId.Keyboard_ArrowUp,
["Key: Num Lock"] = LedId.Keyboard_NumLock,
["Key: Number Pad /"] = LedId.Keyboard_NumSlash,
["Key: Number Pad *"] = LedId.Keyboard_NumAsterisk,
["Key: Number Pad -"] = LedId.Keyboard_NumMinus,
["Key: Number Pad +"] = LedId.Keyboard_NumPlus,
["Key: Number Pad Enter"] = LedId.Keyboard_NumEnter,
["Key: Number Pad 1"] = LedId.Keyboard_Num1,
["Key: Number Pad 2"] = LedId.Keyboard_Num2,
["Key: Number Pad 3"] = LedId.Keyboard_Num3,
["Key: Number Pad 4"] = LedId.Keyboard_Num4,
["Key: Number Pad 5"] = LedId.Keyboard_Num5,
["Key: Number Pad 6"] = LedId.Keyboard_Num6,
["Key: Number Pad 7"] = LedId.Keyboard_Num7,
["Key: Number Pad 8"] = LedId.Keyboard_Num8,
["Key: Number Pad 9"] = LedId.Keyboard_Num9,
["Key: Number Pad 0"] = LedId.Keyboard_Num0,
["Key: Number Pad ."] = LedId.Keyboard_NumPeriodAndDelete,
["Key: Left Fn"] = LedId.Keyboard_Function,
["Key: Right Fn"] = LedId.Keyboard_Function,
["Key: \\ (ISO)"] = LedId.Keyboard_NonUsBackslash,
["Key: Menu"] = LedId.Keyboard_Application,
["Key: Left Control"] = LedId.Keyboard_LeftCtrl,
["Key: Left Shift"] = LedId.Keyboard_LeftShift,
["Key: Left Alt"] = LedId.Keyboard_LeftAlt,
["Key: Left Windows"] = LedId.Keyboard_LeftGui,
["Key: Right Control"] = LedId.Keyboard_RightCtrl,
["Key: Right Shift"] = LedId.Keyboard_RightShift,
["Key: Right Alt"] = LedId.Keyboard_RightAlt,
["Key: Right Windows"] = LedId.Keyboard_RightGui,
["Key: Media Next"] = LedId.Keyboard_MediaNextTrack,
["Key: Media Previous"] = LedId.Keyboard_MediaPreviousTrack,
["Key: Media Stop"] = LedId.Keyboard_MediaStop,
["Key: Media Pause"] = LedId.Keyboard_MediaPlay,
["Key: Media Play"] = LedId.Keyboard_MediaPlay,
["Key: Media Play/Pause"] = LedId.Keyboard_MediaPlay,
["Key: Media Mute"] = LedId.Keyboard_MediaMute,
["Logo"] = LedId.Logo,
["Key: Brightness"] = LedId.Keyboard_Brightness,
["Key: M1"] = LedId.Keyboard_Macro1,
["Key: M2"] = LedId.Keyboard_Macro2,
["Key: M3"] = LedId.Keyboard_Macro3,
["Key: M4"] = LedId.Keyboard_Macro4,
["Key: M5"] = LedId.Keyboard_Macro5,
["Key: G1"] = LedId.Keyboard_Programmable1,
["Key: G2"] = LedId.Keyboard_Programmable2,
["Key: G3"] = LedId.Keyboard_Programmable3,
["Key: G4"] = LedId.Keyboard_Programmable4,
["Key: G5"] = LedId.Keyboard_Programmable5,
["Key: G6"] = LedId.Keyboard_Programmable6,
["Key: G7"] = LedId.Keyboard_Programmable7,
["Key: G8"] = LedId.Keyboard_Programmable8,
["Key: G9"] = LedId.Keyboard_Programmable9,
["Lighting"] = LedId.Keyboard_Brightness,
["Game Mode"] = LedId.Keyboard_WinLock,
};
}
@@ -1,11 +1,12 @@
using OpenRGB.NET.Enums;
using RGB.NET.Core;
namespace RGB.NET.Devices.OpenRGB.Generic;
namespace RGB.NET.Devices.OpenRGB;
/// <inheritdoc />
public class OpenRGBGenericDevice : AbstractOpenRGBDevice<OpenRGBDeviceInfo>
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="OpenRGBGenericDevice"/> class.
/// </summary>
@@ -17,6 +18,10 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice<OpenRGBDeviceInfo>
InitializeLayout();
}
#endregion
#region Methods
/// <summary>
/// Initializes the LEDs of the device based on the data provided by the SDK.
/// </summary>
@@ -25,9 +30,9 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice<OpenRGBDeviceInfo>
LedId initial = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType);
int y = 0;
Size ledSize = new Size(19);
Size ledSize = new(19);
int zoneLedIndex = 0;
const int ledSpacing = 20;
const int LED_SPACING = 20;
foreach (global::OpenRGB.NET.Models.Zone? zone in DeviceInfo.OpenRGBDevice.Zones)
{
@@ -43,18 +48,18 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice<OpenRGBDeviceInfo>
if (index == uint.MaxValue)
continue;
LedId ledId = LedMappings.Default.TryGetValue(DeviceInfo.OpenRGBDevice.Leds[zoneLedIndex + index].Name, out LedId l)
? l
: initial++;
LedId ledId = LedMappings.DEFAULT.TryGetValue(DeviceInfo.OpenRGBDevice.Leds[zoneLedIndex + index].Name, out LedId id)
? id
: initial++;
//HACK: doing this because some different Led Names are mapped to the same LedId
//for example, "Enter" and "ISO Enter".
//this way, at least they'll be controllable as CustomX
while (AddLed(ledId, new Point(ledSpacing * column, y + (ledSpacing * row)), ledSize, zoneLedIndex + (int)index) == null)
while (AddLed(ledId, new Point(LED_SPACING * column, y + (LED_SPACING * row)), ledSize, zoneLedIndex + (int)index) == null)
ledId = initial++;
}
}
y += (int)(zone.MatrixMap.Height * ledSpacing);
y += (int)(zone.MatrixMap.Height * LED_SPACING);
}
else
{
@@ -62,15 +67,17 @@ public class OpenRGBGenericDevice : AbstractOpenRGBDevice<OpenRGBDeviceInfo>
{
LedId ledId = initial++;
while (AddLed(ledId, new Point(ledSpacing * i, y), ledSize, zoneLedIndex + i) == null)
while (AddLed(ledId, new Point(LED_SPACING * i, y), ledSize, zoneLedIndex + i) == null)
ledId = initial++;
}
}
//we'll just set each zone in its own row for now,
//with each led for that zone being horizontally distributed
y += ledSpacing;
y += LED_SPACING;
zoneLedIndex += (int)zone.LedCount;
}
}
#endregion
}
@@ -14,11 +14,13 @@ namespace RGB.NET.Devices.OpenRGB;
public class OpenRGBUpdateQueue : UpdateQueue
{
#region Properties & Fields
private readonly int _deviceid;
private readonly OpenRGBClient _openRGB;
private readonly OpenRGBDevice _device;
private readonly OpenRGBColor[] _colors;
#endregion
#region Constructors
@@ -33,9 +35,10 @@ public class OpenRGBUpdateQueue : UpdateQueue
public OpenRGBUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceid, OpenRGBClient client, OpenRGBDevice device)
: base(updateTrigger)
{
_deviceid = deviceid;
_openRGB = client;
_device = device;
this._deviceid = deviceid;
this._openRGB = client;
this._device = device;
_colors = Enumerable.Range(0, _device.Colors.Length)
.Select(_ => new OpenRGBColor())
.ToArray();
@@ -49,9 +52,7 @@ public class OpenRGBUpdateQueue : UpdateQueue
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
foreach ((object key, Color color) in dataSet)
{
_colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB());
}
_openRGB.UpdateLeds(_deviceid, _colors);
}