Merge pull request #9490 from jdgleaver/horiz-mouse-wheel-fix

Improve horizontal mouse wheel (tilt) navigation
This commit is contained in:
Twinaphex 2019-09-20 16:16:50 +02:00 committed by GitHub
commit bcb7e14d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 12 deletions

View File

@ -29,6 +29,11 @@
RETRO_BEGIN_DECLS RETRO_BEGIN_DECLS
/* Mouse wheel tilt actions repeat at a very high
* frequency - we ignore any input that occurs
* with a period less than MENU_INPUT_HORIZ_WHEEL_DELAY */
#define MENU_INPUT_HORIZ_WHEEL_DELAY 250000 /* 250 ms */
#define MENU_INPUT_HIDE_CURSOR_DELAY 4000000 /* 4 seconds */ #define MENU_INPUT_HIDE_CURSOR_DELAY 4000000 /* 4 seconds */
#define MENU_INPUT_PRESS_TIME_SHORT 250000 /* 250 ms */ #define MENU_INPUT_PRESS_TIME_SHORT 250000 /* 250 ms */

View File

@ -12912,6 +12912,8 @@ static int menu_input_pointer_post_iterate(
static bool last_cancel_pressed = false; static bool last_cancel_pressed = false;
static bool last_left_pressed = false; static bool last_left_pressed = false;
static bool last_right_pressed = false; static bool last_right_pressed = false;
static retro_time_t last_left_action_time = 0;
static retro_time_t last_right_action_time = 0;
bool attenuate_y_accel = true; bool attenuate_y_accel = true;
bool osk_active = menu_input_dialog_get_display_kb_internal(); bool osk_active = menu_input_dialog_get_display_kb_internal();
int ret = 0; int ret = 0;
@ -13120,40 +13122,57 @@ static int menu_input_pointer_post_iterate(
} }
last_cancel_pressed = pointer_hw_state->cancel_pressed; last_cancel_pressed = pointer_hw_state->cancel_pressed;
/* Up /* Up/Down
* Note: This always corresponds to a mouse wheel, which * Note: These always correspond to a mouse wheel, which
* handles differently from other inputs - i.e. we don't * handles differently from other inputs - i.e. we don't
* want a 'last pressed' check */ * want a 'last pressed' check */
/* > Up */
if (pointer_hw_state->up_pressed) if (pointer_hw_state->up_pressed)
{ {
size_t selection = menu_navigation_get_selection(); size_t selection = menu_navigation_get_selection();
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_UP); ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_UP);
} }
/* Down /* > Down */
* Note: This always corresponds to a mouse wheel, which
* handles differently from other inputs - i.e. we don't
* want a 'last pressed' check */
if (pointer_hw_state->down_pressed) if (pointer_hw_state->down_pressed)
{ {
size_t selection = menu_navigation_get_selection(); size_t selection = menu_navigation_get_selection();
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_DOWN); ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_DOWN);
} }
/* Left */ /* Left/Right
* Note: These also always correspond to a mouse wheel...
* In this case, it's a mouse wheel *tilt* operation, which
* is incredibly annoying because holding a tilt direction
* rapidly toggles the input state. The repeat speed is so
* high that any sort of useable control is impossible - so
* we have to apply a 'low pass' filter by ignoring inputs
* that occur below a certain frequency... */
/* > Left */
if (pointer_hw_state->left_pressed && !last_left_pressed) if (pointer_hw_state->left_pressed && !last_left_pressed)
{ {
size_t selection = menu_navigation_get_selection(); if (current_time - last_left_action_time > MENU_INPUT_HORIZ_WHEEL_DELAY)
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_LEFT); {
size_t selection = menu_navigation_get_selection();
last_left_action_time = current_time;
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_LEFT);
}
} }
last_left_pressed = pointer_hw_state->left_pressed; last_left_pressed = pointer_hw_state->left_pressed;
/* Right */ /* > Right */
if (pointer_hw_state->right_pressed && !last_right_pressed) if (pointer_hw_state->right_pressed && !last_right_pressed)
{ {
size_t selection = menu_navigation_get_selection(); if (current_time - last_right_action_time > MENU_INPUT_HORIZ_WHEEL_DELAY)
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_RIGHT); {
size_t selection = menu_navigation_get_selection();
last_right_action_time = current_time;
ret = menu_entry_action(entry, (unsigned)selection, MENU_ACTION_RIGHT);
}
} }
last_right_pressed = pointer_hw_state->right_pressed;
menu_input_set_pointer_visibility(current_time); menu_input_set_pointer_visibility(current_time);