Somehow finished the really basic stuff

This commit is contained in:
DarthAffe committed 2017-01-25 20:33:15 +01:00
1 parent 5cbcbd9d9c
commit c8dac3905d
28 files changed
+306 -260

No files matched your search

@@ -1,4 +1,7 @@
using System.Collections.Generic;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using RGB.NET.Core;
@@ -10,10 +13,15 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Represents a device provider responsible for corsair (CUE) devices.
/// </summary>
public class CorsairDeviceProvider : IDeviceProvider
public class CorsairDeviceProvider : IRGBDeviceProvider
{
#region Properties & Fields
/// <summary>
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
/// </summary>
public static CorsairDeviceProvider Instance { get; } = new CorsairDeviceProvider();
/// <summary>
/// Indicates if the SDK is initialized and ready to use.
/// </summary>
@@ -44,6 +52,13 @@ namespace RGB.NET.Devices.Corsair
#endregion
#region Constructors
private CorsairDeviceProvider()
{ }
#endregion
#region Methods
/// <inheritdoc />
@@ -109,7 +124,7 @@ namespace RGB.NET.Devices.Corsair
{
_CorsairDeviceInfo nativeDeviceInfo =
(_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, DeviceType.Unknown, nativeDeviceInfo);
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, RGBDeviceType.Unknown, nativeDeviceInfo);
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
continue; // Everything that doesn't support lighting control is useless
@@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Represents a Id of a <see cref="Led"/> on a <see cref="CorsairRGBDevice"/>.
/// </summary>
[DebuggerDisplay("{_ledId}")]
[DebuggerDisplay("{" + nameof(_ledId) + "}")]
public class CorsairLedId : ILedId
{
#region Properties & Fields
@@ -15,9 +15,8 @@ namespace RGB.NET.Devices.Corsair
/// </summary>
public override IRGBDeviceInfo DeviceInfo { get; }
private Rectangle _deviceRectangle;
/// <inheritdoc />
public override Rectangle DeviceRectangle => _deviceRectangle;
protected override Size InternalSize { get; set; }
#endregion
@@ -43,7 +42,8 @@ namespace RGB.NET.Devices.Corsair
{
InitializeLeds();
_deviceRectangle = new Rectangle(this.Select(x => x.LedRectangle));
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
/// <summary>
@@ -23,7 +23,7 @@ namespace RGB.NET.Devices.Corsair
public int CorsairDeviceIndex { get; }
/// <inheritdoc />
public DeviceType DeviceType { get; }
public RGBDeviceType DeviceType { get; }
/// <inheritdoc />
public string Manufacturer => "Corsair";
@@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice"/>.</param>
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairRGBDeviceInfo(int deviceIndex, DeviceType deviceType, _CorsairDeviceInfo nativeInfo)
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
@@ -1,4 +1,7 @@
using RGB.NET.Core;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
@@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index of the <see cref="CorsairHeadsetRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Headset, nativeInfo)
: base(deviceIndex, Core.RGBDeviceType.Headset, nativeInfo)
{ }
#endregion
@@ -1,4 +1,7 @@
using System;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using System.Runtime.InteropServices;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
@@ -1,4 +1,7 @@
using RGB.NET.Devices.Corsair.Native;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
@@ -29,7 +32,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index of the <see cref="CorsairKeyboardRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Keyboard, nativeInfo)
: base(deviceIndex, Core.RGBDeviceType.Keyboard, nativeInfo)
{
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
@@ -1,4 +1,7 @@
using RGB.NET.Core;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using RGB.NET.Core;
using RGB.NET.Core.Exceptions;
namespace RGB.NET.Devices.Corsair
@@ -24,7 +24,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index of the <see cref="CorsairMouseRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Mouse, nativeInfo)
: base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo)
{
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
}
@@ -1,4 +1,7 @@
using System;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
@@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index if the <see cref="CorsairMousematRGBDevice"/>.</param>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, Core.DeviceType.Mousemat, nativeInfo)
: base(deviceIndex, Core.RGBDeviceType.Mousemat, nativeInfo)
{ }
#endregion