[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)
This commit is contained in:
emoose 2020-01-15 07:04:03 +00:00 committed by illusion
parent 827a03c121
commit 2711d678ac
1 changed files with 8 additions and 17 deletions

View File

@ -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;
}
}