From 174e82064c87f3a9da2b351275344bb143926bea Mon Sep 17 00:00:00 2001 From: emoose Date: Wed, 15 Jan 2020 07:04:03 +0000 Subject: [PATCH] [HID] Improved WinKey GetKeystroke code Seems the double-keypress issue was because of XINPUT_KEYSTROKE_REPEAT: Xenia would add that to keyup events, but seems REPEAT is only meant for keydown (well SR1 treats it as a keydown event at least) --- src/xenia/hid/winkey/winkey_input_driver.cc | 25 +++++++-------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/xenia/hid/winkey/winkey_input_driver.cc b/src/xenia/hid/winkey/winkey_input_driver.cc index a17e25ea3..b54be91a9 100644 --- a/src/xenia/hid/winkey/winkey_input_driver.cc +++ b/src/xenia/hid/winkey/winkey_input_driver.cc @@ -383,33 +383,24 @@ X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags, } } - if (!cvars::keyboard_passthru) { - if (virtual_key != 0) { - if (evt.transition == true) { - keystroke_flags |= 0x0001; // XINPUT_KEYSTROKE_KEYDOWN - } else if (evt.transition == false) { - keystroke_flags |= 0x0002; // XINPUT_KEYSTROKE_KEYUP - } - + if (virtual_key != 0) { + if (evt.transition == true) { + keystroke_flags |= 0x0001; // XINPUT_KEYSTROKE_KEYDOWN if (evt.prev_state == evt.transition) { keystroke_flags |= 0x0004; // XINPUT_KEYSTROKE_REPEAT } - - result = X_ERROR_SUCCESS; - } - } else { - // Handle keydown & keyup: - if (evt.transition == false) { + } else if (evt.transition == false) { keystroke_flags |= 0x0002; // XINPUT_KEYSTROKE_KEYUP - } else if (evt.transition == true) { - keystroke_flags |= 0x0001; // XINPUT_KEYSTROKE_KEYDOWN } - if (keystroke_flags != 0) { + if (cvars::keyboard_passthru) { WCHAR buf; if (ToUnicode(virtual_key, 0, key_map_, &buf, 1, 0) == 1) { unicode = buf; } + } + + if (keystroke_flags) { result = X_ERROR_SUCCESS; } }