diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index bd9c2f38bb..c789debb05 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -135,7 +135,7 @@ static int action_left_input_desc(unsigned type, const char *label, { rarch_system_info_t *system = runloop_get_system_info(); settings_t *settings = config_get_ptr(); - unsigned btn_idx, user_idx, remap_idx; + unsigned btn_idx, user_idx, remap_idx, bind_idx; if (!settings || !system) return 0; @@ -146,9 +146,25 @@ static int action_left_input_desc(unsigned type, const char *label, if (settings->uints.input_remap_ids[user_idx][btn_idx] == RARCH_UNMAPPED) settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_CUSTOM_BIND_LIST_END - 1; - if (settings->uints.input_remap_ids[user_idx][btn_idx] > 0) - settings->uints.input_remap_ids[user_idx][btn_idx]--; - else if (settings->uints.input_remap_ids[user_idx][btn_idx] == 0) + remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; + for (bind_idx = 0; bind_idx < RARCH_ANALOG_BIND_LIST_END; bind_idx++) + { + if (input_config_bind_order[bind_idx] == remap_idx) + break; + } + + if (bind_idx > 0) + { + if (bind_idx > RARCH_ANALOG_BIND_LIST_END) + settings->uints.input_remap_ids[user_idx][btn_idx]--; + else + { + bind_idx--; + bind_idx = input_config_bind_order[bind_idx]; + settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx; + } + } + else if (bind_idx == 0) settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; else settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_CUSTOM_BIND_LIST_END - 1; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 8b2f29568c..b3e0947323 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -176,7 +176,7 @@ static int action_right_input_desc(unsigned type, const char *label, { rarch_system_info_t *system = runloop_get_system_info(); settings_t *settings = config_get_ptr(); - unsigned btn_idx, user_idx, remap_idx; + unsigned btn_idx, user_idx, remap_idx, bind_idx; if (!settings || !system) return 0; @@ -184,12 +184,35 @@ static int action_right_input_desc(unsigned type, const char *label, user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; - if (settings->uints.input_remap_ids[user_idx][btn_idx] < RARCH_CUSTOM_BIND_LIST_END - 1) - settings->uints.input_remap_ids[user_idx][btn_idx]++; - else if (settings->uints.input_remap_ids[user_idx][btn_idx] == RARCH_CUSTOM_BIND_LIST_END - 1) + remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; + for (bind_idx = 0; bind_idx < RARCH_ANALOG_BIND_LIST_END; bind_idx++) + { + if (input_config_bind_order[bind_idx] == remap_idx) + break; + } + + if (bind_idx < RARCH_CUSTOM_BIND_LIST_END - 1) + { + if (bind_idx > RARCH_ANALOG_BIND_LIST_END) + settings->uints.input_remap_ids[user_idx][btn_idx]++; + else + { + if (bind_idx < RARCH_ANALOG_BIND_LIST_END - 1) + { + bind_idx++; + bind_idx = input_config_bind_order[bind_idx]; + } + else if (bind_idx == RARCH_ANALOG_BIND_LIST_END - 1) + bind_idx = RARCH_UNMAPPED; + else + bind_idx = input_config_bind_order[0]; + settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx; + } + } + else if (bind_idx == RARCH_CUSTOM_BIND_LIST_END - 1) settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; else - settings->uints.input_remap_ids[user_idx][btn_idx] = 0; + settings->uints.input_remap_ids[user_idx][btn_idx] = input_config_bind_order[0]; remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index f0d7c66300..0e1948a65f 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -170,6 +170,8 @@ static int action_scan_input_desc(const char *path, inp_desc_user = atoi(label); /* Skip 'Device Type' and 'Analog to Digital Type' */ key = (unsigned)(idx - 2); + /* Select the reorderer bind */ + key = input_config_bind_order[key]; if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN && type <= MENU_SETTINGS_INPUT_DESC_END) diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index e12735da04..54588032eb 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -521,28 +521,44 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone, while (type > (input_id + 15)) input_id = (input_id + 16); } + + /* Human readable bind order */ + if (type < (input_id + RARCH_ANALOG_BIND_LIST_END)) + { + unsigned index = 0; + int input_num = type - input_id; + for (index = 0; index < sizeof(input_config_bind_order); index++) + { + if (input_config_bind_order[index] == input_num) + { + type = input_id + index; + break; + } + } + } } + /* This is utilized for both Input Binds and Quickmenu controls*/ - if (type == input_id ) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D]; - if (type == (input_id + 1)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L]; - if (type == (input_id + 2)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_SELECT]; - if (type == (input_id + 3)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_START]; - if (type == (input_id + 4)) + if (type == input_id) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_U]; - if (type == (input_id + 5)) + if (type == (input_id + 1)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_D]; - if (type == (input_id + 6)) + if (type == (input_id + 2)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_L]; - if (type == (input_id + 7)) + if (type == (input_id + 3)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_R]; - if (type == (input_id + 8)) + if (type == (input_id + 4)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R]; - if (type == (input_id + 9)) + if (type == (input_id + 5)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D]; + if (type == (input_id + 6)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U]; + if (type == (input_id + 7)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L]; + if (type == (input_id + 8)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_SELECT]; + if (type == (input_id + 9)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_START]; if (type == (input_id + 10)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_LB]; if (type == (input_id + 11)) @@ -556,21 +572,21 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone, if (type == (input_id + 15)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_P]; if (type == (input_id + 16)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_R]; + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_U]; if (type == (input_id + 17)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_L]; + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_D]; if (type == (input_id + 18)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_D]; - if (type == (input_id + 19)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_U]; - if (type == (input_id + 20)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_R]; - if (type == (input_id + 21)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_L]; - if (type == (input_id + 22)) - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_D]; - if (type == (input_id + 23)) + if (type == (input_id + 19)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_R]; + if (type == (input_id + 20)) return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_U]; + if (type == (input_id + 21)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_D]; + if (type == (input_id + 22)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_L]; + if (type == (input_id + 23)) + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_R]; } if ( diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a5da529592..dda8a32a7a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2944,56 +2944,72 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, while (type > (input_id + 15)) input_id = (input_id + 16); } + + /* Human readable bind order */ + if (type < (input_id + RARCH_ANALOG_BIND_LIST_END)) + { + unsigned index = 0; + int input_num = type - input_id; + for (index = 0; index < sizeof(input_config_bind_order); index++) + { + if (input_config_bind_order[index] == input_num) + { + type = input_id + index; + break; + } + } + } } + /* This is utilized for both Input # Binds and Quickmenu controls */ - if ( type == input_id ) - return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_D]; - if ( type == (input_id + 1)) - return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_L]; - if ( type == (input_id + 2)) - return xmb->textures.list[XMB_TEXTURE_INPUT_SELECT]; - if ( type == (input_id + 3)) - return xmb->textures.list[XMB_TEXTURE_INPUT_START]; - if ( type == (input_id + 4)) + if (type == input_id) return xmb->textures.list[XMB_TEXTURE_INPUT_DPAD_U]; - if ( type == (input_id + 5)) + if (type == (input_id + 1)) return xmb->textures.list[XMB_TEXTURE_INPUT_DPAD_D]; - if ( type == (input_id + 6)) + if (type == (input_id + 2)) return xmb->textures.list[XMB_TEXTURE_INPUT_DPAD_L]; - if ( type == (input_id + 7)) + if (type == (input_id + 3)) return xmb->textures.list[XMB_TEXTURE_INPUT_DPAD_R]; - if ( type == (input_id + 8)) + if (type == (input_id + 4)) return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_R]; - if ( type == (input_id + 9)) + if (type == (input_id + 5)) + return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_D]; + if (type == (input_id + 6)) return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_U]; - if ( type == (input_id + 10)) + if (type == (input_id + 7)) + return xmb->textures.list[XMB_TEXTURE_INPUT_BTN_L]; + if (type == (input_id + 8)) + return xmb->textures.list[XMB_TEXTURE_INPUT_SELECT]; + if (type == (input_id + 9)) + return xmb->textures.list[XMB_TEXTURE_INPUT_START]; + if (type == (input_id + 10)) return xmb->textures.list[XMB_TEXTURE_INPUT_LB]; - if ( type == (input_id + 11)) + if (type == (input_id + 11)) return xmb->textures.list[XMB_TEXTURE_INPUT_RB]; - if ( type == (input_id + 12)) + if (type == (input_id + 12)) return xmb->textures.list[XMB_TEXTURE_INPUT_LT]; - if ( type == (input_id + 13)) + if (type == (input_id + 13)) return xmb->textures.list[XMB_TEXTURE_INPUT_RT]; - if ( type == (input_id + 14)) + if (type == (input_id + 14)) return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_P]; - if ( type == (input_id + 15)) + if (type == (input_id + 15)) return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_P]; - if ( type == (input_id + 16)) - return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_R]; - if ( type == (input_id + 17)) - return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_L]; - if ( type == (input_id + 18)) - return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_D]; - if ( type == (input_id + 19)) + if (type == (input_id + 16)) return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_U]; - if ( type == (input_id + 20)) - return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_R]; - if ( type == (input_id + 21)) - return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_L]; - if ( type == (input_id + 22)) + if (type == (input_id + 17)) return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_D]; - if ( type == (input_id + 23)) + if (type == (input_id + 18)) + return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_L]; + if (type == (input_id + 19)) + return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_R]; + if (type == (input_id + 20)) return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_U]; + if (type == (input_id + 21)) + return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_D]; + if (type == (input_id + 22)) + return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_L]; + if (type == (input_id + 23)) + return xmb->textures.list[XMB_TEXTURE_INPUT_STCK_R]; } if ( diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 2cb88a4789..7d8e0140a4 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4340,7 +4340,7 @@ static int menu_displaylist_parse_input_description_list(menu_displaylist_info_t unsigned user_idx; unsigned btn_idx; unsigned current_remap_idx; - size_t i; + size_t i, j; char entry_label[21]; entry_label[0] = '\0'; @@ -4372,9 +4372,12 @@ static int menu_displaylist_parse_input_description_list(menu_displaylist_info_t "%u", info->type); /* Loop over core input definitions */ - for (i = 0; i < RARCH_CUSTOM_BIND_LIST_END; i++) + for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++) { - const char *input_desc_btn = system->input_desc_btn[user_idx][i]; + const char *input_desc_btn; + + i = (j < RARCH_ANALOG_BIND_LIST_END) ? input_config_bind_order[j] : j; + input_desc_btn = system->input_desc_btn[user_idx][i]; /* Check whether an input is defined for * this button */ @@ -9380,14 +9383,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, } { - unsigned retro_id; + unsigned retro_id, j; unsigned device = settings->uints.input_libretro_device[p]; device &= RETRO_DEVICE_MASK; if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG) { - for (retro_id = 0; retro_id < RARCH_ANALOG_BIND_LIST_END; retro_id++) + for (j = 0; j < RARCH_ANALOG_BIND_LIST_END; j++) { + retro_id = (j < RARCH_ANALOG_BIND_LIST_END) ? input_config_bind_order[j] : j; + char desc_label[400]; char descriptor[300]; const struct retro_keybind *keybind = @@ -9423,14 +9428,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (menu_entries_append_enum(list, descriptor, info->path, MSG_UNKNOWN, MENU_SETTINGS_INPUT_DESC_BEGIN + - (p * (RARCH_FIRST_CUSTOM_BIND + 8)) + retro_id, 0, 0)) + (p * (RARCH_FIRST_CUSTOM_BIND + 8)) + retro_id, 0, 0)) count++; } } else if (device == RETRO_DEVICE_KEYBOARD) { - for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND; retro_id++) + for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++) { + retro_id = (j < RARCH_ANALOG_BIND_LIST_END) ? input_config_bind_order[j] : j; + char desc_label[400]; char descriptor[300]; const struct retro_keybind *keybind = diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c3b48dcea6..4c7693994d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -7826,7 +7826,7 @@ static bool setting_append_list_input_player_options( */ static char buffer[MAX_USERS][13+2+1]; static char group_lbl[MAX_USERS][255]; - unsigned i; + unsigned i, j; rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); @@ -8084,8 +8084,10 @@ static bool setting_append_list_input_player_options( #endif } - for (i = 0; i < RARCH_BIND_LIST_END; i ++) + for (j = 0; j < RARCH_BIND_LIST_END; j++) { + i = (j < RARCH_ANALOG_BIND_LIST_END) ? input_config_bind_order[j] : j; + char label[255]; char name[255]; diff --git a/retroarch.h b/retroarch.h index 5e8e7a513f..3b49adb24a 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1987,6 +1987,34 @@ void input_driver_init_joypads(void); void *input_driver_init_wrap(input_driver_t *input, const char *name); +/* Human readable order of input binds */ +static const unsigned input_config_bind_order[] = { + RETRO_DEVICE_ID_JOYPAD_UP, + RETRO_DEVICE_ID_JOYPAD_DOWN, + RETRO_DEVICE_ID_JOYPAD_LEFT, + RETRO_DEVICE_ID_JOYPAD_RIGHT, + RETRO_DEVICE_ID_JOYPAD_A, + RETRO_DEVICE_ID_JOYPAD_B, + RETRO_DEVICE_ID_JOYPAD_X, + RETRO_DEVICE_ID_JOYPAD_Y, + RETRO_DEVICE_ID_JOYPAD_SELECT, + RETRO_DEVICE_ID_JOYPAD_START, + RETRO_DEVICE_ID_JOYPAD_L, + RETRO_DEVICE_ID_JOYPAD_R, + RETRO_DEVICE_ID_JOYPAD_L2, + RETRO_DEVICE_ID_JOYPAD_R2, + RETRO_DEVICE_ID_JOYPAD_L3, + RETRO_DEVICE_ID_JOYPAD_R3, + 19, /* Left Analog Up */ + 18, /* Left Analog Down */ + 17, /* Left Analog Left */ + 16, /* Left Analog Right */ + 23, /* Right Analog Up */ + 22, /* Right Analog Down */ + 21, /* Right Analog Left */ + 20, /* Right Analog Right */ +}; + /* Creates folder and core options stub file for subsequent runs */ bool core_options_create_override(bool game_specific); bool core_options_remove_override(bool game_specific);