1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Reorganized project into a (hopefully) better structure

This commit is contained in:
unknown 2015-09-19 16:24:14 +02:00
parent ce4e80c24b
commit fc66ac0ceb
33 changed files with 111 additions and 99 deletions

View File

@ -60,27 +60,27 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Enums\CorsairAccessMode.cs" />
<Compile Include="Enums\CorsairDeviceCaps.cs" />
<Compile Include="Enums\CorsairDeviceType.cs" />
<Compile Include="Enums\Keyboard\CorsairLogicalKeyboardLayout.cs" />
<Compile Include="Enums\Headset\CorsairHeadsetLedId.cs" />
<Compile Include="Enums\Keyboard\CorsairKeyboardKeyId.cs" />
<Compile Include="Enums\Keyboard\CorsairPhysicalKeyboardLayout.cs" />
<Compile Include="Enums\Mouse\CorsairMouseButtonId.cs" />
<Compile Include="Enums\Mouse\CorsairPhysicalMouseLayout.cs" />
<Compile Include="Devices\Generic\Enums\CorsairAccessMode.cs" />
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
<Compile Include="Devices\Keyboard\Enums\CorsairLogicalKeyboardLayout.cs" />
<Compile Include="Devices\Headset\Enums\CorsairHeadsetLedId.cs" />
<Compile Include="Devices\Keyboard\Enums\CorsairKeyboardKeyId.cs" />
<Compile Include="Devices\Keyboard\Enums\CorsairPhysicalKeyboardLayout.cs" />
<Compile Include="Devices\Mouse\Enums\CorsairMouseButtonId.cs" />
<Compile Include="Devices\Mouse\Enums\CorsairPhysicalMouseLayout.cs" />
<Compile Include="Exceptions\CUEException.cs" />
<Compile Include="Exceptions\WrapperException.cs" />
<Compile Include="Wrapper\AbstractCueDevice.cs" />
<Compile Include="Wrapper\CorsairLed.cs" />
<Compile Include="Wrapper\GenericDeviceInfo.cs" />
<Compile Include="Wrapper\Headset\CorsairHeadset.cs" />
<Compile Include="Wrapper\Headset\CorsairHeadsetDeviceInfo.cs" />
<Compile Include="Wrapper\IDeviceInfo.cs" />
<Compile Include="Wrapper\Keyboard\CorsairKey.cs" />
<Compile Include="Wrapper\Keyboard\CorsairKeyboard.cs" />
<Compile Include="Wrapper\Mouse\CorsairMouseDeviceInfo.cs" />
<Compile Include="Wrapper\Mouse\CorsairMouse.cs" />
<Compile Include="Devices\Generic\AbstractCueDevice.cs" />
<Compile Include="Devices\Generic\CorsairLed.cs" />
<Compile Include="Devices\Generic\GenericDeviceInfo.cs" />
<Compile Include="Devices\Headset\CorsairHeadset.cs" />
<Compile Include="Devices\Headset\CorsairHeadsetDeviceInfo.cs" />
<Compile Include="Devices\IDeviceInfo.cs" />
<Compile Include="Devices\Keyboard\CorsairKey.cs" />
<Compile Include="Devices\Keyboard\CorsairKeyboard.cs" />
<Compile Include="Devices\Mouse\CorsairMouseDeviceInfo.cs" />
<Compile Include="Devices\Mouse\CorsairMouse.cs" />
<Compile Include="Native\_CorsairDeviceInfo.cs" />
<Compile Include="Native\_CorsairLedColor.cs" />
<Compile Include="Native\_CorsairLedPosition.cs" />
@ -88,11 +88,11 @@
<Compile Include="Native\_CorsairProtocolDetails.cs" />
<Compile Include="Native\_CUESDK.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums\CorsairError.cs" />
<Compile Include="Wrapper\Keyboard\CorsairKeyboardDeviceInfo.cs" />
<Compile Include="Wrapper\CorsairProtocolDetails.cs" />
<Compile Include="Wrapper\CueSDK.cs" />
<Compile Include="Wrapper\ICueDevice.cs" />
<Compile Include="Devices\Generic\Enums\CorsairError.cs" />
<Compile Include="Devices\Keyboard\CorsairKeyboardDeviceInfo.cs" />
<Compile Include="Devices\Generic\CorsairProtocolDetails.cs" />
<Compile Include="CueSDK.cs" />
<Compile Include="Devices\ICueDevice.cs" />
</ItemGroup>
<ItemGroup>
<None Include="libs\CUESDK.x64_2013.dll" />

