diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 661214bf16..244ef6329c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -159,6 +159,11 @@ else() endif() endif() + option( NO_SDL_JOYSTICK "Disable SDL joystick support (Not applicable to Windows)" OFF ) + if ( NO_SDL_JOYSTICK ) + add_definitions( -DNO_SDL_JOYSTICK=1 ) + endif ( NO_SDL_JOYSTICK ) + if( NO_GTK ) add_definitions( -DNO_GTK ) elseif( DYN_GTK ) diff --git a/src/common/platform/posix/sdl/i_joystick.cpp b/src/common/platform/posix/sdl/i_joystick.cpp index 9d5297ba0f..fe4b25eb64 100644 --- a/src/common/platform/posix/sdl/i_joystick.cpp +++ b/src/common/platform/posix/sdl/i_joystick.cpp @@ -300,8 +300,10 @@ static SDLInputJoystickManager *JoystickManager; void I_StartupJoysticks() { +#ifndef NO_SDL_JOYSTICK if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) JoystickManager = new SDLInputJoystickManager(); +#endif } void I_ShutdownInput() { @@ -316,7 +318,8 @@ void I_GetJoysticks(TArray &sticks) { sticks.Clear(); - JoystickManager->GetDevices(sticks); + if (JoystickManager) + JoystickManager->GetDevices(sticks); } void I_GetAxes(float axes[NUM_JOYAXIS]) @@ -325,7 +328,7 @@ void I_GetAxes(float axes[NUM_JOYAXIS]) { axes[i] = 0; } - if (use_joystick) + if (use_joystick && JoystickManager) { JoystickManager->AddAxes(axes); } @@ -333,7 +336,7 @@ void I_GetAxes(float axes[NUM_JOYAXIS]) void I_ProcessJoysticks() { - if (use_joystick) + if (use_joystick && JoystickManager) JoystickManager->ProcessInput(); }