From 1e5192462e5292509d1163917ffb43fae74c59f0 Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Sat, 10 Nov 2018 17:27:14 +0100 Subject: [PATCH] Analog stick to trigger remap functionality. --- input/input_driver.c | 10 +++++++--- input/input_mapper.c | 2 +- input/input_types.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 2e264c7159..7261a4ca27 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1180,9 +1180,14 @@ void input_get_state_for_port(void *data, unsigned port, input_bits_t *p_new_sta joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.axis_threshold = input_driver_axis_threshold; + if (!joypad_driver) + return; + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { bool bit_pressed = false; + int16_t val; + val = input_joypad_analog(joypad_driver, joypad_info, port, RETRO_DEVICE_INDEX_ANALOG_BUTTON, i, libretro_input_binds[port]); if (input_driver_input_state(joypad_info, libretro_input_binds, port, RETRO_DEVICE_JOYPAD, 0, i) != 0) @@ -1190,11 +1195,10 @@ void input_get_state_for_port(void *data, unsigned port, input_bits_t *p_new_sta if (bit_pressed) BIT256_SET_PTR(p_new_state, i); + if (bit_pressed && val) + p_new_state->analog_buttons[i] = val; } - if (!joypad_driver) - return; - for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) diff --git a/input/input_mapper.c b/input/input_mapper.c index 4e9484e237..b6b386a656 100644 --- a/input/input_mapper.c +++ b/input/input_mapper.c @@ -195,7 +195,7 @@ void input_mapper_poll(input_mapper_t *handle) handle->analog_value[i][ remap_button - RARCH_FIRST_CUSTOM_BIND] = - 32767 * invert; + (current_input.analog_buttons[j] ? current_input.analog_buttons[j] : 32767) * invert; } } } diff --git a/input/input_types.h b/input/input_types.h index 0bc64d8c42..5fa49c1fce 100644 --- a/input/input_types.h +++ b/input/input_types.h @@ -25,6 +25,7 @@ typedef struct input_keyboard_ctx_wait input_keyboard_ctx_wait_t; typedef struct { uint32_t data[8]; uint16_t analogs[8]; + uint16_t analog_buttons[16]; } input_bits_t; typedef struct joypad_connection joypad_connection_t; typedef struct pad_connection_listener_interface pad_connection_listener_t;