WingMan – Diff between revs 20 and 21
?pathlinks?
Rev 20 | Rev 21 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
2 | using System.Collections.Generic; |
- | ||
3 | using System.IO; |
2 | using System.IO; |
|
4 | using System.Threading; |
3 | using System.Threading; |
|
5 | using System.Threading.Tasks; |
4 | using System.Threading.Tasks; |
|
6 | using WindowsInput; |
5 | using WindowsInput; |
|
7 | using WindowsInput.Native; |
6 | using WindowsInput.Native; |
|
8 | using MQTTnet; |
7 | using MQTTnet; |
|
9 | using SimWinInput; |
- | ||
10 | using WingMan.Communication; |
8 | using WingMan.Communication; |
|
11 | using WingMan.Utilities; |
9 | using WingMan.Utilities; |
|
Line 12... | Line 10... | |||
12 | |
10 | |
|
13 | namespace WingMan.Bindings |
11 | namespace WingMan.Bindings |
|
Line 25... | Line 23... | |||
25 | CancellationToken = cancellationToken; |
23 | CancellationToken = cancellationToken; |
|
Line 26... | Line 24... | |||
26 | |
24 | |
|
Line 27... | Line 25... | |||
27 | MqttCommunication.OnMessageReceived += OnMqttMessageReceived; |
25 | MqttCommunication.OnMessageReceived += OnMqttMessageReceived; |
|
28 | |
- | ||
29 | InputSimulator = new InputSimulator(); |
- | ||
30 | /*var values = Enum.GetValues(typeof(InputSimulator)); |
- | ||
31 | foreach (var i in values) |
- | ||
32 | { |
- | ||
33 | VirtualKeyCodeMapper.Add((int)i, values.GetValue()); |
26 | |
|
Line 34... | Line 27... | |||
34 | }*/ |
27 | InputSimulator = new InputSimulator(); |
|
Line 35... | Line 28... | |||
35 | } |
28 | } |
|
36 | |
29 | |
|
37 | private InputSimulator InputSimulator { get; set; } |
30 | private InputSimulator InputSimulator { get; } |
|
38 | |
31 | |
|
Line 68... | Line 61... | |||
68 | new KeyBindingExecutingEventArgs(executeMouseKeyBinding.Nick, |
61 | new KeyBindingExecutingEventArgs(executeMouseKeyBinding.Nick, |
|
69 | executeMouseKeyBinding.Name)), |
62 | executeMouseKeyBinding.Name)), |
|
70 | CancellationToken, |
63 | CancellationToken, |
|
71 | TaskContinuationOptions.None, TaskScheduler); |
64 | TaskContinuationOptions.None, TaskScheduler); |
|
Line -... | Line 65... | |||
- | 65 | |
||
72 | |
66 | #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
|
- | 67 | Task.Run(() => Simulate(executeMouseKeyBinding), CancellationToken); |
||
73 | Simulate(executeMouseKeyBinding); |
68 | #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
|
74 | } |
69 | } |
|
Line 75... | Line 70... | |||
75 | } |
70 | } |
|
76 | |
71 | |
|
Line 81... | Line 76... | |||
81 | if (!string.Equals(localBinding.Name, executeBinding.Name, StringComparison.Ordinal)) |
76 | if (!string.Equals(localBinding.Name, executeBinding.Name, StringComparison.Ordinal)) |
|
82 | continue; |
77 | continue; |
|
Line 83... | Line 78... | |||
83 | |
78 | |
|
84 | foreach (var key in localBinding.Keys) |
79 | foreach (var key in localBinding.Keys) |
|
85 | { |
80 | { |
|
86 | if (!KeyConversion.StringToKeys.TryGetValue(key, out var pressKey)) |
81 | if (!KeyConversion.StringToKeys.TryGetValue(key, out var press)) |
|
Line 87... | Line 82... | |||
87 | continue; |
82 | continue; |
|
88 | |
83 | |
|
89 | InputSimulator.Keyboard.KeyPress((VirtualKeyCode) pressKey); |
84 | InputSimulator.Keyboard.KeyPress((VirtualKeyCode) press); |
|
90 | } |
85 | } |
|
91 | } |
86 | } |
|
92 | } |
87 | } |