From ab8791628c638b37a4d2fa5705521510809b40ff Mon Sep 17 00:00:00 2001 From: Mike Erickson Date: Tue, 24 Oct 2023 15:28:10 +0800 Subject: [PATCH] fix:xinput disconnect lost gamepad (#15819) Co-authored-by: ChenX --- input/drivers_joypad/xinput_hybrid_joypad.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/input/drivers_joypad/xinput_hybrid_joypad.c b/input/drivers_joypad/xinput_hybrid_joypad.c index cb57417f6aa5..fa43b2970add 100644 --- a/input/drivers_joypad/xinput_hybrid_joypad.c +++ b/input/drivers_joypad/xinput_hybrid_joypad.c @@ -242,6 +242,11 @@ static BOOL CALLBACK enum_joypad_cb_hybrid( if (g_joypad_cnt == MAX_USERS) return DIENUM_STOP; + while (!g_xinput_states[g_last_xinput_pad_idx].connected && g_last_xinput_pad_idx < 3) + { + g_last_xinput_pad_idx++; + } + pad = &g_pads[g_joypad_cnt].joypad; #ifdef __cplusplus