diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index cc614274a2..c849470f19 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1337,8 +1337,7 @@ static int16_t android_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { if (binds[port][i].valid) @@ -1349,18 +1348,11 @@ static int16_t android_input_state( } return ret; } - else + + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if ( - button_is_pressed( - joypad, joypad_info, binds[port], - port, id) - || ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id) - ) - return 1; - } + if (ANDROID_KEYBOARD_PORT_INPUT_PRESSED(binds[port], id)) + return 1; } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 98efc2ee1d..aba2be8b34 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -392,13 +392,7 @@ static int16_t cocoa_input_state( unsigned i; /* Do a bitwise OR to combine both input * states together */ - int16_t ret = joypad->state( - joypad_info, binds[port], port) -#ifdef HAVE_MFI - | sec_joypad->state( - joypad_info, binds[port], port) -#endif - ; + int16_t ret = 0; if (!keyboard_mapping_blocked) { @@ -412,24 +406,12 @@ static int16_t cocoa_input_state( } return ret; } - else + + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed( - joypad, - joypad_info, binds[port], port, id)) + if (id < RARCH_BIND_LIST_END) + if (apple_key_state[rarch_keysym_lut[binds[port][id].key]]) return 1; -#ifdef HAVE_MFI - else if (button_is_pressed( - 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; - } } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 570d244100..3a35c00419 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -47,26 +47,6 @@ static int16_t ctr_input_state( unsigned idx, unsigned id) { - if (port >= MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS) - return 0; - - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (id < RARCH_BIND_LIST_END) - if (binds[port][id].valid) - if (button_is_pressed( - joypad, joypad_info, binds[port], port, id)) - return 1; - break; - case RETRO_DEVICE_ANALOG: - break; - } - return 0; } diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 2b735e4e34..38eb947ddf 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -412,8 +412,7 @@ static int16_t dinput_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; if (settings->uints.input_mouse_index[port] == 0) { @@ -444,30 +443,24 @@ static int16_t dinput_input_state( } return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed( - 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) - || !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; - } + 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) + || !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; } } } diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index 39784d483c..c183dcf344 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -75,8 +75,7 @@ static int16_t dos_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -91,20 +90,15 @@ static int16_t dos_input_state( return ret; } - else + + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if ( - button_is_pressed( - joypad, joypad_info, binds[port], - port, id) - || (id < RARCH_BIND_LIST_END - && dos_key_state[DOS_KEYBOARD_PORT] - [rarch_keysym_lut[binds[port][id].key]]) - ) - return 1; - } + if ( + (id < RARCH_BIND_LIST_END + && dos_key_state[DOS_KEYBOARD_PORT] + [rarch_keysym_lut[binds[port][id].key]]) + ) + return 1; } break; case RETRO_DEVICE_KEYBOARD: diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 350c0e337c..72e3e0af22 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -78,16 +78,6 @@ static int16_t gx_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; case RETRO_DEVICE_ANALOG: break; #ifdef HW_RVL diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 335497f343..e4994a9c74 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -92,8 +92,7 @@ static int16_t linuxraw_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -109,23 +108,15 @@ static int16_t linuxraw_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if ( - button_is_pressed( - 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; - } + if ((linuxraw->state[rarch_keysym_lut + [(enum retro_key)binds[port][id].key]] + )) + return 1; } } break; diff --git a/input/drivers/ps2_input.c b/input/drivers/ps2_input.c index db5e0a914d..e4d0c5b143 100644 --- a/input/drivers/ps2_input.c +++ b/input/drivers/ps2_input.c @@ -43,22 +43,6 @@ static int16_t ps2_input_state( unsigned idx, unsigned id) { - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if (button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; - case RETRO_DEVICE_ANALOG: - break; - } - return 0; } diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 4937a3f3de..3223219a5f 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -109,16 +109,6 @@ static int16_t ps3_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if (button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - - break; case RETRO_DEVICE_ANALOG: break; #if 0 diff --git a/input/drivers/ps4_input.c b/input/drivers/ps4_input.c index 68b2b22e6f..f5657a586c 100644 --- a/input/drivers/ps4_input.c +++ b/input/drivers/ps4_input.c @@ -49,23 +49,6 @@ static int16_t ps4_input_state( unsigned idx, unsigned id) { - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; - case RETRO_DEVICE_ANALOG: - break; - } - return 0; } diff --git a/input/drivers/psl1ght_input.c b/input/drivers/psl1ght_input.c index 4173f563dc..7950ea9c1b 100644 --- a/input/drivers/psl1ght_input.c +++ b/input/drivers/psl1ght_input.c @@ -234,8 +234,7 @@ static int16_t ps3_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -249,18 +248,12 @@ static int16_t ps3_input_state( return ret; } - else + + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - else if (psl1ght_keyboard_port_input_pressed( - ps3, binds[port][id].key)) - return 1; - } + 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 03004be8a8..2c411ef828 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -260,16 +260,6 @@ static int16_t psp_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; case RETRO_DEVICE_ANALOG: break; #ifdef VITA diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index a902a6db9e..03bef1fd74 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -789,8 +789,7 @@ static int16_t qnx_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; if (!keyboard_mapping_blocked) { @@ -806,22 +805,17 @@ static int16_t qnx_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed(joypad, - joypad_info, binds[port], port, id)) - return 1; - else if ( - ((id == RARCH_GAME_FOCUS_TOGGLE) || - !keyboard_mapping_blocked) && - qnx_keyboard_pressed(qnx, key) - ) - return 1; - } + if ( + ((id == RARCH_GAME_FOCUS_TOGGLE) || + !keyboard_mapping_blocked) && + qnx_keyboard_pressed(qnx, key) + ) + return 1; } } break; diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 245130e054..7e0db1c84e 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -437,6 +437,24 @@ static int16_t rwebinput_is_pressed( return 0; } +static int16_t rwebinput_is_pressed_no_joypad( + rwebinput_input_t *rwebinput, + const struct retro_keybind *binds, + unsigned port, unsigned id, + bool keyboard_mapping_blocked) +{ + const struct retro_keybind *bind = &binds[id]; + int key = bind->key; + + if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !keyboard_mapping_blocked) + return 1; + if (port == 0 && !!rwebinput_mouse_state(&rwebinput->mouse, + bind->mbutton, false)) + return 1; + return 0; +} + static int16_t rwebinput_input_state( void *data, const input_device_driver_t *joypad, @@ -462,9 +480,8 @@ static int16_t rwebinput_input_state( { if (binds[port][i].valid) { - if (rwebinput_is_pressed( - rwebinput, joypad, - joypad_info, binds[port], port, i, + if (rwebinput_is_pressed_no_joypad( + rwebinput, binds[port], port, i, keyboard_mapping_blocked)) ret |= (1 << i); } @@ -472,18 +489,16 @@ static int16_t rwebinput_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (rwebinput_is_pressed(rwebinput, joypad, - joypad_info, binds[port], - port, id, - keyboard_mapping_blocked)) - return 1; - } + if (rwebinput_is_pressed_no_joypad(rwebinput, + binds[port], + port, id, + keyboard_mapping_blocked)) + return 1; } } break; diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 575f975963..bb763635b4 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -99,8 +99,7 @@ static int16_t sdl_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -111,19 +110,12 @@ static int16_t sdl_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) - { - if (binds[port][id].valid) - { - if (button_is_pressed(joypad, - joypad_info, binds[port], port, id)) - return 1; - else if (sdl_key_pressed(binds[port][id].key)) - return 1; - } - } + if (binds[port][id].valid) + 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 1a3ee9a69b..50d2d02462 100644 --- a/input/drivers/switch_input.c +++ b/input/drivers/switch_input.c @@ -297,16 +297,6 @@ static int16_t switch_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; case RETRO_DEVICE_ANALOG: break; #ifdef HAVE_LIBNX diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 5bf7d75eee..70e14e5bf5 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -1003,8 +1003,7 @@ static int16_t udev_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -1029,26 +1028,21 @@ static int16_t udev_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed(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) - || !keyboard_mapping_blocked) - ) - return 1; - else if (udev_mouse_button_pressed(udev, port, - binds[port][id].mbutton)) - return 1; - } + if ( + (binds[port][id].key < RETROK_LAST) && + udev_keyboard_pressed(udev, binds[port][id].key) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !keyboard_mapping_blocked) + ) + return 1; + else if (udev_mouse_button_pressed(udev, port, + binds[port][id].mbutton)) + return 1; } } break; diff --git a/input/drivers/uwp_input.c b/input/drivers/uwp_input.c index 327a1bb435..d5f3b566f8 100644 --- a/input/drivers/uwp_input.c +++ b/input/drivers/uwp_input.c @@ -86,8 +86,7 @@ static int16_t uwp_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; if (!keyboard_mapping_blocked) { @@ -116,25 +115,20 @@ static int16_t uwp_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed(joypad, joypad_info, - binds[port], port, id)) - return 1; - else if ((binds[port][id].key < RETROK_LAST) - && uwp_keyboard_pressed(binds[port][id].key) - && ((id == RARCH_GAME_FOCUS_TOGGLE) || - !keyboard_mapping_blocked) - ) - return 1; - else if (uwp_mouse_state(port, - binds[port][id].mbutton, false)) - return 1; - } + if ((binds[port][id].key < RETROK_LAST) + && uwp_keyboard_pressed(binds[port][id].key) + && ((id == RARCH_GAME_FOCUS_TOGGLE) || + !keyboard_mapping_blocked) + ) + return 1; + else if (uwp_mouse_state(port, + binds[port][id].mbutton, false)) + return 1; } } break; diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index 6666580f6d..9bec36489b 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -167,8 +167,7 @@ static int16_t input_wl_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { @@ -182,21 +181,13 @@ static int16_t input_wl_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) - { - if (binds[port][id].valid) - { - if (button_is_pressed(joypad, - joypad_info, binds[port], - port, id)) - return 1; - else if (BIT_GET(wl->key_state, - rarch_keysym_lut[binds[port][id].key])) - return 1; - } - } + if (binds[port][id].valid) + if (BIT_GET(wl->key_state, + rarch_keysym_lut[binds[port][id].key])) + return 1; } break; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 17a98248b9..160e895c02 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -108,21 +108,12 @@ static int16_t wiiu_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - return button_is_pressed( - joypad, - joypad_info, binds[port], port, id); + case RETRO_DEVICE_ANALOG: break; case RETRO_DEVICE_KEYBOARD: if (id < RETROK_LAST && keyboard_state[id] && (keyboard_channel > 0)) return 1; break; - case RETRO_DEVICE_ANALOG: - break; case RETRO_DEVICE_POINTER: case RARCH_DEVICE_POINTER_SCREEN: /* TODO: Emulate a relative mouse. diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index a872f7d70d..0738a8afd1 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -624,8 +624,7 @@ static int16_t winraw_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; if (mouse) { @@ -655,27 +654,21 @@ static int16_t winraw_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed( - 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) - || !keyboard_mapping_blocked) - ) - return 1; - else if (mouse && winraw_mouse_button_pressed(wr, - mouse, port, binds[port][id].mbutton)) - return 1; - } + if ( + (binds[port][id].key < RETROK_LAST) + && WINRAW_KEYBOARD_PRESSED(wr, binds[port][id].key) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !keyboard_mapping_blocked) + ) + return 1; + else if (mouse && winraw_mouse_button_pressed(wr, + mouse, port, binds[port][id].mbutton)) + return 1; } } break; diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index e17c28f5c6..d32e685072 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -127,8 +127,7 @@ static int16_t x_input_state( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; - int16_t ret = joypad->state( - joypad_info, binds[port], port); + int16_t ret = 0; if (settings->uints.input_mouse_index[port] == 0) { @@ -157,28 +156,23 @@ static int16_t x_input_state( return ret; } - else + + if (id < RARCH_BIND_LIST_END) { - if (id < RARCH_BIND_LIST_END) + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (button_is_pressed(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) - || !keyboard_mapping_blocked) + if ( + ((binds[port][id].key < RETROK_LAST) && + x_keyboard_pressed(x11, binds[port][id].key)) + && (( id == RARCH_GAME_FOCUS_TOGGLE) + || !keyboard_mapping_blocked) ) + return 1; + else if (settings->uints.input_mouse_index[port] == 0) + { + if (x_mouse_button_pressed(x11, port, + binds[port][id].mbutton)) return 1; - else if (settings->uints.input_mouse_index[port] == 0) - { - if (x_mouse_button_pressed(x11, port, - binds[port][id].mbutton)) - return 1; - } } } } diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index b21f0f73ae..ec86e32c06 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -52,26 +52,6 @@ static int16_t xdk_input_state( unsigned index, unsigned id) { - if (port >= DEFAULT_MAX_PADS) - return 0; - - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return joypad->state( - joypad_info, binds[port], port); - - if (binds[port][id].valid) - if ( - button_is_pressed(joypad, joypad_info, binds[port], - port, id)) - return 1; - break; - case RETRO_DEVICE_ANALOG: - break; - } - return 0; } diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index b2fb383c21..71abea8597 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -27,6 +27,8 @@ #include "../input_driver.h" +/* TODO/FIXME - add joypad driver */ + /* TODO/FIXME - * fix game focus toggle */ @@ -80,6 +82,7 @@ static int16_t xenon360_input_state( switch (device) { case RETRO_DEVICE_JOYPAD: +#if 0 if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { unsigned i; @@ -96,14 +99,13 @@ static int16_t xenon360_input_state( return ret; } - else + + if (binds[port][id].valid) { - if (binds[port][id].valid) - { - if (state[port] & binds[port][id].joykey) - return 1; - } + if (state[port] & binds[port][id].joykey) + return 1; } +#endif break; default: break; diff --git a/retroarch.c b/retroarch.c index 346bae6d29..f64ceb54c2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3623,7 +3623,40 @@ static int16_t input_state_wrap( unsigned id) { input_driver_t *current_input = p_rarch->current_input; - int16_t ret = current_input->input_state( + int16_t ret = 0; + + /* Do a bitwise OR to combine input states together */ + + if (device == RETRO_DEVICE_JOYPAD) + { + if (id == RETRO_DEVICE_ID_JOYPAD_MASK) + { + ret |= joypad->state( + joypad_info, binds[port], port); + if (sec_joypad) + ret |= sec_joypad->state( + joypad_info, binds[port], port); + } + else + { + /* Do a bitwise OR to combine both input + * states together */ + if (binds[port][id].valid) + { + if (button_is_pressed( + joypad, + joypad_info, binds[port], port, id)) + return 1; + else if (sec_joypad && + button_is_pressed( + sec_joypad, + joypad_info, binds[port], port, id)) + return 1; + } + } + } + + ret |= current_input->input_state( data, joypad, sec_joypad,