1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Fixed code issues

This commit is contained in:
Darth Affe 2021-06-01 23:53:56 +02:00
parent 4466acfbf7
commit 7b0e9152fd
54 changed files with 330 additions and 275 deletions

View File

@ -155,8 +155,8 @@ namespace RGB.NET.Core
/// <returns>The color created from the values.</returns>
public static Color Create(float alpha, float h, float c, float l)
{
(float r, float g, float _b) = CalculateRGBFromHcl(h, c, l);
return new Color(alpha, r, g, _b);
(float r, float g, float b) = CalculateRGBFromHcl(h, c, l);
return new Color(alpha, r, g, b);
}
#endregion
@ -167,6 +167,7 @@ namespace RGB.NET.Core
{
const float RADIANS_DEGREES_CONVERSION = 180.0f / MathF.PI;
// ReSharper disable once InconsistentNaming - b is used above
(float l, float a, float _b) = LabColor.CalculateLabFromRGB(r, g, b);
float h, c;

View File

@ -155,6 +155,7 @@ namespace RGB.NET.Core
/// <returns>The color created from the values.</returns>
public static Color Create(float alpha, float l, float a, float b)
{
// ReSharper disable once InconsistentNaming - b is used above
(float r, float g, float _b) = CalculateRGBFromLab(l, a, b);
return new Color(alpha, r, g, _b);
}

View File

@ -1,4 +1,6 @@
using System;
// ReSharper disable EventNeverSubscribedTo.Global
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

View File

@ -33,7 +33,7 @@ namespace RGB.NET.Core
x = (x * cos) - (y * sin);
y = (x * sin) + (y * cos);
return new Point(x + origin.X, y + origin.Y); ;
return new Point(x + origin.X, y + origin.Y);
}
#endregion

View File

@ -73,7 +73,7 @@ namespace RGB.NET.Core
{
lock (GroupLeds)
foreach (Led led in leds)
if ((led != null) && !ContainsLed(led))
if (!ContainsLed(led))
GroupLeds.Add(led);
}
@ -91,8 +91,7 @@ namespace RGB.NET.Core
{
lock (GroupLeds)
foreach (Led led in leds)
if (led != null)
GroupLeds.Remove(led);
GroupLeds.Remove(led);
}
/// <summary>

View File

