From a9a2749af988781e3800ccf5e111f17124869ddf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 00:13:29 +0200 Subject: [PATCH 1/7] Add input_menu_keys_pressed --- input/input_driver.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ input/input_driver.h | 2 ++ menu/menu_driver.c | 15 ++++++++-- runloop.c | 2 +- 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 0ce9206fb7..b7e50356ee 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -660,6 +660,77 @@ uint64_t input_keys_pressed(void) return ret; } +/** + * input_menu_keys_pressed: + * + * Grab an input sample for this frame. We exclude + * keyboard input here. + * + * TODO: In case RARCH_BIND_LIST_END starts exceeding 64, + * and you need a bitmask of more than 64 entries, reimplement + * it to use something like rarch_bits_t. + * + * Returns: Input sample containg a mask of all pressed keys. + */ +uint64_t input_menu_keys_pressed(void) +{ + unsigned i; + uint64_t ret = 0; + settings_t *settings = config_get_ptr(); + + if (!current_input || !current_input_data) + return ret; + + if (current_input->key_pressed && + check_input_driver_block_hotkey( + current_input->key_pressed(current_input_data, RARCH_ENABLE_HOTKEY))) + input_driver_block_libretro_input = true; + else + input_driver_block_libretro_input = false; + + for (i = 0; i < RARCH_BIND_LIST_END; i++) + { + bool state = false; + if (((((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) + || !input_driver_block_hotkey) && current_input->key_pressed)) + && settings->input.binds[0][i].valid) + { + state = input_joypad_pressed(input_driver_get_joypad_driver(), + 0, settings->input.binds[0], i); + } + + if (i >= RARCH_FIRST_META_KEY && settings->input.binds[0][i].valid) + state |= input_joypad_pressed(input_driver_get_joypad_driver(), + 0, settings->input.binds[0], i); + +#ifdef HAVE_OVERLAY + state |= input_overlay_key_pressed(i); +#endif + +#ifdef HAVE_COMMAND + if (input_driver_command) + { + command_handle_t handle; + + handle.handle = input_driver_command; + handle.id = i; + + state |= command_get(&handle); + } +#endif + +#ifdef HAVE_NETWORKGAMEPAD + if (input_driver_remote) + state |= input_remote_key_pressed(i, 0); +#endif + + if (state) + ret |= (UINT64_C(1) << i); + } + + return ret; +} + void *input_driver_get_data(void) { return current_input_data; diff --git a/input/input_driver.h b/input/input_driver.h index 0d07b6d976..8a435a9dcd 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -224,6 +224,8 @@ int16_t input_state(unsigned port, unsigned device, uint64_t input_keys_pressed(void); +uint64_t input_menu_keys_pressed(void); + void *input_driver_get_data(void); const input_driver_t *input_get_ptr(void); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 770a01796b..f369cdc9d4 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -221,8 +221,19 @@ static void menu_input_key_event(bool down, unsigned keycode, (void)keycode; (void)mod; - if (character == '/') - menu_entry_action(NULL, 0, MENU_ACTION_SEARCH); +#if 0 + RARCH_LOG("down: %d, keycode: %d, mod: %d\n", down, keycode, mod); +#endif + + switch (character) + { + case RETROK_SLASH: + menu_entry_action(NULL, 0, MENU_ACTION_SEARCH); + break; + default: + break; + } + } static void menu_driver_toggle(bool latch) diff --git a/runloop.c b/runloop.c index ebfcfe7781..491b23c66f 100644 --- a/runloop.c +++ b/runloop.c @@ -1126,7 +1126,7 @@ int runloop_iterate(unsigned *sleep_ms) static retro_time_t frame_limit_minimum_time = 0.0; static retro_time_t frame_limit_last_time = 0.0; settings_t *settings = config_get_ptr(); - uint64_t current_input = input_keys_pressed(); + uint64_t current_input = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) ? input_menu_keys_pressed() : input_keys_pressed(); uint64_t old_input = last_input; last_input = current_input; From 2bcbe017cd82c2a02ba031ab50c8d606f0769158 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 00:14:01 +0200 Subject: [PATCH 2/7] More work --- menu/menu_driver.c | 16 ++++-------- menu/menu_event.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ menu/menu_event.h | 6 +++++ runloop.c | 47 ++++++++++++++++++---------------- 4 files changed, 100 insertions(+), 32 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index f369cdc9d4..9f0b753035 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -28,6 +28,7 @@ #include "menu_driver.h" #include "menu_cbs.h" #include "menu_display.h" +#include "menu_event.h" #include "menu_navigation.h" #include "widgets/menu_dialog.h" #include "widgets/menu_list.h" @@ -221,19 +222,12 @@ static void menu_input_key_event(bool down, unsigned keycode, (void)keycode; (void)mod; -#if 0 - RARCH_LOG("down: %d, keycode: %d, mod: %d\n", down, keycode, mod); +#if 1 + RARCH_LOG("down: %d, keycode: %d, mod: %d, character: %d\n", down, keycode, mod, character); #endif - switch (character) - { - case RETROK_SLASH: - menu_entry_action(NULL, 0, MENU_ACTION_SEARCH); - break; - default: - break; - } - + if (down) + menu_event_keyboard_set((enum retro_key)keycode); } static void menu_driver_toggle(bool latch) diff --git a/menu/menu_event.c b/menu/menu_event.c index e467e8dd9a..5668aea92c 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -36,6 +36,8 @@ #include "../configuration.h" +static bool menu_keyboard_key_state[RETROK_LAST]; + static int menu_event_pointer(unsigned *action) { const struct retro_keybind *binds[MAX_USERS] = {NULL}; @@ -65,8 +67,24 @@ static int menu_event_pointer(unsigned *action) return 0; } +bool menu_event_keyboard_is_set(enum retro_key key) +{ + if (menu_keyboard_key_state[key] && key == RETROK_F1) + { + menu_keyboard_key_state[key] = false; + return true; + } + return menu_keyboard_key_state[key]; +} + +void menu_event_keyboard_set(enum retro_key key) +{ + menu_keyboard_key_state[key] = true; +} + unsigned menu_event(uint64_t input, uint64_t trigger_input) { + unsigned i; menu_animation_ctx_delta_t delta; float delta_time; /* Used for key repeat */ @@ -187,6 +205,51 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input) trigger_input = 0; } + for (i = 0; i < RETROK_LAST; i++) + { + if (i == RETROK_F1) + continue; + + if (menu_keyboard_key_state[i]) + { + switch ((enum retro_key)i) + { + case RETROK_PAGEUP: + BIT32_SET(trigger_input, settings->menu_scroll_up_btn); + break; + case RETROK_PAGEDOWN: + BIT32_SET(trigger_input, settings->menu_scroll_down_btn); + break; + case RETROK_SLASH: + BIT32_SET(trigger_input, settings->menu_search_btn); + break; + case RETROK_LEFT: + BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT); + break; + case RETROK_RIGHT: + BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT); + break; + case RETROK_UP: + BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_UP); + break; + case RETROK_DOWN: + BIT32_SET(trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN); + break; + case RETROK_BACKSPACE: + BIT32_SET(trigger_input, settings->menu_cancel_btn); + break; + case RETROK_RETURN: + BIT32_SET(trigger_input, settings->menu_ok_btn); + break; +#if 0 + default: + break; +#endif + } + menu_keyboard_key_state[i] = false; + } + } + if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP)) ret = MENU_ACTION_UP; else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN)) diff --git a/menu/menu_event.h b/menu/menu_event.h index 3795ae4d0f..320a80066b 100644 --- a/menu/menu_event.h +++ b/menu/menu_event.h @@ -22,6 +22,8 @@ #include +#include + RETRO_BEGIN_DECLS /* Send input code to menu for one frame. @@ -33,6 +35,10 @@ RETRO_BEGIN_DECLS */ unsigned menu_event(uint64_t input, uint64_t trigger_state); +void menu_event_keyboard_set(enum retro_key key); + +bool menu_event_keyboard_is_set(enum retro_key key); + unsigned kbd_index; char kbd_grid[41]; bool kbd_upper; diff --git a/runloop.c b/runloop.c index 491b23c66f..f43d93bb6c 100644 --- a/runloop.c +++ b/runloop.c @@ -852,23 +852,6 @@ static enum runloop_state runloop_check_state( if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE)) command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); -#ifdef HAVE_MENU - if (runloop_cmd_menu_press(current_input, old_input, trigger_input) || - rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) - { - if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - { - if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) && - !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); - } - else - { - menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER); - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - } - } -#endif #ifdef HAVE_OVERLAY if (osk_enable && !input_keyboard_ctl( @@ -914,18 +897,40 @@ static enum runloop_state runloop_check_state( if (focused || !runloop_idle) menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL); - if (!focused || runloop_idle) + if (!focused) return RUNLOOP_STATE_SLEEP; + } +#endif + + if (runloop_idle) + return RUNLOOP_STATE_SLEEP; +#ifdef HAVE_MENU + if ( menu_event_keyboard_is_set(RETROK_F1) || + runloop_cmd_menu_press(current_input, old_input, trigger_input) || + rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) + { + if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) + { + if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) && + !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + } + else + { + menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER); + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + } + } + + if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) + { if (!settings->menu.throttle_framerate && !settings->fastforward_ratio) return RUNLOOP_STATE_MENU_ITERATE; return RUNLOOP_STATE_END; } #endif - - if (runloop_idle) - return RUNLOOP_STATE_SLEEP; if (settings->pause_nonactive) focused = video_driver_is_focused(); From 6235a5cd0dd83f1118f9a0a44c2206d238c3d0d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 06:13:39 +0200 Subject: [PATCH 3/7] Can now toggle fullscreen, use quit key from menu (mouse grab toggle doesn't work yet) --- menu/menu_event.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ menu/menu_input.h | 3 ++- runloop.c | 35 +++++++++++++++++----------------- runloop.h | 5 +++++ 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/menu/menu_event.c b/menu/menu_event.c index 5668aea92c..4427e45865 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -28,13 +28,18 @@ #include "menu_event.h" +#include "content.h" #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" #include "menu_display.h" #include "menu_navigation.h" +#include "widgets/menu_dialog.h" + #include "../configuration.h" +#include "../retroarch.h" +#include "../runloop.h" static bool menu_keyboard_key_state[RETROK_LAST]; @@ -214,6 +219,15 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input) { switch ((enum retro_key)i) { + case RETROK_ESCAPE: + BIT32_SET(trigger_input, RARCH_QUIT_KEY); + break; + case RETROK_f: + BIT32_SET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY); + break; + case RETROK_F11: + BIT32_SET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE); + break; case RETROK_PAGEUP: BIT32_SET(trigger_input, settings->menu_scroll_up_btn); break; @@ -277,6 +291,40 @@ unsigned menu_event(uint64_t input, uint64_t trigger_input) else if (trigger_input & (UINT64_C(1) << RARCH_MENU_TOGGLE)) ret = MENU_ACTION_TOGGLE; + if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY)) + command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL); + + if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE)) + command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); + + if (runloop_cmd_press(trigger_input, RARCH_QUIT_KEY)) + { + int should_we_quit = true; + + if (!runloop_is_quit_confirm()) + { + if (settings && settings->confirm_on_exit) + { + if (menu_dialog_is_active()) + should_we_quit = false; + else if (content_is_inited()) + { + if(menu_display_toggle_get_reason() != MENU_TOGGLE_REASON_USER) + menu_display_toggle_set_reason(MENU_TOGGLE_REASON_MESSAGE); + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + } + + menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); + + should_we_quit = false; + } + + if ((settings && !settings->confirm_on_exit) || + should_we_quit) + return MENU_ACTION_QUIT; + } + } + mouse_enabled = settings->menu.mouse.enable; #ifdef HAVE_OVERLAY if (!mouse_enabled) diff --git a/menu/menu_input.h b/menu/menu_input.h index cb61e9a45d..ca19e665aa 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -42,7 +42,8 @@ enum menu_action MENU_ACTION_SCROLL_UP, MENU_ACTION_TOGGLE, MENU_ACTION_POINTER_MOVED, - MENU_ACTION_POINTER_PRESSED + MENU_ACTION_POINTER_PRESSED, + MENU_ACTION_QUIT }; enum menu_input_pointer_state diff --git a/runloop.c b/runloop.c index f43d93bb6c..91354f917a 100644 --- a/runloop.c +++ b/runloop.c @@ -88,16 +88,20 @@ #define DEFAULT_EXT "" #endif -#define runloop_cmd_triggered(trigger_input, id) (BIT64_GET(trigger_input, id)) - -#define runloop_cmd_press(current_input, id) BIT64_GET(current_input, id) -#define runloop_cmd_pressed(old_input, id) BIT64_GET(old_input, id) #ifdef HAVE_MENU -#define runloop_cmd_menu_press(current_input, old_input, trigger_input) (BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) || \ - runloop_cmd_get_state_menu_toggle_button_combo( \ - settings, current_input, old_input, trigger_input)) +#define runloop_cmd_menu_press(current_input, old_input, trigger_input) (BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) || runloop_cmd_get_state_menu_toggle_button_combo(settings, current_input, old_input, trigger_input)) #endif +enum runloop_state +{ + RUNLOOP_STATE_NONE = 0, + RUNLOOP_STATE_ITERATE, + RUNLOOP_STATE_SLEEP, + RUNLOOP_STATE_MENU_ITERATE, + RUNLOOP_STATE_END, + RUNLOOP_STATE_QUIT +}; + static rarch_system_info_t runloop_system; static struct retro_frame_time_callback runloop_frame_time; static retro_keyboard_event_t runloop_key_event = NULL; @@ -720,16 +724,6 @@ void runloop_set_quit_confirm(bool on) runloop_quit_confirm = on; } -enum runloop_state -{ - RUNLOOP_STATE_NONE = 0, - RUNLOOP_STATE_ITERATE, - RUNLOOP_STATE_SLEEP, - RUNLOOP_STATE_MENU_ITERATE, - RUNLOOP_STATE_END, - RUNLOOP_STATE_QUIT -}; - /* Time to exit out of the main loop? * Reasons for exiting: * a) Shutdown environment callback was invoked. @@ -801,6 +795,10 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) return -1; } +void runloop_external_state_checks(uint64_t trigger_input) +{ +} + static enum runloop_state runloop_check_state( settings_t *settings, uint64_t current_input, @@ -899,6 +897,9 @@ static enum runloop_state runloop_check_state( if (!focused) return RUNLOOP_STATE_SLEEP; + + if (action == MENU_ACTION_QUIT) + return RUNLOOP_STATE_QUIT; } #endif diff --git a/runloop.h b/runloop.h index 46ddbe558b..dd2d1ea1d3 100644 --- a/runloop.h +++ b/runloop.h @@ -26,6 +26,11 @@ #include "input/input_defines.h" +#define runloop_cmd_triggered(trigger_input, id) (BIT64_GET(trigger_input, id)) + +#define runloop_cmd_press(current_input, id) (BIT64_GET(current_input, id)) +#define runloop_cmd_pressed(old_input, id) (BIT64_GET(old_input, id)) + RETRO_BEGIN_DECLS enum runloop_ctl_state From 8f30b3e706cf3da3b0a6f7aec70260aa871b3264 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 06:34:53 +0200 Subject: [PATCH 4/7] Update menu_keys_pressed --- input/input_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/input/input_driver.c b/input/input_driver.c index d2493683ea..de8d4459d0 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -694,6 +694,14 @@ uint64_t input_menu_keys_pressed(void) for (i = 0; i < RARCH_BIND_LIST_END; i++) { bool state = false; +#if 0 + if (((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) + || !input_driver_block_hotkey) && current_input->key_pressed) + state = current_input->key_pressed(current_input_data, i); + + if (i >= RARCH_FIRST_META_KEY) + state |= current_input->meta_key_pressed(current_input_data, i); +#else if (((((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) || !input_driver_block_hotkey) && current_input->key_pressed)) && settings->input.binds[0][i].valid) @@ -705,6 +713,7 @@ uint64_t input_menu_keys_pressed(void) if (i >= RARCH_FIRST_META_KEY && settings->input.binds[0][i].valid) state |= input_joypad_pressed(input_driver_get_joypad_driver(), 0, settings->input.binds[0], i); +#endif #ifdef HAVE_OVERLAY state |= input_overlay_key_pressed(i); From 660f021dbc4ba02ff0ee41f321058e557cfffb69 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 06:49:18 +0200 Subject: [PATCH 5/7] Simplify input_menu_keys_pressed --- input/input_driver.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index de8d4459d0..7b4af2c3ea 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -694,26 +694,24 @@ uint64_t input_menu_keys_pressed(void) for (i = 0; i < RARCH_BIND_LIST_END; i++) { bool state = false; -#if 0 - if (((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) + if ( + (((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) || !input_driver_block_hotkey) && current_input->key_pressed) +#if 1 + && settings->input.binds[0][i].valid +#endif + ) + { +#if 1 + state = input_joypad_pressed(input_driver_get_joypad_driver(), + 0, settings->input.binds[0], i); +#else state = current_input->key_pressed(current_input_data, i); +#endif + } if (i >= RARCH_FIRST_META_KEY) state |= current_input->meta_key_pressed(current_input_data, i); -#else - if (((((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) - || !input_driver_block_hotkey) && current_input->key_pressed)) - && settings->input.binds[0][i].valid) - { - state = input_joypad_pressed(input_driver_get_joypad_driver(), - 0, settings->input.binds[0], i); - } - - if (i >= RARCH_FIRST_META_KEY && settings->input.binds[0][i].valid) - state |= input_joypad_pressed(input_driver_get_joypad_driver(), - 0, settings->input.binds[0], i); -#endif #ifdef HAVE_OVERLAY state |= input_overlay_key_pressed(i); From 2a0dba30097be6811c2590c86f578caf045f90e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 06:53:06 +0200 Subject: [PATCH 6/7] Move all_users_control_menu code to input/input_driver.c --- input/input_driver.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 7b4af2c3ea..83385f53b9 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -702,9 +702,19 @@ uint64_t input_menu_keys_pressed(void) #endif ) { + int port; + int port_max = 1; #if 1 - state = input_joypad_pressed(input_driver_get_joypad_driver(), - 0, settings->input.binds[0], i); + if (settings->input.all_users_control_menu) + port_max = settings->input.max_users; + + for (port = 0; port < port_max; port++) + { + state = input_joypad_pressed(input_driver_get_joypad_driver(), + port, settings->input.binds[0], i); + if (state) + break; + } #else state = current_input->key_pressed(current_input_data, i); #endif From 53ad28ffde84a8c2f4d7e9dc89e08514ccc4230f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Oct 2016 07:03:37 +0200 Subject: [PATCH 7/7] Backport this patch --- input/drivers/android_input.c | 16 +++------------- input/drivers/cocoa_input.c | 33 ++++++-------------------------- input/drivers/ctr_input.c | 16 +++------------- input/drivers/dinput.c | 13 ++----------- input/drivers/gx_input.c | 16 +++------------- input/drivers/linuxraw_input.c | 16 +++------------- input/drivers/ps3_input.c | 13 ++----------- input/drivers/psp_input.c | 13 ++----------- input/drivers/qnx_input.c | 13 ++----------- input/drivers/sdl_input.c | 20 +++++-------------- input/drivers/udev_input.c | 16 +++------------- input/drivers/wiiu_input.c | 16 +++------------- input/drivers/x11_input.c | 13 ++----------- input/drivers/xdk_xinput_input.c | 16 +++------------- 14 files changed, 42 insertions(+), 188 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index ccd96d956d..6f504a8434 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1162,24 +1162,14 @@ static bool android_input_key_pressed(void *data, int key) { android_input_t *android = (android_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; if(settings->input.binds[0][key].valid && android_keyboard_port_input_pressed(settings->input.binds[0],key)) return true; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(android->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(android->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(android->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 12cc18b739..d20ea096ac 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -315,41 +315,20 @@ static bool cocoa_input_key_pressed(void *data, int key) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; if (settings->input.binds[0][key].valid && apple_input_is_pressed(0, settings->input.binds[0], key)) return true; - if (settings->input.all_users_control_menu) + if (settings->input.binds[0][key].valid) { - for (port = 0; port < MAX_USERS; port++) - { - if (settings->input.binds[0][key].valid) - { - if (input_joypad_pressed(apple->joypad, - port, settings->input.binds[0], key)) - return true; + if (input_joypad_pressed(apple->joypad, + 0, settings->input.binds[0], key)) + return true; #ifdef HAVE_MFI - if (input_joypad_pressed(apple->sec_joypad, port, settings->input.binds[0], key)) - return true; + if (input_joypad_pressed(apple->sec_joypad, 0, settings->input.binds[0], key)) + return true; #endif - } - } - } - else - { - if (settings->input.binds[0][key].valid) - { - if (input_joypad_pressed(apple->joypad, - 0, settings->input.binds[0], key)) - return true; - -#ifdef HAVE_MFI - if (input_joypad_pressed(apple->sec_joypad, 0, settings->input.binds[0], key)) - return true; -#endif - } } return false; diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 9f5619c407..5dbea29058 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -95,21 +95,11 @@ static bool ctr_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); ctr_input_t *ctr = (ctr_input_t*)data; - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(ctr->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(ctr->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(ctr->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 88d9922795..58c6625e04 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -314,19 +314,10 @@ static int16_t dinput_pressed_analog(struct dinput_input *di, static bool dinput_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (dinput_is_pressed((struct dinput_input*)data, - settings->input.binds[0], port, key)) - return true; - } - else - if (dinput_is_pressed((struct dinput_input*)data, + if (dinput_is_pressed((struct dinput_input*)data, settings->input.binds[0], 0, key)) - return true; + return true; return false; } diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 021f09873d..51a9c3deb5 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -100,21 +100,11 @@ static bool gx_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); gx_input_t *gx = (gx_input_t*)data; - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(gx->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(gx->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(gx->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 99389fa1b4..77d39a725b 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -111,24 +111,14 @@ static bool linuxraw_input_key_pressed(void *data, int key) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; if (linuxraw_is_pressed(linuxraw, settings->input.binds[0], key)) return true; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(linuxraw->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(linuxraw->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(linuxraw->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 666933b1d0..add2992546 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -186,19 +186,10 @@ static bool ps3_input_key_pressed(void *data, int key) { ps3_input_t *ps3 = (ps3_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (input_joypad_pressed(ps3->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (input_joypad_pressed(ps3->joypad, + if (input_joypad_pressed(ps3->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index c774e088fb..32df4b9345 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -113,19 +113,10 @@ static bool psp_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); psp_input_t *psp = (psp_input_t*)data; - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (input_joypad_pressed(psp->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (input_joypad_pressed(psp->joypad, + if (input_joypad_pressed(psp->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index dbd4e7709d..0f2bf1888b 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -798,19 +798,10 @@ static bool qnx_input_key_pressed(void *data, int key) { qnx_input_t *qnx = (qnx_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (input_joypad_pressed(qnx->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (input_joypad_pressed(qnx->joypad, + if (input_joypad_pressed(qnx->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 88c3d12f66..968f0e69f8 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -110,27 +110,17 @@ static bool sdl_input_key_pressed(void *data, int key) { if (key >= 0 && key < RARCH_BIND_LIST_END) { - sdl_input_t *sdl = (sdl_input_t*)data; - settings_t *settings = config_get_ptr(); - int port = 0; + sdl_input_t *sdl = (sdl_input_t*)data; + settings_t *settings = config_get_ptr(); const struct retro_keybind *binds = settings->input.binds[0]; if (sdl_is_pressed(sdl, 0, binds, key)) return true; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(sdl->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(sdl->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(sdl->joypad, 0, settings->input.binds[0], key)) - return true; + return true; } return false; diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 59168a6b9d..f3a077e141 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -552,25 +552,15 @@ static bool udev_input_key_pressed(void *data, int key) { udev_input_t *udev = (udev_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; if (settings->input.binds[0][key].valid && udev_input_is_pressed(settings->input.binds[0], key)) return true; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(udev->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(udev->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(udev->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 17fb270c3a..611b9ba12f 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -98,21 +98,11 @@ static bool wiiu_input_key_pressed(void *data, int key) { settings_t *settings = config_get_ptr(); wiiu_input_t *wiiu = (wiiu_input_t*)data; - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(wiiu->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(wiiu->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(wiiu->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 48acc1a681..ba437436b8 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -123,22 +123,13 @@ static bool x_input_key_pressed(void *data, int key) { x11_input_t *x11 = (x11_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; if (settings->input.binds[0][key].valid && x_is_pressed(x11, settings->input.binds[0], key)) return true; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (input_joypad_pressed(x11->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (input_joypad_pressed(x11->joypad, + if (input_joypad_pressed(x11->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; } diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index e7c5d51469..cd6f8daceb 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -100,21 +100,11 @@ static bool xdk_input_key_pressed(void *data, int key) { xdk_input_t *xdk = (xdk_input_t*)data; settings_t *settings = config_get_ptr(); - int port = 0; - if (settings->input.all_users_control_menu) - { - for (port = 0; port < MAX_USERS; port++) - if (settings->input.binds[0][key].valid && - input_joypad_pressed(xdk->joypad, - port, settings->input.binds[0], key)) - return true; - } - else - if (settings->input.binds[0][key].valid && - input_joypad_pressed(xdk->joypad, + if (settings->input.binds[0][key].valid && + input_joypad_pressed(xdk->joypad, 0, settings->input.binds[0], key)) - return true; + return true; return false; }