Rewrite fast forward code

This commit is contained in:
twinaphex 2017-05-21 13:32:36 +02:00
parent d1b50acfee
commit 1e02bd3455
1 changed files with 27 additions and 15 deletions

View File

@ -2528,26 +2528,38 @@ static enum runloop_state runloop_check_state(
} }
} }
/* Check fast forward button */
/* To avoid continous switching if we hold the button down, we require /* To avoid continous switching if we hold the button down, we require
* that the button must go from pressed to unpressed back to pressed * that the button must go from pressed to unpressed back to pressed
* to be able to toggle between then. * to be able to toggle between then.
*/ */
if (runloop_cmd_triggered(trigger_input, RARCH_FAST_FORWARD_KEY))
{ {
if (input_driver_is_nonblock) static bool old_button_state = false;
input_driver_unset_nonblock_state(); static bool old_hold_button_state = false;
else bool new_button_state = runloop_cmd_press(
input_driver_set_nonblock_state(); current_input, RARCH_FAST_FORWARD_KEY);
driver_set_nonblock_state(); bool new_hold_button_state = runloop_cmd_press(
} current_input, RARCH_FAST_FORWARD_HOLD_KEY);
else if ((runloop_cmd_pressed(old_input, RARCH_FAST_FORWARD_HOLD_KEY)
!= runloop_cmd_press(current_input, RARCH_FAST_FORWARD_HOLD_KEY))) if (new_button_state && !old_button_state)
{ {
if (runloop_cmd_press(current_input, RARCH_FAST_FORWARD_HOLD_KEY)) if (input_driver_is_nonblock)
input_driver_set_nonblock_state(); input_driver_unset_nonblock_state();
else else
input_driver_unset_nonblock_state(); input_driver_set_nonblock_state();
driver_set_nonblock_state(); driver_set_nonblock_state();
}
else if (old_hold_button_state != new_hold_button_state)
{
if (new_hold_button_state)
input_driver_set_nonblock_state();
else
input_driver_unset_nonblock_state();
driver_set_nonblock_state();
}
old_button_state = new_button_state;
old_hold_button_state = new_hold_button_state;
} }
/* Check state slots */ /* Check state slots */