@ -1,4 +1,6 @@
using System;
// ReSharper disable EventNeverSubscribedTo.Global
using System;
namespace RGB.NET.Core
{

View File

@ -1,6 +1,7 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using System.Diagnostics;
namespace RGB.NET.Core
@ -65,9 +66,8 @@ namespace RGB.NET.Core
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="Point" /> equivalent to this <see cref="Point" />; otherwise, <c>false</c>.</returns>
public override bool Equals(object? obj)
{
if (!(obj is Point)) return false;
if (obj is not Point comparePoint) return false;
Point comparePoint = (Point)obj;
return ((float.IsNaN(X) && float.IsNaN(comparePoint.X)) || X.EqualsInTolerance(comparePoint.X))
&& ((float.IsNaN(Y) && float.IsNaN(comparePoint.Y)) || Y.EqualsInTolerance(comparePoint.Y));
}
@ -76,15 +76,7 @@ namespace RGB.NET.Core
/// Returns a hash code for this <see cref="Point" />.
/// </summary>
/// <returns>An integer value that specifies the hash code for this <see cref="Point" />.</returns>
public override int GetHashCode()
{
unchecked
{
int hashCode = X.GetHashCode();
hashCode = (hashCode * 397) ^ Y.GetHashCode();
return hashCode;
}
}
public override int GetHashCode() => HashCode.Combine(X, Y);
#endregion

View File

@ -74,7 +74,7 @@ namespace RGB.NET.Core
{
T[] rent = ArrayPool<T>.Shared.Rent(bufferSize);
Span<T> buffer = new Span<T>(rent).Slice(0, bufferSize);
Span<T> buffer = new Span<T>(rent)[..bufferSize];
GetRegionData(x, y, width, height, buffer);
Span<T> pixelData = stackalloc T[_dataPerPixel];

View File

@ -9,6 +9,7 @@ namespace RGB.NET.Core
{
#region Properties & Fields
/// <inheritdoc />
public abstract double LastUpdateTime { get; protected set; }
#endregion

View File

@ -53,7 +53,7 @@ namespace RGB.NET.Core
if (_currentDataSet.Count == 0) return;
dataSet = ArrayPool<(TIdentifier, TData)>.Shared.Rent(_currentDataSet.Count);
data = new Span<(TIdentifier, TData)>(dataSet).Slice(0, _currentDataSet.Count);
data = new Span<(TIdentifier, TData)>(dataSet)[.._currentDataSet.Count];
int i = 0;
foreach ((TIdentifier key, TData value) in _currentDataSet)
@ -115,6 +115,8 @@ namespace RGB.NET.Core
_updateTrigger.Update -= OnUpdate;
Reset();
GC.SuppressFinalize(this);
}
#endregion

View File

@ -14,7 +14,7 @@ namespace RGB.NET.Core
{
#region Properties & Fields
private AutoResetEvent _mutex = new(false);
private readonly AutoResetEvent _mutex = new(false);
private Task? UpdateTask { get; set; }
private CancellationTokenSource? UpdateTokenSource { get; set; }
private CancellationToken UpdateToken { get; set; }

View File

@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
@ -14,7 +15,7 @@ namespace RGB.NET.Core
{
#region Properties & Fields
private object _lock = new();
private readonly object _lock = new();
protected Task? UpdateTask { get; set; }
protected CancellationTokenSource? UpdateTokenSource { get; set; }
@ -46,6 +47,7 @@ namespace RGB.NET.Core
public TimerUpdateTrigger(bool autostart = true)
{
if (autostart)
// ReSharper disable once VirtualMemberCallInConstructor - HACK DarthAffe 01.06.2021: I've no idea how to correctly handle that case, for now just disable it
Start();
}
@ -109,7 +111,11 @@ namespace RGB.NET.Core
}
/// <inheritdoc />
public override void Dispose() => Stop();
public override void Dispose()
{
Stop();
GC.SuppressFinalize(this);
}
#endregion
}

View File

@ -7,160 +7,159 @@ namespace RGB.NET.Devices.Asus
/// <summary>
/// A LED mapping containing ASUS keyboard LED IDs
/// </summary>
public static readonly LedMapping<AsusLedId> KeyboardMapping =
new()
{
{LedId.Keyboard_Escape, AsusLedId.KEY_ESCAPE},
{LedId.Keyboard_F1, AsusLedId.KEY_F1},
{LedId.Keyboard_F2, AsusLedId.KEY_F2},
{LedId.Keyboard_F3, AsusLedId.KEY_F3},
{LedId.Keyboard_F4, AsusLedId.KEY_F4},
{LedId.Keyboard_F5, AsusLedId.KEY_F5},
{LedId.Keyboard_F6, AsusLedId.KEY_F6},
{LedId.Keyboard_F7, AsusLedId.KEY_F7},
{LedId.Keyboard_F8, AsusLedId.KEY_F8},
{LedId.Keyboard_F9, AsusLedId.KEY_F9},
{LedId.Keyboard_F10, AsusLedId.KEY_F10},
{LedId.Keyboard_F11, AsusLedId.KEY_F11},
{LedId.Keyboard_F12, AsusLedId.KEY_F12},
{LedId.Keyboard_1, AsusLedId.KEY_1},
{LedId.Keyboard_2, AsusLedId.KEY_2},
{LedId.Keyboard_3, AsusLedId.KEY_3},
{LedId.Keyboard_4, AsusLedId.KEY_4},
{LedId.Keyboard_5, AsusLedId.KEY_5},
{LedId.Keyboard_6, AsusLedId.KEY_6},
{LedId.Keyboard_7, AsusLedId.KEY_7},
{LedId.Keyboard_8, AsusLedId.KEY_8},
{LedId.Keyboard_9, AsusLedId.KEY_9},
{LedId.Keyboard_0, AsusLedId.KEY_0},
{LedId.Keyboard_MinusAndUnderscore, AsusLedId.KEY_MINUS},
{LedId.Keyboard_EqualsAndPlus, AsusLedId.KEY_EQUALS},
{LedId.Keyboard_Backspace, AsusLedId.KEY_BACK},
{LedId.Keyboard_Tab, AsusLedId.KEY_TAB},
{LedId.Keyboard_Q, AsusLedId.KEY_Q},
{LedId.Keyboard_W, AsusLedId.KEY_W},
{LedId.Keyboard_E, AsusLedId.KEY_E},
{LedId.Keyboard_R, AsusLedId.KEY_R},
{LedId.Keyboard_T, AsusLedId.KEY_T},
{LedId.Keyboard_Y, AsusLedId.KEY_Y},
{LedId.Keyboard_U, AsusLedId.KEY_U},
{LedId.Keyboard_I, AsusLedId.KEY_I},
{LedId.Keyboard_O, AsusLedId.KEY_O},
{LedId.Keyboard_P, AsusLedId.KEY_P},
{LedId.Keyboard_BracketLeft, AsusLedId.KEY_LBRACKET},
{LedId.Keyboard_BracketRight, AsusLedId.KEY_RBRACKET},
{LedId.Keyboard_Enter, AsusLedId.KEY_RETURN},
{LedId.Keyboard_CapsLock, AsusLedId.KEY_CAPITAL},
{LedId.Keyboard_A, AsusLedId.KEY_A},
{LedId.Keyboard_S, AsusLedId.KEY_S},
{LedId.Keyboard_D, AsusLedId.KEY_D},
{LedId.Keyboard_F, AsusLedId.KEY_F},
{LedId.Keyboard_G, AsusLedId.KEY_G},
{LedId.Keyboard_H, AsusLedId.KEY_H},
{LedId.Keyboard_J, AsusLedId.KEY_J},
{LedId.Keyboard_K, AsusLedId.KEY_K},
{LedId.Keyboard_L, AsusLedId.KEY_L},
{LedId.Keyboard_SemicolonAndColon, AsusLedId.KEY_SEMICOLON},
{LedId.Keyboard_ApostropheAndDoubleQuote, AsusLedId.KEY_APOSTROPHE},
{LedId.Keyboard_GraveAccentAndTilde, AsusLedId.KEY_GRAVE},
{LedId.Keyboard_LeftShift, AsusLedId.KEY_LSHIFT},
{LedId.Keyboard_Backslash, AsusLedId.KEY_BACKSLASH},
{LedId.Keyboard_Z, AsusLedId.KEY_Z},
{LedId.Keyboard_X, AsusLedId.KEY_X},
{LedId.Keyboard_C, AsusLedId.KEY_C},
{LedId.Keyboard_V, AsusLedId.KEY_V},
{LedId.Keyboard_B, AsusLedId.KEY_B},
{LedId.Keyboard_N, AsusLedId.KEY_N},
{LedId.Keyboard_M, AsusLedId.KEY_M},
{LedId.Keyboard_CommaAndLessThan, AsusLedId.KEY_COMMA},
{LedId.Keyboard_PeriodAndBiggerThan, AsusLedId.KEY_PERIOD},
{LedId.Keyboard_SlashAndQuestionMark, AsusLedId.KEY_SLASH},
{LedId.Keyboard_RightShift, AsusLedId.KEY_RSHIFT},
{LedId.Keyboard_LeftCtrl, AsusLedId.KEY_LCONTROL},
{LedId.Keyboard_LeftGui, AsusLedId.KEY_LWIN},
{LedId.Keyboard_LeftAlt, AsusLedId.KEY_LMENU},
{LedId.Keyboard_Space, AsusLedId.KEY_SPACE},
{LedId.Keyboard_RightAlt, AsusLedId.KEY_RMENU},
{LedId.Keyboard_RightGui, AsusLedId.KEY_RWIN},
{LedId.Keyboard_Application, AsusLedId.KEY_APPS},
{LedId.Keyboard_RightCtrl, AsusLedId.KEY_RCONTROL},
{LedId.Keyboard_PrintScreen, AsusLedId.KEY_SYSRQ},
{LedId.Keyboard_ScrollLock, AsusLedId.KEY_SCROLL},
{LedId.Keyboard_PauseBreak, AsusLedId.KEY_PAUSE},
{LedId.Keyboard_Insert, AsusLedId.KEY_INSERT},
{LedId.Keyboard_Home, AsusLedId.KEY_HOME},
{LedId.Keyboard_PageUp, AsusLedId.KEY_PRIOR},
{LedId.Keyboard_Delete, AsusLedId.KEY_DELETE},
{LedId.Keyboard_End, AsusLedId.KEY_END},
{LedId.Keyboard_PageDown, AsusLedId.KEY_NEXT},
{LedId.Keyboard_ArrowUp, AsusLedId.KEY_UP},
{LedId.Keyboard_ArrowLeft, AsusLedId.KEY_LEFT},
{LedId.Keyboard_ArrowDown, AsusLedId.KEY_DOWN},
{LedId.Keyboard_ArrowRight, AsusLedId.KEY_RIGHT},
{LedId.Keyboard_NumLock, AsusLedId.KEY_NUMLOCK},
{LedId.Keyboard_NumSlash, AsusLedId.KEY_DIVIDE},
{LedId.Keyboard_NumAsterisk, AsusLedId.KEY_MULTIPLY},
{LedId.Keyboard_NumMinus, AsusLedId.KEY_SUBTRACT},
{LedId.Keyboard_Num7, AsusLedId.KEY_NUMPAD7},
{LedId.Keyboard_Num8, AsusLedId.KEY_NUMPAD8},
{LedId.Keyboard_Num9, AsusLedId.KEY_NUMPAD9},
{LedId.Keyboard_NumPeriodAndDelete, AsusLedId.KEY_DECIMAL},
{LedId.Keyboard_NumPlus, AsusLedId.KEY_ADD},
{LedId.Keyboard_Num4, AsusLedId.KEY_NUMPAD4},
{LedId.Keyboard_Num5, AsusLedId.KEY_NUMPAD5},
{LedId.Keyboard_Num6, AsusLedId.KEY_NUMPAD6},
{LedId.Keyboard_Num1, AsusLedId.KEY_NUMPAD1},
{LedId.Keyboard_Num2, AsusLedId.KEY_NUMPAD2},
{LedId.Keyboard_Num3, AsusLedId.KEY_NUMPAD3},
{LedId.Keyboard_Num0, AsusLedId.KEY_NUMPAD0},
{LedId.Keyboard_NumEnter, AsusLedId.KEY_NUMPADENTER},
{LedId.Keyboard_NonUsBackslash, AsusLedId.UNDOCUMENTED_1},
{LedId.Keyboard_NonUsTilde, AsusLedId.UNDOCUMENTED_2},
{LedId.Keyboard_NumComma, AsusLedId.KEY_NUMPADCOMMA},
{LedId.Logo, AsusLedId.UNDOCUMENTED_3},
{LedId.Keyboard_Function, AsusLedId.KEY_FN},
{LedId.Keyboard_MediaMute, AsusLedId.KEY_MUTE},
{LedId.Keyboard_MediaPlay, AsusLedId.KEY_PLAYPAUSE},
{LedId.Keyboard_MediaStop, AsusLedId.KEY_MEDIASTOP},
{LedId.Keyboard_MediaVolumeDown, AsusLedId.KEY_VOLUMEDOWN},
{LedId.Keyboard_MediaVolumeUp, AsusLedId.KEY_VOLUMEUP},
{LedId.Keyboard_Custom1, AsusLedId.KEY_F13},
{LedId.Keyboard_Custom2, AsusLedId.KEY_F14},
{LedId.Keyboard_Custom3, AsusLedId.KEY_F15},
{LedId.Keyboard_Custom4, AsusLedId.KEY_KANA},
{LedId.Keyboard_Custom5, AsusLedId.KEY_ABNT_C1},
{LedId.Keyboard_Custom6, AsusLedId.KEY_CONVERT},
{LedId.Keyboard_Custom7, AsusLedId.KEY_NOCONVERT},
{LedId.Keyboard_Custom8, AsusLedId.KEY_YEN},
{LedId.Keyboard_Custom9, AsusLedId.KEY_ABNT_C2},
{LedId.Keyboard_Custom10, AsusLedId.KEY_NUMPADEQUALS},
{LedId.Keyboard_Custom11, AsusLedId.KEY_CIRCUMFLEX},
{LedId.Keyboard_Custom12, AsusLedId.KEY_AT},
{LedId.Keyboard_Custom13, AsusLedId.KEY_COLON},
{LedId.Keyboard_Custom14, AsusLedId.KEY_UNDERLINE},
{LedId.Keyboard_Custom15, AsusLedId.KEY_KANJI},
{LedId.Keyboard_Custom16, AsusLedId.KEY_STOP},
{LedId.Keyboard_Custom17, AsusLedId.KEY_AX},
{LedId.Keyboard_Custom18, AsusLedId.KEY_UNLABELED},
{LedId.Keyboard_Custom19, AsusLedId.KEY_NEXTTRACK},
{LedId.Keyboard_Custom20, AsusLedId.KEY_CALCULATOR},
{LedId.Keyboard_Custom21, AsusLedId.KEY_POWER},
{LedId.Keyboard_Custom22, AsusLedId.KEY_SLEEP},
{LedId.Keyboard_Custom23, AsusLedId.KEY_WAKE},
{LedId.Keyboard_Custom24, AsusLedId.KEY_WEBSEARCH},
{LedId.Keyboard_Custom25, AsusLedId.KEY_WEBFAVORITES},
{LedId.Keyboard_Custom26, AsusLedId.KEY_WEBREFRESH},
{LedId.Keyboard_Custom27, AsusLedId.KEY_WEBSTOP},
{LedId.Keyboard_Custom28, AsusLedId.KEY_WEBFORWARD},
{LedId.Keyboard_Custom29, AsusLedId.KEY_WEBHOME},
{LedId.Keyboard_Custom30, AsusLedId.KEY_WEBBACK},
{LedId.Keyboard_Custom31, AsusLedId.KEY_MYCOMPUTER},
{LedId.Keyboard_Custom32, AsusLedId.KEY_MAIL},
{LedId.Keyboard_Custom33, AsusLedId.KEY_MEDIASELECT},
{LedId.Keyboard_Custom34, AsusLedId.UNDOCUMENTED_4},
{LedId.Keyboard_Custom35, AsusLedId.UNDOCUMENTED_5},
{LedId.Keyboard_Custom36, AsusLedId.UNDOCUMENTED_6}
};
public static LedMapping<AsusLedId> KeyboardMapping { get; } = new()
{
{ LedId.Keyboard_Escape, AsusLedId.KEY_ESCAPE },
{ LedId.Keyboard_F1, AsusLedId.KEY_F1 },
{ LedId.Keyboard_F2, AsusLedId.KEY_F2 },
{ LedId.Keyboard_F3, AsusLedId.KEY_F3 },
{ LedId.Keyboard_F4, AsusLedId.KEY_F4 },
{ LedId.Keyboard_F5, AsusLedId.KEY_F5 },
{ LedId.Keyboard_F6, AsusLedId.KEY_F6 },
{ LedId.Keyboard_F7, AsusLedId.KEY_F7 },
{ LedId.Keyboard_F8, AsusLedId.KEY_F8 },
{ LedId.Keyboard_F9, AsusLedId.KEY_F9 },
{ LedId.Keyboard_F10, AsusLedId.KEY_F10 },
{ LedId.Keyboard_F11, AsusLedId.KEY_F11 },
{ LedId.Keyboard_F12, AsusLedId.KEY_F12 },
{ LedId.Keyboard_1, AsusLedId.KEY_1 },
{ LedId.Keyboard_2, AsusLedId.KEY_2 },
{ LedId.Keyboard_3, AsusLedId.KEY_3 },
{ LedId.Keyboard_4, AsusLedId.KEY_4 },
{ LedId.Keyboard_5, AsusLedId.KEY_5 },
{ LedId.Keyboard_6, AsusLedId.KEY_6 },
{ LedId.Keyboard_7, AsusLedId.KEY_7 },
{ LedId.Keyboard_8, AsusLedId.KEY_8 },
{ LedId.Keyboard_9, AsusLedId.KEY_9 },
{ LedId.Keyboard_0, AsusLedId.KEY_0 },
{ LedId.Keyboard_MinusAndUnderscore, AsusLedId.KEY_MINUS },
{ LedId.Keyboard_EqualsAndPlus, AsusLedId.KEY_EQUALS },
{ LedId.Keyboard_Backspace, AsusLedId.KEY_BACK },
{ LedId.Keyboard_Tab, AsusLedId.KEY_TAB },
{ LedId.Keyboard_Q, AsusLedId.KEY_Q },
{ LedId.Keyboard_W, AsusLedId.KEY_W },
{ LedId.Keyboard_E, AsusLedId.KEY_E },
{ LedId.Keyboard_R, AsusLedId.KEY_R },
{ LedId.Keyboard_T, AsusLedId.KEY_T },
{ LedId.Keyboard_Y, AsusLedId.KEY_Y },
{ LedId.Keyboard_U, AsusLedId.KEY_U },
{ LedId.Keyboard_I, AsusLedId.KEY_I },
{ LedId.Keyboard_O, AsusLedId.KEY_O },
{ LedId.Keyboard_P, AsusLedId.KEY_P },
{ LedId.Keyboard_BracketLeft, AsusLedId.KEY_LBRACKET },
{ LedId.Keyboard_BracketRight, AsusLedId.KEY_RBRACKET },
{ LedId.Keyboard_Enter, AsusLedId.KEY_RETURN },
{ LedId.Keyboard_CapsLock, AsusLedId.KEY_CAPITAL },
{ LedId.Keyboard_A, AsusLedId.KEY_A },
{ LedId.Keyboard_S, AsusLedId.KEY_S },
{ LedId.Keyboard_D, AsusLedId.KEY_D },
{ LedId.Keyboard_F, AsusLedId.KEY_F },
{ LedId.Keyboard_G, AsusLedId.KEY_G },
{ LedId.Keyboard_H, AsusLedId.KEY_H },
{ LedId.Keyboard_J, AsusLedId.KEY_J },
{ LedId.Keyboard_K, AsusLedId.KEY_K },
{ LedId.Keyboard_L, AsusLedId.KEY_L },
{ LedId.Keyboard_SemicolonAndColon, AsusLedId.KEY_SEMICOLON },
{ LedId.Keyboard_ApostropheAndDoubleQuote, AsusLedId.KEY_APOSTROPHE },
{ LedId.Keyboard_GraveAccentAndTilde, AsusLedId.KEY_GRAVE },
{ LedId.Keyboard_LeftShift, AsusLedId.KEY_LSHIFT },
{ LedId.Keyboard_Backslash, AsusLedId.KEY_BACKSLASH },
{ LedId.Keyboard_Z, AsusLedId.KEY_Z },
{ LedId.Keyboard_X, AsusLedId.KEY_X },
{ LedId.Keyboard_C, AsusLedId.KEY_C },
{ LedId.Keyboard_V, AsusLedId.KEY_V },
{ LedId.Keyboard_B, AsusLedId.KEY_B },
{ LedId.Keyboard_N, AsusLedId.KEY_N },
{ LedId.Keyboard_M, AsusLedId.KEY_M },
{ LedId.Keyboard_CommaAndLessThan, AsusLedId.KEY_COMMA },
{ LedId.Keyboard_PeriodAndBiggerThan, AsusLedId.KEY_PERIOD },
{ LedId.Keyboard_SlashAndQuestionMark, AsusLedId.KEY_SLASH },
{ LedId.Keyboard_RightShift, AsusLedId.KEY_RSHIFT },
{ LedId.Keyboard_LeftCtrl, AsusLedId.KEY_LCONTROL },
{ LedId.Keyboard_LeftGui, AsusLedId.KEY_LWIN },
{ LedId.Keyboard_LeftAlt, AsusLedId.KEY_LMENU },
{ LedId.Keyboard_Space, AsusLedId.KEY_SPACE },
{ LedId.Keyboard_RightAlt, AsusLedId.KEY_RMENU },
{ LedId.Keyboard_RightGui, AsusLedId.KEY_RWIN },
{ LedId.Keyboard_Application, AsusLedId.KEY_APPS },
{ LedId.Keyboard_RightCtrl, AsusLedId.KEY_RCONTROL },
{ LedId.Keyboard_PrintScreen, AsusLedId.KEY_SYSRQ },
{ LedId.Keyboard_ScrollLock, AsusLedId.KEY_SCROLL },
{ LedId.Keyboard_PauseBreak, AsusLedId.KEY_PAUSE },
{ LedId.Keyboard_Insert, AsusLedId.KEY_INSERT },
{ LedId.Keyboard_Home, AsusLedId.KEY_HOME },
{ LedId.Keyboard_PageUp, AsusLedId.KEY_PRIOR },
{ LedId.Keyboard_Delete, AsusLedId.KEY_DELETE },
{ LedId.Keyboard_End, AsusLedId.KEY_END },
{ LedId.Keyboard_PageDown, AsusLedId.KEY_NEXT },
{ LedId.Keyboard_ArrowUp, AsusLedId.KEY_UP },
{ LedId.Keyboard_ArrowLeft, AsusLedId.KEY_LEFT },
{ LedId.Keyboard_ArrowDown, AsusLedId.KEY_DOWN },
{ LedId.Keyboard_ArrowRight, AsusLedId.KEY_RIGHT },
{ LedId.Keyboard_NumLock, AsusLedId.KEY_NUMLOCK },
{ LedId.Keyboard_NumSlash, AsusLedId.KEY_DIVIDE },
{ LedId.Keyboard_NumAsterisk, AsusLedId.KEY_MULTIPLY },
{ LedId.Keyboard_NumMinus, AsusLedId.KEY_SUBTRACT },
{ LedId.Keyboard_Num7, AsusLedId.KEY_NUMPAD7 },
{ LedId.Keyboard_Num8, AsusLedId.KEY_NUMPAD8 },
{ LedId.Keyboard_Num9, AsusLedId.KEY_NUMPAD9 },
{ LedId.Keyboard_NumPeriodAndDelete, AsusLedId.KEY_DECIMAL },
{ LedId.Keyboard_NumPlus, AsusLedId.KEY_ADD },
{ LedId.Keyboard_Num4, AsusLedId.KEY_NUMPAD4 },
{ LedId.Keyboard_Num5, AsusLedId.KEY_NUMPAD5 },
{ LedId.Keyboard_Num6, AsusLedId.KEY_NUMPAD6 },
{ LedId.Keyboard_Num1, AsusLedId.KEY_NUMPAD1 },
{ LedId.Keyboard_Num2, AsusLedId.KEY_NUMPAD2 },
{ LedId.Keyboard_Num3, AsusLedId.KEY_NUMPAD3 },
{ LedId.Keyboard_Num0, AsusLedId.KEY_NUMPAD0 },
{ LedId.Keyboard_NumEnter, AsusLedId.KEY_NUMPADENTER },
{ LedId.Keyboard_NonUsBackslash, AsusLedId.UNDOCUMENTED_1 },
{ LedId.Keyboard_NonUsTilde, AsusLedId.UNDOCUMENTED_2 },
{ LedId.Keyboard_NumComma, AsusLedId.KEY_NUMPADCOMMA },
{ LedId.Logo, AsusLedId.UNDOCUMENTED_3 },
{ LedId.Keyboard_Function, AsusLedId.KEY_FN },
{ LedId.Keyboard_MediaMute, AsusLedId.KEY_MUTE },
{ LedId.Keyboard_MediaPlay, AsusLedId.KEY_PLAYPAUSE },
{ LedId.Keyboard_MediaStop, AsusLedId.KEY_MEDIASTOP },
{ LedId.Keyboard_MediaVolumeDown, AsusLedId.KEY_VOLUMEDOWN },
{ LedId.Keyboard_MediaVolumeUp, AsusLedId.KEY_VOLUMEUP },
{ LedId.Keyboard_Custom1, AsusLedId.KEY_F13 },
{ LedId.Keyboard_Custom2, AsusLedId.KEY_F14 },
{ LedId.Keyboard_Custom3, AsusLedId.KEY_F15 },
{ LedId.Keyboard_Custom4, AsusLedId.KEY_KANA },
{ LedId.Keyboard_Custom5, AsusLedId.KEY_ABNT_C1 },
{ LedId.Keyboard_Custom6, AsusLedId.KEY_CONVERT },
{ LedId.Keyboard_Custom7, AsusLedId.KEY_NOCONVERT },
{ LedId.Keyboard_Custom8, AsusLedId.KEY_YEN },
{ LedId.Keyboard_Custom9, AsusLedId.KEY_ABNT_C2 },
{ LedId.Keyboard_Custom10, AsusLedId.KEY_NUMPADEQUALS },
{ LedId.Keyboard_Custom11, AsusLedId.KEY_CIRCUMFLEX },
{ LedId.Keyboard_Custom12, AsusLedId.KEY_AT },
{ LedId.Keyboard_Custom13, AsusLedId.KEY_COLON },
{ LedId.Keyboard_Custom14, AsusLedId.KEY_UNDERLINE },
{ LedId.Keyboard_Custom15, AsusLedId.KEY_KANJI },
{ LedId.Keyboard_Custom16, AsusLedId.KEY_STOP },
{ LedId.Keyboard_Custom17, AsusLedId.KEY_AX },
{ LedId.Keyboard_Custom18, AsusLedId.KEY_UNLABELED },
{ LedId.Keyboard_Custom19, AsusLedId.KEY_NEXTTRACK },
{ LedId.Keyboard_Custom20, AsusLedId.KEY_CALCULATOR },
{ LedId.Keyboard_Custom21, AsusLedId.KEY_POWER },
{ LedId.Keyboard_Custom22, AsusLedId.KEY_SLEEP },
{ LedId.Keyboard_Custom23, AsusLedId.KEY_WAKE },
{ LedId.Keyboard_Custom24, AsusLedId.KEY_WEBSEARCH },
{ LedId.Keyboard_Custom25, AsusLedId.KEY_WEBFAVORITES },
{ LedId.Keyboard_Custom26, AsusLedId.KEY_WEBREFRESH },
{ LedId.Keyboard_Custom27, AsusLedId.KEY_WEBSTOP },
{ LedId.Keyboard_Custom28, AsusLedId.KEY_WEBFORWARD },
{ LedId.Keyboard_Custom29, AsusLedId.KEY_WEBHOME },
{ LedId.Keyboard_Custom30, AsusLedId.KEY_WEBBACK },
{ LedId.Keyboard_Custom31, AsusLedId.KEY_MYCOMPUTER },
{ LedId.Keyboard_Custom32, AsusLedId.KEY_MAIL },
{ LedId.Keyboard_Custom33, AsusLedId.KEY_MEDIASELECT },
{ LedId.Keyboard_Custom34, AsusLedId.UNDOCUMENTED_4 },
{ LedId.Keyboard_Custom35, AsusLedId.UNDOCUMENTED_5 },
{ LedId.Keyboard_Custom36, AsusLedId.UNDOCUMENTED_6 }
};
/// <summary>
/// A LED mapping containing extra lights for the ROG Zephyrus Duo 15
@ -170,20 +169,19 @@ namespace RGB.NET.Devices.Asus
/// </para>
/// <para>You may add more of these by further populating <see cref="AsusKeyboardRGBDevice.ExtraLedMappings"/>.</para>
/// </summary>
public static readonly LedMapping<int> ROGZephyrusDuo15 =
new()
{
{LedId.Keyboard_Custom50, 39}, // Mapping starts at Custom50 to avoid possible conflicts with KeyboardMapping above
{LedId.Keyboard_Custom51, 40},
{LedId.Keyboard_Custom52, 55},
{LedId.Keyboard_Custom53, 57},
{LedId.Keyboard_Custom54, 97},
{LedId.Keyboard_Custom55, 99},
{LedId.Keyboard_Custom56, 118},
{LedId.Keyboard_Custom57, 120},
{LedId.Keyboard_Custom58, 130},
{LedId.Keyboard_Custom59, 131},
{LedId.Keyboard_Custom60, 133},
};
public static LedMapping<int> ROGZephyrusDuo15 { get; } = new()
{
{ LedId.Keyboard_Custom50, 39 }, // Mapping starts at Custom50 to avoid possible conflicts with KeyboardMapping above
{ LedId.Keyboard_Custom51, 40 },
{ LedId.Keyboard_Custom52, 55 },
{ LedId.Keyboard_Custom53, 57 },
{ LedId.Keyboard_Custom54, 97 },
{ LedId.Keyboard_Custom55, 99 },
{ LedId.Keyboard_Custom56, 118 },
{ LedId.Keyboard_Custom57, 120 },
{ LedId.Keyboard_Custom58, 130 },
{ LedId.Keyboard_Custom59, 131 },
{ LedId.Keyboard_Custom60, 133 },
};
}
}

View File

@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Asus
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
/// Keep a list of those and rely on <see cref="WMIHelper.GetSystemModelInfo()"/> to get the real model
/// </summary>
private static List<string> GenericDeviceNames = new() {"NotebookKeyboard"};
private static readonly List<string> GENERIC_DEVICE_NAMES = new() { "NotebookKeyboard" };
/// <inheritdoc />
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
@ -37,10 +37,7 @@ namespace RGB.NET.Devices.Asus
#region Methods
private static string? GetKeyboardModel(string deviceName)
{
return GenericDeviceNames.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName;
}
private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName;
#endregion
}

View File

@ -44,7 +44,7 @@ namespace RGB.NET.Devices.CoolerMaster
this.DeviceType = deviceType;
this.DeviceIndex = deviceIndex;
Model = deviceIndex.GetDescription() ?? "Unknown";
Model = deviceIndex.GetDescription();
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.CoolerMaster
{
#region Properties & Fields
private CoolerMasterDevicesIndexes _deviceIndex;
private readonly CoolerMasterDevicesIndexes _deviceIndex;
private readonly _CoolerMasterColorMatrix _deviceMatrix;
#endregion
@ -29,8 +29,7 @@ namespace RGB.NET.Devices.CoolerMaster
{
this._deviceIndex = deviceIndex;
_deviceMatrix = new _CoolerMasterColorMatrix();
_deviceMatrix.KeyColor = new _CoolerMasterKeyColor[_CoolerMasterColorMatrix.ROWS, _CoolerMasterColorMatrix.COLUMNS];
_deviceMatrix = new _CoolerMasterColorMatrix { KeyColor = new _CoolerMasterKeyColor[_CoolerMasterColorMatrix.ROWS, _CoolerMasterColorMatrix.COLUMNS] };
}
#endregion

View File

@ -15,7 +15,7 @@ namespace RGB.NET.Devices.CoolerMaster.Helper
/// </summary>
/// <param name="source">The enum value to get the description from.</param>
/// <returns>The value of the <see cref="DescriptionAttribute"/> or the <see cref="Enum.ToString()" /> result of the source.</returns>
internal static string? GetDescription(this Enum source)
internal static string GetDescription(this Enum source)
=> source.GetAttribute<DescriptionAttribute>()?.Description ?? source.ToString();
/// <summary>

View File

@ -18,7 +18,9 @@ namespace RGB.NET.Devices.CoolerMaster
/// <param name="info">The specific information provided by CoolerMaster for the mouse</param>
internal CoolerMasterMouseRGBDevice(CoolerMasterMouseRGBDeviceInfo info, IDeviceUpdateTrigger updateTrigger)
: base(info, updateTrigger)
{ }
{
InitializeLayout();
}
#endregion

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMethodReturnValue.Global
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
@ -53,13 +54,10 @@ namespace RGB.NET.Devices.CoolerMaster.Native
_setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer));
}
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion

