diff --git a/driver.h b/driver.h index 5ab6685815..a8dd99752b 100644 --- a/driver.h +++ b/driver.h @@ -266,7 +266,6 @@ typedef struct driver #ifdef HAVE_NETWORK_GAMEPAD rarch_remote_t *remote; #endif - bool block_libretro_input; bool nonblock_state; /* Last message given to the video driver */ diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 3ff7d7bb56..fe43d91f34 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -94,7 +94,6 @@ static PyObject *py_read_input(PyObject *self, PyObject *args) unsigned user, key, i; const struct retro_keybind *py_binds[MAX_USERS]; int16_t res = 0; - driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); for (i = 0; i < MAX_USERS; i++) @@ -108,7 +107,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args) if (user > MAX_USERS || user < 1 || key >= RARCH_FIRST_META_KEY) return NULL; - if (!driver->block_libretro_input) + if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) res = input_driver_state(py_binds, user - 1, RETRO_DEVICE_JOYPAD, 0, key); return PyBool_FromLong(res); } diff --git a/gfx/video_state_tracker.c b/gfx/video_state_tracker.c index 1dc126bf23..470a96d22f 100644 --- a/gfx/video_state_tracker.c +++ b/gfx/video_state_tracker.c @@ -276,7 +276,6 @@ static void state_tracker_update_input(state_tracker_t *tracker) unsigned i; const struct retro_keybind *binds[MAX_USERS]; settings_t *settings = config_get_ptr(); - driver_t *driver = driver_get_ptr(); uint16_t state[2] = {0}; /* Only bind for up to two players for now. */ @@ -290,7 +289,7 @@ static void state_tracker_update_input(state_tracker_t *tracker) input_push_analog_dpad(settings->input.autoconf_binds[i], settings->input.analog_dpad_mode[i]); - if (!driver->block_libretro_input) + if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) { for (i = 4; i < 16; i++) { diff --git a/input/input_driver.c b/input/input_driver.c index c8ad9bab85..0d24c2fa7f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -83,6 +83,7 @@ struct turbo_buttons }; static bool flushing_input; +static bool block_libretro_input; static bool block_hotkey; static turbo_buttons_t turbo_btns; @@ -283,7 +284,7 @@ static retro_input_t input_driver_keys_pressed(void) for (key = 0; key < RARCH_BIND_LIST_END; key++) { bool state = false; - if ((!driver->block_libretro_input && ((key < RARCH_FIRST_META_KEY))) + if ((!block_libretro_input && ((key < RARCH_FIRST_META_KEY))) || !block_hotkey) state = input_driver_key_pressed(key); @@ -500,7 +501,7 @@ int16_t input_state(unsigned port, unsigned device, if (settings->input.remap_binds_enable) input_remapping_state(port, &device, &idx, &id); - if (!flushing_input && !driver->block_libretro_input) + if (!flushing_input && !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); @@ -610,8 +611,7 @@ retro_input_t input_keys_pressed(void) return 0; turbo_btns.count++; - - driver->block_libretro_input = + block_libretro_input = check_block_hotkey(input_driver_key_pressed(RARCH_ENABLE_HOTKEY)); for (i = 0; i < settings->input.max_users; i++) @@ -624,7 +624,7 @@ retro_input_t input_keys_pressed(void) turbo_btns.frame_enable[i] = 0; } - if (!driver->block_libretro_input) + if (!block_libretro_input) { for (i = 0; i < settings->input.max_users; i++) turbo_btns.frame_enable[i] = input_driver_state(binds, @@ -737,6 +737,14 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) break; case RARCH_INPUT_CTL_IS_FLUSHING_INPUT: return flushing_input; + case RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED: + block_libretro_input = true; + break; + case RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED: + block_libretro_input = false; + break; + case RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED: + return block_libretro_input; case RARCH_INPUT_CTL_NONE: default: break; diff --git a/input/input_driver.h b/input/input_driver.h index f7883af300..0042b2f09a 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -59,7 +59,10 @@ enum rarch_input_ctl_state 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 + RARCH_INPUT_CTL_IS_FLUSHING_INPUT, + RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, + RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, + RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED }; struct retro_keybind diff --git a/menu/menu_display.c b/menu/menu_display.c index a2dffb9e7a..43dc6786e8 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -316,12 +316,14 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data) if (menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL)) { - driver_t *driver = driver_get_ptr(); - bool block_libretro_input = driver->block_libretro_input; + bool libretro_input_is_blocked = input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL); + + if (!libretro_input_is_blocked) + input_driver_ctl(RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); - driver->block_libretro_input = true; core.retro_run(); - driver->block_libretro_input = block_libretro_input; + + input_driver_ctl(RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); return true; } diff --git a/netplay.c b/netplay.c index eb99b85e72..a770213fdd 100644 --- a/netplay.c +++ b/netplay.c @@ -221,10 +221,9 @@ static bool get_self_input_state(netplay_t *netplay) { uint32_t state = 0; struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; - driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!driver->block_libretro_input && netplay->frame_count > 0) + if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL) && netplay->frame_count > 0) { unsigned i;