1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-02 10:43:31 +00:00

Updated the Corsair-Mice-DeviceProvider to benefit from CUE.NET 1.0.3

This commit is contained in:
Darth Affe 2016-06-04 09:56:48 +02:00
parent 2616179e7f
commit f871f9ffde

View File

@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Media;
@ -23,8 +22,8 @@ namespace Artemis.DeviceProviders.Corsair
public override bool TryEnable()
{
CanUse = CanInitializeSdk();
if (CanUse)
CueSDK.MouseSDK.UpdateMode = UpdateMode.Manual;
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize();
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
return CanUse;
@ -66,29 +65,13 @@ namespace Artemis.DeviceProviders.Corsair
private static bool CanInitializeSdk()
{
// If already initialized, return result right away
if (CueSDK.ProtocolDetails != null)
return CueSDK.MouseSDK != null;
// Else try to enable the SDK
for (var tries = 0; tries < 9; tries++)
{
if (CueSDK.ProtocolDetails != null)
break;
try
{
CueSDK.Initialize();
}
catch (Exception)
{
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard))
return true;
Thread.Sleep(2000);
}
}
if (CueSDK.ProtocolDetails == null)
return false;
return CueSDK.MouseSDK != null;
}
}
}