View File

@ -80,7 +80,7 @@ namespace RGB.NET.Devices.Corsair
// DarthAffe 02.02.2021: 127 is iCUE
if (!_CUESDK.CorsairSetLayerPriority(128))
Throw(new CUEException(LastError), false);
Throw(new CUEException(LastError));
}
/// <inheritdoc />

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMethodReturnValue.Global
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
@ -61,13 +62,13 @@ namespace RGB.NET.Devices.Corsair.Native
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion

View File

@ -1,6 +1,8 @@
#pragma warning disable 169 // Field 'x' is never used
#pragma warning disable 414 // Field 'x' is assigned but its value never used
#pragma warning disable 649 // Field 'x' is never assigned
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable NotAccessedField.Global
using System.Runtime.InteropServices;

View File

@ -15,7 +15,7 @@ namespace RGB.NET.Devices.DMX.E131
/// <summary>
/// The UDP-Connection used to send data.
/// </summary>
private UdpClient _socket;
private readonly UdpClient _socket;
/// <summary>
/// Gets the byte-representation of a E1.31 packet as described in http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf.
@ -26,7 +26,7 @@ namespace RGB.NET.Devices.DMX.E131
/// <summary>
/// The sequence-number used to detect the order in which packages where sent.
/// </summary>
private byte _sequenceNumber = 0;
private byte _sequenceNumber;
#endregion

