+#ifdef USE_SDL_LIBRARY
+
+ 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_LIBRARY */
+