X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=b127c7844055152de46fc5f8474abd93c5be1237;hb=bafa61706833e7bfe942c388471058749c20c79e;hp=1bc222a958c49c227bfc9fa9a6a23bf853cd8a33;hpb=f8f691137746b187cca2f997604a2336882b5cd9;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 1bc222a9..b127c784 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1440,6 +1440,7 @@ void HandleJoystickEvent(Event *event) void SDLInitJoysticks() { static boolean sdl_joystick_subsystem_initialized = FALSE; + boolean print_warning = !sdl_joystick_subsystem_initialized; int i; if (!sdl_joystick_subsystem_initialized) @@ -1459,11 +1460,19 @@ void SDLInitJoysticks() int joystick_nr = getJoystickNrFromDeviceName(device_name); if (joystick_nr >= SDL_NumJoysticks()) + { + if (setup.input[i].use_joystick && print_warning) + Error(ERR_WARN, "cannot find joystick %d", joystick_nr); + joystick_nr = -1; + } /* misuse joystick file descriptor variable to store joystick number */ joystick.fd[i] = joystick_nr; + if (joystick_nr == -1) + continue; + /* this allows subsequent calls to 'InitJoysticks' for re-initialization */ if (SDLCheckJoystickOpened(joystick_nr)) SDLCloseJoystick(joystick_nr); @@ -1473,7 +1482,9 @@ void SDLInitJoysticks() if (!SDLOpenJoystick(joystick_nr)) { - Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + if (print_warning) + Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + continue; }