mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 03:35:22 +00:00
Refactor away input_key_pressed_func
This commit is contained in:
parent
ac41067df5
commit
310438f15b
@ -186,6 +186,8 @@ int main_entry_iterate_menu_preinit(signature(), args_type() args)
|
||||
|
||||
int main_entry_iterate_menu(signature(), args_type() args)
|
||||
{
|
||||
retro_input_t input = 0;
|
||||
|
||||
if (menu_iterate())
|
||||
{
|
||||
if (driver.frontend_ctx && driver.frontend_ctx->process_events)
|
||||
@ -199,7 +201,9 @@ int main_entry_iterate_menu(signature(), args_type() args)
|
||||
rarch_main_command(RARCH_CMD_AUDIO_START);
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_FLUSH_INPUT);
|
||||
|
||||
if (input_key_pressed_func(RARCH_QUIT_KEY) ||
|
||||
input = input_keys_pressed_func(RARCH_QUIT_KEY, RARCH_QUIT_KEY + 1);
|
||||
|
||||
if (BIND_PRESSED(input, RARCH_QUIT_KEY) ||
|
||||
!driver.video->alive(driver.video_data))
|
||||
return 1;
|
||||
|
||||
|
@ -319,7 +319,8 @@ bool menu_iterate(void)
|
||||
|
||||
rarch_input_poll();
|
||||
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY);
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY,
|
||||
RARCH_BIND_LIST_END);
|
||||
|
||||
rarch_check_block_hotkey(BIND_PRESSED(input, RARCH_ENABLE_HOTKEY));
|
||||
#ifdef HAVE_OVERLAY
|
||||
|
@ -301,7 +301,7 @@ bool menu_custom_bind_keyboard_cb(void *data, unsigned code)
|
||||
uint64_t menu_input(void)
|
||||
{
|
||||
unsigned i;
|
||||
uint64_t input_state = 0;
|
||||
uint64_t input_state = 0, input_meta = 0;
|
||||
static const struct retro_keybind *binds[] = { g_settings.input.binds[0] };
|
||||
|
||||
if (!driver.menu)
|
||||
@ -327,7 +327,10 @@ uint64_t menu_input(void)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
input_state |= input_key_pressed_func(RARCH_MENU_TOGGLE)
|
||||
|
||||
input_meta = input_keys_pressed_func(RARCH_MENU_TOGGLE, RARCH_MENU_TOGGLE + 1);
|
||||
|
||||
input_state |= BIND_PRESSED(input_meta, RARCH_MENU_TOGGLE)
|
||||
? (1ULL << RARCH_MENU_TOGGLE) : 0;
|
||||
|
||||
input_pop_analog_dpad((struct retro_keybind*)binds[0]);
|
||||
|
@ -516,6 +516,12 @@ static int android_input_get_id(android_input_t *android, AInputEvent *event)
|
||||
return id;
|
||||
}
|
||||
|
||||
static bool pause_key_pressed(void)
|
||||
{
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_PAUSE_TOGGLE, RARCH_PAUSE_TOGGLE+1);
|
||||
return BIND_PRESSED(input, RARCH_PAUSE_TOGGLE);
|
||||
}
|
||||
|
||||
/* Handle all events. If our activity is in pause state,
|
||||
* block until we're unpaused.
|
||||
*/
|
||||
@ -525,7 +531,7 @@ static void android_input_poll(void *data)
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
android_input_t *android = (android_input_t*)data;
|
||||
|
||||
while ((ident = ALooper_pollAll((input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||
while ((ident = ALooper_pollAll((pause_key_pressed())
|
||||
? -1 : 0,
|
||||
NULL, NULL, NULL)) >= 0)
|
||||
{
|
||||
|
@ -218,18 +218,19 @@ static inline bool input_key_pressed_func(int key)
|
||||
|
||||
/* Returns a 64-bit mask of all pressed buttons, starting
|
||||
* from the specified key up until the last queryable key
|
||||
* (RARCH_BIND_LIST_END).
|
||||
* (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.
|
||||
*/
|
||||
|
||||
static inline retro_input_t input_keys_pressed_func(unsigned key)
|
||||
static inline retro_input_t input_keys_pressed_func(unsigned key,
|
||||
unsigned key_end)
|
||||
{
|
||||
retro_input_t ret = 0;
|
||||
|
||||
for (; key < RARCH_BIND_LIST_END; key++)
|
||||
for (; key < key_end; key++)
|
||||
{
|
||||
if (input_key_pressed_func(key))
|
||||
ret |= (1ULL << key);
|
||||
|
@ -3686,7 +3686,8 @@ void rarch_main_command(unsigned cmd)
|
||||
bool rarch_main_iterate(void)
|
||||
{
|
||||
unsigned i;
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY);
|
||||
retro_input_t input = input_keys_pressed_func(RARCH_FIRST_META_KEY,
|
||||
RARCH_BIND_LIST_END);
|
||||
|
||||
/* SHUTDOWN on consoles should exit RetroArch completely. */
|
||||
if (g_extern.system.shutdown)
|
||||
|
Loading…
x
Reference in New Issue
Block a user