From 34649d1abf25c422e439a5f864a20e3f11fdb063 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 31 Mar 2018 11:13:00 -0500 Subject: [PATCH] remap-redux part 2: start inverting the gamepad mapper columns --- input/input_defines.h | 2 + menu/cbs/menu_cbs_get_value.c | 78 ++++++++++++++++------------------- menu/menu_cbs.c | 2 +- menu/menu_displaylist.c | 61 ++++++++++++++++----------- menu/menu_driver.h | 2 +- 5 files changed, 76 insertions(+), 69 deletions(-) diff --git a/input/input_defines.h b/input/input_defines.h index 91f14d2766..4f203d4f46 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -28,6 +28,8 @@ RETRO_BEGIN_DECLS #define MAX_INPUT_DEVICES 16 +#define MAX_KEYS 136 + #define RARCH_FIRST_CUSTOM_BIND 16 #define RARCH_FIRST_LIGHTGUN_BIND RARCH_ANALOG_BIND_LIST_END #define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index bd764c518b..36f35b5092 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -547,72 +547,60 @@ static void menu_action_setting_disp_set_label_input_desc( const char *path, char *s2, size_t len2) { - char descriptor[255]; + rarch_system_info_t *system = NULL; + const char* descriptor = NULL; const struct retro_keybind *auto_bind = NULL; const struct retro_keybind *keybind = NULL; settings_t *settings = config_get_ptr(); unsigned inp_desc_index_offset = type - MENU_SETTINGS_INPUT_DESC_BEGIN; unsigned inp_desc_user = inp_desc_index_offset / - (RARCH_FIRST_CUSTOM_BIND + 4); + (RARCH_FIRST_CUSTOM_BIND + 8); unsigned inp_desc_button_index_offset = inp_desc_index_offset - - (inp_desc_user * (RARCH_FIRST_CUSTOM_BIND + 4)); + (inp_desc_user * (RARCH_FIRST_CUSTOM_BIND + 8)); unsigned remap_id = 0; - if (!settings) + system = runloop_get_system_info(); + + if (!system) return; - descriptor[0] = '\0'; - - remap_id = settings->uints.input_remap_ids - [inp_desc_user][inp_desc_button_index_offset]; - - keybind = &input_config_binds[inp_desc_user][remap_id]; - auto_bind = (const struct retro_keybind*) - input_config_get_bind_auto(inp_desc_user, remap_id); - - input_config_get_bind_string(descriptor, - keybind, auto_bind, sizeof(descriptor)); - - if (inp_desc_button_index_offset < RARCH_FIRST_CUSTOM_BIND) - { - if(strstr(descriptor, "Auto") && !strstr(descriptor, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE))) - strlcpy(s, - descriptor, - len); - else - { - const struct retro_keybind *keyptr = &input_config_binds[inp_desc_user] - [remap_id]; - - strlcpy(s, msg_hash_to_str(keyptr->enum_idx), len); - } - } - - + descriptor = system->input_desc_btn[inp_desc_user][inp_desc_button_index_offset]; + if (inp_desc_button_index_offset < RARCH_FIRST_CUSTOM_BIND + 8) + strlcpy(s, descriptor ? descriptor : "---", len); else { - const char *str = NULL; switch (remap_id) { case 0: - str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X); + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS); break; case 1: - str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y); + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS); break; case 2: - str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X); + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS); break; case 3: - str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y); + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS); + break; + case 4: + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS); + break; + case 5: + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS); + break; + case 6: + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS); + break; + case 7: + descriptor = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS); break; } - if (!string_is_empty(str)) - strlcpy(s, str, len); + if (!string_is_empty(descriptor)) + strlcpy(s, descriptor, len); } *w = 19; @@ -654,8 +642,14 @@ static void menu_action_setting_disp_set_label_input_desc_kbd( if(remap_id == key_descriptors[key_id].key) break; } - snprintf(desc, sizeof(desc), "Keyboard %s", key_descriptors[key_id].desc); - strlcpy(s, desc, len); + + if (key_descriptors[key_id].key != RETROK_FIRST) + { + snprintf(desc, sizeof(desc), "Keyboard %s", key_descriptors[key_id].desc); + strlcpy(s, desc, len); + } + else + strlcpy(s, "---", len); *w = 19; strlcpy(s2, path, len2); diff --git a/menu/menu_cbs.c b/menu/menu_cbs.c index 28dd055114..230839574e 100644 --- a/menu/menu_cbs.c +++ b/menu/menu_cbs.c @@ -32,7 +32,7 @@ static void menu_cbs_init_log(const char *entry_label, const char *bind_label, c #endif } -struct key_desc key_descriptors[MENU_SETTINGS_INPUT_DESC_KBD_END] = +struct key_desc key_descriptors[136] = { {RETROK_FIRST, "Unmapped"}, {RETROK_BACKSPACE, "Backspace"}, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 207ea58981..b3ba5fb744 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3240,33 +3240,44 @@ static int menu_displaylist_parse_options_remappings( if (system) { + settings_t *settings = config_get_ptr(); + unsigned device; for (p = 0; p < max_users; p++) { - for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 4; retro_id++) + device = settings->uints.input_libretro_device[p]; + device &= RETRO_DEVICE_MASK; + + if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG) { - char desc_label[64]; - unsigned user = p + 1; - unsigned desc_offset = retro_id; - const char *description = NULL; + for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 8; retro_id++) + { + char desc_label[64]; + unsigned user = p + 1; + unsigned desc_offset = retro_id; + char descriptor[255]; + const struct retro_keybind *auto_bind = NULL; + const struct retro_keybind *keybind = NULL; - desc_label[0] = '\0'; + keybind = &input_config_binds[p][retro_id]; + auto_bind = (const struct retro_keybind*) + input_config_get_bind_auto(p, retro_id); - if (desc_offset >= RARCH_FIRST_CUSTOM_BIND) - desc_offset = RARCH_FIRST_CUSTOM_BIND - + (desc_offset - RARCH_FIRST_CUSTOM_BIND) * 2; + input_config_get_bind_string(descriptor, + keybind, auto_bind, sizeof(descriptor)); - description = system->input_desc_btn[p][desc_offset]; + if(!strstr(descriptor, "Auto")) + { + const struct retro_keybind *keyptr = + &input_config_binds[p][retro_id]; - if (!description) - continue; + strlcpy(descriptor, msg_hash_to_str(keyptr->enum_idx), sizeof(descriptor)); + } - snprintf(desc_label, sizeof(desc_label), - "%s %u %s : ", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USER), - user, description); - menu_entries_append_enum(info->list, desc_label, "", - MSG_UNKNOWN, - MENU_SETTINGS_INPUT_DESC_BEGIN + - (p * (RARCH_FIRST_CUSTOM_BIND + 4)) + retro_id, 0, 0); + menu_entries_append_enum(info->list, descriptor, "", + MSG_UNKNOWN, + MENU_SETTINGS_INPUT_DESC_BEGIN + + (p * (RARCH_FIRST_CUSTOM_BIND + 8)) + retro_id, 0, 0); + } } } } @@ -3276,9 +3287,9 @@ static int menu_displaylist_parse_options_remappings( settings_t *settings = config_get_ptr(); unsigned device; - for (int i = 0; i < MAX_USERS; i++) + for (p = 0; p < MAX_USERS; p++) { - device = settings->uints.input_libretro_device[i]; + device = settings->uints.input_libretro_device[p]; device &= RETRO_DEVICE_MASK; if (device == RETRO_DEVICE_KEYBOARD) @@ -3291,9 +3302,9 @@ static int menu_displaylist_parse_options_remappings( const struct retro_keybind *auto_bind = NULL; const struct retro_keybind *keybind = NULL; - keybind = &input_config_binds[i][retro_id]; + keybind = &input_config_binds[p][retro_id]; auto_bind = (const struct retro_keybind*) - input_config_get_bind_auto(i, retro_id); + input_config_get_bind_auto(p, retro_id); input_config_get_bind_string(descriptor, keybind, auto_bind, sizeof(descriptor)); @@ -3301,14 +3312,14 @@ static int menu_displaylist_parse_options_remappings( if(!strstr(descriptor, "Auto")) { const struct retro_keybind *keyptr = - &input_config_binds[i][retro_id]; + &input_config_binds[p][retro_id]; strlcpy(descriptor, msg_hash_to_str(keyptr->enum_idx), sizeof(descriptor)); } menu_entries_append_enum(info->list, descriptor, "", MSG_UNKNOWN, - (MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + retro_id) * (i + 1), 0, 0); + (MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + retro_id) * (p + 1), 0, 0); } } } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index a18bf606b3..c4df110eb8 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -208,7 +208,7 @@ enum menu_settings_type MENU_SETTINGS_INPUT_DESC_BEGIN, MENU_SETTINGS_INPUT_DESC_END = MENU_SETTINGS_INPUT_DESC_BEGIN + (MAX_USERS * (RARCH_FIRST_CUSTOM_BIND + 4)), MENU_SETTINGS_INPUT_DESC_KBD_BEGIN, - MENU_SETTINGS_INPUT_DESC_KBD_END = (MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 135) * MAX_USERS, + MENU_SETTINGS_INPUT_DESC_KBD_END = (MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 136) * MAX_USERS, MENU_SETTINGS_SUBSYSTEM_LOAD,