Pause local games if a player's gamepad disconnects

This commit is contained in:
AJ Martinez 2024-03-25 00:48:17 -07:00
parent fa5e8a5537
commit 1a6d27897e

View file

@ -227,11 +227,9 @@ static void HandleGamepadDeviceRemoved(event_t *ev)
int i = 0;
I_Assert(ev != NULL);
I_Assert(ev->type == ev_gamepad_device_removed);
G_UnregisterAvailableGamepad(ev->device);
CONS_Alert(CONS_NOTICE, "Gamepad device %d disconnected\n", ev->device);
// Downstream responders need to update player gamepad assignments, pause, etc
boolean playerinterrupted = false;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
@ -239,8 +237,17 @@ static void HandleGamepadDeviceRemoved(event_t *ev)
if (device == ev->device)
{
G_SetDeviceForPlayer(i, -1);
playerinterrupted = true;
}
}
// Downstream responders need to update player gamepad assignments, pause, etc
G_UnregisterAvailableGamepad(ev->device);
if (playerinterrupted && Playing() && !netgame && !demo.playback)
{
M_StartControlPanel();
}
}
/// Respond to added/removed device events, for bookkeeping available gamepads.