Merge pull request #12156 from sonninnos/bind-reorder

Cosmetic input bind order
This commit is contained in:
Autechre 2021-03-16 12:43:02 +01:00 committed by GitHub
commit 70d79eb01c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 186 additions and 76 deletions

View File

@ -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;

View File

@ -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];

View File

@ -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)

View File

@ -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 (

View File

@ -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 (

View File

@ -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 =

View File

@ -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];

View File

@ -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);