Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions input/input_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define RARCH_FIRST_META_KEY RARCH_CUSTOM_BIND_LIST_END

#define RARCH_UNMAPPED 1024
#define RARCH_NO_BIND "---"

/* Specialized _MOUSE that targets the full screen regardless of viewport.
*/
Expand Down
2 changes: 1 addition & 1 deletion input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -3941,7 +3941,7 @@ size_t input_config_get_bind_string(

/*completely empty?*/
if (*s == '\0')
_len += strlcpy(s + _len, "---", len - _len);
_len += strlcpy(s + _len, RARCH_NO_BIND, len - _len);
return _len;
}

Expand Down
4 changes: 2 additions & 2 deletions menu/cbs/menu_cbs_get_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ static size_t menu_action_setting_disp_set_label_input_desc(
}
}
/* If descriptor was not found, set this instead */
return strlcpy(s, "---", len);
return strlcpy(s, RARCH_NO_BIND, len);
}

static size_t menu_action_setting_disp_set_label_input_desc_kbd(
Expand Down Expand Up @@ -860,7 +860,7 @@ static size_t menu_action_setting_disp_set_label_input_desc_kbd(
_len += strlcpy(s + _len, key_descriptors[key_id].desc, len - _len);
}
else
_len = strlcpy(s, "---", len);
_len = strlcpy(s, RARCH_NO_BIND, len);

*w = 19;

Expand Down
71 changes: 33 additions & 38 deletions menu/cbs/menu_cbs_left.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,60 +136,56 @@ static int action_left_cheat(unsigned type, const char *label,
#endif

static int action_left_input_desc(unsigned type, const char *label,
bool wraparound)
bool wraparound)
{
unsigned user_idx;
unsigned btn_idx;
unsigned remap_idx;
unsigned bind_idx;
unsigned mapped_port;
settings_t *settings = config_get_ptr();
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;

if (!settings || !sys_info)
return 0;

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;
mapped_port = settings->uints.input_remap_ports[user_idx];
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;
}
settings_t *settings = config_get_ptr();
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;

/* Search for the last input desc bind */
if (remap_idx == RARCH_UNMAPPED)
if (settings && sys_info)
{
uint8_t i;
unsigned bind_idx;
unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx;
unsigned mapped_port = settings->uints.input_remap_ports[user_idx];
unsigned remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx];

for (i = 0; i < RARCH_ANALOG_BIND_LIST_END; i++)
for (bind_idx = 0; bind_idx < RARCH_ANALOG_BIND_LIST_END; bind_idx++)
{
if (string_is_empty(sys_info->input_desc_btn[mapped_port][i]))
if (input_config_bind_order[bind_idx] == remap_idx)
break;
}
settings->uints.input_remap_ids[user_idx][btn_idx] = input_config_bind_order[i - 1];
}
else if (bind_idx > 0)
{
if (bind_idx > RARCH_ANALOG_BIND_LIST_END)
settings->uints.input_remap_ids[user_idx][btn_idx]--;
else

/* If pressed from unmapped bind, start from the bottom */
if (label)
{
struct menu_state *menu_st = menu_state_get_ptr();
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
if (string_is_equal(entry.value, RARCH_NO_BIND))
bind_idx = RARCH_ANALOG_BIND_LIST_END;
}

if (bind_idx > 0)
{
bind_idx--;
bind_idx = input_config_bind_order[bind_idx];
settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx;

/* Skip empty descs */
if (string_is_empty(sys_info->input_desc_btn[mapped_port][bind_idx]))
return action_left_input_desc(type, NULL, wraparound);
}
else
settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED;
}
else if (bind_idx == 0)
settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED;

return 0;
}

static int action_left_input_desc_kbd(unsigned type, const char *label,
bool wraparound)
bool wraparound)
{
unsigned remap_id;
unsigned key_id, user_idx, btn_idx;
Expand All @@ -201,8 +197,7 @@ static int action_left_input_desc_kbd(unsigned type, const char *label,
user_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) / RARCH_ANALOG_BIND_LIST_END;
btn_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) - RARCH_ANALOG_BIND_LIST_END * user_idx;

remap_id =
settings->uints.input_keymapper_ids[user_idx][btn_idx];
remap_id = settings->uints.input_keymapper_ids[user_idx][btn_idx];

