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

Renamed CUESDK to fit general native class-naming, added missing x86 dll-imports

This commit is contained in:
unknown 2015-09-18 23:41:16 +02:00
parent b47abedae2
commit ebdbe69e7c
4 changed files with 54 additions and 18 deletions

View File

@ -77,7 +77,7 @@
<Compile Include="Native\_CorsairLedPosition.cs" />
<Compile Include="Native\_CorsairLedPositions.cs" />
<Compile Include="Native\_CorsairProtocolDetails.cs" />
<Compile Include="Native\CUESDK.cs" />
<Compile Include="Native\_CUESDK.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums\CorsairError.cs" />
<Compile Include="Wrapper\CorsairDeviceInfo.cs" />

View File

@ -5,41 +5,77 @@ using CUE.NET.Enums;
namespace CUE.NET.Native
{
// ReSharper disable once InconsistentNaming
internal static class CUESDK
internal static class _CUESDK
{
// set specified leds to some colors. The color is retained until changed by successive calls. This function does not take logical layout into account
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#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);
//[DllImport("CUESDK.x64_2013.dll")]
//#if WIN64
// [DllImport("CUESDK.x64_2013.dll")]
//#else
// [DllImport("CUESDK_2013.dll")]
//#endif
//public static extern bool CorsairSetLedsColorsAsync(int size, CorsairLedColor* ledsColors, void(*CallbackType)(void*, bool, CorsairError), void* context);
// returns number of connected Corsair devices that support lighting control.
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#endif
// returns number of connected Corsair devices that support lighting control.
public static extern int CorsairGetDeviceCount();
// returns information about device at provided index
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#endif
// returns information about device at provided index
public static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
// provides list of keyboard LEDs with their physical positions.
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#endif
// provides list of keyboard LEDs with their physical positions.
public static extern IntPtr CorsairGetLedPositions();
// retrieves led id for key name taking logical layout into account.
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#endif
// retrieves led id for key name taking logical layout into account.
public static extern CorsairLedId CorsairGetLedIdForKeyName(char keyName);
// 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
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#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);
// checks file and protocol version of CUE to understand which of SDK functions can be used with this version of CUE
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#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();
// returns last error that occured while using any of Corsair* functions
#if WIN64
[DllImport("CUESDK.x64_2013.dll")]
#else
[DllImport("CUESDK_2013.dll")]
#endif
// returns last error that occured while using any of Corsair* functions
public static extern CorsairError CorsairGetLastError();
}
}

View File

@ -24,13 +24,13 @@ namespace CUE.NET.Wrapper
public void SetKeyColor(char key, Color color)
{
CorsairLedId id = CUESDK.CorsairGetLedIdForKeyName(key);
CorsairLedId id = _CUESDK.CorsairGetLedIdForKeyName(key);
_CorsairLedColor ledColor = new _CorsairLedColor { ledId = id, r = color.R, g = color.G, b = color.B };
//TODO DarthAffe 18.09.2015: Generalize and move to base class
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(_CorsairLedColor)));
Marshal.StructureToPtr(ledColor, ptr, true);
CUESDK.CorsairSetLedsColors(1, ptr);
_CUESDK.CorsairSetLedsColors(1, ptr);
}
#endregion

View File

@ -15,7 +15,7 @@ namespace CUE.NET.Wrapper
public static CorsairProtocolDetails ProtocolDetails { get; private set; }
public static bool HasExclusiveAccess { get; private set; }
public static CorsairError LastError => CUESDK.CorsairGetLastError();
public static CorsairError LastError => _CUESDK.CorsairGetLastError();
public static CueKeyboard KeyboardSDK { get; private set; }
public static CueMouse MouseSDK { get; private set; }
@ -32,7 +32,7 @@ namespace CUE.NET.Wrapper
if (ProtocolDetails != null)
throw new WrapperException("CueSDK is already initialized.");
ProtocolDetails = new CorsairProtocolDetails(CUESDK.CorsairPerformProtocolHandshake());
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
CorsairError error = LastError;
if (error != CorsairError.CE_Success)
@ -40,16 +40,16 @@ namespace CUE.NET.Wrapper
if (exclusiveAccess)
{
if (!CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
Throw(error);
HasExclusiveAccess = true;
}
int deviceCount = CUESDK.CorsairGetDeviceCount();
int deviceCount = _CUESDK.CorsairGetDeviceCount();
for (int i = 0; i < deviceCount; i++)
{
CorsairDeviceInfo info = new CorsairDeviceInfo((_CorsairDeviceInfo)Marshal.PtrToStructure(CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)));
CorsairDeviceInfo info = new CorsairDeviceInfo((_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)));
switch (info.Type)
{
case CorsairDeviceType.CDT_Keyboard: