diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 813ba6cc57..d150008da1 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1418,6 +1418,32 @@ bool android_run_events(void *data) return true; } +static bool android_is_pressed( + android_input_t *android, + settings_t *settings, + rarch_joypad_info_t *joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + /* Auto-binds are per joypad, not per user. */ + const uint64_t joykey = (binds[id].joykey != NO_BTN) + ? binds[id].joykey : joypad_info->auto_binds[i].joykey; + const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) + ? binds[id].joyaxis : joypad_info->auto_binds[i].joyaxis; + + if ((uint16_t)joykey != NO_BTN + && android->joypad->button( + joypad_info->joy_idx, (uint16_t)joykey)) + return true; + + if (((float)abs(android->joypad->axis(joypad_info->joy_idx, joyaxis)) + / 0x8000) > joypad_info->axis_threshold) + return true; + + return false; +} + static int16_t android_input_state(void *data, rarch_joypad_info_t *joypad_info, const struct retro_keybind **binds, unsigned port, unsigned device, @@ -1439,37 +1465,24 @@ static int16_t android_input_state(void *data, ? binds[port][i].joykey : joypad_info->auto_binds[i].joykey; const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE) ? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis; - if ((uint16_t)joykey != NO_BTN && android->joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - { - ret |= (1 << i); - continue; - } - if (((float)abs(android->joypad->axis( - joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) - { - ret |= (1 << i); - continue; - } - if (android_keyboard_port_input_pressed(binds[port], i)) + + if ( + android_keyboard_port_input_pressed(binds[port], i) + || android_is_pressed( + android, settings, joypad_info, binds[port], + port, i) + ) ret |= (1 << i); } return ret; } else { - /* Auto-binds are per joypad, not per user. */ - const uint64_t joykey = (binds[port][id].joykey != NO_BTN) - ? binds[port][id].joykey : joypad_info->auto_binds[id].joykey; - const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE) - ? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis; - if ((uint16_t)joykey != NO_BTN && android->joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(android->joypad->axis( - joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) - return 1; - if (android_keyboard_port_input_pressed(binds[port], id)) + if ( + android_keyboard_port_input_pressed(binds[port], id) + || android_is_pressed( + android, settings, joypad_info, binds[port], + port, id)) return 1; } break; diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 3b3aeaeec9..ba28f8ed85 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -545,8 +545,8 @@ static bool dinput_is_pressed( { const struct retro_keybind *bind = &binds[id]; /* Auto-binds are per joypad, not per user. */ - const uint64_t joykey = (binds[id].joykey != NO_BTN) - ? binds[id].joykey : joypad_info->auto_binds[id].joykey; + const uint64_t joykey = (binds[id].joykey != NO_BTN) + ? binds[id].joykey : joypad_info->auto_binds[id].joykey; const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; @@ -560,7 +560,8 @@ static bool dinput_is_pressed( joypad_info->joy_idx, (uint16_t)joykey)) return true; - if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) + if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) + / 0x8000) > joypad_info->axis_threshold) return true; return false; @@ -594,10 +595,7 @@ static int16_t dinput_input_state(void *data, if (binds[port][i].valid) if (dinput_is_pressed( di, settings, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } } } else diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 9eb7ddc26a..9de97441fe 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -89,10 +89,10 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind * return pressed_plus + pressed_minus; } -static int16_t sdl_joypad_device_state(sdl_input_t *sdl, +static bool sdl_is_pressed(sdl_input_t *sdl, rarch_joypad_info_t *joypad_info, const struct retro_keybind *binds, - unsigned port, unsigned id, enum input_device_type *device) + unsigned port, unsigned id) { /* Auto-binds are per joypad, not per user. */ const uint64_t joykey = (binds[id].joykey != NO_BTN) @@ -101,26 +101,17 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl, ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key)) - { - *device = INPUT_DEVICE_TYPE_KEYBOARD; - return 1; - } + return true; if ((uint16_t)joykey != NO_BTN && sdl->joypad->button( joypad_info->joy_idx, (uint16_t)joykey)) - { - *device = INPUT_DEVICE_TYPE_JOYPAD; - return 1; - } + return true; if (((float)abs(sdl->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) - { - *device = INPUT_DEVICE_TYPE_JOYPAD; - return 1; - } + return true; - return 0; + return false; } static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id) @@ -154,6 +145,7 @@ static int16_t sdl_pointer_device_state(sdl_input_t *sdl, unsigned idx, unsigned id, bool screen) { struct video_viewport vp; + const int edge_detect = 32700; bool inside = false; int16_t res_x = 0; int16_t res_y = 0; @@ -226,7 +218,6 @@ static int16_t sdl_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - enum input_device_type type = INPUT_DEVICE_TYPE_NONE; sdl_input_t *sdl = (sdl_input_t*)data; switch (device) @@ -239,12 +230,9 @@ static int16_t sdl_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (sdl_joypad_device_state( - sdl, joypad_info, binds[port], port, i, &type)) - { + if (sdl_is_pressed( + sdl, joypad_info, binds[port], port, i)) ret |= (1 << i); - continue; - } } return ret; @@ -252,8 +240,8 @@ static int16_t sdl_input_state(void *data, else { if (id < RARCH_BIND_LIST_END) - if (sdl_joypad_device_state(sdl, - joypad_info, binds[port], port, id, &type)) + if (sdl_is_pressed(sdl, + joypad_info, binds[port], port, id)) return 1; } break; diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 6860438c00..afd94bc623 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -1025,10 +1025,7 @@ static int16_t udev_input_state(void *data, { if (udev_is_pressed( udev, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } } return ret; diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index 251eeede52..72b2f29fd7 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -660,10 +660,7 @@ static int16_t winraw_input_state(void *d, if (binds[port][i].valid) if (winraw_is_pressed( wr, mouse, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } } } else @@ -676,10 +673,7 @@ static int16_t winraw_input_state(void *d, if (binds[port][i].valid) if (winraw_is_pressed( wr, mouse, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } } }