WingMan

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 21  →  ?path2? @ 20
/trunk/WingMan/Bindings/KeyInterceptor.cs
@@ -36,13 +36,18 @@
}
 
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()
@@ -70,8 +75,6 @@
 
// 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);
@@ -136,8 +139,7 @@
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,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -5,6 +6,7 @@
using WindowsInput;
using WindowsInput.Native;
using MQTTnet;
using SimWinInput;
using WingMan.Communication;
using WingMan.Utilities;
 
@@ -25,9 +27,14 @@
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; }
private InputSimulator InputSimulator { get; set; }
 
private MqttCommunication MqttCommunication { get; }
private TaskScheduler TaskScheduler { get; }
@@ -63,9 +70,7 @@
CancellationToken,
TaskContinuationOptions.None, TaskScheduler);
 
#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
Simulate(executeMouseKeyBinding);
}
}
 
@@ -78,10 +83,10 @@
 
foreach (var key in localBinding.Keys)
{
if (!KeyConversion.StringToKeys.TryGetValue(key, out var press))
if (!KeyConversion.StringToKeys.TryGetValue(key, out var pressKey))
continue;
 
InputSimulator.Keyboard.KeyPress((VirtualKeyCode) press);
InputSimulator.Keyboard.KeyPress((VirtualKeyCode) pressKey);
}
}
}