View File

@ -1,14 +1,15 @@
// ReSharper disable MemberCanBePrivate.Global
using System.Runtime.InteropServices;
using CUE.NET.Enums;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Headset;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Devices.Mouse;
using CUE.NET.Exceptions;
using CUE.NET.Native;
using CUE.NET.Wrapper.Headset;
using CUE.NET.Wrapper.Keyboard;
using CUE.NET.Wrapper.Mouse;
namespace CUE.NET.Wrapper
namespace CUE.NET
{
public static class CueSDK
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using CUE.NET.Native;
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices.Generic
{
public abstract class AbstractCueDevice : ICueDevice
{
@ -29,15 +29,15 @@ namespace CUE.NET.Wrapper
protected CorsairLed GetLed(int ledId)
{
if (!Leds.ContainsKey(ledId))
Leds.Add(ledId, new CorsairLed());
if (!this.Leds.ContainsKey(ledId))
this.Leds.Add(ledId, new CorsairLed());
return Leds[ledId];
return this.Leds[ledId];
}
public virtual void UpdateLeds(bool fullUpdate = false)
{
IList<KeyValuePair<int, CorsairLed>> ledsToUpdate = (fullUpdate ? Leds : Leds.Where(x => x.Value.IsDirty)).ToList();
IList<KeyValuePair<int, CorsairLed>> ledsToUpdate = (fullUpdate ? this.Leds : this.Leds.Where(x => x.Value.IsDirty)).ToList();
if (!ledsToUpdate.Any())
return; // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array
@ -52,7 +52,7 @@ namespace CUE.NET.Wrapper
ledId = led.Key,
r = led.Value.Color.R,
g = led.Value.Color.G,
b = led.Value.Color.B,
b = led.Value.Color.B
};
Marshal.StructureToPtr(color, addPtr, false);

View File

@ -1,12 +1,12 @@
using System.Drawing;
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices.Generic
{
public class CorsairLed
{
#region Properties & Fields
public bool IsDirty { get; set; } = false;
public bool IsDirty { get; private set; } = false;
private Color _color = Color.Black;
public Color Color

View File

@ -5,7 +5,7 @@ using System;
using System.Runtime.InteropServices;
using CUE.NET.Native;
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices.Generic
{
/// <summary>
/// Managed wrapper for CorsairProtocolDetails.

View File

@ -1,7 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace CUE.NET.Enums
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
/// Contains list of available SDK access modes.

View File

@ -3,7 +3,7 @@
using System;
namespace CUE.NET.Enums
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
/// Contains list of device capabilities

View File

@ -1,7 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace CUE.NET.Enums
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
/// Contains list of available device types.

View File

@ -1,7 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace CUE.NET.Enums
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
/// Shared list of all errors which could happen during calling of Corsair* functions.

View File

@ -1,9 +1,9 @@
using System;
using System.Runtime.InteropServices;
using CUE.NET.Enums;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Native;
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices.Generic
{
public class GenericDeviceInfo : IDeviceInfo
{

View File

@ -1,4 +1,6 @@
namespace CUE.NET.Wrapper.Headset
using CUE.NET.Devices.Generic;
namespace CUE.NET.Devices.Headset
{
//TODO DarthAffe 18.09.2015: Implement
public class CorsairHeadset : AbstractCueDevice

View File

@ -0,0 +1,12 @@
using CUE.NET.Devices.Generic;
using CUE.NET.Native;
namespace CUE.NET.Devices.Headset
{
public class CorsairHeadsetDeviceInfo : GenericDeviceInfo
{
internal CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo)
: base(nativeInfo)
{ }
}
}

View File

@ -1,7 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace CUE.NET.Enums.Headset
namespace CUE.NET.Devices.Headset.Enums
{
public enum CorsairHeadsetLedId
{

View File

@ -1,4 +1,4 @@
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices
{
public interface ICueDevice
{

View File

@ -1,12 +1,14 @@
using CUE.NET.Enums;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Wrapper
namespace CUE.NET.Devices
{
public interface IDeviceInfo
{
/// <summary>
/// Device type
/// </summary>
CorsairDeviceType Type { get; }
//TODO DarthAffe 17.09.2015: This could be an Enum
/// <summary>
/// Device model (like “K95RGB”).
/// </summary>

View File

@ -1,6 +1,7 @@
using CUE.NET.Enums.Keyboard;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.Wrapper.Keyboard
namespace CUE.NET.Devices.Keyboard
{
public class CorsairKey
{

View File

@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using CUE.NET.Enums.Keyboard;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.Wrapper.Keyboard
namespace CUE.NET.Devices.Keyboard
{
public class CorsairKeyboard : AbstractCueDevice
{
@ -13,7 +14,7 @@ namespace CUE.NET.Wrapper.Keyboard
private Dictionary<CorsairKeyboardKeyId, CorsairKey> _keys = new Dictionary<CorsairKeyboardKeyId, CorsairKey>();
public CorsairKey this[CorsairKeyboardKeyId keyId]
{
get { return _keys[keyId]; }
get { return this._keys[keyId]; }
private set { throw new NotSupportedException(); }
}
@ -26,7 +27,7 @@ namespace CUE.NET.Wrapper.Keyboard
{
this.KeyboardDeviceInfo = info;
InitializeKeys();
this.InitializeKeys();
}
#endregion
@ -36,7 +37,7 @@ namespace CUE.NET.Wrapper.Keyboard
private void InitializeKeys()
{
foreach (CorsairKeyboardKeyId keyId in Enum.GetValues(typeof(CorsairKeyboardKeyId)))
_keys.Add(keyId, new CorsairKey(keyId, GetLed((int)keyId)));
this._keys.Add(keyId, new CorsairKey(keyId, this.GetLed((int)keyId)));
}
#endregion

View File

@ -1,10 +1,11 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
using CUE.NET.Enums.Keyboard;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Keyboard.Enums;
using CUE.NET.Native;
namespace CUE.NET.Wrapper.Keyboard
namespace CUE.NET.Devices.Keyboard
{
public class CorsairKeyboardDeviceInfo : GenericDeviceInfo
{

View File

@ -1,7 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace CUE.NET.Enums.Keyboard
namespace CUE.NET.Devices.Keyboard.Enums
{
public enum CorsairKeyboardKeyId
{

View File

@ -1,7 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
namespace CUE.NET.Enums.Keyboard
namespace CUE.NET.Devices.Keyboard.Enums
{
/// <summary>
/// Contains list of available logical layouts for keyboards.

View File

@ -1,7 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace CUE.NET.Enums.Keyboard
namespace CUE.NET.Devices.Keyboard.Enums
{
/// <summary>
/// Contains list of available physical layouts for keyboards.

View File

@ -1,4 +1,6 @@
namespace CUE.NET.Wrapper.Mouse
using CUE.NET.Devices.Generic;
namespace CUE.NET.Devices.Mouse
{
//TODO DarthAffe 18.09.2015: Implement
public class CorsairMouse : AbstractCueDevice

View File

@ -1,10 +1,11 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
using CUE.NET.Enums.Mouse;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Native;
namespace CUE.NET.Wrapper.Mouse
namespace CUE.NET.Devices.Mouse
{
public class CorsairMouseDeviceInfo : GenericDeviceInfo
{

View File

@ -1,7 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace CUE.NET.Enums.Mouse
namespace CUE.NET.Devices.Mouse.Enums
{
public enum CorsairMouseLedId
{

View File

@ -1,7 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace CUE.NET.Enums.Mouse
namespace CUE.NET.Devices.Mouse.Enums
{
/// <summary>
/// Contains list of available physical layouts for mice.

View File

@ -1,10 +1,10 @@
using System;
using System.Drawing;
using CUE.NET.Enums;
using CUE.NET.Enums.Keyboard;
using CUE.NET;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Devices.Keyboard.Enums;
using CUE.NET.Exceptions;
using CUE.NET.Wrapper;
using CUE.NET.Wrapper.Keyboard;
namespace SimpleDevTest
{

View File

@ -2,7 +2,7 @@
// ReSharper disable MemberCanBePrivate.Global
using System;
using CUE.NET.Enums;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Exceptions
{

View File

@ -1,6 +1,6 @@
using System;
using System.Runtime.InteropServices;
using CUE.NET.Enums;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Native
{
@ -13,14 +13,14 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account
public static extern bool CorsairSetLedsColors(int size, IntPtr ledsColors);
internal static extern bool CorsairSetLedsColors(int size, IntPtr ledsColors);
//#if WIN64
// [DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
//#else
// [DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
//#endif
//public static extern bool CorsairSetLedsColorsAsync(int size, CorsairLedColor* ledsColors, void(*CallbackType)(void*, bool, CorsairError), void* context);
//internal static extern bool CorsairSetLedsColorsAsync(int size, CorsairLedColor* ledsColors, void(*CallbackType)(void*, bool, CorsairError), void* context);
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -28,7 +28,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// returns number of connected Corsair devices that support lighting control.
public static extern int CorsairGetDeviceCount();
internal static extern int CorsairGetDeviceCount();
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -36,7 +36,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// returns information about device at provided index
public static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
internal static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -44,7 +44,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// provides list of keyboard LEDs with their physical positions.
public static extern IntPtr CorsairGetLedPositions();
internal static extern IntPtr CorsairGetLedPositions();
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -52,7 +52,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// retrieves led id for key name taking logical layout into account.
public static extern int CorsairGetLedIdForKeyName(char keyName);
internal static extern int CorsairGetLedIdForKeyName(char keyName);
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -60,7 +60,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// requestes control using specified access mode. By default client has shared control over lighting so there is no need to call CorsairRequestControl unless client requires exclusive control
public static extern bool CorsairRequestControl(CorsairAccessMode accessMode);
internal static extern bool CorsairRequestControl(CorsairAccessMode accessMode);
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -68,7 +68,7 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE
public static extern _CorsairProtocolDetails CorsairPerformProtocolHandshake();
internal static extern _CorsairProtocolDetails CorsairPerformProtocolHandshake();
#if WIN64
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
@ -76,6 +76,6 @@ namespace CUE.NET.Native
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
// returns last error that occured while using any of Corsair* functions
public static extern CorsairError CorsairGetLastError();
internal static extern CorsairError CorsairGetLastError();
}
}

View File

@ -4,13 +4,13 @@
using System;
using System.Runtime.InteropServices;
using CUE.NET.Enums;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
[StructLayout(LayoutKind.Sequential)]
public class _CorsairDeviceInfo // contains information about device
internal class _CorsairDeviceInfo // contains information about device
{
internal CorsairDeviceType type; // enum describing device type
internal IntPtr model; // null - terminated device model(like “K95RGB”)

View File

@ -8,7 +8,7 @@ namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
[StructLayout(LayoutKind.Sequential)]
public class _CorsairLedColor // contains information about led and its color
internal class _CorsairLedColor // contains information about led and its color
{
internal int ledId; // identifier of LED to set

View File

@ -8,7 +8,7 @@ namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
[StructLayout(LayoutKind.Sequential)]
public class _CorsairLedPosition // contains led id and position of led rectangle.Most of the keys are rectangular. In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
internal class _CorsairLedPosition // contains led id and position of led rectangle.Most of the keys are rectangular. In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
{
internal int ledId; // identifier of led
internal double top;

View File

@ -9,7 +9,7 @@ namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
[StructLayout(LayoutKind.Sequential)]
public class _CorsairLedPositions // contains number of leds and arrays with their positions
internal class _CorsairLedPositions // contains number of leds and arrays with their positions
{
internal int numberOfLed; // integer value.Number of elements in following array
internal IntPtr pLedPosition; // array of led positions

View File

@ -1,11 +0,0 @@
using CUE.NET.Native;
namespace CUE.NET.Wrapper.Headset
{
public class CorsairHeadsetDeviceInfo : GenericDeviceInfo
{
public CorsairHeadsetDeviceInfo(_CorsairDeviceInfo nativeInfo)
: base(nativeInfo)
{ }
}
}