[ioquake3] 29/59: Fix joystick w/o controller mapping not working with SDL update.
Simon McVittie
smcv at debian.org
Wed Sep 21 19:57:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit c5c01e771a2eb01d5c6bc994fff272bf2469fb26
Author: SmileTheory <SmileTheory at gmail.com>
Date: Tue Aug 16 19:01:18 2016 -0700
Fix joystick w/o controller mapping not working with SDL update.
---
code/sdl/sdl_input.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c
index d0ebebc..4c8ff1f 100644
--- a/code/sdl/sdl_input.c
+++ b/code/sdl/sdl_input.c
@@ -439,6 +439,21 @@ static void IN_InitJoystick( void )
gamepad = NULL;
memset(&stick_state, '\0', sizeof (stick_state));
+ // SDL 2.0.4 requires SDL_INIT_JOYSTICK to be initialized separately from
+ // SDL_INIT_GAMECONTROLLER for SDL_JoystickOpen() to work correctly,
+ // despite https://wiki.libsdl.org/SDL_Init (retrieved 2016-08-16)
+ // indicating SDL_INIT_JOYSTICK should be initialized automatically.
+ if (!SDL_WasInit(SDL_INIT_JOYSTICK))
+ {
+ Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
+ if (SDL_Init(SDL_INIT_JOYSTICK) != 0)
+ {
+ Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) failed: %s\n", SDL_GetError());
+ return;
+ }
+ Com_DPrintf("SDL_Init(SDL_INIT_JOYSTICK) passed.\n");
+ }
+
if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER))
{
Com_DPrintf("Calling SDL_Init(SDL_INIT_GAMECONTROLLER)...\n");
@@ -477,7 +492,7 @@ static void IN_InitJoystick( void )
stick = SDL_JoystickOpen( in_joystickNo->integer );
if (stick == NULL) {
- Com_DPrintf( "No joystick opened.\n" );
+ Com_DPrintf( "No joystick opened: %s\n", SDL_GetError() );
return;
}
@@ -507,6 +522,9 @@ static void IN_ShutdownJoystick( void )
if ( !SDL_WasInit( SDL_INIT_GAMECONTROLLER ) )
return;
+ if ( !SDL_WasInit( SDL_INIT_JOYSTICK ) )
+ return;
+
if (gamepad)
{
SDL_GameControllerClose(gamepad);
@@ -520,6 +538,7 @@ static void IN_ShutdownJoystick( void )
}
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list