Start turning the two input functions closer together

This commit is contained in:
twinaphex 2019-08-20 18:46:01 +02:00
parent 75c7b2a29a
commit c1f961b94e

View File

@ -12394,14 +12394,14 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY]; const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY];
const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY]; const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY];
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 = input_driver_axis_threshold;
if (check_input_driver_block_hotkey(binds_norm, binds_auto)) if (check_input_driver_block_hotkey(binds_norm, binds_auto))
{ {
const struct retro_keybind *htkey = &input_config_binds[port][RARCH_ENABLE_HOTKEY]; const struct retro_keybind *htkey = &input_config_binds[port][RARCH_ENABLE_HOTKEY];
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 = input_driver_axis_threshold;
if (htkey->valid if (htkey->valid
&& current_input->input_state(current_input_data, joypad_info, && current_input->input_state(current_input_data, joypad_info,
&binds[0], port, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) &binds[0], port, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY))
@ -12427,7 +12427,6 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
{ {
for (port = 0; port < port_max; port++) for (port = 0; port < port_max; port++)
{ {
const struct retro_keybind *binds = input_config_binds[0];
const struct retro_keybind *mtkey = &input_config_binds[port][i]; const struct retro_keybind *mtkey = &input_config_binds[port][i];
if (!mtkey->valid) if (!mtkey->valid)
continue; continue;
@ -12436,7 +12435,7 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
joypad_info.axis_threshold = input_driver_axis_threshold; joypad_info.axis_threshold = input_driver_axis_threshold;
if (current_input->input_state(current_input_data, joypad_info, if (current_input->input_state(current_input_data, joypad_info,
&binds, joypad_info.joy_idx, RETRO_DEVICE_JOYPAD, 0, i)) &binds[0], joypad_info.joy_idx, RETRO_DEVICE_JOYPAD, 0, i))
{ {
bit_pressed = true; bit_pressed = true;
break; break;
@ -12459,7 +12458,6 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
{ {
for (port = 0; port < port_max; port++) for (port = 0; port < port_max; port++)
{ {
const struct retro_keybind *binds = input_config_binds[0];
const struct retro_keybind *mtkey = &input_config_binds[port][i]; const struct retro_keybind *mtkey = &input_config_binds[port][i];
if (!mtkey->valid) if (!mtkey->valid)
continue; continue;
@ -12468,7 +12466,7 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
joypad_info.axis_threshold = input_driver_axis_threshold; joypad_info.axis_threshold = input_driver_axis_threshold;
if (current_input->input_state(current_input_data, joypad_info, if (current_input->input_state(current_input_data, joypad_info,
&binds, joypad_info.joy_idx, RETRO_DEVICE_JOYPAD, 0, i)) &binds[0], joypad_info.joy_idx, RETRO_DEVICE_JOYPAD, 0, i))
{ {
bit_pressed = true; bit_pressed = true;
break; break;
@ -12548,58 +12546,74 @@ static void input_menu_keys_pressed(input_bits_t *p_new_state,
*/ */
static void input_keys_pressed(input_bits_t *p_new_state) static void input_keys_pressed(input_bits_t *p_new_state)
{ {
unsigned i; unsigned i, port;
rarch_joypad_info_t joypad_info; rarch_joypad_info_t joypad_info;
settings_t *settings = configuration_settings; settings_t *settings = configuration_settings;
const struct retro_keybind *binds = input_config_binds[0]; const struct retro_keybind *binds[MAX_USERS] = {NULL};
const struct retro_keybind *binds_auto = &input_autoconf_binds[0][RARCH_ENABLE_HOTKEY]; uint8_t max_users = 1;
const struct retro_keybind *binds_norm = &binds[RARCH_ENABLE_HOTKEY]; uint8_t port_max = 1;
joypad_info.joy_idx = settings->uints.input_joypad_map[0]; joypad_info.joy_idx = 0;
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.auto_binds = NULL;
joypad_info.axis_threshold = input_driver_axis_threshold;
if (check_input_driver_block_hotkey(binds_norm, binds_auto)) for (i = 0; i < max_users; i++)
{ {
const struct retro_keybind *enable_hotkey = binds[i] = input_config_binds[i];
&input_config_binds[0][RARCH_ENABLE_HOTKEY];
if ( enable_hotkey && enable_hotkey->valid
&& current_input->input_state(
current_input_data, joypad_info, &binds, 0,
RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY))
input_driver_block_libretro_input = true;
else
input_driver_block_hotkey = true;
} }
if (binds[RARCH_GAME_FOCUS_TOGGLE].valid) for (port = 0; port < port_max; port++)
{ {
const struct retro_keybind *focus_binds_auto = const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY];
&input_autoconf_binds[0][RARCH_GAME_FOCUS_TOGGLE]; const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY];
const struct retro_keybind *focus_normal =
&binds[RARCH_GAME_FOCUS_TOGGLE];
/* Allows rarch_focus_toggle hotkey to still work joypad_info.joy_idx = settings->uints.input_joypad_map[port];
* even though every hotkey is blocked */ joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
if (check_input_driver_block_hotkey( joypad_info.axis_threshold = input_driver_axis_threshold;
focus_normal, focus_binds_auto))
if (check_input_driver_block_hotkey(binds_norm, binds_auto))
{ {
if (current_input->input_state(current_input_data, joypad_info, &binds, 0, const struct retro_keybind *enable_hotkey =
RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE)) &input_config_binds[port][RARCH_ENABLE_HOTKEY];
input_driver_block_hotkey = false;
if ( enable_hotkey && enable_hotkey->valid
&& current_input->input_state(
current_input_data, joypad_info,
&binds[port], port,
RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY))
input_driver_block_libretro_input = true;
else
input_driver_block_hotkey = true;
}
if (binds[port][RARCH_GAME_FOCUS_TOGGLE].valid)
{
const struct retro_keybind *focus_binds_auto =
&input_autoconf_binds[port][RARCH_GAME_FOCUS_TOGGLE];
const struct retro_keybind *focus_normal =
&binds[port][RARCH_GAME_FOCUS_TOGGLE];
/* Allows rarch_focus_toggle hotkey to still work
* even though every hotkey is blocked */
if (check_input_driver_block_hotkey(
focus_normal, focus_binds_auto))
{
if (current_input->input_state(current_input_data, joypad_info,
&binds[port], port,
RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE))
input_driver_block_hotkey = false;
}
} }
} }
/* Check the libretro input first */ /* Check the libretro input first */
{ {
int16_t ret = current_input->input_state(current_input_data, int16_t ret = current_input->input_state(current_input_data,
joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, joypad_info, &binds[0], 0, RETRO_DEVICE_JOYPAD, 0,
RETRO_DEVICE_ID_JOYPAD_MASK); RETRO_DEVICE_ID_JOYPAD_MASK);
for (i = 0; i < RARCH_FIRST_META_KEY; i++) for (i = 0; i < RARCH_FIRST_META_KEY; i++)
{ {
bool bit_pressed = !input_driver_block_libretro_input bool bit_pressed = !input_driver_block_libretro_input
&& binds[i].valid && (ret & (1 << i)); && binds[0][i].valid && (ret & (1 << i));
if (bit_pressed || input_keys_pressed_other_sources(i, p_new_state)) if (bit_pressed || input_keys_pressed_other_sources(i, p_new_state))
{ {
BIT256_SET_PTR(p_new_state, i); BIT256_SET_PTR(p_new_state, i);
@ -12610,9 +12624,9 @@ static void input_keys_pressed(input_bits_t *p_new_state)
/* Check the hotkeys */ /* Check the hotkeys */
for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++)
{ {
bool bit_pressed = !input_driver_block_hotkey && binds[i].valid bool bit_pressed = !input_driver_block_hotkey && binds[0][i].valid
&& current_input->input_state(current_input_data, joypad_info, && current_input->input_state(current_input_data, joypad_info,
&binds, 0, RETRO_DEVICE_JOYPAD, 0, i); &binds[0], 0, RETRO_DEVICE_JOYPAD, 0, i);
if ( bit_pressed if ( bit_pressed
|| BIT64_GET(lifecycle_state, i) || BIT64_GET(lifecycle_state, i)
|| input_keys_pressed_other_sources(i, p_new_state)) || input_keys_pressed_other_sources(i, p_new_state))