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

Added capability check on initialization

This commit is contained in:
unknown 2015-09-19 10:10:27 +02:00
parent 75412594a5
commit 531a68fa06
3 changed files with 14 additions and 2 deletions

View File

@ -43,6 +43,10 @@ namespace CUE.NET.Wrapper
#region Constructors
/// <summary>
/// Internal constructor of managed CorsairDeviceInfo.
/// </summary>
/// <param name="nativeInfo">The native CorsairDeviceInfo-struct</param>
public CorsairDeviceInfo(_CorsairDeviceInfo nativeInfo)
{
this.Type = nativeInfo.type;

View File

@ -42,7 +42,7 @@ namespace CUE.NET.Wrapper
/// <summary>
/// Boolean that specifies if there were breaking changes between version of protocol implemented by server and client.
/// </summary>
public byte BreakingChanges { get; }
public bool BreakingChanges { get; }
#endregion
@ -58,7 +58,7 @@ namespace CUE.NET.Wrapper
this.ServerVersion = nativeDetails.serverVersion == IntPtr.Zero ? null : Marshal.PtrToStringAuto(nativeDetails.serverVersion);
this.SdkProtocolVersion = nativeDetails.sdkProtocolVersion;
this.ServerProtocolVersion = nativeDetails.serverProtocolVersion;
this.BreakingChanges = nativeDetails.breakingChanges;
this.BreakingChanges = nativeDetails.breakingChanges != 0;
}
#endregion

View File

@ -38,6 +38,11 @@ namespace CUE.NET.Wrapper
if (error != CorsairError.CE_Success)
Throw(error);
if (ProtocolDetails.BreakingChanges)
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n" +
$"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n" +
$"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})");
if (exclusiveAccess)
{
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.CAM_ExclusiveLightingControl))
@ -50,6 +55,9 @@ namespace CUE.NET.Wrapper
for (int i = 0; i < deviceCount; i++)
{
CorsairDeviceInfo info = new CorsairDeviceInfo((_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)));
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.CDC_Lighting))
continue; // Everything that doesn't support lighting control is useless
switch (info.Type)
{
case CorsairDeviceType.CDT_Keyboard: