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

Fixed CUE.NET implementation to actually use the Nuget package

This commit is contained in:
SpoinkyNL 2017-01-24 22:32:36 +01:00
parent 182d710d16
commit 310bd52efc
7 changed files with 337 additions and 338 deletions

View File

@ -160,7 +160,6 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="CUE.NET, Version=1.1.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="CUE.NET, Version=1.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CUE.NET.1.1.1\lib\net45\CUE.NET.dll</HintPath> <HintPath>..\packages\CUE.NET.1.1.1\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>

View File

@ -27,7 +27,7 @@ namespace Artemis.DeviceProviders.Corsair
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse); Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
if (CanUse) if (CanUse)
CueSDK.HeadsetSDK.UpdateMode = UpdateMode.Manual; CueSDK.UpdateMode = UpdateMode.Manual;
return CanUse; return CanUse;
} }

View File

@ -8,8 +8,8 @@ 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;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard.Keys;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Helper; using CUE.NET.Helper;
using Ninject.Extensions.Logging; using Ninject.Extensions.Logging;
@ -47,7 +47,7 @@ namespace Artemis.DeviceProviders.Corsair
if (!CueSDK.IsInitialized) if (!CueSDK.IsInitialized)
CueSDK.Initialize(); CueSDK.Initialize();
CueSDK.KeyboardSDK.UpdateMode = UpdateMode.Manual; CueSDK.UpdateMode = UpdateMode.Manual;
_keyboard = CueSDK.KeyboardSDK; _keyboard = CueSDK.KeyboardSDK;
switch (_keyboard.DeviceInfo.Model) switch (_keyboard.DeviceInfo.Model)
{ {
@ -136,24 +136,24 @@ namespace Artemis.DeviceProviders.Corsair
public override KeyMatch? GetKeyPosition(Keys keyCode) public override KeyMatch? GetKeyPosition(Keys keyCode)
{ {
var widthMultiplier = Width / _keyboard.KeyboardRectangle.Width; var widthMultiplier = Width / _keyboard.Brush.RenderedRectangle.Width;
var heightMultiplier = Height / _keyboard.KeyboardRectangle.Height; var heightMultiplier = Height / _keyboard.Brush.RenderedRectangle.Height;
CorsairKey cueKey = null; CorsairLed cueLed = null;
try try
{ {
cueKey = _keyboard.Keys.FirstOrDefault(k => k.KeyId.ToString() == keyCode.ToString()) ?? cueLed = _keyboard.Leds.FirstOrDefault(k => k.Id.ToString() == keyCode.ToString()) ??
_keyboard.Keys.FirstOrDefault(k => k.KeyId == KeyMap.FormsKeys[keyCode]); _keyboard.Leds.FirstOrDefault(k => k.Id == KeyMap.FormsKeys[keyCode]);
} }
catch (Exception) catch (Exception)
{ {
// ignored // ignored
} }
if (cueKey == null) if (cueLed == null)
return null; return null;
var center = cueKey.KeyRectangle.GetCenter(); var center = cueLed.LedRectangle.GetCenter();
return new KeyMatch(keyCode, (int)(center.X * widthMultiplier), (int)(center.Y * heightMultiplier)); return new KeyMatch(keyCode, (int)(center.X * widthMultiplier), (int)(center.Y * heightMultiplier));
} }
} }

View File

@ -27,7 +27,7 @@ namespace Artemis.DeviceProviders.Corsair
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse); Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
if (CanUse) if (CanUse)
CueSDK.MouseSDK.UpdateMode = UpdateMode.Manual; CueSDK.UpdateMode = UpdateMode.Manual;
return CanUse; return CanUse;
} }

View File

