X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=948f1ceb73602a5bbdfda6c0c2161be133678c15;hb=41cfe645942062496cd063eb46e17d677a76c645;hp=ddd4def814d661eba2e1ade1a6ff5d63753a01e9;hpb=0e5a0f487acaed09a34c655b83ea637c83f4a0f0;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index ddd4def8..948f1ceb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2087,11 +2087,17 @@ void CalibrateJoystick(int player_nr) } #ifndef MSDOS + +#ifdef USE_SDL_LIBRARY + joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0); + joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1); +#else if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) { joystick_status = JOYSTICK_OFF; goto error_out; } +#endif new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x); new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x); @@ -2199,7 +2205,18 @@ void CalibrateJoystick(int player_nr) StopAnimation(); DrawSetupInputScreen(); - while(Joystick(player_nr) & JOY_BUTTON); + + /* wait until the last pressed button was released */ + while(Joystick(player_nr) & JOY_BUTTON) + { + if (PendingEvent()) /* got event */ + { + Event event; + + NextEvent(&event); + HandleOtherEvents(&event); + } + } return; error_out: