mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Added generic DeviceInfo to Devices
This commit is contained in:
1 parent
86bc26233b
commit
67fcc8e52e
38 files changed
+210
-246
No files matched your search
@@ -129,7 +129,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
||||
continue; // Everything that doesn't support lighting control is useless
|
||||
|
||||
CorsairRGBDevice device;
|
||||
ICorsairRGBDevice device;
|
||||
switch (info.CorsairDeviceType)
|
||||
{
|
||||
case CorsairDeviceType.Keyboard:
|
||||
@@ -178,7 +178,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddSpecialParts(CorsairRGBDevice device)
|
||||
private void AddSpecialParts(ICorsairRGBDevice device)
|
||||
{
|
||||
if (device.DeviceInfo.Model.Equals("K95 RGB Platinum", StringComparison.OrdinalIgnoreCase))
|
||||
device.AddSpecialDevicePart(new LightbarSpecialPart(device));
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class CorsairRGBDevice : AbstractRGBDevice
|
||||
public abstract class CorsairRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ICorsairRGBDevice
|
||||
where TDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@@ -21,17 +22,17 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.Corsair.CorsairRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
public override TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="CorsairRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by CUE for the device.</param>
|
||||
protected CorsairRGBDevice(IRGBDeviceInfo info)
|
||||
protected CorsairRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
@@ -43,7 +44,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a corsair RGB-device.
|
||||
/// </summary>
|
||||
internal interface ICorsairRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@@ -9,17 +9,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Represents a corsair headset.
|
||||
/// </summary>
|
||||
public class CorsairHeadsetRGBDevice : CorsairRGBDevice
|
||||
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CorsairHeadsetRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CorsairHeadsetRGBDeviceInfo HeadsetDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -29,9 +20,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="info">The specific information provided by CUE for the headset</param>
|
||||
internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.HeadsetDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -43,7 +32,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
InitializeLed(new CorsairLedId(this, CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10));
|
||||
InitializeLed(new CorsairLedId(this, CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10));
|
||||
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{HeadsetDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Headsets"));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Represents a corsair keyboard.
|
||||
/// </summary>
|
||||
public class CorsairKeyboardRGBDevice : CorsairRGBDevice
|
||||
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CorsairKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CorsairKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -32,9 +23,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="info">The specific information provided by CUE for the keyboard</param>
|
||||
internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.KeyboardDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -58,10 +47,10 @@ namespace RGB.NET.Devices.Corsair
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
}
|
||||
|
||||
string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
|
||||
$@"Layouts\Corsair\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards"));
|
||||
$@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Represents a corsair mouse.
|
||||
/// </summary>
|
||||
public class CorsairMouseRGBDevice : CorsairRGBDevice
|
||||
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CorsairMouseRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CorsairMouseRGBDeviceInfo MouseDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="info">The specific information provided by CUE for the mouse</param>
|
||||
internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.MouseDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -41,7 +30,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
switch (MouseDeviceInfo.PhysicalLayout)
|
||||
switch (DeviceInfo.PhysicalLayout)
|
||||
{
|
||||
case CorsairPhysicalMouseLayout.Zones1:
|
||||
InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10));
|
||||
@@ -62,10 +51,10 @@ namespace RGB.NET.Devices.Corsair
|
||||
InitializeLed(new CorsairLedId(this, CorsairLedIds.B4), new Rectangle(30, 0, 10, 10));
|
||||
break;
|
||||
default:
|
||||
throw new RGBDeviceException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
|
||||
throw new RGBDeviceException($"Can't initial mouse with layout '{DeviceInfo.PhysicalLayout}'");
|
||||
}
|
||||
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{MouseDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mice"));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <summary>
|
||||
/// Represents a corsair mousepad.
|
||||
/// </summary>
|
||||
public class CorsairMousepadRGBDevice : CorsairRGBDevice
|
||||
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CorsairMousepadRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CorsairMousepadRGBDeviceInfo MousepadDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -34,9 +25,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="info">The specific information provided by CUE for the mousepad</param>
|
||||
internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.MousepadDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -47,7 +36,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
_CorsairLedPositions nativeLedPositions =
|
||||
(_CorsairLedPositions)
|
||||
Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(MousepadDeviceInfo.CorsairDeviceIndex),
|
||||
Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex),
|
||||
typeof(_CorsairLedPositions));
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
@@ -65,7 +54,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
InitializeLed(new CorsairLedId(this, ledPosition.ledId),
|
||||
new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
|
||||
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{MousepadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mousepads"));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<Compile Include="Generic\CorsairProtocolDetails.cs" />
|
||||
<Compile Include="Generic\CorsairRGBDeviceInfo.cs" />
|
||||
<Compile Include="Generic\CorsairRGBDevice.cs" />
|
||||
<Compile Include="Generic\ICorsairRGBDevice.cs" />
|
||||
<Compile Include="Headset\CorsairHeadsetRGBDevice.cs" />
|
||||
<Compile Include="Headset\CorsairHeadsetRGBDeviceInfo.cs" />
|
||||
<Compile Include="Keyboard\CorsairKeyboardRGBDevice.cs" />
|
||||
|
||||
Reference in new issue
Block a user