diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 54efa3fd07..adb8bcc570 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1435,10 +1435,10 @@ static int16_t android_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { if ( - android_keyboard_port_input_pressed(binds[port], i) - || button_is_pressed( + button_is_pressed( android->joypad, joypad_info, binds[port], port, i) + || android_keyboard_port_input_pressed(binds[port], i) ) ret |= (1 << i); } @@ -1447,10 +1447,11 @@ static int16_t android_input_state(void *data, else { if ( - android_keyboard_port_input_pressed(binds[port], id) - || button_is_pressed( + button_is_pressed( android->joypad, joypad_info, binds[port], - port, id)) + port, id) + || android_keyboard_port_input_pressed(binds[port], id) + ) return 1; } break; diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 0be3ba5913..cb427c4579 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -306,36 +306,36 @@ static int16_t cocoa_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (apple_key_state[rarch_keysym_lut[binds[port][i].key]]) - ret |= (1 << i); - else if (button_is_pressed( + if (button_is_pressed( apple->joypad, joypad_info, binds[port], port, i)) - ret |= (1 << i); + ret |= (1 << i); #ifdef HAVE_MFI else if (button_is_pressed( apple->sec_joypad, joypad_info, binds[port], port, i)) ret |= (1 << i); #endif + else if (apple_key_state[rarch_keysym_lut[binds[port][i].key]]) + ret |= (1 << i); } return ret; } else { - if (id < RARCH_BIND_LIST_END) + if (button_is_pressed( + apple->joypad, + joypad_info, binds[port], port, id)) + return 1; +#ifdef HAVE_MFI + else if (button_is_pressed( + apple->sec_joypad, + joypad_info, binds[port], port, id)) + return 1; +#endif + else if (id < RARCH_BIND_LIST_END) if (apple_key_state[rarch_keysym_lut[binds[port][id].key]]) return 1; - if (button_is_pressed( - apple->joypad, - joypad_info, binds[port], port, id)) - return 1; -#ifdef HAVE_MFI - if (button_is_pressed( - apple->sec_joypad, - joypad_info, binds[port], port, id)) - return 1; -#endif } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 909277be42..20bd42e00e 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -74,11 +74,9 @@ static int16_t ctr_input_state(void *data, else { if (id < RARCH_BIND_LIST_END) - { if (binds[port][id].valid) return button_is_pressed( ctr->joypad, joypad_info, binds[port], port, id); - } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 17ffce2e28..441569bec7 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -563,16 +563,16 @@ static int16_t dinput_input_state(void *data, { if (binds[port][i].valid) { - if ( + if (button_is_pressed( + di->joypad, + joypad_info, binds[port], port, i)) + ret |= (1 << i); + else if ( settings->uints.input_mouse_index[port] == 0 && dinput_mouse_button_pressed( di, port, binds[port][i].mbutton) ) ret |= (1 << i); - else if (button_is_pressed( - di->joypad, - joypad_info, binds[port], port, i)) - ret |= (1 << i); } } } @@ -580,20 +580,21 @@ static int16_t dinput_input_state(void *data, { for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ((binds[port][i].key < RETROK_LAST) && - di->state[rarch_keysym_lut[(enum retro_key)binds[port][i].key]] & 0x80) - ret |= (1 << i); - else if (binds[port][i].valid) + if (binds[port][i].valid) { - if ( + if (button_is_pressed( + di->joypad, joypad_info, + binds[port], port, i)) + ret |= (1 << i); + else if ((binds[port][i].key < RETROK_LAST) && + di->state[rarch_keysym_lut + [(enum retro_key)binds[port][i].key]] & 0x80) + ret |= (1 << i); + else if ( settings->uints.input_mouse_index[port] == 0 && dinput_mouse_button_pressed( di, port, binds[port][i].mbutton) - ) - ret |= (1 << i); - else if (button_is_pressed( - di->joypad, joypad_info, - binds[port], port, i)) + ) ret |= (1 << i); } } @@ -604,23 +605,25 @@ static int16_t dinput_input_state(void *data, { if (id < RARCH_BIND_LIST_END) { - if (binds[port][id].key < RETROK_LAST) - { - if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] & 0x80) - if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked) - return 1; - } if (binds[port][id].valid) { - if ( + if (button_is_pressed( + di->joypad, + joypad_info, binds[port], port, id)) + return 1; + else if (binds[port][id].key < RETROK_LAST + && (di->state[rarch_keysym_lut + [(enum retro_key)binds[port][id].key]] & 0x80) + && ( (id == RARCH_GAME_FOCUS_TOGGLE) + || !input_dinput.keyboard_mapping_blocked) + ) + return 1; + else if ( settings->uints.input_mouse_index[port] == 0 && dinput_mouse_button_pressed( di, port, binds[port][id].mbutton) - ) + ) return 1; - return button_is_pressed( - di->joypad, - joypad_info, binds[port], port, id); } } } @@ -723,23 +726,25 @@ static int16_t dinput_input_state(void *data, new_id = RARCH_LIGHTGUN_START; break; } - if (binds[port][new_id].key < RETROK_LAST) - { - if (!input_dinput.keyboard_mapping_blocked) - if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][new_id].key]] & 0x80) - return 1; - } if (binds[port][new_id].valid) { - if ( + if (button_is_pressed(di->joypad, + joypad_info, + binds[port], port, new_id)) + return 1; + else if ( + binds[port][new_id].key < RETROK_LAST + && !input_dinput.keyboard_mapping_blocked + && di->state[rarch_keysym_lut + [(enum retro_key)binds[port][new_id].key]] & 0x80 + ) + return 1; + else if ( settings->uints.input_mouse_index[port] == 0 && dinput_mouse_button_pressed( di, port, binds[port][new_id].mbutton) - ) + ) return 1; - return button_is_pressed(di->joypad, - joypad_info, - binds[port], port, new_id); } } break; diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index 90bc588d2c..799ae2eafd 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -89,22 +89,32 @@ static int16_t dos_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - dos_keyboard_port_input_pressed(binds[port], i) - || button_is_pressed(dos->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed( + dos->joypad, joypad_info, binds[port], + port, i) + || dos_keyboard_port_input_pressed(binds[port], i) + ) + ret |= (1 << i); + } } return ret; } else { - if ( - dos_keyboard_port_input_pressed(binds[port], id) - || button_is_pressed(dos->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed( + dos->joypad, joypad_info, binds[port], + port, id) + || dos_keyboard_port_input_pressed(binds[port], id) + ) + return 1; + } } break; case RETRO_DEVICE_KEYBOARD: diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 9b28cf2bac..72f3c45114 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -154,20 +154,25 @@ static int16_t gx_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(gx->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed( + gx->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(gx->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + if ( + button_is_pressed(gx->joypad, joypad_info, binds[port], + port, id)) + return 1; } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 1886baca77..bd7337a1e7 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -122,32 +122,19 @@ static int16_t linuxraw_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - /* Auto-binds are per joypad, not per user. */ - const uint64_t joykey = (binds[port][i].joykey != NO_BTN) - ? 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 ((binds[port]->valid && + if (binds[port][i].valid) + { + if ( + button_is_pressed( + linuxraw->joypad, joypad_info, binds[port], + port, i) + ) + ret |= (1 << i); + else if ( linuxraw->state[rarch_keysym_lut[ (enum retro_key)binds[port][i].key]] - )) - { - ret |= (1 << i); - continue; - } - - if ((uint16_t)joykey != NO_BTN && linuxraw->joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - { - ret |= (1 << i); - continue; - } - if (((float)abs(linuxraw->joypad->axis( - joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) - { - ret |= (1 << i); - continue; + ) + ret |= (1 << i); } } @@ -155,20 +142,22 @@ static int16_t linuxraw_input_state(void *data, } 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 (((id < RARCH_BIND_LIST_END) && binds[port]->valid && - linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] - )) - return 1; - - if ((uint16_t)joykey != NO_BTN && linuxraw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(linuxraw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) - return 1; + if (id < RARCH_BIND_LIST_END) + { + if (binds[port][id].valid) + { + if ( + button_is_pressed( + linuxraw->joypad, joypad_info, binds[port], + port, id) + ) + return 1; + else if ((linuxraw->state[rarch_keysym_lut + [(enum retro_key)binds[port][id].key]] + )) + return 1; + } + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/ps2_input.c b/input/drivers/ps2_input.c index 7fbe16e4b7..16c49f1a1c 100644 --- a/input/drivers/ps2_input.c +++ b/input/drivers/ps2_input.c @@ -58,18 +58,24 @@ static int16_t ps2_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (button_is_pressed(ps2->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if (button_is_pressed(ps2->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if (button_is_pressed(ps2->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if (button_is_pressed(ps2->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index c0ac1a46d9..147522933d 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -113,19 +113,25 @@ static int16_t ps3_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(ps3->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(ps3->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if (button_is_pressed(ps3->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if (button_is_pressed(ps3->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/ps4_input.c b/input/drivers/ps4_input.c index 92e88465b6..8a58487dfa 100644 --- a/input/drivers/ps4_input.c +++ b/input/drivers/ps4_input.c @@ -62,20 +62,26 @@ static int16_t ps4_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(ps4->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(ps4->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(ps4->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed(ps4->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/psl1ght_input.c b/input/drivers/psl1ght_input.c index 99c58967a3..468e7ad010 100644 --- a/input/drivers/psl1ght_input.c +++ b/input/drivers/psl1ght_input.c @@ -223,25 +223,31 @@ static int16_t ps3_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(ps3->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); - else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(ps3->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(ps3->joypad, joypad_info, binds[port], - port, id)) - return 1; - else if (psl1ght_keyboard_port_input_pressed( - ps3, binds[port][id].key)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed(ps3->joypad, joypad_info, binds[port], + port, id)) + return 1; + else if (psl1ght_keyboard_port_input_pressed( + ps3, binds[port][id].key)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index d79d13be5c..e0ff93da52 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -305,20 +305,26 @@ static int16_t psp_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(psp->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(psp->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(psp->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed(psp->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index e940b84695..6c99a92ac0 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -752,26 +752,20 @@ static int16_t qnx_is_pressed( { const struct retro_keybind *bind = &binds[id]; int key = bind->key; - if (id >= RARCH_BIND_LIST_END) - return 0; + /* 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 uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) + ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; if (qnx_keyboard_pressed(qnx, key)) if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_qnx.keyboard_mapping_blocked) return 1; - if (binds && binds[id].valid) - { - /* 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 uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) - ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; - - if ((uint16_t)joykey != NO_BTN && joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) - / 0x8000) > joypad_info->axis_threshold) - return 1; - } + if ((uint16_t)joykey != NO_BTN && joypad->button( + joypad_info->joy_idx, (uint16_t)joykey)) + return 1; + if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) + / 0x8000) > joypad_info->axis_threshold) + return 1; return 0; } @@ -823,21 +817,29 @@ static int16_t qnx_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (qnx_is_pressed( - qnx, qnx->joypad, - joypad_info, binds[port], port, i)) + if (binds[port][i].valid) { - ret |= (1 << i); - continue; + if (qnx_is_pressed( + qnx, qnx->joypad, + joypad_info, binds[port], port, i)) + ret |= (1 << i); } } return ret; } else - if (qnx_is_pressed(qnx, qnx->joypad, - joypad_info, binds[port], port, id)) - return 1; + { + if (id < RARCH_BIND_LIST_END) + { + if (binds[port][id].valid) + { + if (qnx_is_pressed(qnx, qnx->joypad, + joypad_info, binds[port], port, id)) + return 1; + } + } + } break; case RETRO_DEVICE_ANALOG: if (binds[port]) diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 9a5baeecc5..6fc48951bc 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -475,33 +475,25 @@ static int16_t rwebinput_is_pressed( const struct retro_keybind *binds, unsigned port, unsigned id) { - if (id < RARCH_BIND_LIST_END) - { - const struct retro_keybind *bind = &binds[id]; - int key = bind->key; + 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 uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) + ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; + int key = bind->key; - if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) - if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_rwebinput.keyboard_mapping_blocked) - return 1; - - if (bind->valid) - { - /* 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 uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) - ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; - - if (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse, - bind->mbutton, false)) - return 1; - if ((uint16_t)joykey != NO_BTN && joypad->button(joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) - / 0x8000) > joypad_info->axis_threshold) - return 1; - } - } + if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_rwebinput.keyboard_mapping_blocked) + return 1; + if (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse, + bind->mbutton, false)) + return 1; + if ((uint16_t)joykey != NO_BTN && joypad->button(joypad_info->joy_idx, (uint16_t)joykey)) + return 1; + if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) + / 0x8000) > joypad_info->axis_threshold) + return 1; return 0; } @@ -515,12 +507,18 @@ static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput, input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus); - if (rwebinput_is_pressed(rwebinput, - rwebinput->joypad, joypad_info, binds, idx, id_minus)) - pressed_minus = -0x7fff; - if (rwebinput_is_pressed(rwebinput, - rwebinput->joypad, joypad_info, binds, idx, id_plus)) - pressed_plus = 0x7fff; + if (id < RARCH_BIND_LIST_END) + { + if (binds[id].valid) + { + if (rwebinput_is_pressed(rwebinput, + rwebinput->joypad, joypad_info, binds, idx, id_minus)) + pressed_minus = -0x7fff; + if (rwebinput_is_pressed(rwebinput, + rwebinput->joypad, joypad_info, binds, idx, id_plus)) + pressed_plus = 0x7fff; + } + } return pressed_plus + pressed_minus; } @@ -541,12 +539,12 @@ static int16_t rwebinput_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (rwebinput_is_pressed( - rwebinput, rwebinput->joypad, - joypad_info, binds[port], port, i)) + if (binds[port][i].valid) { - ret |= (1 << i); - continue; + if (rwebinput_is_pressed( + rwebinput, rwebinput->joypad, + joypad_info, binds[port], port, i)) + ret |= (1 << i); } } @@ -555,10 +553,15 @@ static int16_t rwebinput_input_state(void *data, else { if (id < RARCH_BIND_LIST_END) - if (rwebinput_is_pressed(rwebinput, rwebinput->joypad, - joypad_info, binds[port], - port, id)) - return true; + { + if (binds[port][id].valid) + { + if (rwebinput_is_pressed(rwebinput, rwebinput->joypad, + joypad_info, binds[port], + port, id)) + return 1; + } + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index f630efadd2..2f84e47370 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -89,29 +89,6 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind * return pressed_plus + pressed_minus; } -static int16_t sdl_is_pressed( - const input_device_driver_t *joypad, - rarch_joypad_info_t *joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned 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 uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) - ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; - - if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key)) - return 1; - if ((uint16_t)joykey != NO_BTN && joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) - / 0x8000) > joypad_info->axis_threshold) - return 1; - return 0; -} - static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id) { switch (id) @@ -228,9 +205,14 @@ static int16_t sdl_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (sdl_is_pressed( - sdl->joypad, joypad_info, binds[port], port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if (button_is_pressed( + sdl->joypad, joypad_info, binds[port], port, i)) + ret |= (1 << i); + else if (sdl_key_pressed(binds[port][i].key)) + ret |= (1 << i); + } } return ret; @@ -238,9 +220,16 @@ static int16_t sdl_input_state(void *data, else { if (id < RARCH_BIND_LIST_END) - if (sdl_is_pressed(sdl->joypad, - joypad_info, binds[port], port, id)) - return 1; + { + if (binds[port][id].valid) + { + if (button_is_pressed(sdl->joypad, + joypad_info, binds[port], port, id)) + return 1; + else if (sdl_key_pressed(binds[port][id].key)) + return 1; + } + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/switch_input.c b/input/drivers/switch_input.c index 4e6068c17a..7ed1b7ad04 100644 --- a/input/drivers/switch_input.c +++ b/input/drivers/switch_input.c @@ -399,20 +399,26 @@ static int16_t switch_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(sw->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(sw->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(sw->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed(sw->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 81960b3380..c3b52989a8 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -1018,10 +1018,12 @@ static int16_t udev_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { if (binds[port][i].valid) + { if (udev_is_pressed( udev, udev->joypad, joypad_info, binds[port], port, i)) ret |= (1 << i); + } } } else @@ -1032,12 +1034,8 @@ static int16_t udev_input_state(void *data, { if (udev_is_pressed(udev, udev->joypad, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } - - if ((binds[port][i].key < RETROK_LAST) && + else if ((binds[port][i].key < RETROK_LAST) && udev_keyboard_pressed(udev, binds[port][i].key)) ret |= (1 << i); } @@ -1050,14 +1048,19 @@ static int16_t udev_input_state(void *data, { if (id < RARCH_BIND_LIST_END) { - if ( (binds[port][id].key < RETROK_LAST) && - udev_keyboard_pressed(udev, binds[port][id].key)) - if (( id == RARCH_GAME_FOCUS_TOGGLE) - || !input_udev.keyboard_mapping_blocked) - return 1; if (binds[port][id].valid) - return udev_is_pressed(udev, udev->joypad, - joypad_info, binds[port], port, id); + { + if (udev_is_pressed(udev, udev->joypad, + joypad_info, binds[port], port, id)) + return 1; + else if ( + (binds[port][id].key < RETROK_LAST) && + udev_keyboard_pressed(udev, binds[port][id].key) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !input_udev.keyboard_mapping_blocked) + ) + return 1; + } } } break; @@ -1222,17 +1225,25 @@ static int16_t udev_input_state(void *data, case RETRO_DEVICE_ID_LIGHTGUN_X: { udev_input_mouse_t *mouse = udev_get_mouse(udev, port); - return (mouse) ? udev_mouse_get_x(mouse) : 0; + if (mouse) + return udev_mouse_get_x(mouse); } + break; case RETRO_DEVICE_ID_LIGHTGUN_Y: { udev_input_mouse_t *mouse = udev_get_mouse(udev, port); - return (mouse) ? udev_mouse_get_y(mouse) : 0; + if (mouse) + return udev_mouse_get_y(mouse); } + break; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return udev_is_pressed(udev, udev->joypad, - joypad_info, - binds[port], port, RARCH_LIGHTGUN_START); + if (binds[port][RARCH_LIGHTGUN_START].valid) + { + return udev_is_pressed(udev, udev->joypad, + joypad_info, + binds[port], port, RARCH_LIGHTGUN_START); + } + break; } break; } diff --git a/input/drivers/uwp_input.c b/input/drivers/uwp_input.c index 8957de1577..17617ea3da 100644 --- a/input/drivers/uwp_input.c +++ b/input/drivers/uwp_input.c @@ -190,11 +190,11 @@ static int16_t uwp_input_state(void *data, int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (uwp_pressed_joypad( - uwp, joypad_info, binds[port], port, i)) + if (binds[port][i].valid) { - ret |= (1 << i); - continue; + if (uwp_pressed_joypad( + uwp, joypad_info, binds[port], port, i)) + ret |= (1 << i); } } @@ -203,8 +203,14 @@ static int16_t uwp_input_state(void *data, else { if (id < RARCH_BIND_LIST_END) - if (uwp_pressed_joypad(uwp, joypad_info, binds[port], port, id)) - return 1; + { + if (binds[port][i].valid) + { + if (uwp_pressed_joypad(uwp, joypad_info, + binds[port], port, id)) + return 1; + } + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index 23cdef02de..a76d4ea384 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -635,13 +635,13 @@ static int16_t winraw_input_state(void *d, { if (binds[port][i].valid) { - if (mouse && winraw_mouse_button_pressed(wr, - mouse, port, binds[port][i].mbutton)) - ret |= (1 << i); - else if (button_is_pressed( + if (button_is_pressed( wr->joypad, joypad_info, binds[port], port, i)) ret |= (1 << i); + else if (mouse && winraw_mouse_button_pressed(wr, + mouse, port, binds[port][i].mbutton)) + ret |= (1 << i); } } } @@ -649,18 +649,18 @@ static int16_t winraw_input_state(void *d, { for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ((binds[port][i].key < RETROK_LAST) && - winraw_keyboard_pressed(wr, binds[port][i].key)) - ret |= (1 << i); - else if (binds[port][i].valid) + if (binds[port][i].valid) { - if (mouse && winraw_mouse_button_pressed(wr, - mouse, port, binds[port][i].mbutton)) - ret |= (1 << i); - else if (button_is_pressed( + if (button_is_pressed( wr->joypad, joypad_info, binds[port], port, i)) ret |= (1 << i); + else if ((binds[port][i].key < RETROK_LAST) && + winraw_keyboard_pressed(wr, binds[port][i].key)) + ret |= (1 << i); + else if (mouse && winraw_mouse_button_pressed(wr, + mouse, port, binds[port][i].mbutton)) + ret |= (1 << i); } } } @@ -671,19 +671,22 @@ static int16_t winraw_input_state(void *d, { if (id < RARCH_BIND_LIST_END) { - if ((binds[port][id].key < RETROK_LAST) - && winraw_keyboard_pressed(wr, binds[port][id].key)) - if (( id == RARCH_GAME_FOCUS_TOGGLE) - || !input_winraw.keyboard_mapping_blocked) - return 1; if (binds[port][id].valid) { - if (mouse && winraw_mouse_button_pressed(wr, + if (button_is_pressed( + wr->joypad, + joypad_info, binds[port], port, id)) + return 1; + else if ( + (binds[port][id].key < RETROK_LAST) + && winraw_keyboard_pressed(wr, binds[port][id].key) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !input_winraw.keyboard_mapping_blocked) + ) + return 1; + else if (mouse && winraw_mouse_button_pressed(wr, mouse, port, binds[port][id].mbutton)) return 1; - return button_is_pressed( - wr->joypad, - joypad_info, binds[port], port, id); } } } diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 967aafb919..0389974dec 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -333,12 +333,8 @@ static int16_t x_input_state(void *data, { if (x_is_pressed(x11, x11->joypad, joypad_info, binds[port], port, i)) - { ret |= (1 << i); - continue; - } - - if ((binds[port][i].key < RETROK_LAST) && + else if ((binds[port][i].key < RETROK_LAST) && x_keyboard_pressed(x11, binds[port][i].key)) ret |= (1 << i); } @@ -351,14 +347,19 @@ static int16_t x_input_state(void *data, { if (id < RARCH_BIND_LIST_END) { - if ((binds[port][id].key < RETROK_LAST) && - x_keyboard_pressed(x11, binds[port][id].key) ) - if (( id == RARCH_GAME_FOCUS_TOGGLE) - || !input_x.keyboard_mapping_blocked) - return 1; if (binds[port][id].valid) - return x_is_pressed(x11, x11->joypad, - joypad_info, binds[port], port, id); + { + if (x_is_pressed(x11, x11->joypad, + joypad_info, binds[port], port, id)) + return 1; + else if ( + ((binds[port][id].key < RETROK_LAST) && + x_keyboard_pressed(x11, binds[port][id].key)) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !input_x.keyboard_mapping_blocked) + ) + return 1; + } } } break; diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index ec4415d9a7..5c4d9cd051 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -69,20 +69,26 @@ static int16_t xdk_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if ( - button_is_pressed(xdk->joypad, joypad_info, binds[port], - port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if ( + button_is_pressed(xdk->joypad, joypad_info, binds[port], + port, i)) + ret |= (1 << i); + } } return ret; } else { - if ( - button_is_pressed(xdk->joypad, joypad_info, binds[port], - port, id)) - return 1; + if (binds[port][id].valid) + { + if ( + button_is_pressed(xdk->joypad, joypad_info, binds[port], + port, id)) + return 1; + } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index acda1e59cd..378b9d9337 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -81,15 +81,23 @@ static int16_t xenon360_input_state(void *data, for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (state[port] & binds[port][i].joykey) - ret |= (1 << i); + if (binds[port][i].valid) + { + if (state[port] & binds[port][i].joykey) + ret |= (1 << i); + } } return ret; } else - if (state[port] & binds[port][id].joykey) - return 1; + { + if (binds[port][id].valid) + { + if (state[port] & binds[port][id].joykey) + return 1; + } + } break; default: break;