don't exit if joystick initialization failed, better report SDL_Init errors (#229)

This commit is contained in:
Roman Fomin 2021-06-28 13:32:27 +07:00 committed by GitHub
parent 8ae8e25b33
commit ded6543817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,7 @@
#include "i_system.h" #include "i_system.h"
// haleyjd: SDL init flags // haleyjd: SDL init flags
#define BASE_INIT_FLAGS (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) #define BASE_INIT_FLAGS SDL_INIT_VIDEO
#ifdef _DEBUG #ifdef _DEBUG
#define INIT_FLAGS (BASE_INIT_FLAGS | SDL_INIT_NOPARACHUTE) #define INIT_FLAGS (BASE_INIT_FLAGS | SDL_INIT_NOPARACHUTE)
@ -51,7 +51,7 @@ int main(int argc, char **argv)
// haleyjd: init SDL // haleyjd: init SDL
if(SDL_Init(INIT_FLAGS) == -1) if(SDL_Init(INIT_FLAGS) == -1)
{ {
puts("Failed to initialize SDL library.\n"); printf("Failed to initialize SDL library: %s\n", SDL_GetError());
return -1; return -1;
} }

View File

@ -669,9 +669,10 @@ void I_InitSound(void)
audio_buffers = SAMPLECOUNT * snd_samplerate / 11025; audio_buffers = SAMPLECOUNT * snd_samplerate / 11025;
// haleyjd: the docs say we should do this // haleyjd: the docs say we should do this
if(SDL_InitSubSystem(SDL_INIT_AUDIO)) // In SDL2, SDL_InitSubSystem() and SDL_Init() are interchangeable.
if (SDL_Init(SDL_INIT_AUDIO) < 0)
{ {
printf("Couldn't initialize SDL audio.\n"); printf("Couldn't initialize SDL audio: %s\n", SDL_GetError());
snd_card = 0; snd_card = 0;
mus_card = 0; mus_card = 0;
return; return;

View File

@ -170,6 +170,7 @@ void I_InitJoystick(void)
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
{ {
printf("Failed to initialize joystick: %s\n", SDL_GetError());
return; return;
} }