bwRavencl/ControllerBuddy

Issue with pause key events

bwRavencl opened this issue · 3 comments

There seems to be some strange difference between the keyboard events generated by ControllerBuddy and the Windows OSK concerning the Pause key.

Generally the Pause key seems to work just fine, however e.g. in DCS a combination of Right CTRL + Pause is not handled correctly, although seems to get detected correctly by the DCS internal input mapper.

It seems this issue can be replicated with the following tool: https://w3c.github.io/uievents/tools/key-event-viewer.html

When pressing the Pause key via ControllerBuddy the tool detects an "unrecognized key".
Pressing the key via the Windows OSK the site shows "Pause".
The behaviour does not "improve" when the KEYEVENTF_EXTENDEDKEY flag is not set.

OSK uses virtual key codes instead of scan codes:

Screenshot 2020-12-30 183205

Next up: compare with the events generated by a physical keyboard

From https://github.com/chromium/chromium/blob/99314be8152e688bafbbf9a615536bdbb289ea87/remoting/host/keyboard_layout_monitor_win.cc#L179

// The USB keyboard driver translates NumLock to the scancode 0x45, but it
// is delivered to applications as 0xE045. Meanwhile, Pause is translated
// to the scancode sequence 0xE1 0x1D 0x45 0xE1 0x9D 0xC5, but is delivered
// to applications as a plain 0x45.
//
// Injecting 0x45 using SendInput does get interpreted by Windows as
// VK_NUMLOCK, but is not translated to 0xE045 before being delivered to
// applications as it is with a physical keyboard. As a result, Chrome (for
// example) reports a key value of "NumLock" but a code value of "Pause".
//
// Injecting 0xE045, on the otherhand, does not get interpreted as
// VK_NUMLOCK, so Chrome sees reports a code value of "NumLock", but a key
// value of "Unidentified".
//
// I have not been able to determine any way to use SendInput to inject an
// event that Windows interprets as VK_PAUSE.