From ebdbe69e7cb2852c1fa11da9b514c431bea0e44a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Sep 2015 23:41:16 +0200 Subject: [PATCH] Renamed CUESDK to fit general native class-naming, added missing x86 dll-imports --- CUE.NET.csproj | 2 +- Native/{CUESDK.cs => _CUESDK.cs} | 56 ++++++++++++++++++++++++++------ Wrapper/CueKeyboard.cs | 4 +-- Wrapper/CueSDK.cs | 10 +++--- 4 files changed, 54 insertions(+), 18 deletions(-) rename Native/{CUESDK.cs => _CUESDK.cs} (75%) diff --git a/CUE.NET.csproj b/CUE.NET.csproj index 7e8561c..30cd022 100644 --- a/CUE.NET.csproj +++ b/CUE.NET.csproj @@ -77,7 +77,7 @@ - + diff --git a/Native/CUESDK.cs b/Native/_CUESDK.cs similarity index 75% rename from Native/CUESDK.cs rename to Native/_CUESDK.cs index 654871c..19a1cd9 100644 --- a/Native/CUESDK.cs +++ b/Native/_CUESDK.cs @@ -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(); } } diff --git a/Wrapper/CueKeyboard.cs b/Wrapper/CueKeyboard.cs index 721e6a7..5083bf3 100644 --- a/Wrapper/CueKeyboard.cs +++ b/Wrapper/CueKeyboard.cs @@ -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 diff --git a/Wrapper/CueSDK.cs b/Wrapper/CueSDK.cs index 6ffed46..51fff3a 100644 --- a/Wrapper/CueSDK.cs +++ b/Wrapper/CueSDK.cs @@ -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: