diff --git a/config.def.h b/config.def.h index 955985a6d8..6c5e6d410f 100644 --- a/config.def.h +++ b/config.def.h @@ -841,14 +841,18 @@ static const unsigned input_backtouch_toggle = false; #define DEFAULT_OVERLAY_SHOW_INPUTS_PORT 0 -#define DEFAULT_ALL_USERS_CONTROL_MENU false - #if defined(ANDROID) || defined(_WIN32) #define DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS true #else #define DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS false #endif +#if defined(WIIU) +#define DEFAULT_ALL_USERS_CONTROL_MENU true +#else +#define DEFAULT_ALL_USERS_CONTROL_MENU false +#endif + #define DEFAULT_QUIT_PRESS_TWICE true #define DEFAULT_LOG_TO_FILE false diff --git a/configuration.c b/configuration.c index 7b9af50662..ee06d81499 100644 --- a/configuration.c +++ b/configuration.c @@ -1587,6 +1587,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("desktop_menu_enable", &settings->bools.desktop_menu_enable, true, DEFAULT_DESKTOP_MENU_ENABLE, false); SETTING_BOOL("video_gpu_record", &settings->bools.video_gpu_record, true, DEFAULT_GPU_RECORD, false); SETTING_BOOL("input_remap_binds_enable", &settings->bools.input_remap_binds_enable, true, true, false); + SETTING_BOOL("all_users_control_menu", &settings->bools.input_all_users_control_menu, true, DEFAULT_ALL_USERS_CONTROL_MENU, false); SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->bools.input_menu_swap_ok_cancel_buttons, true, DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS, false); #ifdef HAVE_NETWORKING SETTING_BOOL("netplay_public_announce", &settings->bools.netplay_public_announce, true, DEFAULT_NETPLAY_PUBLIC_ANNOUNCE, false); diff --git a/configuration.h b/configuration.h index 002318b724..a8881f4cd1 100644 --- a/configuration.h +++ b/configuration.h @@ -593,6 +593,7 @@ typedef struct settings bool input_overlay_auto_scale; bool input_descriptor_label_show; bool input_descriptor_hide_unbound; + bool input_all_users_control_menu; bool input_menu_swap_ok_cancel_buttons; bool input_backtouch_enable; bool input_backtouch_toggle; diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 1c69280285..51f67f5c1f 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1367,7 +1367,7 @@ static int16_t android_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index c7699c7036..0cd8d7401d 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -377,7 +377,7 @@ static int16_t cocoa_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 2627771cd5..b4ab37aebe 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -484,7 +484,7 @@ static int16_t dinput_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index e901946d3a..3c2c18e0c2 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -54,7 +54,7 @@ static int16_t dos_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 91c3929a77..04079c8837 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -64,7 +64,7 @@ static int16_t rvl_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index e4994a9c74..60a48c05f8 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -77,7 +77,7 @@ static int16_t linuxraw_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index ecfe0a901c..41bee3a558 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -98,7 +98,7 @@ static int16_t ps3_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/psl1ght_input.c b/input/drivers/psl1ght_input.c index e8d067f298..331a0611d9 100644 --- a/input/drivers/psl1ght_input.c +++ b/input/drivers/psl1ght_input.c @@ -216,7 +216,7 @@ static int16_t ps3_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index 7f42aca420..4b77749abf 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -237,7 +237,7 @@ static int16_t vita_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 6dc966b2c4..4ae9a9b688 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -773,7 +773,7 @@ static int16_t qnx_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 58ae91b6ab..9facda33ff 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -429,7 +429,7 @@ static int16_t rwebinput_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index d0961411ac..579e23e8d4 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -114,7 +114,7 @@ static int16_t sdl_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/switch_input.c b/input/drivers/switch_input.c index 245474fa04..a8e5d14c0b 100644 --- a/input/drivers/switch_input.c +++ b/input/drivers/switch_input.c @@ -286,7 +286,7 @@ static int16_t switch_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 1d5ba410dd..b34ef560b5 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -1101,7 +1101,7 @@ static int16_t udev_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/uwp_input.c b/input/drivers/uwp_input.c index 1b1bfb917d..3fc8e26fe5 100644 --- a/input/drivers/uwp_input.c +++ b/input/drivers/uwp_input.c @@ -55,7 +55,7 @@ static int16_t uwp_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index e1ba4c6b67..153eb623f8 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -152,7 +152,7 @@ static int16_t input_wl_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 80413e180d..48e39875a7 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -90,7 +90,7 @@ static int16_t wiiu_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index 7b5e01f982..fd5ce28e0a 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -611,7 +611,7 @@ static int16_t winraw_input_lightgun_state( winraw_mouse_t *mouse, const input_device_driver_t *joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned id, @@ -682,7 +682,7 @@ static int16_t winraw_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index fa38d406db..a631b33d0c 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -147,7 +147,7 @@ static int16_t x_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned port, unsigned device, diff --git a/input/input_driver.c b/input/input_driver.c index 38ece125fc..bbba433cae 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -95,7 +95,7 @@ static int16_t input_null_input_state( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **retro_keybinds, + const retro_keybind_set *retro_keybinds, bool keyboard_mapping_blocked, unsigned port, unsigned device, unsigned index, unsigned id) { return 0; } static void input_null_free(void *data) { } @@ -644,7 +644,7 @@ int16_t input_state_wrap( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned _port, unsigned device, @@ -653,6 +653,10 @@ int16_t input_state_wrap( { int16_t ret = 0; + if(!binds || !binds[_port]) { + return 0; + } + /* Do a bitwise OR to combine input states together */ if (device == RETRO_DEVICE_JOYPAD) @@ -2678,7 +2682,7 @@ void input_config_reset(void) input_config_reset_autoconfig_binds(i); - input_st->libretro_input_binds[i] = input_config_binds[i]; + input_st->libretro_input_binds[i] = &input_config_binds[i]; } } @@ -3479,7 +3483,7 @@ void input_keys_pressed( bool is_menu, int input_hotkey_block_delay, input_bits_t *p_new_state, - const struct retro_keybind **binds, + retro_keybind_set *binds, const struct retro_keybind *binds_norm, const struct retro_keybind *binds_auto, const input_device_driver_t *joypad, @@ -3489,6 +3493,10 @@ void input_keys_pressed( unsigned i; input_driver_state_t *input_st = &input_driver_st; + if(!binds || !binds[port]) { + return; + } + if (CHECK_INPUT_DRIVER_BLOCK_HOTKEY(binds_norm, binds_auto)) { if ( input_state_wrap( @@ -3513,9 +3521,7 @@ void input_keys_pressed( input_st->block_hotkey = true; } } - - if ( !is_menu - && binds[port][RARCH_GAME_FOCUS_TOGGLE].valid) + if (!is_menu && binds[port][RARCH_GAME_FOCUS_TOGGLE].valid) { const struct retro_keybind *focus_binds_auto = &input_autoconf_binds[port][RARCH_GAME_FOCUS_TOGGLE]; @@ -3634,7 +3640,7 @@ int16_t input_state_device( #endif { bool bind_valid = input_st->libretro_input_binds[port] - && input_st->libretro_input_binds[port][id].valid; + && (*input_st->libretro_input_binds[port])[id].valid; unsigned remap_button = settings->uints.input_remap_ids[port][id]; /* TODO/FIXME: What on earth is this code doing...? */ @@ -3844,7 +3850,7 @@ int16_t input_state_device( if (id < RARCH_FIRST_META_KEY) { bool bind_valid = input_st->libretro_input_binds[port] - && input_st->libretro_input_binds[port][id].valid; + && (*input_st->libretro_input_binds[port])[id].valid; if (bind_valid) { @@ -3933,7 +3939,7 @@ int16_t input_state_device( if (id < RARCH_FIRST_META_KEY) { bool bind_valid = input_st->libretro_input_binds[port] - && input_st->libretro_input_binds[port][id].valid; + && (*input_st->libretro_input_binds[port])[id].valid; if (bind_valid) { @@ -4000,14 +4006,14 @@ void input_driver_poll(void) joypad_info[i].joy_idx = settings->uints.input_joypad_index[i]; joypad_info[i].auto_binds = input_autoconf_binds[joypad_info[i].joy_idx]; - input_st->turbo_btns.frame_enable[i] = input_st->libretro_input_binds[i][RARCH_TURBO_ENABLE].valid ? + input_st->turbo_btns.frame_enable[i] = (*input_st->libretro_input_binds[i])[RARCH_TURBO_ENABLE].valid ? input_state_wrap( input_st->current_driver, input_st->current_data, joypad, sec_joypad, &joypad_info[i], - input_st->libretro_input_binds, + (*input_st->libretro_input_binds), input_st->keyboard_mapping_blocked, (unsigned)i, RETRO_DEVICE_JOYPAD, @@ -4105,7 +4111,7 @@ void input_driver_poll(void) input_st->primary_joypad, sec_joypad, &joypad_info[i], - input_st->libretro_input_binds, + (*input_st->libretro_input_binds), input_st->keyboard_mapping_blocked, (unsigned)i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); @@ -4115,7 +4121,7 @@ void input_driver_poll(void) if (ret & (1 << k)) { bool valid_bind = - input_st->libretro_input_binds[i][k].valid; + (*input_st->libretro_input_binds[i])[k].valid; if (valid_bind) { @@ -4126,7 +4132,7 @@ void input_driver_poll(void) joypad, &joypad_info[i], k, - &input_st->libretro_input_binds[i][k] + &(*input_st->libretro_input_binds[i])[k] ); if (val) p_new_state->analog_buttons[k] = val; @@ -4152,7 +4158,7 @@ void input_driver_poll(void) &joypad_info[i], k, j, - input_st->libretro_input_binds[i]); + (*input_st->libretro_input_binds[i])); if (val >= 0) p_new_state->analogs[offset] = val; @@ -4879,7 +4885,7 @@ int16_t input_state_internal(unsigned port, unsigned device, joypad, sec_joypad, &joypad_info, - input_st->libretro_input_binds, + (*input_st->libretro_input_binds), input_st->keyboard_mapping_blocked, mapped_port, device, idx, id); @@ -4892,7 +4898,7 @@ int16_t input_state_internal(unsigned port, unsigned device, { if (id < RARCH_FIRST_CUSTOM_BIND) { - bool valid_bind = input_st->libretro_input_binds[mapped_port][id].valid; + bool valid_bind = (*input_st->libretro_input_binds[mapped_port])[id].valid; if (valid_bind) { @@ -4902,7 +4908,7 @@ int16_t input_state_internal(unsigned port, unsigned device, input_analog_sensitivity, sec_joypad, &joypad_info, id, - &input_st->libretro_input_binds[mapped_port][id]); + &(*input_st->libretro_input_binds[mapped_port])[id]); if (joypad && (ret == 0)) ret = input_joypad_analog_button( @@ -4910,7 +4916,7 @@ int16_t input_state_internal(unsigned port, unsigned device, input_analog_sensitivity, joypad, &joypad_info, id, - &input_st->libretro_input_binds[mapped_port][id]); + &(*input_st->libretro_input_binds[mapped_port])[id]); } } } @@ -4925,7 +4931,7 @@ int16_t input_state_internal(unsigned port, unsigned device, &joypad_info, idx, id, - input_st->libretro_input_binds[mapped_port]); + (*input_st->libretro_input_binds[mapped_port])); if (joypad && (ret == 0)) ret = input_joypad_analog_axis( @@ -4936,7 +4942,7 @@ int16_t input_state_internal(unsigned port, unsigned device, &joypad_info, idx, id, - input_st->libretro_input_binds[mapped_port]); + (*input_st->libretro_input_binds[mapped_port])); } } } diff --git a/input/input_driver.h b/input/input_driver.h index d04622928f..f925b421d1 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -257,7 +257,7 @@ struct input_driver const input_device_driver_t *joypad_data, const input_device_driver_t *sec_joypad_data, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **retro_keybinds, + const retro_keybind_set *retro_keybinds, bool keyboard_mapping_blocked, unsigned port, unsigned device, unsigned index, unsigned id); @@ -387,7 +387,7 @@ typedef struct void *current_data; const input_device_driver_t *primary_joypad; /* ptr alignment */ const input_device_driver_t *secondary_joypad; /* ptr alignment */ - const struct retro_keybind *libretro_input_binds[MAX_USERS]; + const retro_keybind_set *libretro_input_binds[MAX_USERS]; #ifdef HAVE_COMMAND command_t *command[MAX_CMD_DRIVERS]; #endif @@ -796,7 +796,7 @@ int16_t input_state_wrap( const input_device_driver_t *joypad, const input_device_driver_t *sec_joypad, rarch_joypad_info_t *joypad_info, - const struct retro_keybind **binds, + const retro_keybind_set *binds, bool keyboard_mapping_blocked, unsigned _port, unsigned device, @@ -1023,7 +1023,7 @@ void input_keys_pressed( bool is_menu, int input_hotkey_block_delay, input_bits_t *p_new_state, - const struct retro_keybind **binds, + retro_keybind_set *binds, const struct retro_keybind *binds_norm, const struct retro_keybind *binds_auto, const input_device_driver_t *joypad, diff --git a/input/input_types.h b/input/input_types.h index 235bae2626..77514d195b 100644 --- a/input/input_types.h +++ b/input/input_types.h @@ -76,6 +76,8 @@ struct retro_keybind bool valid; }; +typedef struct retro_keybind retro_keybind_set[RARCH_BIND_LIST_END]; + typedef struct { uint32_t data[8]; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6e33089330..4efb4893d5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6380,6 +6380,10 @@ unsigned menu_displaylist_build_list( MENU_ENUM_LABEL_MENU_INPUT_SWAP_OK_CANCEL, PARSE_ONLY_BOOL, false) == 0) count++; + if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, + MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU, + PARSE_ONLY_BOOL, false) == 0) + count++; if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, MENU_ENUM_LABEL_MENU_SCROLL_FAST, PARSE_ONLY_BOOL, false) == 0) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 2efcd64567..0cd47fceca 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2038,7 +2038,7 @@ void menu_input_get_touchscreen_hw_state( unsigned fb_width, fb_height; int pointer_x = 0; int pointer_y = 0; - const struct retro_keybind *binds[MAX_USERS] = {NULL}; + const retro_keybind_set *binds[MAX_USERS] = {NULL}; /* Is a background texture set for the current menu driver? * Checks if the menu framebuffer is set. * This would usually only return true @@ -2095,7 +2095,7 @@ void menu_input_get_touchscreen_hw_state( input_driver_st->current_data, joypad, sec_joypad, - &joypad_info, binds, + &joypad_info, (*binds), keyboard_mapping_blocked, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X); @@ -2126,7 +2126,7 @@ void menu_input_get_touchscreen_hw_state( input_driver_st->current_data, joypad, sec_joypad, - &joypad_info, binds, + &joypad_info, (*binds), keyboard_mapping_blocked, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y); @@ -2153,7 +2153,7 @@ void menu_input_get_touchscreen_hw_state( input_driver_st->current_data, joypad, sec_joypad, - &joypad_info, binds, + &joypad_info, (*binds), keyboard_mapping_blocked, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_PRESSED); @@ -2168,7 +2168,7 @@ void menu_input_get_touchscreen_hw_state( input_driver_st->current_data, joypad, sec_joypad, - &joypad_info, binds, + &joypad_info, (*binds), keyboard_mapping_blocked, 0, pointer_device, 0, RARCH_DEVICE_ID_POINTER_BACK); @@ -3021,7 +3021,7 @@ bool menu_driver_search_filter_enabled(const char *label, unsigned type) void menu_input_key_bind_poll_bind_state( input_driver_state_t *input_driver_st, - const struct retro_keybind **binds, + const retro_keybind_set *binds, float input_axis_threshold, unsigned joy_idx, struct menu_bind_state *state, @@ -5372,7 +5372,7 @@ bool menu_input_key_bind_set_mode( binds); menu_input_key_bind_poll_bind_state( input_st, - input_st->libretro_input_binds, + (*input_st->libretro_input_binds), settings->floats.input_axis_threshold, settings->uints.input_joypad_index[binds->port], binds, false, @@ -5480,7 +5480,7 @@ current_time; menu_input_key_bind_poll_bind_state( input_st, - input_st->libretro_input_binds, + (*input_st->libretro_input_binds), settings->floats.input_axis_threshold, settings->uints.input_joypad_index[new_binds.port], &new_binds, timed_out, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 8e3c423caa..d58931b0f3 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -760,7 +760,7 @@ void menu_input_pointer_close_messagebox(struct menu_state *menu_st); void menu_input_key_bind_poll_bind_state( input_driver_state_t *input_driver_st, - const struct retro_keybind **binds, + const retro_keybind_set *binds, float input_axis_threshold, unsigned joy_idx, struct menu_bind_state *state, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 434c3b87d2..b67fe31ad3 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -13185,6 +13185,22 @@ static bool setting_append_list( SD_FLAG_NONE ); + CONFIG_BOOL( + list, list_info, + &settings->bools.input_all_users_control_menu, + MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU, + MENU_ENUM_LABEL_VALUE_INPUT_ALL_USERS_CONTROL_MENU, + DEFAULT_ALL_USERS_CONTROL_MENU, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE + ); + CONFIG_BOOL( list, list_info, &settings->bools.input_remap_binds_enable, diff --git a/retroarch.c b/retroarch.c index 642513f9ff..d5311adafb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -309,8 +309,8 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { #ifdef HAVE_DISCORD bool discord_is_inited = false; #endif -struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; -struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; +retro_keybind_set input_config_binds[MAX_USERS]; +retro_keybind_set input_autoconf_binds[MAX_USERS]; static runloop_core_status_msg_t runloop_core_status_msg = { @@ -18537,6 +18537,211 @@ static void runloop_apply_fastmotion_override(runloop_state_t *runloop_st, setti fastforward_ratio_current); } +static void collect_system_input(struct rarch_state *p_rarch, + settings_t *settings, input_bits_t *current_bits) +{ + unsigned port; + rarch_joypad_info_t joypad_info; + int block_delay = settings->uints.input_hotkey_block_delay; + input_driver_state_t *input_st = input_state_get_ptr(); + const input_device_driver_t *joypad = input_st->primary_joypad; +#ifdef HAVE_MFI + const input_device_driver_t + *sec_joypad = input_st->secondary_joypad; +#else + const input_device_driver_t + *sec_joypad = NULL; +#endif +#ifdef HAVE_MENU + bool display_kb = menu_input_dialog_get_display_kb(); + bool menu_input_active = menu_state_get_ptr()->alive && + !(settings->bools.menu_unified_controls && !display_kb); +#endif + input_driver_t *current_input = input_st->current_driver; + unsigned max_users = settings->uints.input_max_users; + bool all_users_control_menu = settings->bools.input_all_users_control_menu; + +#if !(defined(HAVE_ACCESSIBILITY) && defined(HAVE_TRANSLATE)) + (void)p_rarch; +#endif + joypad_info.axis_threshold = settings->floats.input_axis_threshold; + + /* Gather input from each (enabled) joypad */ + for(port = 0; port < max_users; port++) + { + const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY]; + const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY]; + struct retro_keybind *auto_binds = input_autoconf_binds[port]; + struct retro_keybind *general_binds = input_config_binds[port]; + joypad_info.joy_idx = settings->uints.input_joypad_index[port]; + joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; + input_bits_t *loop_bits = NULL; + input_bits_t tmp_bits; + unsigned i; + + if (port == 0) + loop_bits = current_bits; + else + { + loop_bits = &tmp_bits; + BIT256_CLEAR_ALL_PTR(loop_bits); + } + +#ifdef HAVE_MENU + if (menu_input_active) + { + unsigned k; + unsigned x_plus = RARCH_ANALOG_LEFT_X_PLUS; + unsigned y_plus = RARCH_ANALOG_LEFT_Y_PLUS; + unsigned x_minus = RARCH_ANALOG_LEFT_X_MINUS; + unsigned y_minus = RARCH_ANALOG_LEFT_Y_MINUS; + + /* Push analog to D-Pad mappings to binds. */ + for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) + { + (auto_binds)[k].orig_joyaxis = (auto_binds)[k].joyaxis; + (general_binds)[k].orig_joyaxis = (general_binds)[k].joyaxis; + } + + if (!INHERIT_JOYAXIS(auto_binds)) + { + unsigned j = x_plus + 3; + /* Inherit joyaxis from analogs. */ + for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) + (auto_binds)[k].joyaxis = (auto_binds)[j--].joyaxis; + } + + if (!INHERIT_JOYAXIS(general_binds)) + { + unsigned j = x_plus + 3; + /* Inherit joyaxis from analogs. */ + for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) + (general_binds)[k].joyaxis = (general_binds)[j--].joyaxis; + } + } +#endif /* HAVE_MENU */ + + input_keys_pressed(port, + menu_input_active, + block_delay, + loop_bits, + input_config_binds, + binds_norm, + binds_auto, + joypad, + sec_joypad, + &joypad_info); + +#ifdef HAVE_MENU + if (menu_input_active) + { + unsigned j; + + /* Restores analog D-pad binds temporarily overridden. */ + for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) + { + (auto_binds)[j].joyaxis = (auto_binds)[j].orig_joyaxis; + (general_binds)[j].joyaxis = (general_binds)[j].orig_joyaxis; + } + } +#endif /* HAVE_MENU */ + + /* we write port 0 directly to input_bits to save one iteration of this loop */ + if (port != 0) + { + /* Update compound 'current_bits' record + * Note: Only digital inputs are considered */ + for(i = 0; i < sizeof(current_bits->data) / sizeof(current_bits->data[0]); i++) + current_bits->data[i] |= loop_bits->data[i]; + } + else if (!all_users_control_menu) + break; + + } + +#ifdef HAVE_MENU + if (menu_input_active) + { + /* Gather keyboard input, if enabled + * Note: Keyboard input always read from + * port 0 */ + if ( !display_kb + && current_input->input_state) + { + unsigned i; + unsigned ids[][2] = + { + {RETROK_SPACE, RETRO_DEVICE_ID_JOYPAD_START }, + {RETROK_SLASH, RETRO_DEVICE_ID_JOYPAD_X }, + {RETROK_RSHIFT, RETRO_DEVICE_ID_JOYPAD_SELECT }, + {RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT }, + {RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT }, + {RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN }, + {RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP }, + {RETROK_PAGEUP, RETRO_DEVICE_ID_JOYPAD_L }, + {RETROK_PAGEDOWN, RETRO_DEVICE_ID_JOYPAD_R }, + {0, RARCH_QUIT_KEY }, + {0, RARCH_FULLSCREEN_TOGGLE_KEY }, + {RETROK_BACKSPACE, RETRO_DEVICE_ID_JOYPAD_B }, + {RETROK_RETURN, RETRO_DEVICE_ID_JOYPAD_A }, + {RETROK_DELETE, RETRO_DEVICE_ID_JOYPAD_Y }, + {0, RARCH_UI_COMPANION_TOGGLE }, + {0, RARCH_FPS_TOGGLE }, + {0, RARCH_SEND_DEBUG_INFO }, + {0, RARCH_NETPLAY_HOST_TOGGLE }, + {0, RARCH_MENU_TOGGLE }, + }; + + ids[9][0] = input_config_binds[0][RARCH_QUIT_KEY].key; + ids[10][0] = input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY].key; + ids[14][0] = input_config_binds[0][RARCH_UI_COMPANION_TOGGLE].key; + ids[15][0] = input_config_binds[0][RARCH_FPS_TOGGLE].key; + ids[16][0] = input_config_binds[0][RARCH_SEND_DEBUG_INFO].key; + ids[17][0] = input_config_binds[0][RARCH_NETPLAY_HOST_TOGGLE].key; + ids[18][0] = input_config_binds[0][RARCH_MENU_TOGGLE].key; + + if (settings->bools.input_menu_swap_ok_cancel_buttons) + { + ids[11][1] = RETRO_DEVICE_ID_JOYPAD_A; + ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B; + } + + for (i = 0; i < ARRAY_SIZE(ids); i++) + { + if (current_input->input_state( + input_st->current_data, + joypad, + sec_joypad, + &joypad_info, input_config_binds, + input_st->keyboard_mapping_blocked, + 0, + RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) + BIT256_SET_PTR(current_bits, ids[i][1]); + } + } + } + else +#endif /* HAVE_MENU */ + { +#if defined(HAVE_ACCESSIBILITY) && defined(HAVE_TRANSLATE) + if (settings->bools.ai_service_enable) + { + unsigned i; + + input_st->gamepad_input_override = 0; + + for (i = 0; i < MAX_USERS; i++) + { + /* Set gamepad input override */ + if (p_rarch->ai_gamepad_state[i] == 2) + input_st->gamepad_input_override |= (1 << i); + p_rarch->ai_gamepad_state[i] = 0; + } + } +#endif /* defined(HAVE_ACCESSIBILITY) && defined(HAVE_TRANSLATE) */ + } +} + static enum runloop_state_enum runloop_check_state( struct rarch_state *p_rarch, settings_t *settings, @@ -18595,7 +18800,6 @@ static enum runloop_state_enum runloop_check_state( return RUNLOOP_STATE_QUIT; #endif - BIT256_CLEAR_ALL_PTR(¤t_bits); input_st->block_libretro_input = false; @@ -18604,165 +18808,7 @@ static enum runloop_state_enum runloop_check_state( if (input_st->keyboard_mapping_blocked) input_st->block_hotkey = true; - { - rarch_joypad_info_t joypad_info; - unsigned port = 0; - int input_hotkey_block_delay = settings->uints.input_hotkey_block_delay; - input_driver_t *current_input = input_st->current_driver; - const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY]; - const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY]; - const struct retro_keybind *binds = input_config_binds[port]; - struct retro_keybind *auto_binds = input_autoconf_binds[port]; - struct retro_keybind *general_binds = input_config_binds[port]; -#ifdef HAVE_MENU - bool menu_input_active = menu_is_alive && !(settings->bools.menu_unified_controls && !display_kb); -#else - bool menu_input_active = false; -#endif - const input_device_driver_t *joypad = input_st->primary_joypad; -#ifdef HAVE_MFI - const input_device_driver_t - *sec_joypad = input_st->secondary_joypad; -#else - const input_device_driver_t - *sec_joypad = NULL; -#endif - - joypad_info.joy_idx = settings->uints.input_joypad_index[port]; - joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; - joypad_info.axis_threshold = settings->floats.input_axis_threshold; - -#ifdef HAVE_MENU - if (menu_input_active) - { - unsigned k; - unsigned x_plus = RARCH_ANALOG_LEFT_X_PLUS; - unsigned y_plus = RARCH_ANALOG_LEFT_Y_PLUS; - unsigned x_minus = RARCH_ANALOG_LEFT_X_MINUS; - unsigned y_minus = RARCH_ANALOG_LEFT_Y_MINUS; - - /* Push analog to D-Pad mappings to binds. */ - - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - { - (auto_binds)[k].orig_joyaxis = (auto_binds)[k].joyaxis; - (general_binds)[k].orig_joyaxis = (general_binds)[k].joyaxis; - } - - if (!INHERIT_JOYAXIS(auto_binds)) - { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - (auto_binds)[k].joyaxis = (auto_binds)[j--].joyaxis; - } - if (!INHERIT_JOYAXIS(general_binds)) - { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - (general_binds)[k].joyaxis = (general_binds)[j--].joyaxis; - } - } -#endif - - input_keys_pressed(port, - menu_input_active, input_hotkey_block_delay, - ¤t_bits, &binds, binds_norm, binds_auto, - joypad, sec_joypad, - &joypad_info); - -#ifdef HAVE_MENU - if (menu_input_active) - { - unsigned j; - - /* Restores analog D-pad binds temporarily overridden. */ - - for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) - { - (auto_binds)[j].joyaxis = (auto_binds)[j].orig_joyaxis; - (general_binds)[j].joyaxis = (general_binds)[j].orig_joyaxis; - } - - if ( !display_kb - && current_input->input_state) - { - unsigned i; - unsigned ids[][2] = - { - {RETROK_SPACE, RETRO_DEVICE_ID_JOYPAD_START }, - {RETROK_SLASH, RETRO_DEVICE_ID_JOYPAD_X }, - {RETROK_RSHIFT, RETRO_DEVICE_ID_JOYPAD_SELECT }, - {RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT }, - {RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT }, - {RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN }, - {RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP }, - {RETROK_PAGEUP, RETRO_DEVICE_ID_JOYPAD_L }, - {RETROK_PAGEDOWN, RETRO_DEVICE_ID_JOYPAD_R }, - {0, RARCH_QUIT_KEY }, - {0, RARCH_FULLSCREEN_TOGGLE_KEY }, - {RETROK_BACKSPACE, RETRO_DEVICE_ID_JOYPAD_B }, - {RETROK_RETURN, RETRO_DEVICE_ID_JOYPAD_A }, - {RETROK_DELETE, RETRO_DEVICE_ID_JOYPAD_Y }, - {0, RARCH_UI_COMPANION_TOGGLE }, - {0, RARCH_FPS_TOGGLE }, - {0, RARCH_SEND_DEBUG_INFO }, - {0, RARCH_NETPLAY_HOST_TOGGLE }, - {0, RARCH_MENU_TOGGLE }, - }; - - ids[9][0] = input_config_binds[port][RARCH_QUIT_KEY].key; - ids[10][0] = input_config_binds[port][RARCH_FULLSCREEN_TOGGLE_KEY].key; - ids[14][0] = input_config_binds[port][RARCH_UI_COMPANION_TOGGLE].key; - ids[15][0] = input_config_binds[port][RARCH_FPS_TOGGLE].key; - ids[16][0] = input_config_binds[port][RARCH_SEND_DEBUG_INFO].key; - ids[17][0] = input_config_binds[port][RARCH_NETPLAY_HOST_TOGGLE].key; - ids[18][0] = input_config_binds[port][RARCH_MENU_TOGGLE].key; - - if (settings->bools.input_menu_swap_ok_cancel_buttons) - { - ids[11][1] = RETRO_DEVICE_ID_JOYPAD_A; - ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B; - } - - for (i = 0; i < ARRAY_SIZE(ids); i++) - { - if (current_input->input_state( - input_st->current_data, - joypad, - sec_joypad, - &joypad_info, &binds, - input_st->keyboard_mapping_blocked, - port, - RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) - BIT256_SET_PTR(¤t_bits, ids[i][1]); - } - } - } - else -#endif - { -#ifdef HAVE_ACCESSIBILITY -#ifdef HAVE_TRANSLATE - if (settings->bools.ai_service_enable) - { - unsigned i; - - input_st->gamepad_input_override = 0; - - for (i = 0; i < MAX_USERS; i++) - { - /* Set gamepad input override */ - if (p_rarch->ai_gamepad_state[i] == 2) - input_st->gamepad_input_override |= (1 << i); - p_rarch->ai_gamepad_state[i] = 0; - } - } -#endif -#endif - } - } + collect_system_input(p_rarch, settings, ¤t_bits); #ifdef HAVE_MENU last_input = current_bits;