Update KeyboardTester to use TestDevices / AhkKeys

interception_wait
Clive Galway 2 years ago
parent cff6770756
commit a57e693a88

@ -35,25 +35,27 @@ namespace TestApp
// Given a Name, get Code
public static string Name(ushort code)
{
return _keyCodes[code].Name;
return Obj(code).Name;
}
// Given a Code, get Name
public static int Code(string name)
{
return _keyNames[name].Code;
return Obj(name).Code;
}
// Given a Name, get AhkKey object
public static AhkKey Obj(string name)
{
return _keyNames[name];
var keyObj = _keyNames.ContainsKey(name) ? _keyNames[name] : new AhkKey(0, "UNKNOWN");
return keyObj;
}
// Given a Code, get AhkKey object
public static AhkKey Obj(ushort code)
{
return _keyCodes[code];
var keyObj = _keyCodes.ContainsKey(code) ? _keyCodes[code] : new AhkKey(code, "UNKNOWN");
return keyObj;
}
private static void AddKey(ushort code, string name)

@ -9,20 +9,22 @@ namespace TestApp
{
public class KeyboardTester
{
public KeyboardTester()
public KeyboardTester(TestDevice device)
{
var im = new Manager();
var devId = im.GetKeyboardId(0x04F2, 0x0112);
var devId = device.GetDeviceId();
if (devId == 0) return;
im.SubscribeKeyboard(devId, false, new Action<ushort, int>(OnKeyEvent));
im.SubscribeKeyboard(devId, true, new Action<ushort, int>(OnKeyEvent));
}
public void OnKeyEvent(ushort code, int value)
{
Console.WriteLine($"Code: {code}, State: {value}");
var keyObj = AhkKeys.Obj(code);
Console.WriteLine($"Name: {keyObj.Name}, Code: {keyObj.LogCode()}, State: {value}");
}
}
}

@ -9,8 +9,8 @@ namespace TestApp
{
//var mt = new MouseTester();
//var mbt = new MouseButtonsTester();
//var kt = new KeyboardTester();
var kkt = new KeyboardKeyTester(TestDevices.WyseKeyboard, AhkKeys.Obj("1"));
var kt = new KeyboardTester(TestDevices.WyseKeyboard);
//var kkt = new KeyboardKeyTester(TestDevices.WyseKeyboard, AhkKeys.Obj("1"));
//var tt = new TabletTester();
//var sct = new ScanCodeTester();
//var sst = new SetStateTester(TestDevices.WyseKeyboard, AhkKeys.Obj("1"));

Loading…
Cancel
Save