mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
LUA is made up out of modules now Added DI to LUA Added GetKeyPosition to keyboard module Cleaned up event arguments (see wiki) Made all internal classes public since Artemis isn't a library anyway Added DI convention based bindings
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows.Forms;
|
|
using Artemis.DeviceProviders;
|
|
using Artemis.Managers;
|
|
using MoonSharp.Interpreter;
|
|
|
|
namespace Artemis.Profiles.Lua.Modules
|
|
{
|
|
[MoonSharpUserData]
|
|
public class LuaKeyboardModule : LuaModule
|
|
{
|
|
private readonly KeyboardProvider _keyboardProvider;
|
|
|
|
public LuaKeyboardModule(LuaManager luaManager) : base(luaManager)
|
|
{
|
|
_keyboardProvider = luaManager.KeyboardProvider;
|
|
|
|
// Register the KeyMatch type for usage in GetKeyPosition
|
|
UserData.RegisterType(typeof(KeyMatch));
|
|
}
|
|
|
|
public override string ModuleName => "Keyboard";
|
|
|
|
public string Name => _keyboardProvider.Name;
|
|
public string Slug => _keyboardProvider.Slug;
|
|
public int Width => _keyboardProvider.Width;
|
|
public int Height => _keyboardProvider.Height;
|
|
|
|
public void PressKeys(string keys)
|
|
{
|
|
SendKeys.SendWait(keys);
|
|
}
|
|
|
|
public KeyMatch? GetKeyPosition(string key)
|
|
{
|
|
// Convert string to Keys enum, I'm not sure if built-in enums can be converted automatically
|
|
try
|
|
{
|
|
var keyEnum = (Keys)Enum.Parse(typeof(Keys), key);
|
|
return _keyboardProvider.GetKeyPosition(keyEnum);
|
|
}
|
|
catch (ArgumentException)
|
|
{
|
|
throw new ScriptRuntimeException($"Key '{key}' not found");
|
|
}
|
|
}
|
|
}
|
|
} |