mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Added generic DeviceInfo to Devices
This commit is contained in:
parent
86bc26233b
commit
67fcc8e52e
@ -12,12 +12,16 @@ namespace RGB.NET.Core
|
||||
/// <summary>
|
||||
/// Represents a generic RGB-device
|
||||
/// </summary>
|
||||
public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice
|
||||
public abstract class AbstractRGBDevice<TDeviceInfo> : AbstractBindable, IRGBDevice<TDeviceInfo>
|
||||
where TDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IRGBDeviceInfo DeviceInfo { get; }
|
||||
public abstract TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
|
||||
@ -137,20 +141,14 @@ namespace RGB.NET.Core
|
||||
/// Returns an enumerator that iterates over all <see cref="T:RGB.NET.Core.Led" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.
|
||||
/// </summary>
|
||||
/// <returns>An enumerator for all <see cref="T:RGB.NET.Core.Led" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.</returns>
|
||||
public IEnumerator<Led> GetEnumerator()
|
||||
{
|
||||
return LedMapping.Values.GetEnumerator();
|
||||
}
|
||||
public IEnumerator<Led> GetEnumerator() => LedMapping.Values.GetEnumerator();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates over all <see cref="T:RGB.NET.Core.Led" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.
|
||||
/// </summary>
|
||||
/// <returns>An enumerator for all <see cref="T:RGB.NET.Core.Led" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.</returns>
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ namespace RGB.NET.Core
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic RGB-device
|
||||
/// Represents a generic RGB-device.
|
||||
/// </summary>
|
||||
public interface IRGBDevice : IEnumerable<Led>, IBindable, IDisposable
|
||||
{
|
||||
@ -79,4 +79,17 @@ namespace RGB.NET.Core
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic RGB-device with an known device-info type.
|
||||
/// </summary>
|
||||
public interface IRGBDevice<out TDeviceInfo> : IRGBDevice
|
||||
where TDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets generic information about the <see cref="IRGBDevice"/>.
|
||||
/// </summary>
|
||||
new TDeviceInfo DeviceInfo { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,8 +109,7 @@ namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
IntPtr handle = Marshal.ReadIntPtr(mainboardHandles, i);
|
||||
_AsusSDK.SetMbMode(handle, 1);
|
||||
AsusMainboardRGBDevice device =
|
||||
new AsusMainboardRGBDevice(new AsusMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle));
|
||||
AsusMainboardRGBDevice device = new AsusMainboardRGBDevice(new AsusMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
|
||||
@ -12,7 +12,8 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a generic Asus-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class AsusRGBDevice : AbstractRGBDevice
|
||||
public abstract class AsusRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IAsusRGBDevice
|
||||
where TDeviceInfo : AsusRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@ -25,17 +26,17 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.Asus.AsusRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
public override TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AsusRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="AsusRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by Asus for the device.</param>
|
||||
protected AsusRGBDevice(IRGBDeviceInfo info)
|
||||
protected AsusRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
@ -43,11 +44,11 @@ namespace RGB.NET.Devices.Asus
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
|
||||
12
RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs
Normal file
12
RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a asus RGB-device.
|
||||
/// </summary>
|
||||
internal interface IAsusRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a Asus graphicsCard.
|
||||
/// </summary>
|
||||
public class AsusGraphicsCardRGBDevice : AsusRGBDevice
|
||||
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusGraphicsCardRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="AsusGraphicsCardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public AsusGraphicsCardRGBDeviceInfo GraphicsCardDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <param name="info">The specific information provided by Asus for the graphics card.</param>
|
||||
internal AsusGraphicsCardRGBDevice(AsusGraphicsCardRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.GraphicsCardDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 07.10.2017: Look for a good default layout
|
||||
int ledCount = _AsusSDK.GetGPULedCount(GraphicsCardDeviceInfo.Handle);
|
||||
int ledCount = _AsusSDK.GetGPULedCount(DeviceInfo.Handle);
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
InitializeLed(new AsusLedId(this, AsusLedIds.GraphicsCardLed1 + i, i), new Rectangle(i * 10, 0, 10, 10));
|
||||
|
||||
//TODO DarthAffe 07.10.2017: We don'T know the model, how to save layouts and images?
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{GraphicsCardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Asus\GraphicsCards"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ApplyColorData() => _AsusSDK.SetGPUColor(GraphicsCardDeviceInfo.Handle, ColorData);
|
||||
protected override void ApplyColorData() => _AsusSDK.SetGPUColor(DeviceInfo.Handle, ColorData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a Asus keyboard.
|
||||
/// </summary>
|
||||
public class AsusKeyboardRGBDevice : AsusRGBDevice
|
||||
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="AsusKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public AsusKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <param name="info">The specific information provided by Asus for the keyboard.</param>
|
||||
internal AsusKeyboardRGBDevice(AsusKeyboardRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.KeyboardDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 07.10.2017: Look for a good default layout
|
||||
int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(KeyboardDeviceInfo.Handle);
|
||||
int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(DeviceInfo.Handle);
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
InitializeLed(new AsusLedId(this, AsusLedIds.KeyboardLed1 + i, i), new Rectangle(i * 19, 0, 19, 19));
|
||||
|
||||
string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards"));
|
||||
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
|
||||
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ApplyColorData() => _AsusSDK.SetClaymoreKeyboardColor(KeyboardDeviceInfo.Handle, ColorData);
|
||||
protected override void ApplyColorData() => _AsusSDK.SetClaymoreKeyboardColor(DeviceInfo.Handle, ColorData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a Asus mainboard.
|
||||
/// </summary>
|
||||
public class AsusMainboardRGBDevice : AsusRGBDevice
|
||||
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusMainboardRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="AsusMainboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public AsusMainboardRGBDeviceInfo MainboardDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <param name="info">The specific information provided by Asus for the mainboard.</param>
|
||||
internal AsusMainboardRGBDevice(AsusMainboardRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.MainboardDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 07.10.2017: Look for a good default layout
|
||||
int ledCount = _AsusSDK.GetMbLedCount(MainboardDeviceInfo.Handle);
|
||||
int ledCount = _AsusSDK.GetMbLedCount(DeviceInfo.Handle);
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
InitializeLed(new AsusLedId(this, AsusLedIds.MainboardAudio1 + i, i), new Rectangle(i * 40, 0, 40, 8));
|
||||
|
||||
//TODO DarthAffe 07.10.2017: We don'T know the model, how to save layouts and images?
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{MainboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Asus\Mainboards"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ApplyColorData() => _AsusSDK.SetMbColor(MainboardDeviceInfo.Handle, ColorData);
|
||||
protected override void ApplyColorData() => _AsusSDK.SetMbColor(DeviceInfo.Handle, ColorData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a Asus mouse.
|
||||
/// </summary>
|
||||
public class AsusMouseRGBDevice : AsusRGBDevice
|
||||
public class AsusMouseRGBDevice : AsusRGBDevice<AsusMouseRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="AsusMouseRGBDevice"/>.
|
||||
/// </summary>
|
||||
public AsusMouseRGBDeviceInfo MouseDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <param name="info">The specific information provided by Asus for the mouse.</param>
|
||||
internal AsusMouseRGBDevice(AsusMouseRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.MouseDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -39,16 +28,16 @@ namespace RGB.NET.Devices.Asus
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
//TODO DarthAffe 07.10.2017: Look for a good default layout
|
||||
int ledCount = _AsusSDK.GetRogMouseLedCount(MouseDeviceInfo.Handle);
|
||||
int ledCount = _AsusSDK.GetRogMouseLedCount(DeviceInfo.Handle);
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
InitializeLed(new AsusLedId(this, AsusLedIds.MouseLed1 + i, i), new Rectangle(i * 10, 0, 10, 10));
|
||||
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{MouseDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"),
|
||||
null, PathHelper.GetAbsolutePath(@"Images\Asus\Mouses"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ApplyColorData() => _AsusSDK.SetRogMouseColor(MouseDeviceInfo.Handle, ColorData);
|
||||
protected override void ApplyColorData() => _AsusSDK.SetRogMouseColor(DeviceInfo.Handle, ColorData);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
<Compile Include="Generic\AsusRGBDevice.cs" />
|
||||
<Compile Include="Generic\AsusLedId.cs" />
|
||||
<Compile Include="Generic\AsusRGBDeviceInfo.cs" />
|
||||
<Compile Include="Generic\IAsusRGBDevice.cs" />
|
||||
<Compile Include="GraphicsCard\AsusGraphicsCardRGBDevice.cs" />
|
||||
<Compile Include="GraphicsCard\AsusGraphicsCardRGBDeviceInfo.cs" />
|
||||
<Compile Include="Keyboard\AsusKeyboardRGBDevice.cs" />
|
||||
|
||||
@ -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" />
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
12
RGB.NET.Devices.Corsair/Generic/ICorsairRGBDevice.cs
Normal file
12
RGB.NET.Devices.Corsair/Generic/ICorsairRGBDevice.cs
Normal file
@ -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" />
|
||||
|
||||
12
RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs
Normal file
12
RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a logitech RGB-device.
|
||||
/// </summary>
|
||||
internal interface ILogitechRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,8 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Represents a generic Logitech-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class LogitechRGBDevice : AbstractRGBDevice
|
||||
public abstract class LogitechRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, ILogitechRGBDevice
|
||||
where TDeviceInfo : LogitechRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@ -18,17 +19,17 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.Logitech.LogitechRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
public override TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LogitechRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="LogitechRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by Logitech for the device.</param>
|
||||
protected LogitechRGBDevice(IRGBDeviceInfo info)
|
||||
protected LogitechRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
@ -40,7 +41,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
if (DeviceChecker.IsPerKeyDeviceConnected)
|
||||
{
|
||||
(string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerKeyDeviceData;
|
||||
LogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageBasePath, imageLayout, layoutPath));
|
||||
ILogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageBasePath, imageLayout, layoutPath));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
@ -113,7 +113,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
if (DeviceChecker.IsPerDeviceDeviceConnected)
|
||||
{
|
||||
(string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerDeviceDeviceData;
|
||||
LogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageBasePath, imageLayout, layoutPath));
|
||||
ILogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageBasePath, imageLayout, layoutPath));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
|
||||
@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Represents a logitech per-device-lightable device.
|
||||
/// </summary>
|
||||
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice
|
||||
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="LogitechPerDeviceRGBDevice"/>.
|
||||
/// </summary>
|
||||
public LogitechRGBDeviceInfo PerDeviceDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <param name="info">The specific information provided by logitech for the per-device-lightable device</param>
|
||||
internal LogitechPerDeviceRGBDevice(LogitechRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.PerDeviceDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Represents a logitech per-key-lightable device.
|
||||
/// </summary>
|
||||
public class LogitechPerKeyRGBDevice : LogitechRGBDevice
|
||||
public class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="LogitechPerKeyRGBDevice"/>.
|
||||
/// </summary>
|
||||
public LogitechRGBDeviceInfo PerKeyDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <param name="info">The specific information provided by logitech for the per-key-lightable device</param>
|
||||
internal LogitechPerKeyRGBDevice(LogitechRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.PerKeyDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
<Compile Include="Enum\LogitechPhysicalKeyboardLayout.cs" />
|
||||
<Compile Include="Enum\LogitechDeviceCaps.cs" />
|
||||
<Compile Include="Enum\LogitechLedIds.cs" />
|
||||
<Compile Include="Generic\ILogitechRGBDevice.cs" />
|
||||
<Compile Include="Generic\LogitechLedId.cs" />
|
||||
<Compile Include="Generic\LogitechRGBDevice.cs" />
|
||||
<Compile Include="Generic\LogitechRGBDeviceInfo.cs" />
|
||||
|
||||
12
RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs
Normal file
12
RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Msi
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a msi RGB-device.
|
||||
/// </summary>
|
||||
internal interface IMsiRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core.Layout;
|
||||
using RGB.NET.Devices.Msi.Native;
|
||||
@ -13,7 +12,8 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <summary>
|
||||
/// Represents a generic Msi-device. (keyboard, mouse, headset, mousepad).
|
||||
/// </summary>
|
||||
public abstract class MsiRGBDevice : AbstractRGBDevice
|
||||
public abstract class MsiRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, IMsiRGBDevice
|
||||
where TDeviceInfo : MsiRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
@ -21,17 +21,17 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.Msi.MsiRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
public override TDeviceInfo DeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MsiRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="MsiRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by Msi for the device.</param>
|
||||
protected MsiRGBDevice(IRGBDeviceInfo info)
|
||||
protected MsiRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
this.DeviceInfo = info;
|
||||
}
|
||||
@ -43,7 +43,7 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
@ -106,7 +106,7 @@ namespace RGB.NET.Devices.Msi
|
||||
|
||||
if (leds.Count > 0)
|
||||
{
|
||||
string deviceType = ((MsiRGBDeviceInfo)DeviceInfo).MsiDeviceType;
|
||||
string deviceType = DeviceInfo.MsiDeviceType;
|
||||
foreach (Led led in leds)
|
||||
_MsiSDK.SetLedColor(deviceType, ((MsiLedId)led.Id).Index, led.Color.R, led.Color.G, led.Color.B);
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <inheritdoc />
|
||||
public RGBDeviceType DeviceType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal type of the <see cref="IRGBDevice"/>.
|
||||
/// </summary>
|
||||
public string MsiDeviceType { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Enum\MsiLedIds.cs" />
|
||||
<Compile Include="Exceptions\MysticLightException.cs" />
|
||||
<Compile Include="Generic\IMsiRGBDevice.cs" />
|
||||
<Compile Include="Generic\MsiLedId.cs" />
|
||||
<Compile Include="Generic\MsiRGBDevice.cs" />
|
||||
<Compile Include="Generic\MsiRGBDeviceInfo.cs" />
|
||||
|
||||
12
RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs
Normal file
12
RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a novation RGB-device.
|
||||
/// </summary>
|
||||
internal interface INovationRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
@ -12,30 +12,31 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <summary>
|
||||
/// Represents a generic Novation-device. (launchpad).
|
||||
/// </summary>
|
||||
public abstract class NovationRGBDevice : AbstractRGBDevice
|
||||
public abstract class NovationRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, INovationRGBDevice
|
||||
where TDeviceInfo : NovationRGBDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly OutputDevice _outputDevice;
|
||||
private readonly NovationRGBDeviceInfo _deviceInfo;
|
||||
private readonly TDeviceInfo _deviceInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="T:RGB.NET.Devices.Novation.NovationRGBDevice" />.
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo => _deviceInfo;
|
||||
public override TDeviceInfo DeviceInfo => _deviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NovationRGBDevice"/> class.
|
||||
/// Initializes a new instance of the <see cref="NovationRGBDevice{TDeviceInfo}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The generic information provided by Novation for the device.</param>
|
||||
protected NovationRGBDevice(NovationRGBDeviceInfo info)
|
||||
protected NovationRGBDevice(TDeviceInfo info)
|
||||
{
|
||||
_deviceInfo = info;
|
||||
this._deviceInfo = info;
|
||||
|
||||
_outputDevice = new OutputDevice(info.DeviceId);
|
||||
}
|
||||
@ -48,7 +49,7 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeLayout();
|
||||
|
||||
@ -123,12 +124,12 @@ namespace RGB.NET.Devices.Novation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the <see cref="NovationRGBDevice"/> back top default.
|
||||
/// Resets the <see cref="NovationRGBDevice{TDeviceInfo}"/> back top default.
|
||||
/// </summary>
|
||||
public virtual void Reset() => SendMessage(0xB0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
||||
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
|
||||
@ -146,7 +147,7 @@ namespace RGB.NET.Devices.Novation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
|
||||
/// The conversion uses the full rgb-range.
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
||||
@ -158,7 +159,7 @@ namespace RGB.NET.Devices.Novation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
|
||||
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
|
||||
/// The conversion uses only a limited amount of colors (3 red, 3 yellow, 3 green).
|
||||
/// </summary>
|
||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
||||
@ -178,7 +179,7 @@ namespace RGB.NET.Devices.Novation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message to the <see cref="NovationRGBDevice"/>.
|
||||
/// Sends a message to the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
/// <param name="status">The status-code of the message.</param>
|
||||
/// <param name="data1">The first data-package of the message.</param>
|
||||
|
||||
@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <summary>
|
||||
/// Represents a Novation launchpad.
|
||||
/// </summary>
|
||||
public class NovationLaunchpadRGBDevice : NovationRGBDevice
|
||||
public class NovationLaunchpadRGBDevice : NovationRGBDevice<NovationLaunchpadRGBDeviceInfo>
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="NovationLaunchpadRGBDevice"/>.
|
||||
/// </summary>
|
||||
public NovationLaunchpadRGBDeviceInfo LaunchpadDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <param name="info">The specific information provided by Novation for the launchpad</param>
|
||||
internal NovationLaunchpadRGBDevice(NovationLaunchpadRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.LaunchpadDeviceInfo = info;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -54,7 +43,7 @@ namespace RGB.NET.Devices.Novation
|
||||
InitializeLed(new NovationLedId(this, ledId), rectangle);
|
||||
}
|
||||
|
||||
string model = LaunchpadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
|
||||
$@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads"));
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace RGB.NET.Devices.Novation
|
||||
|
||||
if (deviceId == null) continue;
|
||||
|
||||
NovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
|
||||
INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@
|
||||
<Compile Include="Generic\NovationRGBDeviceInfo.cs" />
|
||||
<Compile Include="Helper\EnumExtension.cs" />
|
||||
<Compile Include="Helper\NovationLedIdsExtension.cs" />
|
||||
<Compile Include="Generic\INovationRGBDevice.cs" />
|
||||
<Compile Include="Launchpad\NovationLaunchpadRGBDevice.cs" />
|
||||
<Compile Include="Launchpad\NovationLaunchpadRGBDeviceInfo.cs" />
|
||||
<Compile Include="NovationDeviceProvider.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user