mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 09:08:34 +00:00
Renamed CUESDK to fit general native class-naming, added missing x86 dll-imports
This commit is contained in:
parent
b47abedae2
commit
ebdbe69e7c
@ -77,7 +77,7 @@
|
|||||||
<Compile Include="Native\_CorsairLedPosition.cs" />
|
<Compile Include="Native\_CorsairLedPosition.cs" />
|
||||||
<Compile Include="Native\_CorsairLedPositions.cs" />
|
<Compile Include="Native\_CorsairLedPositions.cs" />
|
||||||
<Compile Include="Native\_CorsairProtocolDetails.cs" />
|
<Compile Include="Native\_CorsairProtocolDetails.cs" />
|
||||||
<Compile Include="Native\CUESDK.cs" />
|
<Compile Include="Native\_CUESDK.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Enums\CorsairError.cs" />
|
<Compile Include="Enums\CorsairError.cs" />
|
||||||
<Compile Include="Wrapper\CorsairDeviceInfo.cs" />
|
<Compile Include="Wrapper\CorsairDeviceInfo.cs" />
|
||||||
|
|||||||
@ -5,41 +5,77 @@ using CUE.NET.Enums;
|
|||||||
namespace CUE.NET.Native
|
namespace CUE.NET.Native
|
||||||
{
|
{
|
||||||
// ReSharper disable once InconsistentNaming
|
// 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")]
|
[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);
|
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);
|
//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")]
|
[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();
|
public static extern int CorsairGetDeviceCount();
|
||||||
|
|
||||||
// returns information about device at provided index
|
#if WIN64
|
||||||
[DllImport("CUESDK.x64_2013.dll")]
|
[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);
|
public static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
|
||||||
|
|
||||||
// provides list of keyboard LEDs with their physical positions.
|
#if WIN64
|
||||||
[DllImport("CUESDK.x64_2013.dll")]
|
[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();
|
public static extern IntPtr CorsairGetLedPositions();
|
||||||
|
|
||||||
// retrieves led id for key name taking logical layout into account.
|
#if WIN64
|
||||||
[DllImport("CUESDK.x64_2013.dll")]
|
[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);
|
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")]
|
[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);
|
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")]
|
[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();
|
public static extern _CorsairProtocolDetails CorsairPerformProtocolHandshake();
|
||||||
|
|
||||||
// returns last error that occured while using any of Corsair* functions
|
#if WIN64
|
||||||
[DllImport("CUESDK.x64_2013.dll")]
|
[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();
|
public static extern CorsairError CorsairGetLastError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,13 +24,13 @@ namespace CUE.NET.Wrapper
|
|||||||
|
|
||||||
public void SetKeyColor(char key, Color color)
|
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 };
|
_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
|
//TODO DarthAffe 18.09.2015: Generalize and move to base class
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(_CorsairLedColor)));
|
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(_CorsairLedColor)));
|
||||||
Marshal.StructureToPtr(ledColor, ptr, true);
|
Marshal.StructureToPtr(ledColor, ptr, true);
|
||||||
CUESDK.CorsairSetLedsColors(1, ptr);
|
_CUESDK.CorsairSetLedsColors(1, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace CUE.NET.Wrapper
|
|||||||
|
|
||||||
public static CorsairProtocolDetails ProtocolDetails { get; private set; }
|
public static CorsairProtocolDetails ProtocolDetails { get; private set; }
|
||||||
public static bool HasExclusiveAccess { 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 CueKeyboard KeyboardSDK { get; private set; }
|
||||||
public static CueMouse MouseSDK { get; private set; }
|
public static CueMouse MouseSDK { get; private set; }
|
||||||
@ -32,7 +32,7 @@ namespace CUE.NET.Wrapper
|
|||||||
if (ProtocolDetails != null)
|
if (ProtocolDetails != null)
|
||||||
throw new WrapperException("CueSDK is already initialized.");
|
throw new WrapperException("CueSDK is already initialized.");
|
||||||
|
|
||||||
ProtocolDetails = new CorsairProtocolDetails(CUESDK.CorsairPerformProtocolHandshake());
|
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
|
||||||
|
|
||||||
CorsairError error = LastError;
|
CorsairError error = LastError;
|
||||||
if (error != CorsairError.CE_Success)
|
if (error != CorsairError.CE_Success)
|
||||||
@ -40,16 +40,16 @@ namespace CUE.NET.Wrapper
|
|||||||
|
|
||||||
if (exclusiveAccess)
|
if (exclusiveAccess)
|
||||||
{
|
{
|
||||||
if (!CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
|
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
|
||||||
Throw(error);
|
Throw(error);
|
||||||
|
|
||||||
HasExclusiveAccess = true;
|
HasExclusiveAccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int deviceCount = CUESDK.CorsairGetDeviceCount();
|
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||||
for (int i = 0; i < deviceCount; i++)
|
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)
|
switch (info.Type)
|
||||||
{
|
{
|
||||||
case CorsairDeviceType.CDT_Keyboard:
|
case CorsairDeviceType.CDT_Keyboard:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user