From 5a5bb1a7372731699dece4f17597e29ade32c37a Mon Sep 17 00:00:00 2001 From: Fabio Olimpieri Date: Sun, 15 Jan 2017 16:19:14 +0100 Subject: [PATCH] Fast up and down menu scrolling --- src/menu_sdl.c | 17 ++++++++++++++++- src/menu_sdl.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/menu_sdl.c b/src/menu_sdl.c index 0f88148..8074a8b 100644 --- a/src/menu_sdl.c +++ b/src/menu_sdl.c @@ -1238,6 +1238,17 @@ uint32_t menu_wait_key_press(int *joy_n_p) joy_keys_last = keys; if (!joy_keys_changed) keys = 0; + + //Quick scrolling + for (nr = 0; nr < ordenador.joystick_number; nr++) { + joy = ordenador.joystick_sdl[nr]; + + Sint16 axis3 = SDL_JoystickGetAxis(joy, 3); + + if (axis3 < -15000 ) keys |= KEY_UP_FAST; + else if( axis3 > 15000 ) keys |= KEY_DOWN_FAST; + } + if (SDL_PollEvent(&ev)) { @@ -1347,7 +1358,11 @@ static int menu_select_internal(SDL_Surface *screen, if (keys & KEY_UP) {select_next(p_menu, 0, -1, 1);play_click(0);} else if (keys & KEY_DOWN) - {select_next(p_menu, 0, 1, 1);play_click(0);} + {select_next(p_menu, 0, 1, 1);play_click(0);} + else if (keys & KEY_UP_FAST) + {select_next(p_menu, 0, -1, 1);} + else if (keys & KEY_DOWN_FAST) + {select_next(p_menu, 0, 1, 1);} else if (keys & KEY_PAGEUP) {select_next(p_menu, 0, -19, 0);play_click(0);} else if (keys & KEY_PAGEDOWN) diff --git a/src/menu_sdl.h b/src/menu_sdl.h index 76a5b7c..5b68a89 100644 --- a/src/menu_sdl.h +++ b/src/menu_sdl.h @@ -38,7 +38,9 @@ #define KEY_PAGEDOWN 64 #define KEY_PAGEUP 128 #define KEY_HELP 256 -#define KEY_DESELECT 512 +#define KEY_DESELECT 512 +#define KEY_UP_FAST 1024 +#define KEY_DOWN_FAST 2048 enum font {FONT_NORM, FONT_ALT};