[HID] Fix any poll on XInput.

This commit is contained in:
Joel Linn 2020-04-21 02:07:17 +02:00 committed by Rick Gibbed
parent c8da7fbfe4
commit d7d5d92e59
1 changed files with 10 additions and 6 deletions

View File

@ -149,12 +149,16 @@ X_RESULT XInputInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
// https://stackoverflow.com/questions/23669238/xinputgetkeystroke-returning-error-success-while-controller-is-unplugged // https://stackoverflow.com/questions/23669238/xinputgetkeystroke-returning-error-success-while-controller-is-unplugged
// //
// So we first check if the device is connected via XInputGetCapabilities, so // So we first check if the device is connected via XInputGetCapabilities, so
// we are not passing back an uninitialized X_INPUT_KEYSTROKE structure: // we are not passing back an uninitialized X_INPUT_KEYSTROKE structure.
XINPUT_CAPABILITIES caps; // If any user (0xFF) is polled this bug does not occur but GetCapabilities
auto xigc = (decltype(&XInputGetCapabilities))XInputGetCapabilities_; // would fail so we need to skip it.
result = xigc(user_index, 0, &caps); if (user_index != 0xFF) {
if (result) { XINPUT_CAPABILITIES caps;
return result; auto xigc = (decltype(&XInputGetCapabilities))XInputGetCapabilities_;
result = xigc(user_index, 0, &caps);
if (result) {
return result;
}
} }
XINPUT_KEYSTROKE native_keystroke; XINPUT_KEYSTROKE native_keystroke;