Merge pull request #11986 from sonninnos/device-type-dropdown

Submenu for Device Type
This commit is contained in:
Autechre 2021-02-04 19:36:42 +01:00 committed by GitHub
commit fa898fc02e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 201 additions and 15 deletions

View File

@ -684,6 +684,10 @@ MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX,
"deferred_dropdown_box_list_disk_index"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE,
"deferred_dropdown_box_list_input_device_type"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION,
"deferred_dropdown_box_list_input_description"

View File

@ -650,6 +650,7 @@ GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_playlist_sor
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_manual_content_scan_system_name, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME)
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_manual_content_scan_core_name, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_CORE_NAME)
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_disk_index, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_DISK_INDEX)
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_input_device_type, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_INPUT_DEVICE_TYPE)
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_input_description, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION)
GENERIC_DEFERRED_PUSH_CLEAR_GENERAL(deferred_push_dropdown_box_list_input_description_kbd, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION_KBD)
@ -680,6 +681,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LEFT_THUMBNAIL_MODE, deferred_push_dropdown_box_list_playlist_left_thumbnail_mode},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_SORT_MODE, deferred_push_dropdown_box_list_playlist_sort_mode},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX, deferred_push_dropdown_box_list_disk_index},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE, deferred_push_dropdown_box_list_input_device_type},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION, deferred_push_dropdown_box_list_input_description},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION_KBD, deferred_push_dropdown_box_list_input_description_kbd},
{MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_LIST, deferred_push_browse_url_list},

View File

