X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=69d7a2120a6fe78f2c7536f16954c2fb4908cc2d;hb=aa931ed885e278dc0102b5e10f59b2ba52fb690a;hp=a870bf7433f4156337d627d82632ecf2ebf53a14;hpb=b62e4322b0b7d01aac9340adaddba753e04c9c51;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index a870bf74..69d7a212 100644 --- a/src/events.c +++ b/src/events.c @@ -354,6 +354,7 @@ void ClearEventQueue() #if defined(TARGET_SDL2) case SDL_CONTROLLERBUTTONUP: + HandleJoystickEvent(&event); ClearPlayerAction(); break; #endif @@ -399,6 +400,7 @@ void SleepWhileUnmapped() #if defined(TARGET_SDL2) case SDL_CONTROLLERBUTTONUP: + HandleJoystickEvent(&event); key_joystick_mapping = 0; break; #endif @@ -2010,10 +2012,23 @@ void HandleJoystick() case GAME_MODE_INFO: { static unsigned int joystickmove_delay = 0; + static unsigned int joystickmove_delay_value = GADGET_FRAME_DELAY; + static int joystick_last = 0; if (joystick && !button && - !DelayReached(&joystickmove_delay, GADGET_FRAME_DELAY)) + !DelayReached(&joystickmove_delay, joystickmove_delay_value)) + { + /* delay joystick actions if buttons/axes continually pressed */ newbutton = dx = dy = 0; + } + else + { + /* start with longer delay, then continue with shorter delay */ + if (joystick != joystick_last) + joystickmove_delay_value = GADGET_FRAME_DELAY_FIRST; + else + joystickmove_delay_value = GADGET_FRAME_DELAY; + } if (game_status == GAME_MODE_TITLE) HandleTitleScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); @@ -2027,6 +2042,9 @@ void HandleJoystick() HandleSetupScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_INFO) HandleInfoScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + + joystick_last = joystick; + break; }