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
@@ -101,7 +101,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
_CoolerMasterSDK.SetControlDevice(index);
|
||||
if (_CoolerMasterSDK.IsDevicePlugged())
|
||||
{
|
||||
CoolerMasterRGBDevice device;
|
||||
ICoolerMasterRGBDevice device;
|
||||
switch (index.GetDeviceType())
|
||||
{
|
||||
case RGBDeviceType.Keyboard:
|
||||
|
||||
@@ -12,24 +12,25 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <summary>
|
||||
/// Represents a generic CoolerMaster-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class CoolerMasterRGBDevice : AbstractRGBDevice
|
||||
public abstract class CoolerMasterRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ICoolerMasterRGBDevice
|
||||
where TDeviceInfo : CoolerMasterRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
public override TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CoolerMasterRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="CoolerMasterRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by CoolerMaster for the device.</param>
|
||||
protected CoolerMasterRGBDevice(IRGBDeviceInfo info)
|
||||
protected CoolerMasterRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
@@ -42,7 +43,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
@@ -105,7 +106,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
|
||||
if (leds.Count > 0)
|
||||
{
|
||||
_CoolerMasterSDK.SetControlDevice(((CoolerMasterRGBDeviceInfo)DeviceInfo).DeviceIndex);
|
||||
_CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex);
|
||||
|
||||
foreach (Led led in leds)
|
||||
{
|
||||
@@ -120,7 +121,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
_CoolerMasterSDK.SetControlDevice(((CoolerMasterRGBDeviceInfo)DeviceInfo).DeviceIndex);
|
||||
_CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex);
|
||||
_CoolerMasterSDK.EnableLedControl(false);
|
||||
|
||||
base.Dispose();
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.CoolerMaster
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a CoolerMaster RGB-device.
|
||||
/// </summary>
|
||||
internal interface ICoolerMasterRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,8 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <summary>
|
||||
/// Represents a CoolerMaster keyboard.
|
||||
/// </summary>
|
||||
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice
|
||||
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CoolerMasterKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CoolerMasterKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -28,9 +19,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <param name="info">The specific information provided by CoolerMaster for the keyboard</param>
|
||||
internal CoolerMasterKeyboardRGBDevice(CoolerMasterKeyboardRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.KeyboardDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -39,16 +28,16 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
Dictionary<CoolerMasterLedIds, Tuple<int, int>> mapping = CoolerMasterKeyboardLedMappings.Mapping[KeyboardDeviceInfo.DeviceIndex][KeyboardDeviceInfo.PhysicalLayout];
|
||||
Dictionary<CoolerMasterLedIds, Tuple<int, int>> mapping = CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout];
|
||||
|
||||
foreach (KeyValuePair<CoolerMasterLedIds, Tuple<int, int>> led in mapping)
|
||||
InitializeLed(new CoolerMasterLedId(this, led.Key, led.Value.Item1, led.Value.Item2),
|
||||
new Rectangle(led.Value.Item2 * 19, led.Value.Item1 * 19, 19, 19));
|
||||
|
||||
string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
|
||||
$@"Layouts\CoolerMaster\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards"));
|
||||
$@"Layouts\CoolerMaster\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<Compile Include="Generic\CoolerMasterLedId.cs" />
|
||||
<Compile Include="Generic\CoolerMasterRGBDevice.cs" />
|
||||
<Compile Include="Generic\CoolerMasterRGBDeviceInfo.cs" />
|
||||
<Compile Include="Generic\ICoolerMasterRGBDevice.cs" />
|
||||
<Compile Include="Helper\EnumExtension.cs" />
|
||||
<Compile Include="Keyboard\CoolerMasterKeyboardRGBDevice.cs" />
|
||||
<Compile Include="Keyboard\CoolerMasterKeyboardRGBDeviceInfo.cs" />
|
||||
|
||||
Reference in new issue
Block a user