mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Refactor menu_input - add input_keys_pressed in addition to
meta_input_keys_pressed
This commit is contained in:
parent
2309a3e716
commit
8015061720
@ -316,20 +316,9 @@ uint64_t menu_input(void)
|
||||
input_push_analog_dpad(g_settings.input.autoconf_binds[i],
|
||||
g_settings.input.analog_dpad_mode[i]);
|
||||
|
||||
if (!driver.block_libretro_input)
|
||||
{
|
||||
for (i = 0; i < RETRO_DEVICE_ID_JOYPAD_R2; i++)
|
||||
{
|
||||
input_state |= driver.input->input_state(driver.input_data, binds,
|
||||
0, RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
|
||||
#ifdef HAVE_OVERLAY
|
||||
input_state |= (driver.overlay_state.buttons & (UINT64_C(1) << i))
|
||||
? (1ULL << i) : 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
input_state = input_keys_pressed(0, RETRO_DEVICE_ID_JOYPAD_R2, binds);
|
||||
|
||||
input_meta = input_keys_pressed_func(RARCH_MENU_TOGGLE, RARCH_MENU_TOGGLE + 1,
|
||||
input_meta = meta_input_keys_pressed(RARCH_MENU_TOGGLE, RARCH_MENU_TOGGLE + 1,
|
||||
&old_state);
|
||||
|
||||
input_state |= BIND_PRESSED(input_meta, RARCH_MENU_TOGGLE)
|
||||
|
@ -1611,3 +1611,71 @@ void input_pop_analog_dpad(struct retro_keybind *binds)
|
||||
binds[i].joyaxis = binds[i].orig_joyaxis;
|
||||
}
|
||||
|
||||
#if !defined(IS_JOYCONFIG) && !defined(IS_RETROLAUNCH)
|
||||
retro_input_t input_keys_pressed(unsigned key,
|
||||
unsigned key_end, const struct retro_keybind **binds)
|
||||
{
|
||||
retro_input_t ret = 0;
|
||||
|
||||
for (; key < key_end; key++)
|
||||
{
|
||||
if (driver.block_libretro_input)
|
||||
return 0;
|
||||
|
||||
ret |= driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_JOYPAD, 0, key) ? (1ULL << key) : 0;
|
||||
#ifdef HAVE_OVERLAY
|
||||
ret |= (driver.overlay_state.buttons & (UINT64_C(1) << key))
|
||||
? (1ULL << key) : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns a 64-bit mask of all pressed meta keys, starting
|
||||
* from the specified key up until the last queryable key
|
||||
* (key_end).
|
||||
*
|
||||
* TODO: In case RARCH_BIND_LIST_END starts exceeding 64,
|
||||
* and you need a bitmask of more than 64 entries, don't
|
||||
* use this function.
|
||||
*/
|
||||
|
||||
retro_input_t meta_input_keys_pressed(unsigned key,
|
||||
unsigned key_end, retro_input_t *old_state)
|
||||
{
|
||||
static retro_input_t old_ret = 0;
|
||||
retro_input_t ret = 0;
|
||||
*old_state = old_ret;
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
rarch_check_block_hotkey(driver.input->key_pressed(driver.input_data,
|
||||
RARCH_ENABLE_HOTKEY));
|
||||
#endif
|
||||
|
||||
for (; key < key_end; key++)
|
||||
{
|
||||
bool state = false;
|
||||
|
||||
if (!driver.block_hotkey)
|
||||
state = driver.input->key_pressed(driver.input_data, key);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
state = state || (driver.overlay_state.buttons & (1ULL << key));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMMAND
|
||||
if (driver.command)
|
||||
state = state || rarch_cmd_get(driver.command, key);
|
||||
#endif
|
||||
|
||||
if (state)
|
||||
ret |= (1ULL << key);
|
||||
}
|
||||
|
||||
old_ret = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
@ -197,51 +197,11 @@ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode);
|
||||
|
||||
void input_pop_analog_dpad(struct retro_keybind *binds);
|
||||
|
||||
/* Returns a 64-bit mask of all pressed buttons, starting
|
||||
* from the specified key up until the last queryable key
|
||||
* (key_end).
|
||||
*
|
||||
* TODO: In case RARCH_BIND_LIST_END starts exceeding 64,
|
||||
* and you need a bitmask of more than 64 entries, don't
|
||||
* use this function.
|
||||
*/
|
||||
retro_input_t input_keys_pressed(unsigned key,
|
||||
unsigned key_end, const struct retro_keybind **binds);
|
||||
|
||||
static inline retro_input_t input_keys_pressed_func(unsigned key,
|
||||
unsigned key_end, retro_input_t *old_state)
|
||||
{
|
||||
static retro_input_t old_ret = 0;
|
||||
retro_input_t ret = 0;
|
||||
*old_state = old_ret;
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
rarch_check_block_hotkey(driver.input->key_pressed(driver.input_data,
|
||||
RARCH_ENABLE_HOTKEY));
|
||||
#endif
|
||||
|
||||
for (; key < key_end; key++)
|
||||
{
|
||||
bool state = false;
|
||||
|
||||
if (!driver.block_hotkey)
|
||||
state = driver.input->key_pressed(driver.input_data, key);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
state = state || (driver.overlay_state.buttons & (1ULL << key));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMMAND
|
||||
if (driver.command)
|
||||
state = state || rarch_cmd_get(driver.command, key);
|
||||
#endif
|
||||
|
||||
if (state)
|
||||
ret |= (1ULL << key);
|
||||
}
|
||||
|
||||
old_ret = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
retro_input_t meta_input_keys_pressed(unsigned key,
|
||||
unsigned key_end, retro_input_t *old_state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -3228,7 +3228,7 @@ bool rarch_main_iterate(void)
|
||||
{
|
||||
unsigned i;
|
||||
retro_input_t old_input, trigger_input;
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY,
|
||||
retro_input_t input = meta_input_keys_pressed(RARCH_FIRST_META_KEY,
|
||||
RARCH_BIND_LIST_END, &old_input);
|
||||
|
||||
trigger_input = input & ~old_input;
|
||||
|
Loading…
Reference in New Issue
Block a user