From 7685f93d00949cfd88c63934f04afbfd5263c0fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Jun 2017 07:59:41 +0200 Subject: [PATCH] input_menu_keys_pressed - don't use input_joypad_pressed --- input/input_driver.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 15d6adcdfa..b62285fbbf 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -680,11 +680,37 @@ uint64_t input_menu_keys_pressed(void *data, uint64_t last_input) for (port = 0; port < port_max; port++) { - if ( (sec && input_joypad_pressed(sec, - joypad_info, port, input_config_binds[0], i)) || - (first && input_joypad_pressed(first, - joypad_info, port, input_config_binds[0], i)) - ) + bool pressed = false; + uint64_t joykey = (input_config_binds[0][i].joykey != NO_BTN) + ? input_config_binds[0][i].joykey : joypad_info.auto_binds[i].joykey; + uint32_t joyaxis = (input_config_binds[0][i].joyaxis != AXIS_NONE) + ? input_config_binds[0][i].joyaxis : joypad_info.auto_binds[i].joyaxis; + + if (sec) + { + if ((uint16_t)joykey == NO_BTN || !sec->button(joypad_info.joy_idx, (uint16_t)joykey)) + { + int16_t axis = sec->axis(joypad_info.joy_idx, joyaxis); + float scaled_axis = (float)abs(axis) / 0x8000; + pressed = scaled_axis > joypad_info.axis_threshold; + } + else + pressed = true; + } + + if (!pressed && first) + { + if ((uint16_t)joykey == NO_BTN || !first->button(joypad_info.joy_idx, (uint16_t)joykey)) + { + int16_t axis = first->axis(joypad_info.joy_idx, joyaxis); + float scaled_axis = (float)abs(axis) / 0x8000; + pressed = scaled_axis > joypad_info.axis_threshold; + } + else + pressed = true; + } + + if (pressed) { ret |= (UINT64_C(1) << i); continue;