(menu_input.c) Don't need menu_navigation_get_ptr anymore

This commit is contained in:
twinaphex 2015-09-25 18:37:36 +02:00
parent 2759c9fe04
commit 12b870cafe
3 changed files with 40 additions and 13 deletions

View File

@ -1214,13 +1214,14 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
| (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT)
| (1UL << RETRO_DEVICE_ID_JOYPAD_L) | (1UL << RETRO_DEVICE_ID_JOYPAD_L)
| (1UL << RETRO_DEVICE_ID_JOYPAD_R); | (1UL << RETRO_DEVICE_ID_JOYPAD_R);
menu_navigation_t *nav = menu_navigation_get_ptr(); bool set_scroll = false;
menu_display_t *disp = menu_display_get_ptr(); size_t new_scroll_accel = 0;
menu_input_t *menu_input = menu_input_get_ptr(); menu_display_t *disp = menu_display_get_ptr();
driver_t *driver = driver_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr();
settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!driver || !nav || !menu_input) if (!driver || !menu_input)
return 0; return 0;
driver->retro_ctx.poll_cb(); driver->retro_ctx.poll_cb();
@ -1239,21 +1240,29 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
if (menu_input->delay.count >= menu_input->delay.timer) if (menu_input->delay.count >= menu_input->delay.timer)
{ {
first_held = false; set_scroll = true;
first_held = false;
trigger_input |= input & input_repeat; trigger_input |= input & input_repeat;
nav->scroll.acceleration =
min(nav->scroll.acceleration + 1, 64); menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL,
&new_scroll_accel);
new_scroll_accel = min(new_scroll_accel + 1, 64);
} }
initial_held = false; initial_held = false;
} }
else else
{ {
first_held = false; set_scroll = true;
first_held = false;
initial_held = true; initial_held = true;
nav->scroll.acceleration = 0;
} }
if (set_scroll)
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL,
&new_scroll_accel);
menu_input->delay.count += menu_animation_get_delta_time(disp->animation) / IDEAL_DT; menu_input->delay.count += menu_animation_get_delta_time(disp->animation) / IDEAL_DT;
if (menu_input->keyboard.display) if (menu_input->keyboard.display)

View File

@ -209,6 +209,22 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
nav->scroll.indices.list[nav->scroll.indices.size++] = *sel; nav->scroll.indices.list[nav->scroll.indices.size++] = *sel;
} }
return true; return true;
case MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL:
{
size_t *sel = (size_t*)data;
if (!nav || !sel)
return false;
*sel = nav->scroll.acceleration;
}
return true;
case MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL:
{
size_t *sel = (size_t*)data;
if (!nav || !sel)
return false;
nav->scroll.acceleration = *sel;
}
return true;
} }
return false; return false;

View File

@ -56,7 +56,9 @@ enum menu_navigation_ctl_state
MENU_NAVIGATION_CTL_SET_SELECTION, MENU_NAVIGATION_CTL_SET_SELECTION,
MENU_NAVIGATION_CTL_GET_SELECTION, MENU_NAVIGATION_CTL_GET_SELECTION,
MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES, MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES,
MENU_NAVIGATION_CTL_ADD_SCROLL_INDEX MENU_NAVIGATION_CTL_ADD_SCROLL_INDEX,
MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL,
MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL
}; };
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data); bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data);