mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-20 09:48:27 +00:00
Create more RARCH_INPUT_CTL_* commands
This commit is contained in:
parent
14b2b8ada7
commit
92c0907e80
@ -62,14 +62,14 @@ static void event_init_command(void)
|
||||
if (!settings->stdin_cmd_enable && !settings->network_cmd_enable)
|
||||
return;
|
||||
|
||||
if (settings->stdin_cmd_enable && input_driver_grab_stdin())
|
||||
if (settings->stdin_cmd_enable && input_driver_ctl(RARCH_INPUT_CTL_GRAB_STDIN, NULL))
|
||||
{
|
||||
RARCH_WARN("stdin command interface is desired, but input driver has already claimed stdin.\n"
|
||||
"Cannot use this command interface.\n");
|
||||
}
|
||||
|
||||
if (!(driver->command = rarch_cmd_new(settings->stdin_cmd_enable
|
||||
&& !input_driver_grab_stdin(),
|
||||
&& !input_driver_ctl(RARCH_INPUT_CTL_GRAB_STDIN, NULL),
|
||||
settings->network_cmd_enable, settings->network_cmd_port)))
|
||||
RARCH_ERR("Failed to initialize command interface.\n");
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ static bool check_block_hotkey(bool enable_hotkey)
|
||||
|
||||
/* Don't block the check to RARCH_ENABLE_HOTKEY
|
||||
* unless we're really supposed to. */
|
||||
driver->block_hotkey = input_driver_keyboard_mapping_is_blocked();
|
||||
driver->block_hotkey = input_driver_ctl(RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED, NULL);
|
||||
|
||||
/* If we haven't bound anything to this,
|
||||
* always allow hotkeys. */
|
||||
@ -535,7 +535,7 @@ static bool check_block_hotkey(bool enable_hotkey)
|
||||
|| (autoconf_bind->joyaxis != AXIS_NONE);
|
||||
|
||||
driver->block_hotkey =
|
||||
input_driver_keyboard_mapping_is_blocked() ||
|
||||
input_driver_ctl(RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED, NULL) ||
|
||||
(use_hotkey_enable && !enable_hotkey);
|
||||
|
||||
/* If we hold ENABLE_HOTKEY button, block all libretro input to allow
|
||||
|
@ -219,16 +219,6 @@ bool input_driver_grab_mouse(bool state)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_driver_grab_stdin(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->grab_stdin)
|
||||
return input->grab_stdin(driver->input_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
void input_driver_set(const input_driver_t **input, void **input_data)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
@ -250,17 +240,6 @@ void input_driver_destroy(void)
|
||||
driver->input_data = NULL;
|
||||
}
|
||||
|
||||
bool input_driver_keyboard_mapping_is_blocked(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->keyboard_mapping_is_blocked)
|
||||
return driver->input->keyboard_mapping_is_blocked(
|
||||
driver->input_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
void input_driver_keyboard_mapping_set_block(bool value)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
@ -305,6 +284,7 @@ float input_sensor_get_input(unsigned port, unsigned id)
|
||||
bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
@ -321,6 +301,15 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
|
||||
return false;
|
||||
driver->input->free(driver->input_data);
|
||||
return true;
|
||||
case RARCH_INPUT_CTL_GRAB_STDIN:
|
||||
if (input->grab_stdin)
|
||||
return input->grab_stdin(driver->input_data);
|
||||
return false;
|
||||
case RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED:
|
||||
if (input->keyboard_mapping_is_blocked)
|
||||
return driver->input->keyboard_mapping_is_blocked(
|
||||
driver->input_data);
|
||||
return false;
|
||||
case RARCH_INPUT_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -51,6 +51,8 @@ enum rarch_input_ctl_state
|
||||
RARCH_INPUT_CTL_NONE = 0,
|
||||
RARCH_INPUT_CTL_INIT,
|
||||
RARCH_INPUT_CTL_DEINIT,
|
||||
RARCH_INPUT_CTL_GRAB_STDIN,
|
||||
RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED
|
||||
};
|
||||
|
||||
struct retro_keybind
|
||||
@ -170,12 +172,8 @@ const input_device_driver_t * input_driver_get_sec_joypad_driver(void);
|
||||
|
||||
bool input_driver_grab_mouse(bool state);
|
||||
|
||||
bool input_driver_grab_stdin(void);
|
||||
|
||||
void input_driver_destroy(void);
|
||||
|
||||
bool input_driver_keyboard_mapping_is_blocked(void);
|
||||
|
||||
void input_driver_keyboard_mapping_set_block(bool value);
|
||||
|
||||
const input_driver_t *input_get_ptr(void *data);
|
||||
|
Loading…
Reference in New Issue
Block a user