mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added KeyPress layertype (WIP still needs config options)
Added keymap system Added K70 LUX support
This commit is contained in:
parent
e5d15c6ada
commit
fad7f2bb3c
@ -329,6 +329,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Profiles\Layers\Types\Generic\GenericPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Generic\GenericType.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\KeyPress\KeyPressType.cs" />
|
||||
<Compile Include="Profiles\ProfileModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Models\SimplePropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesModel.cs" />
|
||||
@ -485,6 +486,7 @@
|
||||
<Compile Include="Styles\DropTargetAdorners\DropTargetMetroInsertionAdorner.cs" />
|
||||
<Compile Include="Utilities\ColorHelpers.cs" />
|
||||
<Compile Include="Utilities\Converters\JsonConverters.cs" />
|
||||
<Compile Include="Utilities\Converters\NinjectCustomConverter.cs" />
|
||||
<Compile Include="Utilities\Converters\ValueConverters.cs" />
|
||||
<Compile Include="Utilities\DataReaders\DllManager.cs" />
|
||||
<Compile Include="Utilities\ExtensionMethods.cs" />
|
||||
@ -497,7 +499,6 @@
|
||||
<Compile Include="Utilities\Logging.cs" />
|
||||
<Compile Include="Utilities\DataReaders\PipeServer.cs" />
|
||||
<Compile Include="Utilities\Memory\GamePointer.cs" />
|
||||
<Compile Include="Utilities\Keyboard\Key.cs" />
|
||||
<Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" />
|
||||
<Compile Include="Utilities\Memory\Memory.cs" />
|
||||
<Compile Include="Utilities\Memory\MemoryHelpers.cs" />
|
||||
@ -869,9 +870,7 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Utilities\ValueConverters\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\CUE.NET.1.0.3\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.3\build\net45\CUE.NET.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
||||
@ -5,8 +5,11 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.InjectionModules;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Types.KeyPress;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Converters;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using Newtonsoft.Json;
|
||||
@ -79,10 +82,16 @@ namespace Artemis
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Auto};
|
||||
_kernel = new StandardKernel(new BaseModules(), new ArtemisModules(), new ManagerModules());
|
||||
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
|
||||
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
||||
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Auto,
|
||||
ContractResolver = _kernel.Get<NinjectContractResolver>()
|
||||
};
|
||||
JsonConvert.DefaultSettings = () => settings;
|
||||
}
|
||||
|
||||
protected override void OnExit(object sender, EventArgs e)
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
@ -51,6 +53,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
break;
|
||||
case "K70 RGB":
|
||||
case "K70 RGB RAPIDFIRE":
|
||||
case "K70 LUX RGB":
|
||||
Height = 7;
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
|
||||
@ -106,5 +109,19 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
|
||||
image.Dispose();
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
var widthMultiplier = Width/_keyboard.KeyboardRectangle.Width;
|
||||
var heightMultiplier = Height/_keyboard.KeyboardRectangle.Height;
|
||||
|
||||
// TODO: Not all key codes translate to CUE keys
|
||||
var cueKey = _keyboard.Keys.FirstOrDefault(k => k.KeyId.ToString() == keyCode.ToString());
|
||||
if (cueKey != null)
|
||||
return new KeyMatch(keyCode, (int) (cueKey.KeyRectangle.X*widthMultiplier),
|
||||
(int) (cueKey.KeyRectangle.Y*heightMultiplier));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
@ -96,6 +97,27 @@ namespace Artemis.DeviceProviders
|
||||
throw new NotImplementedException(
|
||||
"KeyboardProvider doesn't implement TryEnable, use CanEnableAsync instead.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the real life X and Y coordinates of the given key
|
||||
/// </summary>
|
||||
/// <param name="keyCode"></param>
|
||||
/// <returns></returns>
|
||||
public abstract KeyMatch? GetKeyPosition(Keys keyCode);
|
||||
}
|
||||
|
||||
public struct KeyMatch
|
||||
{
|
||||
public KeyMatch(Keys keyCode, int x, int y)
|
||||
{
|
||||
KeyCode = keyCode;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public Keys KeyCode { get; set; }
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
||||
public struct PreviewSettings
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
@ -17,5 +20,10 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(675, 185, new Thickness(0, 35, 0, 0), Resources.g810);
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
@ -17,5 +20,10 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910);
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
@ -10,128 +9,128 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
// There are several keyboard layouts
|
||||
// TODO: Implemented more layouts and an option to select them
|
||||
UsEnglishOrionKeys = new List<Key>
|
||||
UsEnglishOrionKeys = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new Key(Keys.Escape, 0, 0),
|
||||
new Key(Keys.F1, 1, 0),
|
||||
new Key(Keys.F2, 2, 0),
|
||||
new Key(Keys.F3, 3, 0),
|
||||
new Key(Keys.F4, 4, 0),
|
||||
new Key(Keys.F5, 5, 0),
|
||||
new Key(Keys.F6, 6, 0),
|
||||
new Key(Keys.F7, 7, 0),
|
||||
new Key(Keys.F8, 8, 0),
|
||||
new Key(Keys.F9, 9, 0),
|
||||
new Key(Keys.F10, 10, 0),
|
||||
new Key(Keys.F11, 11, 0),
|
||||
new Key(Keys.F12, 12, 0),
|
||||
new Key(Keys.PrintScreen, 13, 0),
|
||||
new Key(Keys.Scroll, 14, 0),
|
||||
new Key(Keys.Pause, 15, 0),
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 1, 0),
|
||||
new KeyMatch(Keys.F2, 2, 0),
|
||||
new KeyMatch(Keys.F3, 3, 0),
|
||||
new KeyMatch(Keys.F4, 4, 0),
|
||||
new KeyMatch(Keys.F5, 5, 0),
|
||||
new KeyMatch(Keys.F6, 6, 0),
|
||||
new KeyMatch(Keys.F7, 7, 0),
|
||||
new KeyMatch(Keys.F8, 8, 0),
|
||||
new KeyMatch(Keys.F9, 9, 0),
|
||||
new KeyMatch(Keys.F10, 10, 0),
|
||||
new KeyMatch(Keys.F11, 11, 0),
|
||||
new KeyMatch(Keys.F12, 12, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 13, 0),
|
||||
new KeyMatch(Keys.Scroll, 14, 0),
|
||||
new KeyMatch(Keys.Pause, 15, 0),
|
||||
|
||||
// Row 2
|
||||
new Key(Keys.Oemtilde, 0, 1),
|
||||
new Key(Keys.D1, 1, 1),
|
||||
new Key(Keys.D2, 2, 1),
|
||||
new Key(Keys.D3, 3, 1),
|
||||
new Key(Keys.D4, 4, 1),
|
||||
new Key(Keys.D5, 5, 1),
|
||||
new Key(Keys.D6, 6, 1),
|
||||
new Key(Keys.D7, 7, 1),
|
||||
new Key(Keys.D8, 8, 1),
|
||||
new Key(Keys.D9, 9, 1),
|
||||
new Key(Keys.D0, 10, 1),
|
||||
new Key(Keys.OemMinus, 11, 1),
|
||||
new Key(Keys.Oemplus, 12, 1),
|
||||
new Key(Keys.Back, 13, 1),
|
||||
new Key(Keys.Insert, 14, 1),
|
||||
new Key(Keys.Home, 15, 1),
|
||||
new Key(Keys.PageUp, 16, 1),
|
||||
new Key(Keys.NumLock, 17, 1),
|
||||
new Key(Keys.Divide, 18, 1),
|
||||
new Key(Keys.Multiply, 19, 1),
|
||||
new Key(Keys.Subtract, 20, 1),
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new Key(Keys.Tab, 0, 2),
|
||||
new Key(Keys.Q, 1, 2),
|
||||
new Key(Keys.W, 2, 2),
|
||||
new Key(Keys.E, 3, 2),
|
||||
new Key(Keys.R, 4, 2),
|
||||
new Key(Keys.T, 5, 2),
|
||||
new Key(Keys.Y, 6, 2),
|
||||
new Key(Keys.U, 7, 2),
|
||||
new Key(Keys.I, 8, 2),
|
||||
new Key(Keys.O, 9, 2),
|
||||
new Key(Keys.P, 10, 2),
|
||||
new Key(Keys.OemOpenBrackets, 11, 2),
|
||||
new Key(Keys.Oem6, 12, 2),
|
||||
new Key(Keys.Delete, 14, 2),
|
||||
new Key(Keys.End, 15, 2),
|
||||
new Key(Keys.Next, 16, 2),
|
||||
new Key(Keys.NumPad7, 17, 2),
|
||||
new Key(Keys.NumPad8, 18, 2),
|
||||
new Key(Keys.NumPad9, 19, 2),
|
||||
new Key(Keys.Add, 20, 2),
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 4, 2),
|
||||
new KeyMatch(Keys.T, 5, 2),
|
||||
new KeyMatch(Keys.Y, 6, 2),
|
||||
new KeyMatch(Keys.U, 7, 2),
|
||||
new KeyMatch(Keys.I, 8, 2),
|
||||
new KeyMatch(Keys.O, 9, 2),
|
||||
new KeyMatch(Keys.P, 10, 2),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 11, 2),
|
||||
new KeyMatch(Keys.Oem6, 12, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new Key(Keys.Capital, 0, 3),
|
||||
new Key(Keys.A, 1, 3),
|
||||
new Key(Keys.S, 2, 3),
|
||||
new Key(Keys.D, 3, 3),
|
||||
new Key(Keys.F, 4, 3),
|
||||
new Key(Keys.G, 5, 3),
|
||||
new Key(Keys.H, 6, 3),
|
||||
new Key(Keys.J, 7, 3),
|
||||
new Key(Keys.K, 8, 3),
|
||||
new Key(Keys.L, 9, 3),
|
||||
new Key(Keys.Oem1, 10, 3),
|
||||
new Key(Keys.Oem7, 11, 3),
|
||||
new Key(Keys.Oem5, 12, 3),
|
||||
new Key(Keys.Return, 13, 3),
|
||||
new Key(Keys.NumPad4, 17, 3),
|
||||
new Key(Keys.NumPad5, 18, 3),
|
||||
new Key(Keys.NumPad6, 19, 3),
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 2, 3),
|
||||
new KeyMatch(Keys.D, 3, 3),
|
||||
new KeyMatch(Keys.F, 4, 3),
|
||||
new KeyMatch(Keys.G, 5, 3),
|
||||
new KeyMatch(Keys.H, 6, 3),
|
||||
new KeyMatch(Keys.J, 7, 3),
|
||||
new KeyMatch(Keys.K, 8, 3),
|
||||
new KeyMatch(Keys.L, 9, 3),
|
||||
new KeyMatch(Keys.Oem1, 10, 3),
|
||||
new KeyMatch(Keys.Oem7, 11, 3),
|
||||
new KeyMatch(Keys.Oem5, 12, 3),
|
||||
new KeyMatch(Keys.Return, 13, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new Key(Keys.LShiftKey, 1, 4),
|
||||
new Key(Keys.OemBackslash, 2, 4),
|
||||
new Key(Keys.Z, 2, 4),
|
||||
new Key(Keys.X, 3, 4),
|
||||
new Key(Keys.C, 4, 4),
|
||||
new Key(Keys.V, 5, 4),
|
||||
new Key(Keys.B, 6, 4),
|
||||
new Key(Keys.N, 7, 4),
|
||||
new Key(Keys.M, 8, 4),
|
||||
new Key(Keys.Oemcomma, 9, 4),
|
||||
new Key(Keys.OemPeriod, 10, 4),
|
||||
new Key(Keys.OemQuestion, 11, 4),
|
||||
new Key(Keys.RShiftKey, 13, 4),
|
||||
new Key(Keys.Up, 15, 4),
|
||||
new Key(Keys.NumPad1, 17, 4),
|
||||
new Key(Keys.NumPad2, 18, 4),
|
||||
new Key(Keys.NumPad3, 19, 4),
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.Z, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.M, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new Key(Keys.LControlKey, 0, 5),
|
||||
new Key(Keys.LWin, 1, 5),
|
||||
new Key(Keys.LMenu, 2, 5),
|
||||
new Key(Keys.Space, 5, 5),
|
||||
new Key(Keys.RMenu, 11, 5),
|
||||
new Key(Keys.RWin, 12, 5),
|
||||
new Key(Keys.Apps, 13, 5),
|
||||
new Key(Keys.RControlKey, 14, 5),
|
||||
new Key(Keys.Left, 15, 5),
|
||||
new Key(Keys.Down, 16, 5),
|
||||
new Key(Keys.Right, 17, 5),
|
||||
new Key(Keys.NumPad0, 18, 5),
|
||||
new Key(Keys.Decimal, 19, 5)
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 2, 5),
|
||||
new KeyMatch(Keys.Space, 5, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Key> UsEnglishOrionKeys { get; set; }
|
||||
public static List<KeyMatch> UsEnglishOrionKeys { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,13 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.DeviceProviders.Razer.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer;
|
||||
using Corale.Colore.Razer.Keyboard;
|
||||
using Constants = Corale.Colore.Razer.Keyboard.Constants;
|
||||
|
||||
namespace Artemis.DeviceProviders.Razer
|
||||
@ -49,5 +53,11 @@ namespace Artemis.DeviceProviders.Razer
|
||||
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
|
||||
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
// TODO: Needs it's own keymap or a way to get it from the Chroma SDK
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,7 @@ using Artemis.Profiles.Layers.Types.Generic;
|
||||
using Artemis.Profiles.Layers.Types.Headset;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Profiles.Layers.Types.KeyboardGif;
|
||||
using Artemis.Profiles.Layers.Types.KeyPress;
|
||||
using Artemis.Profiles.Layers.Types.Mouse;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Ninject.Modules;
|
||||
@ -78,9 +79,11 @@ namespace Artemis.InjectionModules
|
||||
Bind<ILayerAnimation>().To<SlideLeftAnimation>();
|
||||
Bind<ILayerAnimation>().To<SlideRightAnimation>();
|
||||
Bind<ILayerAnimation>().To<SlideUpAnimation>();
|
||||
|
||||
// Conditions
|
||||
Bind<ILayerCondition>().To<DataModelCondition>();
|
||||
Bind<ILayerCondition>().To<EventCondition>();
|
||||
|
||||
// Types
|
||||
Bind<ILayerType>().To<FolderType>();
|
||||
Bind<ILayerType>().To<HeadsetType>();
|
||||
@ -88,6 +91,10 @@ namespace Artemis.InjectionModules
|
||||
Bind<ILayerType>().To<KeyboardGifType>();
|
||||
Bind<ILayerType>().To<MouseType>();
|
||||
Bind<ILayerType>().To<GenericType>();
|
||||
Bind<ILayerType>().To<KeyPressType>();
|
||||
|
||||
// Bind some Layer Types to self as well in order to allow JSON.NET injection
|
||||
Bind<KeyPressType>().ToSelf();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -43,9 +43,6 @@ namespace Artemis.Managers
|
||||
ProgramEnabled = false;
|
||||
Running = false;
|
||||
|
||||
// TODO: Dependency inject utilities?
|
||||
KeyboardHook = new KeyboardHook();
|
||||
|
||||
// Create and start the web server
|
||||
GameStateWebServer = new GameStateWebServer();
|
||||
GameStateWebServer.Start();
|
||||
@ -67,7 +64,6 @@ namespace Artemis.Managers
|
||||
public ProfileManager ProfileManager { get; set; }
|
||||
|
||||
public PipeServer PipeServer { get; set; }
|
||||
public KeyboardHook KeyboardHook { get; set; }
|
||||
public GameStateWebServer GameStateWebServer { get; set; }
|
||||
public bool ProgramEnabled { get; private set; }
|
||||
public bool Running { get; private set; }
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave
|
||||
{
|
||||
@ -30,7 +29,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
public override void Dispose()
|
||||
{
|
||||
Initialized = false;
|
||||
MainManager.KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||
@ -39,23 +38,19 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
if (_waves.Count >= 25)
|
||||
return;
|
||||
|
||||
var keyMatch = KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == e.KeyCode);
|
||||
var keyMatch = MainManager.DeviceManager.ActiveKeyboard.GetKeyPosition(e.KeyCode);
|
||||
if (keyMatch == null)
|
||||
return;
|
||||
|
||||
_waves.Add(Settings.IsRandomColors
|
||||
? new Wave(new Point(keyMatch.PosX*KeyboardScale, keyMatch.PosY*KeyboardScale), 0, _randomColor)
|
||||
: new Wave(new Point(keyMatch.PosX*KeyboardScale, keyMatch.PosY*KeyboardScale), 0,
|
||||
? new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0, _randomColor)
|
||||
: new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0,
|
||||
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Initialized = false;
|
||||
|
||||
// Listener won't start unless the effect is active
|
||||
MainManager.KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
|
||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using NAudio.CoreAudioApi;
|
||||
|
||||
namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
@ -26,13 +27,13 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
MainManager.KeyboardHook.KeyDownCallback -= KeyPressTask;
|
||||
KeyboardHook.KeyDownCallback -= KeyPressTask;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
// Listener won't start unless the effect is active
|
||||
MainManager.KeyboardHook.KeyDownCallback += KeyPressTask;
|
||||
KeyboardHook.KeyDownCallback += KeyPressTask;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
|
||||
120
Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
Normal file
120
Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Animations;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Generic;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||
{
|
||||
internal class KeyPressType : ILayerType
|
||||
{
|
||||
private readonly MainManager _mainManager;
|
||||
private List<LayerModel> _keyPressLayers = new List<LayerModel>();
|
||||
private LayerPropertiesModel _properties;
|
||||
|
||||
public KeyPressType(MainManager mainManager)
|
||||
{
|
||||
_mainManager = mainManager;
|
||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
public RadialGradientBrush TempBrush { get; set; }
|
||||
|
||||
|
||||
public string Name { get; } = "Keyboard - Key press";
|
||||
public bool ShowInEdtor { get; } = false;
|
||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||
|
||||
public ImageSource DrawThumbnail(LayerModel layer)
|
||||
{
|
||||
var thumbnailRect = new Rect(0, 0, 18, 18);
|
||||
var visual = new DrawingVisual();
|
||||
using (var c = visual.RenderOpen())
|
||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.gif), thumbnailRect);
|
||||
|
||||
var image = new DrawingImage(visual.Drawing);
|
||||
return image;
|
||||
}
|
||||
|
||||
public void Draw(LayerModel layer, DrawingContext c)
|
||||
{
|
||||
lock (_keyPressLayers)
|
||||
{
|
||||
foreach (var keyPressLayer in _keyPressLayers)
|
||||
keyPressLayer.LayerType.Draw(keyPressLayer, c);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||
{
|
||||
// Key press is always as large as the entire keyboard it is drawn for
|
||||
layerModel.Properties.Width = _mainManager.DeviceManager.ActiveKeyboard.Width;
|
||||
layerModel.Properties.Height = _mainManager.DeviceManager.ActiveKeyboard.Height;
|
||||
layerModel.Properties.X = 0;
|
||||
layerModel.Properties.Y = 0;
|
||||
layerModel.Properties.Contain = true;
|
||||
|
||||
_properties = layerModel.Properties;
|
||||
|
||||
lock (_keyPressLayers)
|
||||
{
|
||||
// Remove expired key presses
|
||||
_keyPressLayers = _keyPressLayers.Where(k => !k.LayerAnimation.MustExpire(k)).ToList();
|
||||
// Update the ones that are still active
|
||||
foreach (var keyPressLayer in _keyPressLayers)
|
||||
keyPressLayer.Update(null, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupProperties(LayerModel layerModel)
|
||||
{
|
||||
if (layerModel.Properties is SimplePropertiesModel)
|
||||
return;
|
||||
|
||||
layerModel.Properties = new SimplePropertiesModel(layerModel.Properties);
|
||||
}
|
||||
|
||||
public LayerPropertiesViewModel SetupViewModel(LayerPropertiesViewModel layerPropertiesViewModel,
|
||||
List<ILayerAnimation> layerAnimations, IDataModel dataModel, LayerModel proposedLayer)
|
||||
{
|
||||
if (layerPropertiesViewModel is GenericPropertiesViewModel)
|
||||
return layerPropertiesViewModel;
|
||||
return new GenericPropertiesViewModel(proposedLayer, dataModel, layerAnimations);
|
||||
}
|
||||
|
||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||
{
|
||||
if (_properties == null)
|
||||
return;
|
||||
|
||||
var keyMatch = _mainManager.DeviceManager.ActiveKeyboard.GetKeyPosition(e.KeyCode);
|
||||
if (keyMatch == null)
|
||||
return;
|
||||
|
||||
lock (_keyPressLayers)
|
||||
{
|
||||
var layer = LayerModel.CreateLayer();
|
||||
layer.Properties.Brush = _properties.Brush.CloneCurrentValue();
|
||||
layer.Properties.X = keyMatch.Value.X - 3;
|
||||
layer.Properties.Y = keyMatch.Value.Y - 3;
|
||||
layer.Properties.Width = 6;
|
||||
layer.Properties.Height = 6;
|
||||
|
||||
layer.Properties.AnimationSpeed = 1;
|
||||
layer.LayerAnimation = new GrowAnimation();
|
||||
|
||||
_keyPressLayers.Add(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -172,7 +172,6 @@ namespace Artemis.Profiles
|
||||
/// <summary>
|
||||
/// Resizes layers that are shown in the editor and match exactly the full keyboard widht and height
|
||||
/// </summary>
|
||||
/// <param name="source">The keyboard the profile was made for</param>
|
||||
/// <param name="target">The new keyboard to adjust the layers for</param>
|
||||
public void ResizeLayers(KeyboardProvider target)
|
||||
{
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Utilities.Converters
|
||||
{
|
||||
public class NinjectContractResolver : DefaultContractResolver
|
||||
|
||||
{
|
||||
private readonly IKernel _kernel;
|
||||
|
||||
public NinjectContractResolver(IKernel kernel)
|
||||
{
|
||||
_kernel = kernel;
|
||||
}
|
||||
|
||||
protected override JsonObjectContract CreateObjectContract(Type objectType)
|
||||
|
||||
{
|
||||
var contract = base.CreateObjectContract(objectType);
|
||||
if ((bool) _kernel.CanResolve(objectType))
|
||||
contract.DefaultCreator = () => _kernel.Get(objectType);
|
||||
return contract;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Artemis.Utilities.Keyboard
|
||||
{
|
||||
public class Key
|
||||
{
|
||||
public Key(Keys keyCode, int posX, int posY)
|
||||
{
|
||||
KeyCode = keyCode;
|
||||
PosX = posX;
|
||||
PosY = posY;
|
||||
}
|
||||
|
||||
public Keys KeyCode { get; set; }
|
||||
public int PosX { get; set; }
|
||||
public int PosY { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,21 +4,21 @@ using VirtualInput;
|
||||
|
||||
namespace Artemis.Utilities.Keyboard
|
||||
{
|
||||
public class KeyboardHook
|
||||
public static class KeyboardHook
|
||||
{
|
||||
public delegate void KeyDownCallbackHandler(KeyEventArgs e);
|
||||
|
||||
public KeyboardHook()
|
||||
static KeyboardHook()
|
||||
{
|
||||
VirtualKeyboard.KeyDown += VirtualKeyboardOnKeyDown;
|
||||
VirtualKeyboard.StartInterceptor();
|
||||
VirtualKeyboard.KeyDown += VirtualKeyboardOnKeyDown;
|
||||
}
|
||||
|
||||
private void VirtualKeyboardOnKeyDown(object sender, KeyEventArgs keyEventArgs)
|
||||
private static void VirtualKeyboardOnKeyDown(object sender, KeyEventArgs keyEventArgs)
|
||||
{
|
||||
Task.Factory.StartNew(() => { KeyDownCallback?.Invoke(keyEventArgs); });
|
||||
}
|
||||
|
||||
public event KeyDownCallbackHandler KeyDownCallback;
|
||||
public static event KeyDownCallbackHandler KeyDownCallback;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user