swift-project / pilotclient

Cross-platform cross-simulator pilot client for virtual air traffic networks
https://swift-project.org
GNU General Public License v3.0
94 stars 27 forks source link

Hotkeys sent from external program (MobiFlight) do not get recognized, but are seen in chat text field #147

Open tigert opened 2 years ago

tigert commented 2 years ago

I made a button in my sim cockpit using Mobiflight that lets you generate keystrokes from buttons, so I made a PTT button on my panel, which makes a keystroke when pressed.

This works fine in Notepad for testing, and in VPilot it works as PTT just fine.

But for some reason Swift does not see the key events when set up as a hotkey (or when trying to set it up as one). The keystroke is just not doing anything.

But it works fine when I focus the text commands / chat input field and press the button, the text is entered there.

So Swift hotkey listening code is doing something differently and does not see synthetic key events?

MobiFlight, if I understood correctly, uses WindowsForms SendInput to do this.

https://github.com/MobiFlight/MobiFlight-Connector/blob/main/MobiFlight/KeyboardInput.cs#L116 maybe? Unfortunately I am not very experienced in code so I could be wrong too.