add input option to allow any user to control the menu

This commit is contained in:
Brad Parker 2016-09-03 19:01:29 -04:00
parent 6e89e8f209
commit a17679a0c5
21 changed files with 209 additions and 28 deletions

View File

@ -565,6 +565,7 @@ static bool show_advanced_settings = true;
static const uint32_t menu_entry_normal_color = 0xffffffff;
static const uint32_t menu_entry_hover_color = 0xff64ff64;
static const uint32_t menu_title_color = 0xff64ff64;
#else
static bool default_block_config_read = false;
#endif
@ -597,6 +598,8 @@ static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_NONE;
static bool back_as_menu_toggle_enable = true;
#endif
static bool all_users_control_menu = false;
/* Crop overscanned frames. */
static const bool crop_overscan = true;

View File

@ -680,6 +680,7 @@ static int populate_settings_bool(settings_t *settings, struct config_bool_setti
SETTING_BOOL("video_gpu_record", &settings->video.gpu_record, true, gpu_record, false);
SETTING_BOOL("input_remap_binds_enable", &settings->input.remap_binds_enable, true, true, false);
SETTING_BOOL("back_as_menu_toggle_enable", &settings->input.back_as_menu_toggle_enable, true, true, false);
SETTING_BOOL("all_users_control_menu", &settings->input.all_users_control_menu, true, all_users_control_menu, false);
SETTING_BOOL("netplay_client_swap_input", &settings->input.netplay_client_swap_input, true, netplay_client_swap_input, false);
SETTING_BOOL("input_descriptor_label_show", &settings->input.input_descriptor_label_show, true, input_descriptor_label_show, false);
SETTING_BOOL("input_descriptor_hide_unbound", &settings->input.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false);

View File

@ -288,6 +288,7 @@ typedef struct settings
unsigned menu_toggle_gamepad_combo;
bool back_as_menu_toggle_enable;
bool all_users_control_menu;
#if TARGET_OS_IPHONE
bool small_keyboard_enable;

View File

@ -1153,13 +1153,22 @@ 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(android_keyboard_port_input_pressed(settings->input.binds[0],key))
return true;
if (input_joypad_pressed(android->joypad,
0, 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(android->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(android->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -302,14 +302,33 @@ 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 (apple_input_is_pressed(0, settings->input.binds[0], key))
return true;
if (input_joypad_pressed(apple->joypad, 0, 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(apple->joypad,
port, 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;
if (input_joypad_pressed(apple->sec_joypad, port, settings->input.binds[0], key))
return true;
#endif
}
}
else
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;

View File

@ -88,9 +88,19 @@ 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 (input_joypad_pressed(ctr->joypad, 0, 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(ctr->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(ctr->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -310,7 +310,21 @@ 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();
return dinput_is_pressed((struct dinput_input*)data, settings->input.binds[0], 0, key);
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,
settings->input.binds[0], 0, key))
return true;
return false;
}
static bool dinput_meta_key_pressed(void *data, int key)

View File

@ -95,9 +95,19 @@ 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 (input_joypad_pressed(gx->joypad, 0, 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(gx->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(gx->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -111,12 +111,22 @@ 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 (input_joypad_pressed(linuxraw->joypad, 0, 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(linuxraw->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(linuxraw->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -178,9 +178,19 @@ 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 (input_joypad_pressed(ps3->joypad, 0, 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(ps3->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(ps3->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -104,9 +104,19 @@ 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 (input_joypad_pressed(psp->joypad, 0, 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(psp->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(psp->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -792,9 +792,19 @@ 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 (input_joypad_pressed(qnx->joypad, 0, 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(qnx->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(qnx->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -112,12 +112,23 @@ static bool sdl_input_key_pressed(void *data, int key)
{
sdl_input_t *sdl = (sdl_input_t*)data;
settings_t *settings = config_get_ptr();
int port = 0;
const struct retro_keybind *binds = settings->input.binds[0];
if (sdl_is_pressed(sdl, 0, binds, key))
return true;
if (input_joypad_pressed(sdl->joypad, 0, binds, key))
return true;
if (settings->input.all_users_control_menu)
{
for (port = 0; port < MAX_USERS; port++)
if (input_joypad_pressed(sdl->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(sdl->joypad,
0, settings->input.binds[0], key))
return true;
}
return false;

View File

@ -547,11 +547,22 @@ 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 (udev_input_is_pressed(settings->input.binds[0], key))
return true;
if (input_joypad_pressed(udev->joypad, 0, 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(udev->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(udev->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -123,11 +123,22 @@ 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 (x_is_pressed(x11, settings->input.binds[0], key))
return true;
if (input_joypad_pressed(x11->joypad, 0, 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,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -92,9 +92,19 @@ 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 (input_joypad_pressed(xdk->joypad, 0, 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(xdk->joypad,
port, settings->input.binds[0], key))
return true;
}
else
if (input_joypad_pressed(xdk->joypad,
0, settings->input.binds[0], key))
return true;
return false;
}

View File

@ -1674,6 +1674,9 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
"2 - Press L3 + R3 simultaneously. \n"
"3 - Press Start + Select simultaneously.");
break;
case MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU:
snprintf(s, len, "Allow any RetroPad to control the menu.");
break;
case MENU_ENUM_LABEL_INPUT_AUTODETECT_ENABLE:
snprintf(s, len,
"Enable input auto-detection.\n"
@ -2257,6 +2260,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg)
return "back_as_menu_toggle_enable";
case MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO:
return "input_menu_toggle_gamepad_combo";
case MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU:
return "all_users_control_menu";
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
return "overlay_hide_in_menu";
case MENU_ENUM_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE:
@ -3522,6 +3527,8 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg)
return "Back As Menu Toggle Enable";
case MENU_ENUM_LABEL_VALUE_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO:
return "Menu Toggle Gamepad Combo";
case MENU_ENUM_LABEL_VALUE_INPUT_ALL_USERS_CONTROL_MENU:
return "All Users Control Menu";
case MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU:
return "Hide Overlay In Menu";
case MENU_ENUM_LABEL_VALUE_LANG_POLISH:

View File

@ -5013,6 +5013,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
#endif
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO, PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU, PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_REMAP_BINDS_ENABLE, PARSE_ONLY_BOOL, false);
ret = menu_displaylist_parse_settings_enum(menu, info,

View File

@ -4218,6 +4218,23 @@ static bool setting_append_list(
menu_settings_list_current_add_range(list, list_info, 0, 3, 1, true, true);
menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO);
CONFIG_BOOL(
list, list_info,
&settings->input.all_users_control_menu,
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ALL_USERS_CONTROL_MENU),
all_users_control_menu,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON),
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU);
CONFIG_BOOL(
list, list_info,
&settings->input.remap_binds_enable,

View File

@ -403,6 +403,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU,
MENU_ENUM_LABEL_INPUT_BACK_AS_MENU_ENUM_TOGGLE_ENABLE,
MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO,
MENU_ENUM_LABEL_INPUT_ALL_USERS_CONTROL_MENU,
MENU_ENUM_LABEL_INPUT_HOTKEY_BINDS,
MENU_ENUM_LABEL_INPUT_OSK_OVERLAY_ENABLE,
MENU_ENUM_LABEL_INPUT_OVERLAY_ENABLE,
@ -464,6 +465,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_INPUT_HOTKEY_BINDS,
MENU_ENUM_LABEL_VALUE_INPUT_BACK_AS_MENU_ENUM_TOGGLE_ENABLE,
MENU_ENUM_LABEL_VALUE_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO,
MENU_ENUM_LABEL_VALUE_INPUT_ALL_USERS_CONTROL_MENU,
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU,
MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE,
MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR,

View File

@ -640,6 +640,9 @@
# 0 = none, 1 = L + R + Y + D-Pad Down, 2 = L3 + R3, 3 = Start + Select
# input_menu_toggle_gamepad_combo = 0
# allow any RetroPad to control the menu
# all_users_control_menu = false
# Toggles mouse grab. When mouse is grabbed, RetroArch hides the mouse,
# and keeps the mouse pointer inside the window to allow relative mouse input
# to work better.