[iortcw] 99/152: All: Fix joystick w/o controller mapping not working
Simon McVittie
smcv at debian.org
Fri Sep 8 10:40:18 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.5a
in repository iortcw.
commit 39e89d2c89071b087a3f0c2bdcdd50e49431d174
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date: Wed Aug 17 04:26:19 2016 -0400
All: Fix joystick w/o controller mapping not working
---
MP/code/sdl/sdl_input.c | 21 ++++++++++++++++++++-
SP/code/sdl/sdl_input.c | 21 ++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/MP/code/sdl/sdl_input.c b/MP/code/sdl/sdl_input.c
index 887bff7..d934110 100644
--- a/MP/code/sdl/sdl_input.c
+++ b/MP/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);
}
diff --git a/SP/code/sdl/sdl_input.c b/SP/code/sdl/sdl_input.c
index 887bff7..d934110 100644
--- a/SP/code/sdl/sdl_input.c
+++ b/SP/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/iortcw.git
More information about the Pkg-games-commits
mailing list