Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu navigation hold adjustments #15454

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 24 additions & 27 deletions menu/menu_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5065,10 +5065,11 @@ unsigned menu_event(
bool display_kb)
{
/* Used for key repeat */
static retro_time_t last_time_us = 0;
static float delay_timer = 0.0f;
static float delay_count = 0.0f;
static bool initial_held = true;
static bool first_held = false;
static bool hold_initial = true;
static bool hold_reset = true;
static unsigned ok_old = 0;
unsigned ret = MENU_ACTION_NOOP;
bool set_scroll = false;
Expand Down Expand Up @@ -5257,21 +5258,25 @@ unsigned menu_event(

if (navigation_current)
{
if (!first_held)
{
/* Store first direction in order to block "diagonals" */
if (!navigation_initial)
navigation_initial = navigation_current;
float delta_time = (float)(menu_st->current_time_us - last_time_us) / 1000;

last_time_us = menu_st->current_time_us;

/* don't run anything first frame, only capture held inputs
* for old_input_state. */
/* Store first direction in order to block "diagonals" */
if (!navigation_initial)
navigation_initial = navigation_current;

first_held = true;
if (hold_reset)
{
/* Don't run anything first frame */
hold_reset = false;
delay_timer = (hold_initial) ? menu_scroll_delay : 33.33f;
delay_count = 0;
if (initial_held)
delay_timer = menu_scroll_delay;
else
delay_timer = menu_scroll_delay / 8;
}
else
{
hold_initial = false;
delay_count += delta_time;
}

if (delay_count >= delay_timer)
Expand All @@ -5280,25 +5285,17 @@ unsigned menu_event(
for (i = 0; i < 6; i++)
BIT32_SET(input_repeat, navigation_buttons[i]);

set_scroll = true;
first_held = false;
p_trigger_input->data[0] |= p_input->data[0] & input_repeat;
new_scroll_accel = menu_st->scroll.acceleration;

if (menu_scroll_fast)
new_scroll_accel = MIN(new_scroll_accel + 1, 25);
else
new_scroll_accel = MIN(new_scroll_accel + 1, 5);
set_scroll = true;
hold_reset = true;
new_scroll_accel = MIN(menu_st->scroll.acceleration + 1, (menu_scroll_fast) ? 25 : 5);
}

initial_held = false;
delay_count += anim_get_ptr()->delta_time;
}
else
{
set_scroll = true;
first_held = false;
initial_held = true;
hold_reset = true;
hold_initial = true;
navigation_initial = 0;
}

Expand Down
Loading