Fixed code issues

This commit is contained in:
DarthAffe committed 2021-07-31 16:59:51 +02:00
1 parent 7b0e9152fd
commit 59e11e5b82
120 files changed
+1348 -342

No files matched your search

@@ -21,6 +21,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, new LedMapping<CorsairLedId>(), updateQueue)
{ }
@@ -49,32 +49,21 @@ namespace RGB.NET.Devices.Corsair
#region Methods
private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType)
{
switch (deviceType)
=> deviceType switch
{
case CorsairChannelDeviceType.Invalid:
return RGBDeviceType.Unknown;
case CorsairChannelDeviceType.FanHD:
case CorsairChannelDeviceType.FanSP:
case CorsairChannelDeviceType.FanLL:
case CorsairChannelDeviceType.FanML:
case CorsairChannelDeviceType.DAP:
case CorsairChannelDeviceType.FanQL:
case CorsairChannelDeviceType.FanSPPRO:
return RGBDeviceType.Fan;
case CorsairChannelDeviceType.Strip:
return RGBDeviceType.LedStripe;
case CorsairChannelDeviceType.Pump:
case CorsairChannelDeviceType.WaterBlock:
return RGBDeviceType.Cooler;
default:
throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null);
}
}
CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown,
CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanML => RGBDeviceType.Fan,
CorsairChannelDeviceType.DAP => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanSPPRO => RGBDeviceType.Fan,
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
};
private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo)
{
@@ -126,7 +115,9 @@ namespace RGB.NET.Devices.Corsair
return "Pump";
default:
throw new ArgumentOutOfRangeException(nameof(channelDeviceInfo.type), channelDeviceInfo.type, null);
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null);
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
}
}
@@ -6,7 +6,7 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available SDK access modes.
/// Represents an SDK access mode.
/// </summary>
public enum CorsairAccessMode
{
@@ -7,7 +7,7 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available corsair channel device types.
/// Contains a list of available corsair channel device types.
/// </summary>
public enum CorsairChannelDeviceType
{
@@ -6,7 +6,7 @@ using System;
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of corsair device capabilities.
/// Contains a list of corsair device capabilities.
/// </summary>
[Flags]
public enum CorsairDeviceCaps
@@ -7,7 +7,7 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available corsair device types.
/// Contains a list of available corsair device types.
/// </summary>
public enum CorsairDeviceType
{
+3 -1
View File
@@ -1,9 +1,11 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of all LEDs available for all corsair devices.
/// Contains a list of all LEDs available for all corsair devices.
/// </summary>
public enum CorsairLedId
{
@@ -1,10 +1,11 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available logical layouts for corsair keyboards.
/// Contains a list of available logical layouts for corsair keyboards.
/// </summary>
public enum CorsairLogicalKeyboardLayout
{
@@ -4,7 +4,7 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available physical layouts for corsair keyboards.
/// Contains a list of available physical layouts for corsair keyboards.
/// </summary>
public enum CorsairPhysicalKeyboardLayout
{
@@ -1,7 +1,7 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains list of available physical layouts for mice.
/// Contains a list of available physical layouts for mice.
/// </summary>
public enum CorsairPhysicalMouseLayout
{
@@ -2,6 +2,9 @@
namespace RGB.NET.Devices.Corsair
{
/// <summary>
/// Contains mappings for <see cref="LedId"/> to <see cref="CorsairLedId"/>.
/// </summary>
public static class LedMappings
{
static LedMappings()
@@ -28,18 +31,43 @@ namespace RGB.NET.Devices.Corsair
Keyboard.Add(LedId.Custom101 + i, CorsairLedId.OemLed101 + i);
}
/// <summary>
/// Gets the mapping for graphics cards.
/// </summary>
public static LedMapping<CorsairLedId> GraphicsCard { get; } = new();
/// <summary>
/// Gets the mapping for headsets.
/// </summary>
public static LedMapping<CorsairLedId> HeadsetStand { get; } = new();
/// <summary>
/// Gets the mapping for mainboards.
/// </summary>
public static LedMapping<CorsairLedId> Mainboard { get; } = new();
/// <summary>
/// Gets the mapping for memory.
/// </summary>
public static LedMapping<CorsairLedId> Memory { get; } = new();
/// <summary>
/// Gets the mapping for mousepads.
/// </summary>
public static LedMapping<CorsairLedId> Mousepad { get; } = new();
/// <summary>
/// Gets the mapping for headsets.
/// </summary>
public static LedMapping<CorsairLedId> Headset { get; } = new()
{
{ LedId.Headset1, CorsairLedId.LeftLogo },
{ LedId.Headset2, CorsairLedId.RightLogo },
};
/// <summary>
/// Gets the mapping for mice.
/// </summary>
public static LedMapping<CorsairLedId> Mouse { get; } = new()
{
{ LedId.Mouse1, CorsairLedId.B1 },
@@ -64,6 +92,9 @@ namespace RGB.NET.Devices.Corsair
{ LedId.Mouse20, CorsairLedId.B20 },
};
/// <summary>
/// Gets the mapping for keyboards.
/// </summary>
public static LedMapping<CorsairLedId> Keyboard { get; } = new()
{
{ LedId.Invalid, CorsairLedId.Invalid },
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the graphics card.</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairGraphicsCardRGBDevice(CorsairGraphicsCardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.GraphicsCard, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the headset</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Headset, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the headset stand</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairHeadsetStandRGBDevice(CorsairHeadsetStandRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.HeadsetStand, updateQueue)
{ }
@@ -24,6 +24,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the keyboard</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Keyboard, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the memory.</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairMainboardRGBDevice(CorsairMainboardRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Mainboard, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the memory.</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairMemoryRGBDevice(CorsairMemoryRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Memory, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the mouse</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Mouse, updateQueue)
{ }
@@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the mousepad</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, LedMappings.Mousepad, updateQueue)
{ }
+1 -1
View File
@@ -68,7 +68,7 @@ namespace RGB.NET.Devices.Corsair.Native
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr dllHandle);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
[DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetProcAddress(IntPtr dllHandle, string name);
#endregion