@ -27,7 +27,7 @@ namespace Artemis.DeviceProviders.Corsair
Logger.Debug("Attempted to enable Corsair mousemat. CanUse: {0}", CanUse); Logger.Debug("Attempted to enable Corsair mousemat. CanUse: {0}", CanUse);
if (CanUse) if (CanUse)
CueSDK.MousematSDK.UpdateMode = UpdateMode.Manual; CueSDK.UpdateMode = UpdateMode.Manual;
return CanUse; return CanUse;
} }

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using CUE.NET.Devices.Keyboard.Enums; using CUE.NET.Devices.Generic.Enums;
namespace Artemis.DeviceProviders.Corsair.Utilities namespace Artemis.DeviceProviders.Corsair.Utilities
{ {
@ -8,64 +8,64 @@ namespace Artemis.DeviceProviders.Corsair.Utilities
{ {
static KeyMap() static KeyMap()
{ {
FormsKeys = new Dictionary<Keys, CorsairKeyboardKeyId> FormsKeys = new Dictionary<Keys, CorsairLedId>
{ {
{Keys.Scroll, CorsairKeyboardKeyId.ScrollLock}, {Keys.Scroll, CorsairLedId.ScrollLock},
{Keys.Pause, CorsairKeyboardKeyId.PauseBreak}, {Keys.Pause, CorsairLedId.PauseBreak},
{Keys.Back, CorsairKeyboardKeyId.Backspace}, {Keys.Back, CorsairLedId.Backspace},
{Keys.Oemtilde, CorsairKeyboardKeyId.GraveAccentAndTilde}, {Keys.Oemtilde, CorsairLedId.GraveAccentAndTilde},
{Keys.OemMinus, CorsairKeyboardKeyId.MinusAndUnderscore}, {Keys.OemMinus, CorsairLedId.MinusAndUnderscore},
{Keys.Oemplus, CorsairKeyboardKeyId.EqualsAndPlus}, {Keys.Oemplus, CorsairLedId.EqualsAndPlus},
{Keys.OemOpenBrackets, CorsairKeyboardKeyId.BracketLeft}, {Keys.OemOpenBrackets, CorsairLedId.BracketLeft},
{Keys.Oem6, CorsairKeyboardKeyId.BracketRight}, {Keys.Oem6, CorsairLedId.BracketRight},
{Keys.Return, CorsairKeyboardKeyId.Enter}, {Keys.Return, CorsairLedId.Enter},
{Keys.Next, CorsairKeyboardKeyId.PageDown}, {Keys.Next, CorsairLedId.PageDown},
{Keys.Capital, CorsairKeyboardKeyId.CapsLock}, {Keys.Capital, CorsairLedId.CapsLock},
{Keys.Oem1, CorsairKeyboardKeyId.SemicolonAndColon}, {Keys.Oem1, CorsairLedId.SemicolonAndColon},
{Keys.Oem7, CorsairKeyboardKeyId.ApostropheAndDoubleQuote}, {Keys.Oem7, CorsairLedId.ApostropheAndDoubleQuote},
{Keys.OemBackslash, CorsairKeyboardKeyId.Backslash}, {Keys.OemBackslash, CorsairLedId.Backslash},
{Keys.LShiftKey, CorsairKeyboardKeyId.LeftShift}, {Keys.LShiftKey, CorsairLedId.LeftShift},
{Keys.Oem5, CorsairKeyboardKeyId.NonUsBackslash}, {Keys.Oem5, CorsairLedId.NonUsBackslash},
{Keys.Oemcomma, CorsairKeyboardKeyId.CommaAndLessThan}, {Keys.Oemcomma, CorsairLedId.CommaAndLessThan},
{Keys.OemPeriod, CorsairKeyboardKeyId.PeriodAndBiggerThan}, {Keys.OemPeriod, CorsairLedId.PeriodAndBiggerThan},
{Keys.OemQuestion, CorsairKeyboardKeyId.SlashAndQuestionMark}, {Keys.OemQuestion, CorsairLedId.SlashAndQuestionMark},
{Keys.RShiftKey, CorsairKeyboardKeyId.RightShift}, {Keys.RShiftKey, CorsairLedId.RightShift},
{Keys.LControlKey, CorsairKeyboardKeyId.LeftCtrl}, {Keys.LControlKey, CorsairLedId.LeftCtrl},
{Keys.LWin, CorsairKeyboardKeyId.LeftGui}, {Keys.LWin, CorsairLedId.LeftGui},
{Keys.LMenu, CorsairKeyboardKeyId.LeftAlt}, {Keys.LMenu, CorsairLedId.LeftAlt},
{Keys.RMenu, CorsairKeyboardKeyId.RightAlt}, {Keys.RMenu, CorsairLedId.RightAlt},
{Keys.RWin, CorsairKeyboardKeyId.RightGui}, {Keys.RWin, CorsairLedId.RightGui},
{Keys.Apps, CorsairKeyboardKeyId.Application}, {Keys.Apps, CorsairLedId.Application},
{Keys.RControlKey, CorsairKeyboardKeyId.RightCtrl}, {Keys.RControlKey, CorsairLedId.RightCtrl},
{Keys.Left, CorsairKeyboardKeyId.LeftArrow}, {Keys.Left, CorsairLedId.LeftArrow},
{Keys.Down, CorsairKeyboardKeyId.DownArrow}, {Keys.Down, CorsairLedId.DownArrow},
{Keys.Right, CorsairKeyboardKeyId.RightArrow}, {Keys.Right, CorsairLedId.RightArrow},
{Keys.Up, CorsairKeyboardKeyId.UpArrow}, {Keys.Up, CorsairLedId.UpArrow},
{Keys.NumPad0, CorsairKeyboardKeyId.Keypad0}, {Keys.NumPad0, CorsairLedId.Keypad0},
{Keys.NumPad1, CorsairKeyboardKeyId.Keypad1}, {Keys.NumPad1, CorsairLedId.Keypad1},
{Keys.NumPad2, CorsairKeyboardKeyId.Keypad2}, {Keys.NumPad2, CorsairLedId.Keypad2},
{Keys.NumPad3, CorsairKeyboardKeyId.Keypad3}, {Keys.NumPad3, CorsairLedId.Keypad3},
{Keys.NumPad4, CorsairKeyboardKeyId.Keypad4}, {Keys.NumPad4, CorsairLedId.Keypad4},
{Keys.NumPad5, CorsairKeyboardKeyId.Keypad5}, {Keys.NumPad5, CorsairLedId.Keypad5},
{Keys.NumPad6, CorsairKeyboardKeyId.Keypad6}, {Keys.NumPad6, CorsairLedId.Keypad6},
{Keys.NumPad7, CorsairKeyboardKeyId.Keypad7}, {Keys.NumPad7, CorsairLedId.Keypad7},
{Keys.NumPad8, CorsairKeyboardKeyId.Keypad8}, {Keys.NumPad8, CorsairLedId.Keypad8},
{Keys.NumPad9, CorsairKeyboardKeyId.Keypad9}, {Keys.NumPad9, CorsairLedId.Keypad9},
{Keys.Divide, CorsairKeyboardKeyId.KeypadSlash}, {Keys.Divide, CorsairLedId.KeypadSlash},
{Keys.Multiply, CorsairKeyboardKeyId.KeypadAsterisk}, {Keys.Multiply, CorsairLedId.KeypadAsterisk},
{Keys.Subtract, CorsairKeyboardKeyId.KeypadMinus}, {Keys.Subtract, CorsairLedId.KeypadMinus},
{Keys.Add, CorsairKeyboardKeyId.KeypadPlus}, {Keys.Add, CorsairLedId.KeypadPlus},
{Keys.Decimal, CorsairKeyboardKeyId.KeypadPeriodAndDelete}, {Keys.Decimal, CorsairLedId.KeypadPeriodAndDelete},
{Keys.MediaStop, CorsairKeyboardKeyId.Stop}, {Keys.MediaStop, CorsairLedId.Stop},
{Keys.MediaPreviousTrack, CorsairKeyboardKeyId.ScanPreviousTrack}, {Keys.MediaPreviousTrack, CorsairLedId.ScanPreviousTrack},
{Keys.MediaNextTrack, CorsairKeyboardKeyId.ScanNextTrack}, {Keys.MediaNextTrack, CorsairLedId.ScanNextTrack},
{Keys.MediaPlayPause, CorsairKeyboardKeyId.PlayPause}, {Keys.MediaPlayPause, CorsairLedId.PlayPause},
{Keys.VolumeMute, CorsairKeyboardKeyId.Mute}, {Keys.VolumeMute, CorsairLedId.Mute},
{Keys.VolumeUp, CorsairKeyboardKeyId.VolumeUp}, {Keys.VolumeUp, CorsairLedId.VolumeUp},
{Keys.VolumeDown, CorsairKeyboardKeyId.VolumeDown} {Keys.VolumeDown, CorsairLedId.VolumeDown}
}; };
} }
public static Dictionary<Keys, CorsairKeyboardKeyId> FormsKeys { get; set; } public static Dictionary<Keys, CorsairLedId> FormsKeys { get; set; }
} }
} }

Binary file not shown.