View File

@ -1,4 +1,4 @@
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Logitech
{

View File

@ -140,10 +140,10 @@ namespace RGB.NET.Devices.Logitech
//TODO DarthAffe 04.03.2021: Rework device selection and configuration for HID-based providers
protected override IEnumerable<IRGBDevice> LoadDevices()
{
IEnumerable<(HIDDeviceDefinition<LogitechLedId, int> definition, HidDevice device)> perKeyDevices = PerKeyDeviceDefinitions.GetConnectedDevices();
if ((_perKeyUpdateQueue != null) && perKeyDevices.Any())
(HIDDeviceDefinition<LogitechLedId, int> definition, HidDevice device) perKeyDevice = PerKeyDeviceDefinitions.GetConnectedDevices().FirstOrDefault();
if ((_perKeyUpdateQueue != null) && (perKeyDevice != default))
{
(HIDDeviceDefinition<LogitechLedId, int> definition, _) = perKeyDevices.First();
(HIDDeviceDefinition<LogitechLedId, int> definition, _) = perKeyDevice;
yield return new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.PerKeyRGB, 0), _perKeyUpdateQueue, definition.LedMapping);
}
@ -154,10 +154,10 @@ namespace RGB.NET.Devices.Logitech
yield return new LogitechZoneRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, definition.CustomData.zones), updateQueue, definition.LedMapping);
}
IEnumerable<(HIDDeviceDefinition<int, int> definition, HidDevice device)> perDeviceDevices = PerDeviceDeviceDefinitions.GetConnectedDevices();
if ((_perDeviceUpdateQueue != null) && perDeviceDevices.Any())
(HIDDeviceDefinition<int, int> definition, HidDevice device) perDeviceDevice = PerDeviceDeviceDefinitions.GetConnectedDevices().FirstOrDefault();
if ((_perDeviceUpdateQueue != null) && (perDeviceDevice != default))
{
(HIDDeviceDefinition<int, int> definition, _) = perDeviceDevices.First();
(HIDDeviceDefinition<int, int> definition, _) = perDeviceDevice;
yield return new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(definition.DeviceType, definition.Name, LogitechDeviceCaps.DeviceRGB, 0), _perDeviceUpdateQueue, definition.LedMapping);
}
}
@ -172,6 +172,8 @@ namespace RGB.NET.Devices.Logitech
try { _LogitechGSDK.UnloadLogitechGSDK(); }
catch { /* at least we tried */ }
GC.SuppressFinalize(this);
}
#endregion

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMethodReturnValue.Global
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
@ -62,13 +63,13 @@ namespace RGB.NET.Devices.Logitech.Native
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion

