mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Updated the Corsair-Keyboard-DeviceProvider to benefit from CUE.NET 1.0.3
This commit is contained in:
parent
47f2bf2c0d
commit
2616179e7f
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Properties;
|
using Artemis.Properties;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Devices.Keyboard;
|
using CUE.NET.Devices.Keyboard;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
public class CorsairRGB : KeyboardProvider
|
public class CorsairRGB : KeyboardProvider
|
||||||
{
|
{
|
||||||
private CorsairKeyboard _keyboard;
|
private CorsairKeyboard _keyboard;
|
||||||
|
private ImageBrush _keyboardBrush;
|
||||||
|
|
||||||
public CorsairRGB()
|
public CorsairRGB()
|
||||||
{
|
{
|
||||||
@ -26,29 +27,13 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
|
|
||||||
public override bool CanEnable()
|
public override bool CanEnable()
|
||||||
{
|
{
|
||||||
// If already initialized, return result right away
|
|
||||||
if (CueSDK.ProtocolDetails != null)
|
|
||||||
return CueSDK.KeyboardSDK != null;
|
|
||||||
|
|
||||||
// Else try to enable the SDK
|
|
||||||
for (var tries = 0; tries < 9; tries++)
|
for (var tries = 0; tries < 9; tries++)
|
||||||
{
|
{
|
||||||
if (CueSDK.ProtocolDetails != null)
|
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard))
|
||||||
break;
|
return true;
|
||||||
|
Thread.Sleep(2000);
|
||||||
try
|
|
||||||
{
|
|
||||||
CueSDK.Initialize();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
if (CueSDK.ProtocolDetails == null)
|
|
||||||
return false;
|
|
||||||
return CueSDK.KeyboardSDK != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -56,7 +41,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
if (CueSDK.ProtocolDetails == null)
|
if (!CueSDK.IsInitialized)
|
||||||
CueSDK.Initialize();
|
CueSDK.Initialize();
|
||||||
|
|
||||||
_keyboard = CueSDK.KeyboardSDK;
|
_keyboard = CueSDK.KeyboardSDK;
|
||||||
@ -83,11 +68,13 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
|
PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Disable()
|
public override void Disable()
|
||||||
{
|
{
|
||||||
if (CueSDK.ProtocolDetails != null)
|
if (CueSDK.IsInitialized)
|
||||||
CueSDK.Reinitialize();
|
CueSDK.Reinitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,12 +100,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
image = strafeBitmap;
|
image = strafeBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
var brush = new ImageBrush
|
_keyboardBrush.Image = image;
|
||||||
{
|
|
||||||
Image = image
|
|
||||||
};
|
|
||||||
|
|
||||||
_keyboard.Brush = brush;
|
|
||||||
_keyboard.Update();
|
_keyboard.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user