WingMan
/trunk/WingMan/Bindings/KeyInterceptor.cs |
@@ -36,18 +36,13 @@ |
} |
|
private BatchBlock<string> KeyComboBatchBlock { get; set; } |
|
private ActionBlock<string[]> KeyComboActionBlock { get; set; } |
|
private IDisposable KeyComboDataFlowLink { get; set; } |
|
private SemaphoreSlim DataFlowSemaphoreSlim { get; } |
|
private RemoteKeyBindings RemoteKeyBindings { get; } |
private MqttCommunication MqttCommunication { get; } |
private TaskScheduler TaskScheduler { get; } |
private CancellationToken CancellationToken { get; } |
|
private IKeyboardMouseEvents MouseKeyGloalHook { get; set; } |
|
public void Dispose() |
@@ -75,6 +70,8 @@ |
|
// Create a sliding window of size equal to the longest key combination. |
var maxKeyComboLength = RemoteKeyBindings.Bindings.Max(binding => binding.Keys.Count); |
if (maxKeyComboLength <= 0) |
return; |
|
KeyComboBatchBlock = |
new BatchBlock<string>(maxKeyComboLength); |
@@ -139,7 +136,8 @@ |
await DataFlowSemaphoreSlim.WaitAsync(CancellationToken); |
try |
{ |
if (KeyComboBatchBlock != null) await KeyComboBatchBlock.SendAsync(key, CancellationToken); |
if (KeyComboBatchBlock != null) |
await KeyComboBatchBlock.SendAsync(key, CancellationToken); |
} |
finally |
{ |
/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); |
} |
} |
} |