Skip to content

Commit

Permalink
Menu navigation hold adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Jul 3, 2023
1 parent 8c9e7dd commit f676529
Showing 1 changed file with 24 additions and 27 deletions.
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

0 comments on commit f676529

Please sign in to comment.