X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=92f52c568d337d766e2a69e22956caefdf048290;hb=41cfe645942062496cd063eb46e17d677a76c645;hp=ab51dd9fef4ce8c6ffc1ddacf9df2da289f99fc4;hpb=0e5a0f487acaed09a34c655b83ea637c83f4a0f0;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index ab51dd9f..92f52c56 100644 --- a/src/init.c +++ b/src/init.c @@ -14,6 +14,7 @@ #include #include "init.h" +#include "events.h" #include "misc.h" #include "sound.h" #include "screens.h" @@ -146,6 +147,31 @@ void InitSound() if (sound_status == SOUND_OFF) return; +#ifdef USE_SDL_LIBRARY + /* initialize SDL audio */ + + if (SDL_Init(SDL_INIT_AUDIO) < 0) + { + Error(ERR_WARN, "SDL_Init() failed: %s\n", SDL_GetError()); + sound_status = SOUND_OFF; + return; + } + + if (Mix_OpenAudio(22050, AUDIO_S16, 2, 256) < 0) + { + Error(ERR_WARN, "Mix_OpenAudio() failed: %s\n", SDL_GetError()); + sound_status = SOUND_OFF; + return; + } + + Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4); + Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4); + + sound_status = SOUND_AVAILABLE; + sound_loops_allowed = TRUE; + +#else /* !USE_SDL_LIBRARY */ + #ifndef MSDOS if (access(sound_device_name, W_OK) != 0) { @@ -180,6 +206,7 @@ void InitSound() */ #endif /* MSDOS */ +#endif /* !USE_SDL_LIBRARY */ for(i=0; i= SDL_NumJoysticks()) + joystick_nr = -1; + + /* misuse joystick file descriptor variable to store joystick number */ + stored_player[i].joystick_fd = joystick_nr; + + /* this allows subsequent calls to 'InitJoysticks' for re-initialization */ + if (Check_SDL_JoystickOpened(joystick_nr)) + Close_SDL_Joystick(joystick_nr); + + if (!setup.input[i].use_joystick) + continue; + + if (!Open_SDL_Joystick(joystick_nr)) + { + Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + continue; + } + + joystick_status = JOYSTICK_AVAILABLE; + } + +#else /* !USE_SDL_LIBRARY */ + #ifndef MSDOS for (i=0; i