mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
Add option to disable SDL joystick support.
This also adds some extra sanity checks to avoid crashes when the joystick isn't initialized.
This commit is contained in:
parent
5151dff03c
commit
9bf0f9bbfc
2 changed files with 11 additions and 3 deletions
|
@ -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 )
|
||||
|
|
|
@ -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<IJoystickConfig *> &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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue