Add support for gamepads that SDL is unaware of or change the binding of an existing gamepad.
Defined in <SDL3/SDL_gamepad.h>
mapping | the mapping string |
Returns 1 if a new mapping is added, 0 if an existing mapping is updated, -1 on error; call SDL_GetError() for more information.
The mapping string has the format "GUID,name,mapping", where GUID is the string value from SDL_GetJoystickGUIDString(), name is the human readable string for the device and mappings are gamepad mappings to joystick ones. Under Windows there is a reserved GUID of "xinput" that covers all XInput devices. The mapping format for joystick is:
bX
: a joystick button, index XhX.Y
: hat X with value YaX
: axis X of the joystickButtons can be used as a gamepad axes and vice versa.
This string shows an example of a valid mapping for a gamepad:
It is safe to call this function from any thread.
This function is available since SDL 3.0.0.