diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 25e19ff21a..75d6632664 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -66,10 +66,20 @@ void I_ShutdownGraphics () } if (Video) delete Video, Video = NULL; + + SDL_QuitSubSystem (SDL_INIT_VIDEO); } void I_InitGraphics () { + if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) + { + I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError()); + return; + } + + Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); + UCVarValue val; val.Bool = !!Args->CheckParm ("-devparm"); diff --git a/src/posix/sdl/i_joystick.cpp b/src/posix/sdl/i_joystick.cpp index 9b1d326aef..d99caeca9d 100644 --- a/src/posix/sdl/i_joystick.cpp +++ b/src/posix/sdl/i_joystick.cpp @@ -1,4 +1,4 @@ -#include +#include #include "doomdef.h" #include "templates.h" @@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager; void I_StartupJoysticks() { - JoystickManager = new SDLInputJoystickManager(); + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) + JoystickManager = new SDLInputJoystickManager(); } void I_ShutdownJoysticks() { - delete JoystickManager; + if(JoystickManager) + { + delete JoystickManager; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } } void I_GetJoysticks(TArray &sticks) diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index ff700eff42..d60494d1a5 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -265,14 +265,13 @@ int main (int argc, char **argv) setlocale (LC_ALL, "C"); - if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1) + if (SDL_Init (0) < 0) { fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError()); return -1; } atterm (SDL_Quit); - printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); printf("\n"); try diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index e3f9906b62..6255c8a96c 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms) void I_InitTimer () { + if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) + I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError()); + I_GetTime = I_GetTimeSelect; I_WaitForTic = I_WaitForTicSelect; I_FreezeTime = I_FreezeTimeSelect; @@ -202,5 +205,5 @@ void I_InitTimer () void I_ShutdownTimer () { - + SDL_QuitSubSystem(SDL_INIT_TIMER); }