Move flushing_input to input_driver.c

This commit is contained in:
twinaphex 2015-11-29 17:23:30 +01:00
parent 23d63d0b5a
commit 253649b0cf
6 changed files with 26 additions and 14 deletions

View File

@ -267,7 +267,6 @@ typedef struct driver
rarch_remote_t *remote;
#endif
bool block_libretro_input;
bool flushing_input;
bool nonblock_state;
/* Last message given to the video driver */

View File

@ -82,6 +82,7 @@ struct turbo_buttons
unsigned count;
};
static bool flushing_input;
static bool block_hotkey;
static turbo_buttons_t turbo_btns;
@ -499,7 +500,7 @@ int16_t input_state(unsigned port, unsigned device,
if (settings->input.remap_binds_enable)
input_remapping_state(port, &device, &idx, &id);
if (!driver->flushing_input && !driver->block_libretro_input)
if (!flushing_input && !driver->block_libretro_input)
{
if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD)))
res = input->input_state(driver->input_data, libretro_input_binds, port, device, idx, id);
@ -687,7 +688,8 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
driver->input->free(driver->input_data);
return true;
case RARCH_INPUT_CTL_DESTROY:
block_hotkey = false;
flushing_input = false;
block_hotkey = false;
memset(&turbo_btns, 0, sizeof(turbo_buttons_t));
if (!driver)
return false;
@ -727,6 +729,14 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
}
return true;
case RARCH_INPUT_CTL_SET_FLUSHING_INPUT:
flushing_input = true;
break;
case RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT:
flushing_input = false;
break;
case RARCH_INPUT_CTL_IS_FLUSHING_INPUT:
return flushing_input;
case RARCH_INPUT_CTL_NONE:
default:
break;

View File

@ -56,7 +56,10 @@ enum rarch_input_ctl_state
RARCH_INPUT_CTL_POLL,
RARCH_INPUT_CTL_FIND_DRIVER,
RARCH_INPUT_CTL_GRAB_STDIN,
RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED
RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED,
RARCH_INPUT_CTL_SET_FLUSHING_INPUT,
RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT,
RARCH_INPUT_CTL_IS_FLUSHING_INPUT
};
struct retro_keybind

View File

@ -329,7 +329,7 @@ void menu_driver_toggle(bool latch)
event_command(EVENT_CMD_AUDIO_START);
/* Prevent stray input from going to libretro core */
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
/* Restore libretro keyboard callback. */
if (global)

View File

@ -177,7 +177,7 @@ static void menu_input_key_end_line(void)
menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, NULL);
/* Avoid triggering states on pressing return. */
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
}
static void menu_input_search_callback(void *userdata, const char *str)
@ -744,7 +744,7 @@ int menu_input_key_bind_iterate(char *s, size_t len)
if (menu_input->binds.begin > menu_input->binds.last)
{
/* Avoid new binds triggering things right away. */
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
/* We won't be getting any key events, so just cancel early. */
if (timed_out)
@ -764,7 +764,7 @@ int menu_input_key_bind_iterate(char *s, size_t len)
input_driver_keyboard_mapping_set_block(false);
/* Avoid new binds triggering things right away. */
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
binds.begin++;

View File

@ -818,7 +818,7 @@ static void rarch_main_iterate_linefeed_overlay(driver_t *driver,
#ifdef HAVE_MENU
static bool rarch_main_cmd_get_state_menu_toggle_button_combo(
driver_t *driver, settings_t *settings,
settings_t *settings,
retro_input_t input, retro_input_t old_input,
retro_input_t trigger_input)
{
@ -844,7 +844,7 @@ static bool rarch_main_cmd_get_state_menu_toggle_button_combo(
break;
}
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
return true;
}
#endif
@ -861,7 +861,7 @@ static void rarch_main_cmd_get_state(driver_t *driver,
cmd->grab_mouse_pressed = BIT64_GET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE);
#ifdef HAVE_MENU
cmd->menu_pressed = BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) ||
rarch_main_cmd_get_state_menu_toggle_button_combo(driver,
rarch_main_cmd_get_state_menu_toggle_button_combo(
settings, input,
old_input, trigger_input);
#endif
@ -974,9 +974,9 @@ int rarch_main_iterate(unsigned *sleep_ms)
retro_input_t old_input = last_input;
last_input = input;
if (driver->flushing_input)
if (input_driver_ctl(RARCH_INPUT_CTL_IS_FLUSHING_INPUT, NULL))
{
driver->flushing_input = false;
input_driver_ctl(RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT, NULL);
if (input)
{
input = 0;
@ -986,7 +986,7 @@ int rarch_main_iterate(unsigned *sleep_ms)
* pause toggle to wake it up. */
if (main_is_paused)
BIT64_SET(input, RARCH_PAUSE_TOGGLE);
driver->flushing_input = true;
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
}
}