Back out change supporting multiple names for binding elements

testcontroller expects to be able to call SDL_GetGamepadStringForButton() and find that name in the binding string

We can revisit this later if it becomes important to use new names in bindings. @smcv
main
Sam Lantinga 2023-08-09 11:25:37 -07:00
parent efe15588d5
commit dabd45997e
1 changed files with 25 additions and 27 deletions

View File

@ -1105,31 +1105,29 @@ const char *SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis)
} }
static const char *map_StringForGamepadButton[] = { static const char *map_StringForGamepadButton[] = {
"a", NULL, "a",
"b", NULL, "b",
"x", NULL, "x",
"y", NULL, "y",
"back", NULL, "back",
"guide", NULL, "guide",
"start", NULL, "start",
"leftstick", NULL, "leftstick",
"rightstick", NULL, "rightstick",
"leftshoulder", NULL, "leftshoulder",
"rightshoulder", NULL, "rightshoulder",
"dpup", NULL, "dpup",
"dpdown", NULL, "dpdown",
"dpleft", NULL, "dpleft",
"dpright", NULL, "dpright",
"misc1", NULL, "misc1",
/* Keep using paddle1-4 when we generate mapping strings so that they "paddle1",
* can be reused with SDL2, but accept rightpaddle1 etc. as input */ "paddle2",
"paddle1", "rightpaddle1", "paddle3",
"paddle2", "leftpaddle1", "paddle4",
"paddle3", "rightpaddle2", "touchpad"
"paddle4", "leftpaddle2",
"touchpad", NULL
}; };
SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == 2 * SDL_GAMEPAD_BUTTON_MAX); SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == SDL_GAMEPAD_BUTTON_MAX);
/* /*
* convert a string to its enum equivalent * convert a string to its enum equivalent
@ -1143,8 +1141,8 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str)
} }
for (i = 0; i < SDL_arraysize(map_StringForGamepadButton); ++i) { for (i = 0; i < SDL_arraysize(map_StringForGamepadButton); ++i) {
if (map_StringForGamepadButton[i] && SDL_strcasecmp(str, map_StringForGamepadButton[i]) == 0) { if (SDL_strcasecmp(str, map_StringForGamepadButton[i]) == 0) {
return (SDL_GamepadButton) (i / 2); return (SDL_GamepadButton)i;
} }
} }
return SDL_GAMEPAD_BUTTON_INVALID; return SDL_GAMEPAD_BUTTON_INVALID;
@ -1156,7 +1154,7 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str)
const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button) const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button)
{ {
if (button > SDL_GAMEPAD_BUTTON_INVALID && button < SDL_GAMEPAD_BUTTON_MAX) { if (button > SDL_GAMEPAD_BUTTON_INVALID && button < SDL_GAMEPAD_BUTTON_MAX) {
return map_StringForGamepadButton[button * 2]; return map_StringForGamepadButton[button];
} }
return NULL; return NULL;
} }