View File

@ -40,7 +40,7 @@ namespace RGB.NET.Devices.Logitech
}
/// <inheritdoc />
protected override object? GetLedCustomData(LedId ledId) => _ledMapping[ledId];
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate));

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMethodReturnValue.Global
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
@ -65,16 +66,16 @@ namespace RGB.NET.Devices.Msi.Native
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern bool SetDllDirectory(string lpPathName);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion

View File

@ -41,16 +41,13 @@ namespace RGB.NET.Devices.Novation
{
(double hue, double _, double value) = color.GetHSV();
if ((hue >= 330) || (hue < 30))
return (int)Math.Ceiling(value * 3); // red with brightness 1, 2 or 3
if ((hue >= 30) && (hue < 90)) // yellow with brightness 17, 34 or 51
return (int)Math.Ceiling(value * 3) * 17;
if ((hue >= 90) && (hue < 150)) // green with brightness 16, 32 or 48
return (int)Math.Ceiling(value * 3) * 16;
return 0;
return hue switch
{
>= 330 or < 30 => (int)Math.Ceiling(value * 3), // red with brightness 1, 2 or 3
>= 30 and < 90 => (int)Math.Ceiling(value * 3) * 17, // yellow with brightness 17, 34 or 51
>= 90 and < 150 => (int)Math.Ceiling(value * 3) * 16, // green with brightness 16, 32 or 48
_ => 0
};
}
/// <inheritdoc />

