Skip to content

Commit

Permalink
- Move input flushing hack to input_keys_pressed functions
Browse files Browse the repository at this point in the history
- Move menu binding state hack to menu_input_keys_pressed
  • Loading branch information
inactive123 committed Dec 6, 2016
1 parent 77df0ef commit 4b1c24a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 24 deletions.
49 changes: 47 additions & 2 deletions input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "input_keyboard.h"
#include "input_remapping.h"

#ifdef HAVE_MENU
#include "../menu/menu_driver.h"
#endif

#include "../configuration.h"
#include "../driver.h"
#include "../retroarch.h"
Expand Down Expand Up @@ -666,7 +670,8 @@ static INLINE bool input_keys_pressed_internal(unsigned i,
uint64_t input_keys_pressed(
uint64_t old_input,
uint64_t *last_input,
uint64_t *trigger_input)
uint64_t *trigger_input,
bool runloop_paused)
{
unsigned i;
uint64_t ret = 0;
Expand Down Expand Up @@ -712,6 +717,23 @@ uint64_t input_keys_pressed(

*trigger_input = ret & ~old_input;
*last_input = ret;

if (input_driver_flushing_input)
{
input_driver_flushing_input = false;

if (ret)
{
ret = 0;

/* If core was paused before entering menu, evoke
* pause toggle to wake it up. */
if (runloop_paused)
BIT64_SET(ret, RARCH_PAUSE_TOGGLE);
input_driver_flushing_input = true;
}
}

return ret;
}

Expand All @@ -731,7 +753,8 @@ uint64_t input_keys_pressed(
uint64_t input_menu_keys_pressed(
uint64_t old_input,
uint64_t *last_input,
uint64_t *trigger_input)
uint64_t *trigger_input,
bool runloop_paused)
{
unsigned i;
uint64_t ret = 0;
Expand Down Expand Up @@ -851,6 +874,28 @@ uint64_t input_menu_keys_pressed(
end:
*trigger_input = ret & ~old_input;
*last_input = ret;

if (input_driver_flushing_input)
{
input_driver_flushing_input = false;

if (ret)
{
ret = 0;

/* If core was paused before entering menu, evoke
* pause toggle to wake it up. */
if (runloop_paused)
BIT64_SET(ret, RARCH_PAUSE_TOGGLE);
input_driver_flushing_input = true;
}
}

#ifdef HAVE_MENU
if (menu_driver_is_binding_state())
*trigger_input = 0;
#endif

return ret;
}

Expand Down
6 changes: 4 additions & 2 deletions input/input_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,14 @@ int16_t input_state(unsigned port, unsigned device,
uint64_t input_keys_pressed(
uint64_t old_input,
uint64_t *last_input,
uint64_t *trigger_input);
uint64_t *trigger_input,
bool runloop_paused);

uint64_t input_menu_keys_pressed(
uint64_t old_input,
uint64_t *last_input,
uint64_t *trigger_input);
uint64_t *trigger_input,
bool runloop_paused);

void *input_driver_get_data(void);

Expand Down
22 changes: 2 additions & 20 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,24 +759,6 @@ static enum runloop_state runloop_check_state(
bool focused = true;
bool pause_pressed = runloop_cmd_triggered(trigger_input, RARCH_PAUSE_TOGGLE);

if (input_driver_is_flushing_input())
{
input_driver_unset_flushing_input();
if (current_input)
{
current_input = 0;

/* If core was paused before entering menu, evoke
* pause toggle to wake it up. */
if (runloop_paused)
BIT64_SET(current_input, RARCH_PAUSE_TOGGLE);
input_driver_set_flushing_input();
}
}

if (menu_driver_is_binding_state())
trigger_input = 0;

if (runloop_cmd_triggered(trigger_input, RARCH_OVERLAY_NEXT))
command_event(CMD_EVENT_OVERLAY_NEXT, NULL);

Expand Down Expand Up @@ -1113,8 +1095,8 @@ int runloop_iterate(unsigned *sleep_ms)
uint64_t old_input = last_input;
uint64_t current_input =
menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) ?
input_menu_keys_pressed(old_input, &last_input, &trigger_input) :
input_keys_pressed (old_input, &last_input, &trigger_input);
input_menu_keys_pressed(old_input, &last_input, &trigger_input, runloop_paused) :
input_keys_pressed (old_input, &last_input, &trigger_input, runloop_paused);

if (runloop_frame_time.callback)
{
Expand Down

0 comments on commit 4b1c24a

Please sign in to comment.