Skip to content

Commit

Permalink
Reserve space for extra binds in the bind table.
Browse files Browse the repository at this point in the history
  • Loading branch information
XerTheSquirrel committed Dec 23, 2023
1 parent f236b44 commit b6ee6d9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
9 changes: 9 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT),

DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK),

/* Extra binds are here, but they have no actual bind or menu binding visible!
* These binds cannot be bound at all and are entirely virtualized.
* These are respectively @c RARCH_BIND_ID_EXTRA_BUTTON_START and
* the end point is @c RARCH_BIND_ID_EXTRA_BUTTON_END... */
#if 0
/* Deprecated */
DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO),
Expand Down Expand Up @@ -6093,6 +6098,10 @@ bool input_config_bind_map_get_valid(unsigned bind_index)

unsigned input_config_bind_map_get_meta(unsigned bind_index)
{
/* Binds for extra keys are never mappable in any way. */
if (bind_index >= RARCH_BIND_ID_EXTRA_BUTTON_START && bind_index <= RARCH_BIND_ID_EXTRA_BUTTON_END)
return 0;

const struct input_bind_map *keybind =
(const struct input_bind_map*)INPUT_CONFIG_BIND_MAP_GET(bind_index);
if (!keybind)
Expand Down
8 changes: 8 additions & 0 deletions input/input_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END
#define RARCH_FIRST_META_KEY RARCH_CUSTOM_BIND_LIST_END

/** Static extra button count, must match the value of @c RARCH_MAX_EXTRA_BUTTON !
* This is because core.h is included before libretro.h and this needs to be shared... */
#define RARCH_STATIC_MAX_EXTRA_BUTTON 232

#define RARCH_MAX_EXTRA_BUTTON (RETRO_DEVICE_ID_JOYPAD_MASK - RETRO_DEVICE_ID_JOYPAD_MAX_BUTTONS)
#define RARCH_EXTRA_BUTTON_ID(id) (RETRO_DEVICE_ID_JOYPAD_MAX_BUTTONS + (id))

Expand Down Expand Up @@ -192,6 +196,10 @@ enum
RARCH_OVERLAY_NEXT,
RARCH_OSK,

/* Extra button mappings, these are just virtual buttons and have no meaningful binds for them. */
RARCH_BIND_ID_EXTRA_BUTTON_START,
RARCH_BIND_ID_EXTRA_BUTTON_END = RARCH_BIND_ID_EXTRA_BUTTON_START + RARCH_STATIC_MAX_EXTRA_BUTTON,

RARCH_BIND_LIST_END,

/* Deprecated */
Expand Down
10 changes: 6 additions & 4 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@
if (SETTINGS_LIST_APPEND(a, b)) \
config_hex(a, b, c, d, e, f, g, h, i, j, k, l)

#define CONFIG_BIND_ALT(a, b, c, d, e, f, g, h, i, j, k) \
if (SETTINGS_LIST_APPEND(a, b)) \
config_bind_alt(a, b, c, d, e, f, g, h, i, j, k)
#define CONFIG_BIND_ALT(list, list_info, target, player, player_offset, name, SHORT, default_value, group_info, subgroup_info, parent_group) \
if (SETTINGS_LIST_APPEND(list, list_info)) \
config_bind_alt(list, list_info, target, player, player_offset, name, SHORT, default_value, group_info, subgroup_info, parent_group)

#define CONFIG_BIND(a, b, c, d, e, f, g, h, i, j, k, l) \
if (SETTINGS_LIST_APPEND(a, b)) \
Expand Down Expand Up @@ -9258,12 +9258,14 @@ static bool setting_append_list_input_player_options(
{
char label[NAME_MAX_LENGTH];
char name[NAME_MAX_LENGTH];
bool isExtraKey = (j >= RARCH_BIND_ID_EXTRA_BUTTON_START && j < RARCH_BIND_ID_EXTRA_BUTTON_END);
size_t _len = 0;

i = (j < RARCH_ANALOG_BIND_LIST_END)
? input_config_bind_order[j]
: j;

if (input_config_bind_map_get_meta(i))
if (!isExtraKey && input_config_bind_map_get_meta(i))
continue;

name[0] = '\0';
Expand Down

0 comments on commit b6ee6d9

Please sign in to comment.