From bb4aa82cb308eeca895061c0728e54e4e4c426cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 9 Jun 2020 17:18:31 +0200 Subject: [PATCH] Revert "input_keys_pressed/menu_input_keys_pressed - optimizations" This reverts commit be5985b8e68d7a267e572f978332eaf08e9cc82c. --- retroarch.c | 146 +++++++++++++++++++--------------------------------- 1 file changed, 52 insertions(+), 94 deletions(-) diff --git a/retroarch.c b/retroarch.c index 2ac615974b..9d9ec18c03 100644 --- a/retroarch.c +++ b/retroarch.c @@ -24022,37 +24022,13 @@ static void input_menu_keys_pressed( } else { - p_rarch->input_hotkey_block_counter = 0; - p_rarch->input_driver_block_hotkey = true; + p_rarch->input_hotkey_block_counter = 0; + p_rarch->input_driver_block_hotkey = true; break; } } } - if (p_rarch->input_driver_block_libretro_input) - { - /* Check the libretro input first */ - for (i = 0; i < RARCH_FIRST_META_KEY; i++) - { - if (input_keys_pressed_other_sources(p_rarch, i, p_new_state)) - { - BIT256_SET_PTR(p_new_state, i); - } - } - - /* Check the hotkeys */ - for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) - { - if ( - BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state) - ) - { - BIT256_SET_PTR(p_new_state, i); - } - } - } - else { int16_t ret[MAX_USERS]; /* Check the libretro input first */ @@ -24070,54 +24046,59 @@ static void input_menu_keys_pressed( for (i = 0; i < RARCH_FIRST_META_KEY; i++) { - for (port = 0; port < port_max; port++) + bool bit_pressed = false; + + if (!p_rarch->input_driver_block_libretro_input) { - if (binds[port][i].valid && ret[port] & (UINT64_C(1) << i)) + for (port = 0; port < port_max; port++) { - BIT256_SET_PTR(p_new_state, i); - /* Break out of nested loop */ - goto input_menu_keys_check_libretro_end; + if (binds[port][i].valid && ret[port] & (UINT64_C(1) << i)) + { + bit_pressed = true; + break; + } } } - if (input_keys_pressed_other_sources(p_rarch, i, p_new_state)) + if (bit_pressed || input_keys_pressed_other_sources( + p_rarch, i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); } -input_menu_keys_check_libretro_end: - ; } /* Check the hotkeys */ for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) { - for (port = 0; port < port_max; port++) - { - const struct retro_keybind *mtkey = &input_config_binds[port][i]; - if (!mtkey->valid) - continue; - joypad_info->joy_idx = settings->uints.input_joypad_map[port]; - joypad_info->auto_binds = input_autoconf_binds[joypad_info->joy_idx]; - joypad_info->axis_threshold = p_rarch->input_driver_axis_threshold; + bool bit_pressed = false; - if (p_rarch->current_input->input_state( - p_rarch->current_input_data, joypad_info, - &binds[0], port, RETRO_DEVICE_JOYPAD, 0, i)) + if (!p_rarch->input_driver_block_hotkey) + { + for (port = 0; port < port_max; port++) { - BIT256_SET_PTR(p_new_state, i); - /* Break out of nested loop */ - goto input_menu_keys_check_hotkeys_end; + const struct retro_keybind *mtkey = &input_config_binds[port][i]; + if (!mtkey->valid) + continue; + joypad_info->joy_idx = settings->uints.input_joypad_map[port]; + joypad_info->auto_binds = input_autoconf_binds[joypad_info->joy_idx]; + joypad_info->axis_threshold = p_rarch->input_driver_axis_threshold; + + if (p_rarch->current_input->input_state( + p_rarch->current_input_data, joypad_info, + &binds[0], port, RETRO_DEVICE_JOYPAD, 0, i)) + { + bit_pressed = true; + break; + } } } - if ( BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state) - ) + if ( bit_pressed + || BIT64_GET(lifecycle_state, i) + || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); } -input_menu_keys_check_hotkeys_end: - ; } } @@ -24172,8 +24153,8 @@ static void input_keys_pressed( } else { - p_rarch->input_hotkey_block_counter = 0; - p_rarch->input_driver_block_hotkey = true; + p_rarch->input_hotkey_block_counter = 0; + p_rarch->input_driver_block_hotkey = true; } } @@ -24198,60 +24179,37 @@ static void input_keys_pressed( } } - if (p_rarch->input_driver_block_libretro_input) + /* Check the libretro input first */ { - /* Check the libretro input first */ - for (i = 0; i < RARCH_FIRST_META_KEY; i++) - { - if (input_keys_pressed_other_sources(p_rarch, i, p_new_state)) - { - BIT256_SET_PTR(p_new_state, i); - } - } - - /* Check the hotkeys */ - for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) - { - if ( - BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) - { - BIT256_SET_PTR(p_new_state, i); - } - } - } - else - { - /* Check the libretro input first */ int16_t ret = p_rarch->current_input->input_state( p_rarch->current_input_data, joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); for (i = 0; i < RARCH_FIRST_META_KEY; i++) { - bool bit_pressed = binds[i].valid && (ret & (UINT64_C(1) << i)); + bool bit_pressed = !p_rarch->input_driver_block_libretro_input + && binds[i].valid && (ret & (UINT64_C(1) << i)); if (bit_pressed || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) { BIT256_SET_PTR(p_new_state, i); } } - - /* Check the hotkeys */ - for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) - { - bool bit_pressed = binds[i].valid && p_rarch->current_input->input_state( - p_rarch->current_input_data, joypad_info, - &binds, 0, RETRO_DEVICE_JOYPAD, 0, i); - if ( bit_pressed - || BIT64_GET(lifecycle_state, i) - || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) - { - BIT256_SET_PTR(p_new_state, i); - } - } } + /* Check the hotkeys */ + for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) + { + bool bit_pressed = !p_rarch->input_driver_block_hotkey && binds[i].valid + && p_rarch->current_input->input_state(p_rarch->current_input_data, joypad_info, + &binds, 0, RETRO_DEVICE_JOYPAD, 0, i); + if ( bit_pressed + || BIT64_GET(lifecycle_state, i) + || input_keys_pressed_other_sources(p_rarch, i, p_new_state)) + { + BIT256_SET_PTR(p_new_state, i); + } + } } void *input_driver_get_data(void)