1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 18:23:32 +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;
} }
@ -45,7 +45,7 @@ namespace Artemis.DeviceProviders.Corsair
throw new ArgumentException("Bitmap must be a perfect square"); throw new ArgumentException("Bitmap must be a perfect square");
var leds = CueSDK.HeadsetSDK.Leds.Count(); var leds = CueSDK.HeadsetSDK.Leds.Count();
var step = (double) bitmap.Width/leds; var step = (double)bitmap.Width / leds;
var ledIndex = 0; var ledIndex = 0;
// Color each LED according to one of the pixels // Color each LED according to one of the pixels
@ -53,7 +53,7 @@ namespace Artemis.DeviceProviders.Corsair
{ {
var col = ledIndex == 0 var col = ledIndex == 0
? bitmap.GetPixel(0, 0) ? bitmap.GetPixel(0, 0)
: bitmap.GetPixel((int) ((ledIndex + 1)*step - 1), (int) ((ledIndex + 1)*step - 1)); : bitmap.GetPixel((int)((ledIndex + 1) * step - 1), (int)((ledIndex + 1) * step - 1));
corsairLed.Color = col; corsairLed.Color = col;
ledIndex++; ledIndex++;

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,25 +136,25 @@ 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;
} }
@ -45,7 +45,7 @@ namespace Artemis.DeviceProviders.Corsair
throw new ArgumentException("Bitmap must be a perfect square"); throw new ArgumentException("Bitmap must be a perfect square");
var leds = CueSDK.MouseSDK.Leds.Count(); var leds = CueSDK.MouseSDK.Leds.Count();
var step = (double) bitmap.Width/leds; var step = (double)bitmap.Width / leds;
var ledIndex = 0; var ledIndex = 0;
// Color each LED according to one of the pixels // Color each LED according to one of the pixels
@ -53,7 +53,7 @@ namespace Artemis.DeviceProviders.Corsair
{ {
var col = ledIndex == 0 var col = ledIndex == 0
? bitmap.GetPixel(0, 0) ? bitmap.GetPixel(0, 0)
: bitmap.GetPixel((int) ((ledIndex + 1)*step - 1), (int) ((ledIndex + 1)*step - 1)); : bitmap.GetPixel((int)((ledIndex + 1) * step - 1), (int)((ledIndex + 1) * step - 1));
corsairLed.Color = col; corsairLed.Color = col;
ledIndex++; ledIndex++;

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;
} }
@ -44,8 +44,8 @@ namespace Artemis.DeviceProviders.Corsair
if (bitmap.Width != bitmap.Height) if (bitmap.Width != bitmap.Height)
throw new ArgumentException("Bitmap must be a perfect square"); throw new ArgumentException("Bitmap must be a perfect square");
var yStep = (double) bitmap.Width/4; var yStep = (double)bitmap.Width / 4;
var xStep = (double) bitmap.Width/6; var xStep = (double)bitmap.Width / 6;
// This approach will break if any mousemats with different LED amounts are released, for now it will do. // This approach will break if any mousemats with different LED amounts are released, for now it will do.
var ledIndex = 0; var ledIndex = 0;
@ -57,23 +57,23 @@ namespace Artemis.DeviceProviders.Corsair
if (ledIndex < 5) if (ledIndex < 5)
{ {
col = ledIndex == 0 col = ledIndex == 0
? bitmap.GetPixel(0, (int) (ledIndex*yStep)) ? bitmap.GetPixel(0, (int)(ledIndex * yStep))
: bitmap.GetPixel(0, (int) (ledIndex*yStep) - 1); : bitmap.GetPixel(0, (int)(ledIndex * yStep) - 1);
} }
// Bottom // Bottom
else if (ledIndex < 10) else if (ledIndex < 10)
{ {
// Start at index 1 because the corner belongs to the left side // Start at index 1 because the corner belongs to the left side
var zoneIndex = ledIndex - 4; var zoneIndex = ledIndex - 4;
col = bitmap.GetPixel((int) (zoneIndex*xStep), bitmap.Height - 1); col = bitmap.GetPixel((int)(zoneIndex * xStep), bitmap.Height - 1);
} }
// Right side // Right side
else else
{ {
var zoneIndex = ledIndex - 10; var zoneIndex = ledIndex - 10;
col = zoneIndex == 4 col = zoneIndex == 4
? bitmap.GetPixel(bitmap.Height - 1, bitmap.Height - (int) (zoneIndex*yStep)) ? bitmap.GetPixel(bitmap.Height - 1, bitmap.Height - (int)(zoneIndex * yStep))
: bitmap.GetPixel(bitmap.Height - 1, bitmap.Height - 1 - (int) (zoneIndex*yStep)); : bitmap.GetPixel(bitmap.Height - 1, bitmap.Height - 1 - (int)(zoneIndex * yStep));
} }
corsairLed.Color = col; corsairLed.Color = col;

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.