WingMan

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 20  →  ?path2? @ 21
/trunk/WingMan/Bindings/KeySimulator.cs
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -6,7 +5,6 @@
using WindowsInput;
using WindowsInput.Native;
using MQTTnet;
using SimWinInput;
using WingMan.Communication;
using WingMan.Utilities;
 
@@ -27,14 +25,9 @@
MqttCommunication.OnMessageReceived += OnMqttMessageReceived;
 
InputSimulator = new InputSimulator();
/*var values = Enum.GetValues(typeof(InputSimulator));
foreach (var i in values)
{
VirtualKeyCodeMapper.Add((int)i, values.GetValue());
}*/
}
 
private InputSimulator InputSimulator { get; set; }
private InputSimulator InputSimulator { get; }
 
private MqttCommunication MqttCommunication { get; }
private TaskScheduler TaskScheduler { get; }
@@ -70,7 +63,9 @@
CancellationToken,
TaskContinuationOptions.None, TaskScheduler);
 
Simulate(executeMouseKeyBinding);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Task.Run(() => Simulate(executeMouseKeyBinding), CancellationToken);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
}
 
@@ -83,10 +78,10 @@
 
foreach (var key in localBinding.Keys)
{
if (!KeyConversion.StringToKeys.TryGetValue(key, out var pressKey))
if (!KeyConversion.StringToKeys.TryGetValue(key, out var press))
continue;
 
InputSimulator.Keyboard.KeyPress((VirtualKeyCode) pressKey);
InputSimulator.Keyboard.KeyPress((VirtualKeyCode) press);
}
}
}