for (key_id = 0; key_id < RARCH_MAX_KEYS; key_id++)
{
Expand Down
97 changes: 52 additions & 45 deletions menu/cbs/menu_cbs_right.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,57 @@ static int action_right_cheat_num_passes(unsigned type, const char *label,
}
#endif

static int action_right_input_desc(unsigned type, const char *label,
bool wraparound)
{
settings_t *settings = config_get_ptr();
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;

if (settings && sys_info)
{
unsigned bind_idx;
unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx;
unsigned mapped_port = settings->uints.input_remap_ports[user_idx];
unsigned 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 pressed from unmapped bind, start from the top */
if (label)
{
struct menu_state *menu_st = menu_state_get_ptr();
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
if (string_is_equal(entry.value, RARCH_NO_BIND))
bind_idx = RARCH_UNMAPPED;
}

if (bind_idx < RARCH_ANALOG_BIND_LIST_END - 1)
{
bind_idx++;
bind_idx = input_config_bind_order[bind_idx];
settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx;

/* Skip empty descs */
if (string_is_empty(sys_info->input_desc_btn[mapped_port][bind_idx]))
return action_right_input_desc(type, NULL, wraparound);
}
else if (bind_idx == RARCH_ANALOG_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] = input_config_bind_order[0];
}

return 0;
}

static int action_right_input_desc_kbd(unsigned type, const char *label,
bool wraparound)
{
Expand All @@ -152,8 +203,7 @@ static int action_right_input_desc_kbd(unsigned type, const char *label,
user_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) / RARCH_ANALOG_BIND_LIST_END;
btn_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) - RARCH_ANALOG_BIND_LIST_END * user_idx;

remap_id =
settings->uints.input_keymapper_ids[user_idx][btn_idx];
remap_id = settings->uints.input_keymapper_ids[user_idx][btn_idx];

for (key_id = 0; key_id < RARCH_MAX_KEYS; key_id++)
{
Expand All @@ -171,49 +221,6 @@ static int action_right_input_desc_kbd(unsigned type, const char *label,
return 0;
}

static int action_right_input_desc(unsigned type, const char *label,
bool wraparound)
{
settings_t *settings = config_get_ptr();
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;
if (settings && sys_info)
{
unsigned bind_idx;
unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx;
unsigned mapped_port = settings->uints.input_remap_ports[user_idx];
unsigned 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_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;
}

/* Empty is always last, so right jumps to first */
if (string_is_empty(sys_info->input_desc_btn[mapped_port][remap_idx]))
settings->uints.input_remap_ids[user_idx][btn_idx] = input_config_bind_order[0];
}

return 0;
}

static int action_right_scroll(unsigned type, const char *label,
bool wraparound)
{
Expand Down
57 changes: 25 additions & 32 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -5751,7 +5751,7 @@ static int menu_displaylist_parse_input_retropad_bind_list(
return 0;

if (turbo_bind && menu_entries_append(info_list,
"---",
RARCH_NO_BIND,
"-1",
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_DROPDOWN_ITEM_INPUT_RETROPAD_BIND,
Expand Down Expand Up @@ -6134,7 +6134,6 @@ static int menu_displaylist_parse_input_description_list(
unsigned count = 0;
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;
size_t menu_index = 0;
bool current_input_mapped = false;
struct menu_state *menu_st = menu_state_get_ptr();

entry_lbl[0] = '\0';
Expand All @@ -6157,8 +6156,8 @@ static int menu_displaylist_parse_input_description_list(

/* Get current mapping for selected button */
current_remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx];

if (current_remap_idx >= RARCH_CUSTOM_BIND_LIST_END)
if ( current_remap_idx >= RARCH_CUSTOM_BIND_LIST_END
|| string_is_empty(sys_info->input_desc_btn[mapped_port][current_remap_idx]))
current_remap_idx = RARCH_UNMAPPED;

/* An annoyance: Menu entries do not have
Expand All @@ -6170,6 +6169,27 @@ static int menu_displaylist_parse_input_description_list(
* and pass it as the entry label... */
snprintf(entry_lbl, sizeof(entry_lbl), "%u", info->type);

/* Add 'unmapped' entry */
if (menu_entries_append(info->list,
RARCH_NO_BIND,
entry_lbl,
MENU_ENUM_LABEL_INPUT_DESCRIPTION,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DESCRIPTION,
0, RARCH_UNMAPPED, NULL))
{
/* Add checkmark if input is currently unmapped */
if (current_remap_idx == RARCH_UNMAPPED)
{
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)info->list->list[menu_index].actiondata;
if (cbs)
cbs->checked = true;
menu_st->selection_ptr = menu_index;
}

count++;
menu_index++;
}

/* Loop over core input definitions */
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
{
Expand Down Expand Up @@ -6219,7 +6239,6 @@ static int menu_displaylist_parse_input_description_list(
if (cbs)
cbs->checked = true;
menu_st->selection_ptr = menu_index;
current_input_mapped = true;
}

count++;
Expand All @@ -6228,27 +6247,6 @@ static int menu_displaylist_parse_input_description_list(
}
}

/* Add 'unmapped' entry at end of list */
if (menu_entries_append(info->list,
"---",
entry_lbl,
MENU_ENUM_LABEL_INPUT_DESCRIPTION,
MENU_SETTING_DROPDOWN_ITEM_INPUT_DESCRIPTION,
0, RARCH_UNMAPPED, NULL))
{
/* Add checkmark if input is currently unmapped */
if (!current_input_mapped)
{
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)info->list->list[menu_index].actiondata;
if (cbs)
cbs->checked = true;
menu_st->selection_ptr = menu_index;
}

count++;
menu_index++;
}

return count;
}

Expand Down Expand Up @@ -6337,12 +6335,7 @@ static int menu_displaylist_parse_input_description_kbd_list(
continue;

if (key_id == RETROK_FIRST)
{
input_description[0] = '-';
input_description[1] = '-';
input_description[2] = '-';
input_description[3] = '\0';
}
strlcpy(input_description, RARCH_NO_BIND, sizeof(input_description));
else
{
/* TODO/FIXME: Localize 'Keyboard' */
Expand Down
2 changes: 1 addition & 1 deletion menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -6866,7 +6866,7 @@ static size_t setting_get_string_representation_retropad_bind(
int retro_id = *setting->value.target.integer;

if (retro_id < 0)
return strlcpy(s, "---", len);
return strlcpy(s, RARCH_NO_BIND, len);
else
{
const struct retro_keybind *keyptr =
Expand Down
Loading