mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-30 05:22:21 +00:00
(XInput/DirectInput) Show device disconnect messages when unplugging a gamepad
This commit is contained in:
parent
b3915e8d22
commit
eb3753ee3c
@ -553,6 +553,7 @@ static void dinput_joypad_poll(void)
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
HRESULT ret;
|
||||
struct dinput_joypad_data *pad = &g_pads[i];
|
||||
bool polled = g_xinput_pad_indexes[i] < 0;
|
||||
|
||||
@ -577,8 +578,11 @@ static void dinput_joypad_poll(void)
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInputDevice8_GetDeviceState(pad->joypad,
|
||||
ret = IDirectInputDevice8_GetDeviceState(pad->joypad,
|
||||
sizeof(DIJOYSTATE2), &pad->joy_state);
|
||||
|
||||
if (ret == DIERR_INPUTLOST || ret == DIERR_NOTACQUIRED)
|
||||
input_autoconfigure_disconnect(i, g_pads[i].joy_friendly_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,10 +540,13 @@ static void xinput_joypad_poll(void)
|
||||
#ifdef HAVE_DINPUT
|
||||
if (g_xinput_states[i].connected)
|
||||
{
|
||||
if (g_XInputGetStateEx && g_XInputGetStateEx(i,
|
||||
if (g_XInputGetStateEx(i,
|
||||
&(g_xinput_states[i].xstate))
|
||||
== ERROR_DEVICE_NOT_CONNECTED)
|
||||
{
|
||||
g_xinput_states[i].connected = false;
|
||||
input_autoconfigure_disconnect(i, xinput_joypad_name(i));
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Normally, dinput handles device insertion/removal for us, but
|
||||
@ -551,7 +554,7 @@ static void xinput_joypad_poll(void)
|
||||
/* Also note that on UWP, the controllers are not available on startup
|
||||
* and are instead 'plugged in' a moment later because Microsoft reasons */
|
||||
/* TODO: This may be bad for performance? */
|
||||
bool new_connected = g_XInputGetStateEx && g_XInputGetStateEx(i, &(g_xinput_states[i].xstate)) != ERROR_DEVICE_NOT_CONNECTED;
|
||||
bool new_connected = g_XInputGetStateEx(i, &(g_xinput_states[i].xstate)) != ERROR_DEVICE_NOT_CONNECTED;
|
||||
if (new_connected != g_xinput_states[i].connected)
|
||||
{
|
||||
if (new_connected)
|
||||
@ -561,10 +564,10 @@ static void xinput_joypad_poll(void)
|
||||
xinput_joypad_init(NULL);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_xinput_states[i].connected = new_connected;
|
||||
}
|
||||
|
||||
g_xinput_states[i].connected = new_connected;
|
||||
if (!g_xinput_states[i].connected)
|
||||
input_autoconfigure_disconnect(i, xinput_joypad_name(i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user