mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 13:40:56 +00:00
Controller hot plug support.
This commit is contained in:
parent
1972128927
commit
d09866861e
1 changed files with 13 additions and 8 deletions
|
@ -434,15 +434,15 @@ static void IN_InitJoystick( void )
|
||||||
stick = NULL;
|
stick = NULL;
|
||||||
memset(&stick_state, '\0', sizeof (stick_state));
|
memset(&stick_state, '\0', sizeof (stick_state));
|
||||||
|
|
||||||
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
|
if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER))
|
||||||
{
|
{
|
||||||
Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
|
Com_DPrintf("Calling SDL_Init(SDL_INIT_GAMECONTROLLER)...\n");
|
||||||
if (SDL_Init(SDL_INIT_JOYSTICK) != 0)
|
if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
{
|
{
|
||||||
Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) failed: %s\n", SDL_GetError());
|
Com_DPrintf("SDL_Init(SDL_INIT_GAMECONTROLLER) failed: %s\n", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) passed.\n");
|
Com_DPrintf("SDL_Init(SDL_INIT_GAMECONTROLLER) passed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
total = SDL_NumJoysticks();
|
total = SDL_NumJoysticks();
|
||||||
|
@ -459,7 +459,7 @@ static void IN_InitJoystick( void )
|
||||||
|
|
||||||
if( !in_joystick->integer ) {
|
if( !in_joystick->integer ) {
|
||||||
Com_DPrintf( "Joystick is not active.\n" );
|
Com_DPrintf( "Joystick is not active.\n" );
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ IN_ShutdownJoystick
|
||||||
*/
|
*/
|
||||||
static void IN_ShutdownJoystick( void )
|
static void IN_ShutdownJoystick( void )
|
||||||
{
|
{
|
||||||
if ( !SDL_WasInit( SDL_INIT_JOYSTICK ) )
|
if ( !SDL_WasInit( SDL_INIT_GAMECONTROLLER ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (stick)
|
if (stick)
|
||||||
|
@ -503,7 +503,7 @@ static void IN_ShutdownJoystick( void )
|
||||||
stick = NULL;
|
stick = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -840,6 +840,11 @@ static void IN_ProcessEvents( void )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
|
IN_InitJoystick();
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n");
|
Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue