mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added Corsair key map
This commit is contained in:
parent
fad7f2bb3c
commit
a33f80aa79
@ -279,6 +279,7 @@
|
|||||||
<Compile Include="DAL\ProfileProvider.cs" />
|
<Compile Include="DAL\ProfileProvider.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairMice.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairMice.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairHeadsets.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairHeadsets.cs" />
|
||||||
|
<Compile Include="DeviceProviders\Corsair\Utilities\KeyMap.cs" />
|
||||||
<Compile Include="DeviceProviders\DeviceProvider.cs" />
|
<Compile Include="DeviceProviders\DeviceProvider.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\LogitechGeneric.cs" />
|
<Compile Include="DeviceProviders\Logitech\LogitechGeneric.cs" />
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
using System.Drawing;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Artemis.DeviceProviders.Corsair.Utilities;
|
||||||
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.Generic.Enums;
|
||||||
using CUE.NET.Devices.Keyboard;
|
using CUE.NET.Devices.Keyboard;
|
||||||
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
|
using CUE.NET.Devices.Keyboard.Keys;
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
|
|
||||||
@ -49,6 +53,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
case "K95 RGB":
|
case "K95 RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 25;
|
Width = 25;
|
||||||
|
Slug = "corsair-k95-rgb";
|
||||||
PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
|
PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
|
||||||
break;
|
break;
|
||||||
case "K70 RGB":
|
case "K70 RGB":
|
||||||
@ -56,22 +61,24 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
case "K70 LUX RGB":
|
case "K70 LUX RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 21;
|
Width = 21;
|
||||||
|
Slug = "corsair-k70-rgb";
|
||||||
PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
|
PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
|
||||||
break;
|
break;
|
||||||
case "K65 RGB":
|
case "K65 RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 18;
|
Width = 18;
|
||||||
|
Slug = "corsair-k65-rgb";
|
||||||
PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
|
PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
|
||||||
break;
|
break;
|
||||||
case "STRAFE RGB":
|
case "STRAFE RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 22;
|
Width = 22;
|
||||||
|
Slug = "corsair-strafe-rgb";
|
||||||
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;
|
||||||
}
|
}
|
||||||
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
|
||||||
Slug = "corsair-" + _keyboard.DeviceInfo.Model.Replace(' ', '-').ToLower();
|
|
||||||
|
|
||||||
|
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
||||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +121,18 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
{
|
{
|
||||||
var widthMultiplier = Width/_keyboard.KeyboardRectangle.Width;
|
var widthMultiplier = Width/_keyboard.KeyboardRectangle.Width;
|
||||||
var heightMultiplier = Height/_keyboard.KeyboardRectangle.Height;
|
var heightMultiplier = Height/_keyboard.KeyboardRectangle.Height;
|
||||||
|
|
||||||
// TODO: Not all key codes translate to CUE keys
|
CorsairKey cueKey = null;
|
||||||
var cueKey = _keyboard.Keys.FirstOrDefault(k => k.KeyId.ToString() == keyCode.ToString());
|
try
|
||||||
|
{
|
||||||
|
cueKey = _keyboard.Keys.FirstOrDefault(k => k.KeyId.ToString() == keyCode.ToString()) ??
|
||||||
|
_keyboard.Keys.FirstOrDefault(k => k.KeyId == KeyMap.FormsKeys[keyCode]);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
|
||||||
if (cueKey != null)
|
if (cueKey != null)
|
||||||
return new KeyMatch(keyCode, (int) (cueKey.KeyRectangle.X*widthMultiplier),
|
return new KeyMatch(keyCode, (int) (cueKey.KeyRectangle.X*widthMultiplier),
|
||||||
(int) (cueKey.KeyRectangle.Y*heightMultiplier));
|
(int) (cueKey.KeyRectangle.Y*heightMultiplier));
|
||||||
|
|||||||
72
Artemis/Artemis/DeviceProviders/Corsair/Utilities/KeyMap.cs
Normal file
72
Artemis/Artemis/DeviceProviders/Corsair/Utilities/KeyMap.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
|
using CUE.NET.Devices.Keyboard.Keys;
|
||||||
|
|
||||||
|
namespace Artemis.DeviceProviders.Corsair.Utilities
|
||||||
|
{
|
||||||
|
public static class KeyMap
|
||||||
|
{
|
||||||
|
static KeyMap()
|
||||||
|
{
|
||||||
|
FormsKeys = new Dictionary<Keys, CorsairKeyboardKeyId>
|
||||||
|
{
|
||||||
|
{Keys.Scroll, CorsairKeyboardKeyId.ScrollLock},
|
||||||
|
{Keys.Pause, CorsairKeyboardKeyId.PauseBreak},
|
||||||
|
{Keys.Back, CorsairKeyboardKeyId.Backspace},
|
||||||
|
{Keys.Oemtilde, CorsairKeyboardKeyId.GraveAccentAndTilde},
|
||||||
|
{Keys.OemMinus, CorsairKeyboardKeyId.MinusAndUnderscore},
|
||||||
|
{Keys.Oemplus, CorsairKeyboardKeyId.EqualsAndPlus},
|
||||||
|
{Keys.OemOpenBrackets, CorsairKeyboardKeyId.BracketLeft},
|
||||||
|
{Keys.Oem6, CorsairKeyboardKeyId.BracketRight},
|
||||||
|
{Keys.Return, CorsairKeyboardKeyId.Enter},
|
||||||
|
{Keys.Next, CorsairKeyboardKeyId.PageDown},
|
||||||
|
{Keys.Capital, CorsairKeyboardKeyId.CapsLock},
|
||||||
|
{Keys.Oem1, CorsairKeyboardKeyId.SemicolonAndColon},
|
||||||
|
{Keys.Oem7, CorsairKeyboardKeyId.ApostropheAndDoubleQuote},
|
||||||
|
{Keys.OemBackslash, CorsairKeyboardKeyId.Backslash},
|
||||||
|
{Keys.LShiftKey, CorsairKeyboardKeyId.LeftShift},
|
||||||
|
{Keys.Oem5, CorsairKeyboardKeyId.NonUsBackslash},
|
||||||
|
{Keys.Oemcomma, CorsairKeyboardKeyId.CommaAndLessThan},
|
||||||
|
{Keys.OemPeriod, CorsairKeyboardKeyId.PeriodAndBiggerThan},
|
||||||
|
{Keys.OemQuestion, CorsairKeyboardKeyId.SlashAndQuestionMark},
|
||||||
|
{Keys.RShiftKey, CorsairKeyboardKeyId.RightShift},
|
||||||
|
{Keys.LControlKey, CorsairKeyboardKeyId.LeftCtrl},
|
||||||
|
{Keys.LWin, CorsairKeyboardKeyId.LeftGui},
|
||||||
|
{Keys.LMenu, CorsairKeyboardKeyId.LeftAlt},
|
||||||
|
{Keys.RMenu, CorsairKeyboardKeyId.RightAlt},
|
||||||
|
{Keys.RWin, CorsairKeyboardKeyId.RightGui},
|
||||||
|
{Keys.Apps, CorsairKeyboardKeyId.Application},
|
||||||
|
{Keys.RControlKey, CorsairKeyboardKeyId.RightCtrl},
|
||||||
|
{Keys.Left, CorsairKeyboardKeyId.LeftArrow},
|
||||||
|
{Keys.Down, CorsairKeyboardKeyId.DownArrow},
|
||||||
|
{Keys.Right, CorsairKeyboardKeyId.RightArrow},
|
||||||
|
{Keys.Up, CorsairKeyboardKeyId.UpArrow},
|
||||||
|
{Keys.NumPad0, CorsairKeyboardKeyId.Keypad0},
|
||||||
|
{Keys.NumPad1, CorsairKeyboardKeyId.Keypad1},
|
||||||
|
{Keys.NumPad2, CorsairKeyboardKeyId.Keypad2},
|
||||||
|
{Keys.NumPad3, CorsairKeyboardKeyId.Keypad3},
|
||||||
|
{Keys.NumPad4, CorsairKeyboardKeyId.Keypad4},
|
||||||
|
{Keys.NumPad5, CorsairKeyboardKeyId.Keypad5},
|
||||||
|
{Keys.NumPad6, CorsairKeyboardKeyId.Keypad6},
|
||||||
|
{Keys.NumPad7, CorsairKeyboardKeyId.Keypad7},
|
||||||
|
{Keys.NumPad8, CorsairKeyboardKeyId.Keypad8},
|
||||||
|
{Keys.NumPad9, CorsairKeyboardKeyId.Keypad9},
|
||||||
|
{Keys.Divide, CorsairKeyboardKeyId.KeypadSlash},
|
||||||
|
{Keys.Multiply, CorsairKeyboardKeyId.KeypadAsterisk},
|
||||||
|
{Keys.Subtract, CorsairKeyboardKeyId.KeypadMinus},
|
||||||
|
{Keys.Add, CorsairKeyboardKeyId.KeypadPlus},
|
||||||
|
{Keys.Decimal, CorsairKeyboardKeyId.KeypadPeriodAndDelete},
|
||||||
|
{Keys.MediaStop, CorsairKeyboardKeyId.Stop},
|
||||||
|
{Keys.MediaPreviousTrack, CorsairKeyboardKeyId.ScanPreviousTrack},
|
||||||
|
{Keys.MediaNextTrack, CorsairKeyboardKeyId.ScanNextTrack},
|
||||||
|
{Keys.MediaPlayPause, CorsairKeyboardKeyId.PlayPause},
|
||||||
|
{Keys.VolumeMute, CorsairKeyboardKeyId.Mute},
|
||||||
|
{Keys.VolumeUp, CorsairKeyboardKeyId.VolumeUp},
|
||||||
|
{Keys.VolumeDown, CorsairKeyboardKeyId.VolumeDown}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<Keys, CorsairKeyboardKeyId> FormsKeys { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user