mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-04 15:31:05 +00:00
Adjust SDL_JOYDEVICEREMOVED handler by checking the player's joy device explicitly
This commit is contained in:
parent
a3063ce89f
commit
bcd747c1cd
1 changed files with 13 additions and 20 deletions
|
@ -116,9 +116,6 @@ static INT32 firstEntry = 0;
|
||||||
// Total mouse motion X/Y offsets
|
// Total mouse motion X/Y offsets
|
||||||
static INT32 mousemovex = 0, mousemovey = 0;
|
static INT32 mousemovex = 0, mousemovey = 0;
|
||||||
|
|
||||||
// Keep track of joy unplugged count
|
|
||||||
static INT32 joyunplugcount = 0;
|
|
||||||
|
|
||||||
// SDL vars
|
// SDL vars
|
||||||
static SDL_Surface *vidSurface = NULL;
|
static SDL_Surface *vidSurface = NULL;
|
||||||
static SDL_Surface *bufSurface = NULL;
|
static SDL_Surface *bufSurface = NULL;
|
||||||
|
@ -897,25 +894,21 @@ void I_GetEvent(void)
|
||||||
M_SetupJoystickMenu(0);
|
M_SetupJoystickMenu(0);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYDEVICEREMOVED:
|
case SDL_JOYDEVICEREMOVED:
|
||||||
|
if (JoyInfo.dev && !SDL_JoystickGetAttached(JoyInfo.dev))
|
||||||
{
|
{
|
||||||
// every time a device is unplugged, the "which" index increments by 1?
|
CONS_Printf("Joy device %d removed, was first joystick\n", JoyInfo.oldjoy);
|
||||||
INT32 deviceIdx = evt.jdevice.which - joyunplugcount++;
|
|
||||||
|
|
||||||
CONS_Printf("Joy device %d removed%s\n", deviceIdx,
|
|
||||||
(JoyInfo.oldjoy-1 == deviceIdx) ? " was first joystick" :
|
|
||||||
(JoyInfo2.oldjoy-1 == deviceIdx) ? " was second joystick" : "");
|
|
||||||
|
|
||||||
// I_ShutdownJoystick doesn't shut down the subsystem
|
|
||||||
// It just fires neutral joy events to clean up the unplugged joy
|
|
||||||
if (JoyInfo.oldjoy-1 == deviceIdx)
|
|
||||||
I_ShutdownJoystick();
|
I_ShutdownJoystick();
|
||||||
if (JoyInfo2.oldjoy-1 == deviceIdx)
|
}
|
||||||
|
|
||||||
|
if (JoyInfo2.dev && !SDL_JoystickGetAttached(JoyInfo2.dev))
|
||||||
|
{
|
||||||
|
CONS_Printf("Joy device %d removed, was second joystick\n", JoyInfo2.oldjoy);
|
||||||
I_ShutdownJoystick2();
|
I_ShutdownJoystick2();
|
||||||
|
}
|
||||||
|
|
||||||
// update the menu
|
// update the menu
|
||||||
if (currentMenu == &OP_JoystickSetDef)
|
if (currentMenu == &OP_JoystickSetDef)
|
||||||
M_SetupJoystickMenu(0);
|
M_SetupJoystickMenu(0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
I_Quit();
|
I_Quit();
|
||||||
|
|
Loading…
Reference in a new issue