mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +00:00
Cut down on code duplication
This commit is contained in:
parent
e7d3f36a22
commit
d78e1da956
@ -536,6 +536,43 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE bool input_keys_pressed_internal_reuse(unsigned i)
|
||||||
|
{
|
||||||
|
if (i >= RARCH_FIRST_META_KEY)
|
||||||
|
{
|
||||||
|
if (current_input->meta_key_pressed(current_input_data, i))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_OVERLAY
|
||||||
|
if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i))
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_COMMAND
|
||||||
|
if (input_driver_command)
|
||||||
|
{
|
||||||
|
command_handle_t handle;
|
||||||
|
|
||||||
|
handle.handle = input_driver_command;
|
||||||
|
handle.id = i;
|
||||||
|
|
||||||
|
if (command_get(&handle))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NETWORKGAMEPAD
|
||||||
|
if (input_driver_remote)
|
||||||
|
{
|
||||||
|
if (input_remote_key_pressed(i, 0))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
static INLINE bool input_menu_keys_pressed_internal(
|
static INLINE bool input_menu_keys_pressed_internal(
|
||||||
const struct retro_keybind **binds,
|
const struct retro_keybind **binds,
|
||||||
@ -573,38 +610,6 @@ static INLINE bool input_menu_keys_pressed_internal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= RARCH_FIRST_META_KEY)
|
|
||||||
{
|
|
||||||
if (current_input->meta_key_pressed(current_input_data, i))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_OVERLAY
|
|
||||||
if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_COMMAND
|
|
||||||
if (input_driver_command)
|
|
||||||
{
|
|
||||||
command_handle_t handle;
|
|
||||||
|
|
||||||
handle.handle = input_driver_command;
|
|
||||||
handle.id = i;
|
|
||||||
|
|
||||||
if (command_get(&handle))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKGAMEPAD
|
|
||||||
if (input_driver_remote)
|
|
||||||
{
|
|
||||||
if (input_remote_key_pressed(i, 0))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,13 +726,11 @@ uint64_t input_menu_keys_pressed(void *data, uint64_t last_input)
|
|||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
{
|
{
|
||||||
const struct retro_keybind *mtkey = &input_config_binds[0][RARCH_MENU_TOGGLE];
|
const struct retro_keybind *mtkey = &input_config_binds[0][RARCH_MENU_TOGGLE];
|
||||||
if ( ((settings->uints.input_menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
|
if (
|
||||||
|
((settings->uints.input_menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
|
||||||
input_driver_toggle_button_combo(
|
input_driver_toggle_button_combo(
|
||||||
settings->uints.input_menu_toggle_gamepad_combo, last_input))
|
settings->uints.input_menu_toggle_gamepad_combo, last_input))
|
||||||
|| input_menu_keys_pressed_internal(
|
)
|
||||||
binds, settings, joypad_info, RARCH_MENU_TOGGLE, max_users,
|
|
||||||
mtkey->valid,
|
|
||||||
settings->bools.input_all_users_control_menu))
|
|
||||||
ret |= (UINT64_C(1) << RARCH_MENU_TOGGLE);
|
ret |= (UINT64_C(1) << RARCH_MENU_TOGGLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -735,13 +738,14 @@ uint64_t input_menu_keys_pressed(void *data, uint64_t last_input)
|
|||||||
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
||||||
{
|
{
|
||||||
const struct retro_keybind *mtkey = &input_config_binds[0][i];
|
const struct retro_keybind *mtkey = &input_config_binds[0][i];
|
||||||
if (i != RARCH_MENU_TOGGLE &&
|
if (input_menu_keys_pressed_internal(binds,
|
||||||
input_menu_keys_pressed_internal(binds,
|
|
||||||
settings, joypad_info, i, max_users,
|
settings, joypad_info, i, max_users,
|
||||||
mtkey->valid,
|
mtkey->valid,
|
||||||
settings->bools.input_all_users_control_menu))
|
settings->bools.input_all_users_control_menu))
|
||||||
ret |= (UINT64_C(1) << i);
|
ret |= (UINT64_C(1) << i);
|
||||||
|
|
||||||
|
if (input_keys_pressed_internal_reuse(i))
|
||||||
|
ret |= (UINT64_C(1) << i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < max_users; i++)
|
for (i = 0; i < max_users; i++)
|
||||||
@ -801,6 +805,7 @@ uint64_t input_menu_keys_pressed(void *data, uint64_t last_input)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static INLINE bool input_keys_pressed_internal(
|
static INLINE bool input_keys_pressed_internal(
|
||||||
settings_t *settings,
|
settings_t *settings,
|
||||||
rarch_joypad_info_t joypad_info,
|
rarch_joypad_info_t joypad_info,
|
||||||
@ -822,38 +827,6 @@ static INLINE bool input_keys_pressed_internal(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= RARCH_FIRST_META_KEY)
|
|
||||||
{
|
|
||||||
if (current_input->meta_key_pressed(current_input_data, i))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_OVERLAY
|
|
||||||
if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_COMMAND
|
|
||||||
if (input_driver_command)
|
|
||||||
{
|
|
||||||
command_handle_t handle;
|
|
||||||
|
|
||||||
handle.handle = input_driver_command;
|
|
||||||
handle.id = i;
|
|
||||||
|
|
||||||
if (command_get(&handle))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKGAMEPAD
|
|
||||||
if (input_driver_remote)
|
|
||||||
{
|
|
||||||
if (input_remote_key_pressed(i, 0))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,6 +907,9 @@ uint64_t input_keys_pressed(void *data, uint64_t last_input)
|
|||||||
{
|
{
|
||||||
if (input_keys_pressed_internal(settings, joypad_info, i, binds))
|
if (input_keys_pressed_internal(settings, joypad_info, i, binds))
|
||||||
ret |= (UINT64_C(1) << i);
|
ret |= (UINT64_C(1) << i);
|
||||||
|
|
||||||
|
if (input_keys_pressed_internal_reuse(i))
|
||||||
|
ret |= (UINT64_C(1) << i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user