@ -280,6 +280,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_DISK_INDEX:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION_KBD:
@ -669,6 +671,15 @@ int generic_action_ok_displaylist_push(const char *path,
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE:
info.type = type;
info.directory_ptr = idx;
info_path = path;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION:
info.type = type;
info.directory_ptr = idx;
@ -694,7 +705,7 @@ int generic_action_ok_displaylist_push(const char *path,
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_MUSIC:
if (!string_is_empty(path))
@ -727,7 +738,7 @@ int generic_action_ok_displaylist_push(const char *path,
info_path = path;
info.type = type;
info.directory_ptr = idx;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_OPEN_ARCHIVE:
if (menu)
@ -746,7 +757,7 @@ int generic_action_ok_displaylist_push(const char *path,
info_path = path;
info.type = type;
info.directory_ptr = idx;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_HELP:
info_label = label;
@ -783,7 +794,7 @@ int generic_action_ok_displaylist_push(const char *path,
info.type = type;
info.directory_ptr = idx;
info_label = label;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_FILE_BROWSER_SELECT_FILE:
if (path)
@ -1013,7 +1024,7 @@ int generic_action_ok_displaylist_push(const char *path,
info_path = label;
else
info_path = settings->paths.directory_menu_config;
info_label = label;
info_label = label;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH_DETECT_CORE:
@ -6253,6 +6264,35 @@ static int action_ok_push_dropdown_item_disk_index(const char *path,
return 0;
}
static int action_ok_push_dropdown_item_input_device_type(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
retro_ctx_controller_info_t pad;
unsigned port = 0;
unsigned device = 0;
const char *menu_path = NULL;
menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL);
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(menu_path);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
if (!setting)
return menu_cbs_exit();
port = setting->index_offset;
device = atoi(label);
input_config_set_device(port, device);
pad.port = port;
pad.device = device;
core_set_controller_port_device(&pad);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_input_description(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -7759,6 +7799,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
case MENU_SETTING_DROPDOWN_ITEM_DISK_INDEX:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_disk_index);
break;
case MENU_SETTING_DROPDOWN_ITEM_INPUT_DEVICE_TYPE:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_input_device_type);
break;
case MENU_SETTING_DROPDOWN_ITEM_INPUT_DESCRIPTION:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_input_description);
break;

View File

@ -287,9 +287,15 @@ static int action_get_title_dropdown_item(
path, label, menu_type, s, len);
default:
{
/* Analog to Digital Type -submenus do not have labels */
if ((enum_idx > MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE) &&
(enum_idx < MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE_LAST))
/* Submenu label exceptions */
/* Device Type */
if ((enum_idx >= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE) &&
(enum_idx <= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE_LAST))
enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE;
/* Analog to Digital Type */
if ((enum_idx >= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE) &&
(enum_idx <= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE_LAST))
enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_ADC_TYPE;
{
@ -1642,6 +1648,7 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME, action_get_title_dropdown_manual_content_scan_system_name_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME, action_get_title_dropdown_manual_content_scan_core_name_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX, action_get_title_dropdown_disk_index},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE, action_get_title_dropdown_item},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION, action_get_title_dropdown_input_description},
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION_KBD, action_get_title_dropdown_input_description_kbd},
{MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS, action_get_quick_menu_views_settings_list},

View File

@ -59,6 +59,7 @@ enum
ACTION_OK_DL_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
ACTION_OK_DL_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME,
ACTION_OK_DL_DROPDOWN_BOX_LIST_DISK_INDEX,
ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE,
ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION,
ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION_KBD,
ACTION_OK_DL_OPEN_ARCHIVE,
@ -244,6 +245,8 @@ int action_right_cheat(unsigned type, const char *label,
void input_keyboard_mapping_bits(unsigned mode, unsigned key);
unsigned libretro_device_get_size(unsigned *devices, size_t devices_size, unsigned port);
/* End of function callbacks */
int menu_cbs_init_bind_left(menu_file_list_cbs_t *cbs,

View File

@ -4037,6 +4037,107 @@ static unsigned menu_displaylist_parse_disk_options(
return count;
}
static int menu_displaylist_parse_input_device_type_list(menu_displaylist_info_t *info)
{
retro_ctx_controller_info_t pad;
const struct retro_controller_description *desc = NULL;
const char *name = NULL;
rarch_system_info_t *system = runloop_get_system_info();
settings_t *settings = config_get_ptr();
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
size_t menu_index = 0;
unsigned count = 0;
unsigned i = 0;
unsigned types = 0;
unsigned port = 0;
unsigned current_device = 0;
unsigned devices[128] = {0};
char device_id[10];
device_id[0] = '\0';
if (!system || !settings || !setting)
goto end;
port = setting->index_offset;
if (port >= MAX_USERS)
goto end;
types = libretro_device_get_size(devices, ARRAY_SIZE(devices), port);
current_device = input_config_get_device(port);
for (i = 0; i < types; i++)
{
snprintf(device_id, sizeof(device_id), "%d", devices[i]);
desc = NULL;
name = NULL;
if (system && port < system->ports.size)
desc = libretro_find_controller_description(
&system->ports.data[port],
devices[i]);
if (desc)
name = desc->desc;
if (!name)
{
/* Find generic name. */
switch (devices[i])
{
case RETRO_DEVICE_NONE:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE);
break;
case RETRO_DEVICE_JOYPAD:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD);
break;
case RETRO_DEVICE_ANALOG:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD_WITH_ANALOG);
break;
default:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN);
break;
}
}
/* Add menu entry */
if (menu_entries_append_enum(info->list,
name,
device_id,
MENU_ENUM_LABEL_INPUT_BIND_DEVICE_TYPE,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DEVICE_TYPE,
0, i))
{
/* Add checkmark if input is currently
* mapped to this entry */
if (current_device == devices[i])
{
menu_entries_set_checked(info->list, menu_index, true);
menu_navigation_set_selection(menu_index);
}
count++;
menu_index++;
}
}
end:
/* Fallback */
if (count == 0)
if (menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
FILE_TYPE_NONE, 0, 0))
count++;
return count;
}
static int menu_displaylist_parse_input_description_list(menu_displaylist_info_t *info)
{
unsigned count = 0;
@ -11051,6 +11152,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
info->need_refresh = true;
info->need_push = true;
break;
case DISPLAYLIST_DROPDOWN_LIST_INPUT_DEVICE_TYPE:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
count = menu_displaylist_parse_input_device_type_list(info);
info->need_refresh = true;
info->need_push = true;
break;
case DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
count = menu_displaylist_parse_input_description_list(info);

View File

@ -67,6 +67,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_CORE_NAME,
DISPLAYLIST_DROPDOWN_LIST_DISK_INDEX,
DISPLAYLIST_DROPDOWN_LIST_INPUT_DEVICE_TYPE,
DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION,
DISPLAYLIST_DROPDOWN_LIST_INPUT_DESCRIPTION_KBD,
DISPLAYLIST_CDROM_DETAIL_INFO,

View File

@ -83,6 +83,7 @@ enum menu_settings_type
MENU_SETTING_DROPDOWN_ITEM_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
MENU_SETTING_DROPDOWN_ITEM_MANUAL_CONTENT_SCAN_CORE_NAME,
MENU_SETTING_DROPDOWN_ITEM_DISK_INDEX,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DEVICE_TYPE,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DESCRIPTION,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DESCRIPTION_KBD,
MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM,

View File

@ -2761,6 +2761,22 @@ static int setting_action_ok_uint(
return 0;
}
static int setting_action_ok_libretro_device_type(
rarch_setting_t *setting, size_t idx, bool wraparound)
{
char enum_idx[16];
if (!setting)
return -1;
snprintf(enum_idx, sizeof(enum_idx), "%d", setting->enum_idx);
generic_action_ok_displaylist_push(
enum_idx, /* we will pass the enumeration index of the string as a path */
NULL, NULL, 0, idx, 0,
ACTION_OK_DL_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE);
return 0;
}
static int setting_string_action_left_string_options(
rarch_setting_t* setting, size_t idx, bool wraparound)
{
@ -5196,7 +5212,7 @@ static int setting_action_left_analog_dpad_mode(
return 0;
}
static unsigned libretro_device_get_size(unsigned *devices, size_t devices_size, unsigned port)
unsigned libretro_device_get_size(unsigned *devices, size_t devices_size, unsigned port)
{
unsigned types = 0;
const struct retro_controller_info *desc = NULL;
@ -7873,12 +7889,13 @@ static bool setting_append_list_input_player_options(
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_left = &setting_action_left_libretro_device_type;
(*list)[list_info->index - 1].action_right = &setting_action_right_libretro_device_type;
(*list)[list_info->index - 1].action_select = &setting_action_right_libretro_device_type;
(*list)[list_info->index - 1].action_start = &setting_action_start_libretro_device_type;
(*list)[list_info->index - 1].action_ok = &setting_action_ok_libretro_device_type;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_uint_libretro_device;
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
@ -7895,8 +7912,8 @@ static bool setting_append_list_input_player_options(
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_left = &setting_action_left_analog_dpad_mode;
(*list)[list_info->index - 1].action_right = &setting_action_right_analog_dpad_mode;
(*list)[list_info->index - 1].action_select = &setting_action_right_analog_dpad_mode;
@ -7940,8 +7957,8 @@ static bool setting_append_list_input_player_options(
&group_info,
&subgroup_info,
parent_group);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_start = &setting_action_start_bind_device;
(*list)[list_info->index - 1].action_left = &setting_action_left_bind_device;
(*list)[list_info->index - 1].action_right = &setting_action_right_bind_device;

View File

@ -1411,6 +1411,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DEVICE_TYPE,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_INPUT_DESCRIPTION_KBD,
MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST,