mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 08:48:30 +00:00
Initial commit (simple but working version)
This commit is contained in:
parent
0a8c571244
commit
f07595b50c
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
###############################################################################
|
||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
###############################################################################
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior for command prompt diff.
|
||||||
|
#
|
||||||
|
# This is need for earlier builds of msysgit that does not have it on by
|
||||||
|
# default for csharp files.
|
||||||
|
# Note: This is only used by command line
|
||||||
|
###############################################################################
|
||||||
|
#*.cs diff=csharp
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set the merge driver for project and solution files
|
||||||
|
#
|
||||||
|
# Merging from the command prompt will add diff markers to the files if there
|
||||||
|
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||||
|
# the diff markers are never inserted). Diff markers may cause the following
|
||||||
|
# file extensions to fail to load in VS. An alternative would be to treat
|
||||||
|
# these files as binary and thus will always conflict and require user
|
||||||
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
|
###############################################################################
|
||||||
|
#*.sln merge=binary
|
||||||
|
#*.csproj merge=binary
|
||||||
|
#*.vbproj merge=binary
|
||||||
|
#*.vcxproj merge=binary
|
||||||
|
#*.vcproj merge=binary
|
||||||
|
#*.dbproj merge=binary
|
||||||
|
#*.fsproj merge=binary
|
||||||
|
#*.lsproj merge=binary
|
||||||
|
#*.wixproj merge=binary
|
||||||
|
#*.modelproj merge=binary
|
||||||
|
#*.sqlproj merge=binary
|
||||||
|
#*.wwaproj merge=binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# behavior for image files
|
||||||
|
#
|
||||||
|
# image files are treated as binary by default.
|
||||||
|
###############################################################################
|
||||||
|
#*.jpg binary
|
||||||
|
#*.png binary
|
||||||
|
#*.gif binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# diff behavior for common document formats
|
||||||
|
#
|
||||||
|
# Convert binary document formats to text before diffing them. This feature
|
||||||
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
|
# entries below.
|
||||||
|
###############################################################################
|
||||||
|
#*.doc diff=astextplain
|
||||||
|
#*.DOC diff=astextplain
|
||||||
|
#*.docx diff=astextplain
|
||||||
|
#*.DOCX diff=astextplain
|
||||||
|
#*.dot diff=astextplain
|
||||||
|
#*.DOT diff=astextplain
|
||||||
|
#*.pdf diff=astextplain
|
||||||
|
#*.PDF diff=astextplain
|
||||||
|
#*.rtf diff=astextplain
|
||||||
|
#*.RTF diff=astextplain
|
||||||
106
CUE.NET.csproj
Normal file
106
CUE.NET.csproj
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>CUE.NET</RootNamespace>
|
||||||
|
<AssemblyName>CUE.NET</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;DEBUG;WIN64</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;WIN64</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;DEBUG;WIN32</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;WIN32</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Enums\CorsairAccessMode.cs" />
|
||||||
|
<Compile Include="Enums\CorsairDeviceCaps.cs" />
|
||||||
|
<Compile Include="Enums\CorsairDeviceType.cs" />
|
||||||
|
<Compile Include="Enums\CorsairLedId.cs" />
|
||||||
|
<Compile Include="Enums\CorsairLogicalLayout.cs" />
|
||||||
|
<Compile Include="Enums\CorsairPhysicalLayout.cs" />
|
||||||
|
<Compile Include="Exceptions\CUEException.cs" />
|
||||||
|
<Compile Include="Exceptions\WrapperException.cs" />
|
||||||
|
<Compile Include="Wrapper\AbstractCueDevice.cs" />
|
||||||
|
<Compile Include="Wrapper\CueHeadset.cs" />
|
||||||
|
<Compile Include="Wrapper\CueKeyboard.cs" />
|
||||||
|
<Compile Include="Wrapper\CueMouse.cs" />
|
||||||
|
<Compile Include="Native\_CorsairDeviceInfo.cs" />
|
||||||
|
<Compile Include="Native\_CorsairLedColor.cs" />
|
||||||
|
<Compile Include="Native\_CorsairLedPosition.cs" />
|
||||||
|
<Compile Include="Native\_CorsairLedPositions.cs" />
|
||||||
|
<Compile Include="Native\_CorsairProtocolDetails.cs" />
|
||||||
|
<Compile Include="Native\CUESDK.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Enums\CorsairError.cs" />
|
||||||
|
<Compile Include="Wrapper\CorsairDeviceInfo.cs" />
|
||||||
|
<Compile Include="Wrapper\CorsairProtocolDetails.cs" />
|
||||||
|
<Compile Include="Wrapper\CueSDK.cs" />
|
||||||
|
<Compile Include="Wrapper\ICueDevice.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="libs\CUESDK.x64_2013.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="libs\CUESDK_2013.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>if $(PlatformName) == x86 copy "$(ProjectDir)libs\CUESDK_2013.dll" "$(TargetDir)CUESDK_2013.dll"
|
||||||
|
if $(PlatformName) == x64 copy "$(ProjectDir)libs\CUESDK.x64_2013.dll" "$(TargetDir)CUESDK.x64_2013.dll"</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
2
CUE.NET.csproj.DotSettings
Normal file
2
CUE.NET.csproj.DotSettings
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=libs/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
28
CUE.NET.sln
Normal file
28
CUE.NET.sln
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.23107.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUE.NET", "CUE.NET.csproj", "{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Debug|x64.ActiveCfg = Release|x64
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Debug|x64.Build.0 = Release|x64
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Debug|x86.ActiveCfg = Release|x86
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Debug|x86.Build.0 = Release|x86
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Release|x64.Build.0 = Release|x64
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
13
Enums/CorsairAccessMode.cs
Normal file
13
Enums/CorsairAccessMode.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available SDK access modes.
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairAccessMode
|
||||||
|
{
|
||||||
|
CAM_ExclusiveLightingControl = 0
|
||||||
|
};
|
||||||
|
}
|
||||||
21
Enums/CorsairDeviceCaps.cs
Normal file
21
Enums/CorsairDeviceCaps.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of device capabilities
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairDeviceCaps
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// For devices that do not support any SDK functions
|
||||||
|
/// </summary>
|
||||||
|
CDC_None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For devices that has controlled lighting
|
||||||
|
/// </summary>
|
||||||
|
CDC_Lighting = 1
|
||||||
|
};
|
||||||
|
}
|
||||||
16
Enums/CorsairDeviceType.cs
Normal file
16
Enums/CorsairDeviceType.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available device types.
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairDeviceType
|
||||||
|
{
|
||||||
|
CDT_Unknown = 0,
|
||||||
|
CDT_Mouse = 1,
|
||||||
|
CDT_Keyboard = 2,
|
||||||
|
CDT_Headset = 3
|
||||||
|
};
|
||||||
|
}
|
||||||
42
Enums/CorsairError.cs
Normal file
42
Enums/CorsairError.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Shared list of all errors which could happen during calling of Corsair* functions.
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairError
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// If previously called function completed successfully.
|
||||||
|
/// </summary>
|
||||||
|
CE_Success,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CUE is not running or was shut down or third-party control is disabled in CUE settings. (runtime error)
|
||||||
|
/// </summary>
|
||||||
|
CE_ServerNotFound,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If some other client has or took over exclusive control. (runtime error)
|
||||||
|
/// </summary>
|
||||||
|
CE_NoControl,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If developer did not perform protocol handshake. (developer error)
|
||||||
|
/// </summary>
|
||||||
|
CE_ProtocolHandshakeMissing,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If developer is calling the function that is not supported by the server (either because protocol has broken by server or client or because the function is new and server is too old.
|
||||||
|
/// Check CorsairProtocolDetails for details). (developer error)
|
||||||
|
/// </summary>
|
||||||
|
CE_IncompatibleProtocol,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If developer supplied invalid arguments to the function (for specifics look at function descriptions). (developer error)
|
||||||
|
/// </summary>
|
||||||
|
CE_InvalidArguments
|
||||||
|
};
|
||||||
|
}
|
||||||
166
Enums/CorsairLedId.cs
Normal file
166
Enums/CorsairLedId.cs
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
public enum CorsairLedId
|
||||||
|
{
|
||||||
|
CLI_Invalid = 0,
|
||||||
|
CLK_Escape = 1,
|
||||||
|
CLK_F1 = 2,
|
||||||
|
CLK_F2 = 3,
|
||||||
|
CLK_F3 = 4,
|
||||||
|
CLK_F4 = 5,
|
||||||
|
CLK_F5 = 6,
|
||||||
|
CLK_F6 = 7,
|
||||||
|
CLK_F7 = 8,
|
||||||
|
CLK_F8 = 9,
|
||||||
|
CLK_F9 = 10,
|
||||||
|
CLK_F10 = 11,
|
||||||
|
CLK_F11 = 12,
|
||||||
|
CLK_GraveAccentAndTilde = 13,
|
||||||
|
CLK_1 = 14,
|
||||||
|
CLK_2 = 15,
|
||||||
|
CLK_3 = 16,
|
||||||
|
CLK_4 = 17,
|
||||||
|
CLK_5 = 18,
|
||||||
|
CLK_6 = 19,
|
||||||
|
CLK_7 = 20,
|
||||||
|
CLK_8 = 21,
|
||||||
|
CLK_9 = 22,
|
||||||
|
CLK_0 = 23,
|
||||||
|
CLK_MinusAndUnderscore = 24,
|
||||||
|
CLK_Tab = 25,
|
||||||
|
CLK_Q = 26,
|
||||||
|
CLK_W = 27,
|
||||||
|
CLK_E = 28,
|
||||||
|
CLK_R = 29,
|
||||||
|
CLK_T = 30,
|
||||||
|
CLK_Y = 31,
|
||||||
|
CLK_U = 32,
|
||||||
|
CLK_I = 33,
|
||||||
|
CLK_O = 34,
|
||||||
|
CLK_P = 35,
|
||||||
|
CLK_BracketLeft = 36,
|
||||||
|
CLK_CapsLock = 37,
|
||||||
|
CLK_A = 38,
|
||||||
|
CLK_S = 39,
|
||||||
|
CLK_D = 40,
|
||||||
|
CLK_F = 41,
|
||||||
|
CLK_G = 42,
|
||||||
|
CLK_H = 43,
|
||||||
|
CLK_J = 44,
|
||||||
|
CLK_K = 45,
|
||||||
|
CLK_L = 46,
|
||||||
|
CLK_SemicolonAndColon = 47,
|
||||||
|
CLK_ApostropheAndDoubleQuote = 48,
|
||||||
|
CLK_LeftShift = 49,
|
||||||
|
CLK_NonUsBackslash = 50,
|
||||||
|
CLK_Z = 51,
|
||||||
|
CLK_X = 52,
|
||||||
|
CLK_C = 53,
|
||||||
|
CLK_V = 54,
|
||||||
|
CLK_B = 55,
|
||||||
|
CLK_N = 56,
|
||||||
|
CLK_M = 57,
|
||||||
|
CLK_CommaAndLessThan = 58,
|
||||||
|
CLK_PeriodAndBiggerThan = 59,
|
||||||
|
CLK_SlashAndQuestionMark = 60,
|
||||||
|
CLK_LeftCtrl = 61,
|
||||||
|
CLK_LeftGui = 62,
|
||||||
|
CLK_LeftAlt = 63,
|
||||||
|
CLK_Lang2 = 64,
|
||||||
|
CLK_Space = 65,
|
||||||
|
CLK_Lang1 = 66,
|
||||||
|
CLK_International2 = 67,
|
||||||
|
CLK_RightAlt = 68,
|
||||||
|
CLK_RightGui = 69,
|
||||||
|
CLK_Application = 70,
|
||||||
|
CLK_LedProgramming = 71,
|
||||||
|
CLK_Brightness = 72,
|
||||||
|
CLK_F12 = 73,
|
||||||
|
CLK_PrintScreen = 74,
|
||||||
|
CLK_ScrollLock = 75,
|
||||||
|
CLK_PauseBreak = 76,
|
||||||
|
CLK_Insert = 77,
|
||||||
|
CLK_Home = 78,
|
||||||
|
CLK_PageUp = 79,
|
||||||
|
CLK_BracketRight = 80,
|
||||||
|
CLK_Backslash = 81,
|
||||||
|
CLK_NonUsTilde = 82,
|
||||||
|
CLK_Enter = 83,
|
||||||
|
CLK_International1 = 84,
|
||||||
|
CLK_EqualsAndPlus = 85,
|
||||||
|
CLK_International3 = 86,
|
||||||
|
CLK_Backspace = 87,
|
||||||
|
CLK_Delete = 88,
|
||||||
|
CLK_End = 89,
|
||||||
|
CLK_PageDown = 90,
|
||||||
|
CLK_RightShift = 91,
|
||||||
|
CLK_RightCtrl = 92,
|
||||||
|
CLK_UpArrow = 93,
|
||||||
|
CLK_LeftArrow = 94,
|
||||||
|
CLK_DownArrow = 95,
|
||||||
|
CLK_RightArrow = 96,
|
||||||
|
CLK_WinLock = 97,
|
||||||
|
CLK_Mute = 98,
|
||||||
|
CLK_Stop = 99,
|
||||||
|
CLK_ScanPreviousTrack = 100,
|
||||||
|
CLK_PlayPause = 101,
|
||||||
|
CLK_ScanNextTrack = 102,
|
||||||
|
CLK_NumLock = 103,
|
||||||
|
CLK_KeypadSlash = 104,
|
||||||
|
CLK_KeypadAsterisk = 105,
|
||||||
|
CLK_KeypadMinus = 106,
|
||||||
|
CLK_KeypadPlus = 107,
|
||||||
|
CLK_KeypadEnter = 108,
|
||||||
|
CLK_Keypad7 = 109,
|
||||||
|
CLK_Keypad8 = 110,
|
||||||
|
CLK_Keypad9 = 111,
|
||||||
|
CLK_KeypadComma = 112,
|
||||||
|
CLK_Keypad4 = 113,
|
||||||
|
CLK_Keypad5 = 114,
|
||||||
|
CLK_Keypad6 = 115,
|
||||||
|
CLK_Keypad1 = 116,
|
||||||
|
CLK_Keypad2 = 117,
|
||||||
|
CLK_Keypad3 = 118,
|
||||||
|
CLK_Keypad0 = 119,
|
||||||
|
CLK_KeypadPeriodAndDelete = 120,
|
||||||
|
CLK_G1 = 121,
|
||||||
|
CLK_G2 = 122,
|
||||||
|
CLK_G3 = 123,
|
||||||
|
CLK_G4 = 124,
|
||||||
|
CLK_G5 = 125,
|
||||||
|
CLK_G6 = 126,
|
||||||
|
CLK_G7 = 127,
|
||||||
|
CLK_G8 = 128,
|
||||||
|
CLK_G9 = 129,
|
||||||
|
CLK_G10 = 130,
|
||||||
|
CLK_VolumeUp = 131,
|
||||||
|
CLK_VolumeDown = 132,
|
||||||
|
CLK_MR = 133,
|
||||||
|
CLK_M1 = 134,
|
||||||
|
CLK_M2 = 135,
|
||||||
|
CLK_M3 = 136,
|
||||||
|
CLK_G11 = 137,
|
||||||
|
CLK_G12 = 138,
|
||||||
|
CLK_G13 = 139,
|
||||||
|
CLK_G14 = 140,
|
||||||
|
CLK_G15 = 141,
|
||||||
|
CLK_G16 = 142,
|
||||||
|
CLK_G17 = 143,
|
||||||
|
CLK_G18 = 144,
|
||||||
|
CLK_International5 = 145,
|
||||||
|
CLK_International4 = 146,
|
||||||
|
CLK_Fn = 147,
|
||||||
|
CLM_1 = 148,
|
||||||
|
CLM_2 = 149,
|
||||||
|
CLM_3 = 150,
|
||||||
|
CLM_4 = 151,
|
||||||
|
CLH_LeftLogo = 152,
|
||||||
|
CLH_RightLogo = 153,
|
||||||
|
CLK_Logo = 154,
|
||||||
|
|
||||||
|
CLI_Last = CLK_Logo
|
||||||
|
};
|
||||||
|
}
|
||||||
35
Enums/CorsairLogicalLayout.cs
Normal file
35
Enums/CorsairLogicalLayout.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available logical layouts for keyboards.
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairLogicalLayout
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Dummy value
|
||||||
|
/// </summary>
|
||||||
|
CLL_Invalid = 0,
|
||||||
|
|
||||||
|
CLL_US_Int = 1,
|
||||||
|
CLL_NA = 2,
|
||||||
|
CLL_EU = 3,
|
||||||
|
CLL_UK = 4,
|
||||||
|
CLL_BE = 5,
|
||||||
|
CLL_BR = 6,
|
||||||
|
CLL_CH = 7,
|
||||||
|
CLL_CN = 8,
|
||||||
|
CLL_DE = 9,
|
||||||
|
CLL_ES = 10,
|
||||||
|
CLL_FR = 11,
|
||||||
|
CLL_IT = 12,
|
||||||
|
CLL_ND = 13,
|
||||||
|
CLL_RU = 14,
|
||||||
|
CLL_JP = 15,
|
||||||
|
CLL_KR = 16,
|
||||||
|
CLL_TW = 17,
|
||||||
|
CLL_MEX = 18
|
||||||
|
};
|
||||||
|
}
|
||||||
61
Enums/CorsairPhysicalLayout.cs
Normal file
61
Enums/CorsairPhysicalLayout.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace CUE.NET.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of available physical layouts for keyboards.
|
||||||
|
/// </summary>
|
||||||
|
public enum CorsairPhysicalLayout
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Dummy value
|
||||||
|
/// </summary>
|
||||||
|
CPL_Invalid = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// US-Keyboard
|
||||||
|
/// </summary>
|
||||||
|
CPL_US = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UK-Keyboard
|
||||||
|
/// </summary>
|
||||||
|
CPL_UK = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// BR-Keyboard
|
||||||
|
/// </summary>
|
||||||
|
CPL_BR = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JP-Keyboard
|
||||||
|
/// </summary>
|
||||||
|
CPL_JP = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// KR-Keyboard
|
||||||
|
/// </summary>
|
||||||
|
CPL_KR = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zone1-Mouse
|
||||||
|
/// </summary>
|
||||||
|
CPL_Zones1 = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zone1-Mouse
|
||||||
|
/// </summary>
|
||||||
|
CPL_Zones2 = 7,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zone1-Mouse
|
||||||
|
/// </summary>
|
||||||
|
CPL_Zones3 = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zone1-Mouse
|
||||||
|
/// </summary>
|
||||||
|
CPL_Zones4 = 9
|
||||||
|
};
|
||||||
|
}
|
||||||
26
Exceptions/CUEException.cs
Normal file
26
Exceptions/CUEException.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
|
||||||
|
namespace CUE.NET.Exceptions
|
||||||
|
{
|
||||||
|
public class CUEException : ApplicationException
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
public CorsairError Error { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public CUEException(CorsairError error)
|
||||||
|
{
|
||||||
|
this.Error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Exceptions/WrapperException.cs
Normal file
15
Exceptions/WrapperException.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CUE.NET.Exceptions
|
||||||
|
{
|
||||||
|
public class WrapperException : ApplicationException
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public WrapperException(string message, Exception innerException = null)
|
||||||
|
: base(message, innerException)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Native/CUESDK.cs
Normal file
45
Native/CUESDK.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
|
||||||
|
namespace CUE.NET.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
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
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern bool CorsairSetLedsColors(int size, IntPtr ledsColors);
|
||||||
|
|
||||||
|
//[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
//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.
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern int CorsairGetDeviceCount();
|
||||||
|
|
||||||
|
// returns information about device at provided index
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern IntPtr CorsairGetDeviceInfo(int deviceIndex);
|
||||||
|
|
||||||
|
// provides list of keyboard LEDs with their physical positions.
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern IntPtr CorsairGetLedPositions();
|
||||||
|
|
||||||
|
// retrieves led id for key name taking logical layout into account.
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
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
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
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
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern _CorsairProtocolDetails CorsairPerformProtocolHandshake();
|
||||||
|
|
||||||
|
// returns last error that occured while using any of Corsair* functions
|
||||||
|
[DllImport("CUESDK.x64_2013.dll")]
|
||||||
|
public static extern CorsairError CorsairGetLastError();
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Native/_CorsairDeviceInfo.cs
Normal file
21
Native/_CorsairDeviceInfo.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma warning disable 169 // Field 'x' is never used
|
||||||
|
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||||
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
|
||||||
|
namespace CUE.NET.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public class _CorsairDeviceInfo // contains information about device
|
||||||
|
{
|
||||||
|
internal CorsairDeviceType type; // enum describing device type
|
||||||
|
internal IntPtr model; // null - terminated device model(like “K95RGB”)
|
||||||
|
internal CorsairPhysicalLayout physicalLayout; // enum describing physical layout of the keyboard or mouse
|
||||||
|
internal CorsairLogicalLayout logicalLayout; // enum describing logical layout of the keyboard as set in CUE settings
|
||||||
|
internal int capsMask; // mask that describes device capabilities, formed as logical “or” of CorsairDeviceCaps enum values
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Native/_CorsairLedColor.cs
Normal file
20
Native/_CorsairLedColor.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma warning disable 169 // Field 'x' is never used
|
||||||
|
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||||
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
|
||||||
|
namespace CUE.NET.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public class _CorsairLedColor // contains information about led and its color
|
||||||
|
{
|
||||||
|
|
||||||
|
internal CorsairLedId ledId; // identifier of LED to set
|
||||||
|
internal int r; // red brightness[0..255]
|
||||||
|
internal int g; // green brightness[0..255]
|
||||||
|
internal int b; // blue brightness[0..255]
|
||||||
|
};
|
||||||
|
}
|
||||||
20
Native/_CorsairLedPosition.cs
Normal file
20
Native/_CorsairLedPosition.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma warning disable 169 // Field 'x' is never used
|
||||||
|
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||||
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
|
||||||
|
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 CorsairLedId ledId; // identifier of led
|
||||||
|
internal double top;
|
||||||
|
internal double left;
|
||||||
|
internal double height;
|
||||||
|
internal double width; // values in mm
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Native/_CorsairLedPositions.cs
Normal file
17
Native/_CorsairLedPositions.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma warning disable 169 // Field 'x' is never used
|
||||||
|
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||||
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace CUE.NET.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public 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
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Native/_CorsairProtocolDetails.cs
Normal file
20
Native/_CorsairProtocolDetails.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma warning disable 169 // Field 'x' is never used
|
||||||
|
#pragma warning disable 414 // Field 'x' is assigned but its value never used
|
||||||
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace CUE.NET.Native
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct _CorsairProtocolDetails // contains information about SDK and CUE versions
|
||||||
|
{
|
||||||
|
internal IntPtr sdkVersion; // null - terminated string containing version of SDK(like “1.0.0.1”). Always contains valid value even if there was no CUE found
|
||||||
|
internal IntPtr serverVersion; // null - terminated string containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found.
|
||||||
|
internal int sdkProtocolVersion; // integer number that specifies version of protocol that is implemented by current SDK. Numbering starts from 1. Always contains valid value even if there was no CUE found
|
||||||
|
internal int serverProtocolVersion; // integer number that specifies version of protocol that is implemented by CUE. Numbering starts from 1. If CUE was not found then this value will be 0
|
||||||
|
internal byte breakingChanges; // boolean value that specifies if there were breaking changes between version of protocol implemented by server and client
|
||||||
|
};
|
||||||
|
}
|
||||||
35
Properties/AssemblyInfo.cs
Normal file
35
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("CUE.NET")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Wyrez")]
|
||||||
|
[assembly: AssemblyProduct("CUE.NET")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Wyrez 2015")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("70a266b5-e9d4-4eaa-a91a-947c0039ffb6")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
24
Wrapper/AbstractCueDevice.cs
Normal file
24
Wrapper/AbstractCueDevice.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
public abstract class AbstractCueDevice : ICueDevice
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
public CorsairDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
protected AbstractCueDevice(CorsairDeviceInfo info)
|
||||||
|
{
|
||||||
|
this.DeviceInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
57
Wrapper/CorsairDeviceInfo.cs
Normal file
57
Wrapper/CorsairDeviceInfo.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
using CUE.NET.Native;
|
||||||
|
|
||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
public class CorsairDeviceInfo
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Device type.
|
||||||
|
/// </summary>
|
||||||
|
public CorsairDeviceType Type { get; private set; }
|
||||||
|
|
||||||
|
//TODO DarthAffe 17.09.2015: This could be an Enum
|
||||||
|
/// <summary>
|
||||||
|
/// Device model (like “K95RGB”).
|
||||||
|
/// </summary>
|
||||||
|
public string Model { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Physical layout of the keyboard or mouse.
|
||||||
|
/// </summary>
|
||||||
|
public CorsairPhysicalLayout PhysicalLayout { get; private set; }
|
||||||
|
|
||||||
|
//TODO DarthAffe 17.09.2015: Would device-specific infos be useful?
|
||||||
|
/// <summary>
|
||||||
|
/// Logical layout of the keyboard as set in CUE settings.
|
||||||
|
/// </summary>
|
||||||
|
public CorsairLogicalLayout LogicalLayout { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mask that describes device capabilities, formed as logical "or" of CorsairDeviceCaps enum values
|
||||||
|
/// </summary>
|
||||||
|
public int CapsMask { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public CorsairDeviceInfo(_CorsairDeviceInfo nativeInfo)
|
||||||
|
{
|
||||||
|
this.Type = nativeInfo.type;
|
||||||
|
this.Model = nativeInfo.model == IntPtr.Zero ? null : Marshal.PtrToStringAuto(nativeInfo.model);
|
||||||
|
this.PhysicalLayout = nativeInfo.physicalLayout;
|
||||||
|
this.LogicalLayout = nativeInfo.logicalLayout;
|
||||||
|
this.CapsMask = nativeInfo.capsMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
66
Wrapper/CorsairProtocolDetails.cs
Normal file
66
Wrapper/CorsairProtocolDetails.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Native;
|
||||||
|
|
||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Managed wrapper for CorsairProtocolDetails.
|
||||||
|
/// </summary>
|
||||||
|
public class CorsairProtocolDetails
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// String containing version of SDK(like “1.0.0.1”).
|
||||||
|
/// Always contains valid value even if there was no CUE found.
|
||||||
|
/// </summary>
|
||||||
|
public string SdkVersion { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// String containing version of CUE(like “1.0.0.1”) or NULL if CUE was not found.
|
||||||
|
/// </summary>
|
||||||
|
public string ServerVersion { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Integer that specifies version of protocol that is implemented by current SDK.
|
||||||
|
/// Numbering starts from 1.
|
||||||
|
/// Always contains valid value even if there was no CUE found.
|
||||||
|
/// </summary>
|
||||||
|
public int SdkProtocolVersion { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Integer that specifies version of protocol that is implemented by CUE.
|
||||||
|
/// Numbering starts from 1.
|
||||||
|
/// If CUE was not found then this value will be 0.
|
||||||
|
/// </summary>
|
||||||
|
public int ServerProtocolVersion { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client.
|
||||||
|
/// </summary>
|
||||||
|
public byte BreakingChanges { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal constructor of managed CorsairProtocolDetails.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nativeDetails">The native CorsairProtocolDetails-struct</param>
|
||||||
|
internal CorsairProtocolDetails(_CorsairProtocolDetails nativeDetails)
|
||||||
|
{
|
||||||
|
this.SdkVersion = nativeDetails.sdkVersion == IntPtr.Zero ? null : Marshal.PtrToStringAuto(nativeDetails.sdkVersion);
|
||||||
|
this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAuto(nativeDetails.serverVersion);
|
||||||
|
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
|
||||||
|
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
|
||||||
|
this.BreakingChanges = nativeDetails.breakingChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Wrapper/CueHeadset.cs
Normal file
22
Wrapper/CueHeadset.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
//TODO DarthAffe 18.09.2015: Implement
|
||||||
|
public class CueHeadset : AbstractCueDevice
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public CueHeadset(CorsairDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
38
Wrapper/CueKeyboard.cs
Normal file
38
Wrapper/CueKeyboard.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
using CUE.NET.Native;
|
||||||
|
|
||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
public class CueKeyboard : AbstractCueDevice
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public CueKeyboard(CorsairDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public void SetKeyColor(char key, Color color)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Wrapper/CueMouse.cs
Normal file
22
Wrapper/CueMouse.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
//TODO DarthAffe 18.09.2015: Implement
|
||||||
|
public class CueMouse : AbstractCueDevice
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public CueMouse(CorsairDeviceInfo info)
|
||||||
|
: base(info)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
90
Wrapper/CueSDK.cs
Normal file
90
Wrapper/CueSDK.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Enums;
|
||||||
|
using CUE.NET.Exceptions;
|
||||||
|
using CUE.NET.Native;
|
||||||
|
|
||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
public static class CueSDK
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
public static CorsairProtocolDetails ProtocolDetails { get; private set; }
|
||||||
|
public static bool HasExclusiveAccess { get; private set; }
|
||||||
|
public static CorsairError LastError => CUESDK.CorsairGetLastError();
|
||||||
|
|
||||||
|
public static CueKeyboard KeyboardSDK { get; private set; }
|
||||||
|
public static CueMouse MouseSDK { get; private set; }
|
||||||
|
public static CueHeadset HeadsetSDK { get; private set; }
|
||||||
|
|
||||||
|
// ReSharper restore UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public static void Initialize(bool exclusiveAccess = false)
|
||||||
|
{
|
||||||
|
if (ProtocolDetails != null)
|
||||||
|
throw new WrapperException("CueSDK is already initialized.");
|
||||||
|
|
||||||
|
ProtocolDetails = new CorsairProtocolDetails(CUESDK.CorsairPerformProtocolHandshake());
|
||||||
|
|
||||||
|
CorsairError error = LastError;
|
||||||
|
if (error != CorsairError.CE_Success)
|
||||||
|
Throw(error);
|
||||||
|
|
||||||
|
if (exclusiveAccess)
|
||||||
|
{
|
||||||
|
if (!CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
|
||||||
|
Throw(error);
|
||||||
|
|
||||||
|
HasExclusiveAccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int deviceCount = CUESDK.CorsairGetDeviceCount();
|
||||||
|
for (int i = 0; i < deviceCount; i++)
|
||||||
|
{
|
||||||
|
CorsairDeviceInfo info = new CorsairDeviceInfo((_CorsairDeviceInfo)Marshal.PtrToStructure(CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)));
|
||||||
|
switch (info.Type)
|
||||||
|
{
|
||||||
|
case CorsairDeviceType.CDT_Keyboard:
|
||||||
|
KeyboardSDK = new CueKeyboard(info);
|
||||||
|
break;
|
||||||
|
case CorsairDeviceType.CDT_Mouse:
|
||||||
|
MouseSDK = new CueMouse(info);
|
||||||
|
break;
|
||||||
|
case CorsairDeviceType.CDT_Headset:
|
||||||
|
HeadsetSDK = new CueHeadset(info);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ReSharper disable once RedundantCaseLabel
|
||||||
|
case CorsairDeviceType.CDT_Unknown:
|
||||||
|
default:
|
||||||
|
throw new WrapperException("Unknown Device-Type");
|
||||||
|
}
|
||||||
|
|
||||||
|
error = LastError;
|
||||||
|
if (error != CorsairError.CE_Success)
|
||||||
|
Throw(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Throw(CorsairError error)
|
||||||
|
{
|
||||||
|
ProtocolDetails = null;
|
||||||
|
HasExclusiveAccess = false;
|
||||||
|
KeyboardSDK = null;
|
||||||
|
MouseSDK = null;
|
||||||
|
HeadsetSDK = null;
|
||||||
|
|
||||||
|
throw new CUEException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Wrapper/ICueDevice.cs
Normal file
7
Wrapper/ICueDevice.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace CUE.NET.Wrapper
|
||||||
|
{
|
||||||
|
public interface ICueDevice
|
||||||
|
{
|
||||||
|
CorsairDeviceInfo DeviceInfo { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
libs/CUESDK.x64_2013.dll
Normal file
BIN
libs/CUESDK.x64_2013.dll
Normal file
Binary file not shown.
BIN
libs/CUESDK_2013.dll
Normal file
BIN
libs/CUESDK_2013.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user