- if (sound_status == SOUND_OFF)
- return;
-
-#ifndef USE_SDL_LIBRARY
-
-#if !defined(MSDOS) && !defined(WIN32)
-
- if (pipe(sound_pipe)<0)
- {
- Error(ERR_WARN, "cannot create pipe - no sounds");
- sound_status = SOUND_OFF;
- return;
- }
-
- if ((sound_process_id = fork()) < 0)
- {
- Error(ERR_WARN, "cannot create sound server process - no sounds");
- sound_status = SOUND_OFF;
- return;
- }
-
- if (!sound_process_id) /* we are child */
- {
- SoundServer();
-
- /* never reached */
- exit(0);
- }
- else /* we are parent */
- close(sound_pipe[0]); /* no reading from pipe needed */
-
-#else /* MSDOS || WIN32 */
-
- SoundServer();
-
-#endif /* MSDOS */
-
-#endif /* !USE_SDL_LIBRARY */
-}
-
-void InitJoysticks()
-{
-#ifdef USE_SDL_JOYSTICK
- static boolean sdl_joystick_subsystem_initialized = FALSE;
-#endif
-
- int i;
-
- if (global_joystick_status == JOYSTICK_OFF)
- return;
-
- joystick_status = JOYSTICK_OFF;
-
-#ifdef USE_SDL_JOYSTICK
-
- if (!sdl_joystick_subsystem_initialized)
- {
- sdl_joystick_subsystem_initialized = TRUE;
-
- if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
- {
- Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
- return;
- }
- }
-
- for (i=0; i<MAX_PLAYERS; i++)
- {
- char *device_name = setup.input[i].joy.device_name;
- int joystick_nr = getJoystickNrFromDeviceName(device_name);
-
- if (joystick_nr >= 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_JOYSTICK */
-
-#ifndef MSDOS
- for (i=0; i<MAX_PLAYERS; i++)
- {
- char *device_name = setup.input[i].joy.device_name;
-
- /* this allows subsequent calls to 'InitJoysticks' for re-initialization */
- if (stored_player[i].joystick_fd != -1)
- {
- close(stored_player[i].joystick_fd);
- stored_player[i].joystick_fd = -1;
- }
-
- if (!setup.input[i].use_joystick)
- continue;
-
- if (access(device_name, R_OK) != 0)
- {
- Error(ERR_WARN, "cannot access joystick device '%s'", device_name);
- continue;
- }
-
- if ((stored_player[i].joystick_fd = open(device_name, O_RDONLY)) < 0)
- {
- Error(ERR_WARN, "cannot open joystick device '%s'", device_name);
- continue;
- }
-
- joystick_status = JOYSTICK_AVAILABLE;
- }
-
-#else /* MSDOS */
-
- /* try to access two joysticks; if that fails, try to access just one */
- if (install_joystick(JOY_TYPE_2PADS) == 0 ||
- install_joystick(JOY_TYPE_AUTODETECT) == 0)
- joystick_status = JOYSTICK_AVAILABLE;
-
- /*
- load_joystick_data(JOYSTICK_FILENAME);
- */
-
- for (i=0; i<MAX_PLAYERS; i++)
- {
- char *device_name = setup.input[i].joy.device_name;
- int joystick_nr = getJoystickNrFromDeviceName(device_name);
-
- if (joystick_nr >= num_joysticks)
- joystick_nr = -1;
-
- /* misuse joystick file descriptor variable to store joystick number */
- stored_player[i].joystick_fd = joystick_nr;
- }
-#endif
-
-#endif /* !USE_SDL_LIBRARY */