diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs index f417b4615..8ca491489 100644 --- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs +++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs @@ -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; @@ -42,7 +41,7 @@ namespace Artemis.DeviceProviders.Corsair return; var leds = CueSDK.MouseSDK.Leds.Count(); - var rect = new Rect(new Size(leds*20, leds*20)); + var rect = new Rect(new Size(leds * 20, leds * 20)); var img = brush.Dispatcher.Invoke(() => { var visual = new DrawingVisual(); @@ -57,7 +56,7 @@ namespace Artemis.DeviceProviders.Corsair { corsairLed.Color = ledIndex == 0 ? img.GetPixel(0, 0) - : img.GetPixel((ledIndex + 1)*20 - 1, (ledIndex + 1)*20 - 1); + : img.GetPixel((ledIndex + 1) * 20 - 1, (ledIndex + 1) * 20 - 1); ledIndex++; } @@ -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) - { - Thread.Sleep(2000); - } + if (CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard)) + return true; + Thread.Sleep(2000); } - - if (CueSDK.ProtocolDetails == null) - return false; - return CueSDK.MouseSDK != null; + return false; } } } \ No newline at end of file