View File

@ -5,11 +5,10 @@ using Sanford.Multimedia.Midi;
namespace RGB.NET.Devices.Novation
{
/// <inheritdoc cref="UpdateQueue" />
/// <inheritdoc cref="IDisposable" />
/// <summary>
/// Represents the update-queue performing updates for midi devices.
/// </summary>
public abstract class MidiUpdateQueue : UpdateQueue, IDisposable
public abstract class MidiUpdateQueue : UpdateQueue
{
#region Properties & Fields
@ -66,6 +65,8 @@ namespace RGB.NET.Devices.Novation
base.Dispose();
_outputDevice.Dispose();
GC.SuppressFinalize(this);
}
#endregion

View File

@ -40,7 +40,9 @@ namespace RGB.NET.Devices.Novation
}
/// <inheritdoc />
// ReSharper disable RedundantCast
protected override object GetLedCustomData(LedId ledId) => GetDeviceMapping().TryGetValue(ledId, out (byte mode, byte id, int _, int __) data) ? (data.mode, data.id) : ((byte)0x00, (byte)0x00);
// ReSharper restore RedundantCast
protected virtual Dictionary<LedId, (byte mode, byte id, int x, int y)> GetDeviceMapping()
=> DeviceInfo.LedIdMapping switch

View File

@ -1,4 +1,6 @@
namespace RGB.NET.Devices.PicoPi.Enum
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.PicoPi.Enum
{
public enum UpdateMode
{

View File

@ -38,7 +38,7 @@ namespace RGB.NET.Devices.PicoPi
private readonly byte[] _hidSendBuffer;
private readonly byte[] _bulkSendBuffer;
private int _bulkTransferLength = 0;
private int _bulkTransferLength;
public bool IsBulkSupported { get; private set; }
@ -181,7 +181,7 @@ namespace RGB.NET.Devices.PicoPi
{
if ((data.Length == 0) || !IsBulkSupported) return;
Span<byte> sendBuffer = new Span<byte>(_bulkSendBuffer).Slice(2);
Span<byte> sendBuffer = new Span<byte>(_bulkSendBuffer)[2..];
int payloadSize = data.Length;
sendBuffer[_bulkTransferLength++] = (byte)((channel << 4) | COMMAND_UPDATE_BULK);
@ -212,6 +212,8 @@ namespace RGB.NET.Devices.PicoPi
_hidStream.Dispose();
_bulkDevice?.Dispose();
_usbContext?.Dispose();
GC.SuppressFinalize(this);
}
#endregion

View File

@ -3,7 +3,7 @@
/// <summary>
/// Razer-SDK: Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK.
/// </summary>
public enum RazerError : int
public enum RazerError
{
/// <summary>
/// Razer-SDK: Invalid.

View File

@ -5,7 +5,7 @@ namespace RGB.NET.Devices.Razer
{
public static class LedMappings
{
public static readonly LedMapping<int> Keyboard = new()
public static LedMapping<int> Keyboard { get; } = new()
{
//Row 0 is empty
@ -154,7 +154,7 @@ namespace RGB.NET.Devices.Razer
//Row 7 is also empty
};
public static readonly LedMapping<int> LaptopKeyboard = new()
public static LedMapping<int> LaptopKeyboard { get; } = new()
{
//Row 0 is empty
@ -272,7 +272,7 @@ namespace RGB.NET.Devices.Razer
//Row 7 is also empty
};
public static readonly LedMapping<int> Mouse = new()
public static LedMapping<int> Mouse { get; } = new()
{
//row 0 empty
@ -316,12 +316,12 @@ namespace RGB.NET.Devices.Razer
};
//TODO DarthAffe 27.04.2021: Are mappings for these possible?
public static readonly LedMapping<int> Mousepad = new();
public static LedMapping<int> Mousepad { get; } = new();
public static readonly LedMapping<int> Headset = new();
public static LedMapping<int> Headset { get; } = new();
public static readonly LedMapping<int> Keypad = new();
public static LedMapping<int> Keypad { get; } = new();
public static readonly LedMapping<int> ChromaLink = new();
public static LedMapping<int> ChromaLink { get; } = new();
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.Razer
@ -32,10 +33,12 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc />
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
try { UpdateQueue.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
GC.SuppressFinalize(this);
}
#endregion

View File

@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Razer
}
/// <inheritdoc />
protected override object? GetLedCustomData(LedId ledId) => _ledMapping[ledId];
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
#endregion
}

View File

@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Razer
}
/// <inheritdoc />
protected override object? GetLedCustomData(LedId ledId) => _ledMapping[ledId];
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
#endregion
}

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,7 @@
namespace RGB.NET.Devices.Razer.Native
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Razer.Native
{
internal static class _Defines
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.Razer.Native
{

View File

@ -1,4 +1,5 @@
// ReSharper disable UnusedMethodReturnValue.Global
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
using System;
@ -61,13 +62,13 @@ namespace RGB.NET.Devices.Razer.Native
_dllHandle = IntPtr.Zero;
}
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion

View File

@ -13,6 +13,7 @@ namespace RGB.NET.Devices.SteelSeries.API.Model
[JsonPropertyName("event")]
public string? Name { get; set; }
// ReSharper disable once CollectionNeverQueried.Global
[JsonPropertyName("data")]
public Dictionary<string, object> Data { get; } = new();

View File

@ -114,6 +114,9 @@ namespace RGB.NET.Devices.SteelSeries.API
_client.Dispose();
}
#pragma warning disable IDE0051 // Remove unused private members
// ReSharper disable UnusedMethodReturnValue.Local
// ReSharper disable UnusedMember.Local
private static string TriggerEvent(Event e) => PostJson("/game_event", e);
private static string RegisterGoLispHandler(GoLispHandler handler) => PostJson("/load_golisp_handlers", handler);
private static string RegisterEvent(Event e) => PostJson("/register_game_event", e);
@ -122,6 +125,9 @@ namespace RGB.NET.Devices.SteelSeries.API
private static string UnregisterGame(Game game) => PostJson("/remove_game", game);
private static string StopGame(Game game) => PostJson("/stop_game", game);
private static string SendHeartbeat(Game game) => PostJson("/game_heartbeat", game);
// ReSharper restore UnusedMember.Local
// ReSharper restore UnusedMethodReturnValue.Local
#pragma warning restore IDE0051 // Remove unused private members
private static string PostJson(string urlSuffix, object o)
{

View File

@ -1,4 +1,6 @@
namespace RGB.NET.Devices.SteelSeries
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.SteelSeries
{
public enum SteelSeriesLedId
{

View File

@ -1,4 +1,6 @@
namespace RGB.NET.Devices.Wooting.Enum
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Wooting.Enum
{
public enum WootingDeviceType
{

View File

@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
using RGB.NET.Devices.Wooting.Enum;
namespace RGB.NET.Devices.Wooting.Native

View File

@ -149,8 +149,6 @@ namespace RGB.NET.Layout
XmlNode? node = (customData as XmlNode) ?? (customData as IEnumerable<XmlNode>)?.FirstOrDefault()?.ParentNode; //HACK DarthAffe 16.01.2021: This gives us the CustomData-Node
if ((node == null) || (type == null)) return null;
if (type == null) return null;
using MemoryStream ms = new();
using StreamWriter writer = new(ms);

View File

@ -1,4 +1,6 @@
using System;
// ReSharper disable EventNeverSubscribedTo.Global
using System;
using RGB.NET.Core;
using RGB.NET.Presets.Decorators;

View File

@ -258,13 +258,16 @@
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=DebuggerStepsThrough/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Properties/Options/=XmlDocumentation/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/IntroduceVariableUseVar/UseVarForIntroduceVariableRefactoringEvident/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=131DMX/@EntryIndexedValue">131DMX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AFBG/@EntryIndexedValue">AFBG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ARGB/@EntryIndexedValue">ARGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BGR/@EntryIndexedValue">BGR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BWZ/@EntryIndexedValue">BWZ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CID/@EntryIndexedValue">CID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CM/@EntryIndexedValue">CM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CMSDK/@EntryIndexedValue">CMSDK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CUE/@EntryIndexedValue">CUE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CUESDK/@EntryIndexedValue">CUESDK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DG/@EntryIndexedValue">DG</s:String>
@ -273,6 +276,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EK/@EntryIndexedValue">EK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FM/@EntryIndexedValue">FM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GEZ/@EntryIndexedValue">GEZ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GSDK/@EntryIndexedValue">GSDK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HS/@EntryIndexedValue">HS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HSV/@EntryIndexedValue">HSV</s:String>
@ -284,6 +288,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PDF/@EntryIndexedValue">PDF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PLZ/@EntryIndexedValue">PLZ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ROG/@EntryIndexedValue">ROG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SAP/@EntryIndexedValue">SAP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SDK/@EntryIndexedValue">SDK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String>