mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 10:20:51 +00:00
Move block_libretro_input to input_driver.c
This commit is contained in:
parent
253649b0cf
commit
6fd6288337
1
driver.h
1
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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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++)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user