Add support for keyboard input that is not normalized to US English layout

This is used by the soft keyboards on Android and iOS
This commit is contained in:
Cameron Gutman
2023-04-09 11:55:03 -05:00
parent ae7ae8a870
commit 4e04604696
5 changed files with 37 additions and 20 deletions

View File

@@ -338,15 +338,16 @@ namespace platf {
}
void
keyboard(input_t &input, uint16_t modcode, bool release) {
keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) {
auto raw = (input_raw_t *) input.get();
INPUT i {};
i.type = INPUT_KEYBOARD;
auto &ki = i.ki;
// For some reason, MapVirtualKey(VK_LWIN, MAPVK_VK_TO_VSC) doesn't seem to work :/
if (modcode != VK_LWIN && modcode != VK_RWIN && modcode != VK_PAUSE && raw->keyboard_layout != NULL) {
// If the client did not normalize this VK code to a US English layout, we can't accurately convert it to a scancode.
if (!(flags & SS_KBE_FLAG_NON_NORMALIZED) && modcode != VK_LWIN && modcode != VK_RWIN && modcode != VK_PAUSE && raw->keyboard_layout != NULL) {
// For some reason, MapVirtualKey(VK_LWIN, MAPVK_VK_TO_VSC) doesn't seem to work :/
ki.wScan = MapVirtualKeyEx(modcode, MAPVK_VK_TO_VSC, raw->keyboard_layout);
}
@@ -355,7 +356,7 @@ namespace platf {
ki.dwFlags = KEYEVENTF_SCANCODE;
}
else {
// If there is no scancode mapping, send it as a regular VK event.
// If there is no scancode mapping or it's non-normalized, send it as a regular VK event.
ki.wVk = modcode;
}