---
name: "SDL_AddGamepadMapping"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_AddGamepadMapping"
---

# SDL\_AddGamepadMapping(3)

Add support for gamepads that SDL is unaware of or change the binding of an existing gamepad.

## NAME

SDL\_AddGamepadMapping - Add support for gamepads that SDL is unaware of or change the binding of an existing gamepad.

## HEADER FILE

Defined in SDL3/SDL\_gamepad.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**int SDL\_AddGamepadMapping(const char \*mapping);**

## DESCRIPTION

The mapping string has the format "GUID,name,mapping", where GUID is the string value from  **SDL\_GUIDToString** (), 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 X - **hX.Y** : hat X with value Y - **aX** : axis X of the joystick

Buttons can be used as a gamepad axes and vice versa.

If a device with this GUID is already plugged in, SDL will generate an

**SDL\_EVENT\_GAMEPAD\_ADDED**\
  event.

This string shows an example of a valid mapping for a gamepad:

-

  ```
  "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
  ```

## FUNCTION PARAMETERS

- *mapping*

  the mapping string.

## RETURN VALUE

Returns 1 if a new mapping is added, 0 if an existing mapping is updated, -1 on failure; call  **SDL\_GetError** () for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_AddGamepadMappingsFromFile**(3)](/SDL_AddGamepadMappingsFromFile/3.md), **•**(3), [**SDL\_AddGamepadMappingsFromIO**(3)](/SDL_AddGamepadMappingsFromIO/3.md), **•**(3), [**SDL\_GetGamepadMapping**(3)](/SDL_GetGamepadMapping/3.md), **•**(3), [**SDL\_GetGamepadMappingForGUID**(3)](/SDL_GetGamepadMappingForGUID/3.md), **•**(3), [**SDL\_HINT\_GAMECONTROLLERCONFIG**(3)](/SDL_HINT_GAMECONTROLLERCONFIG/3.md), **•**(3), [**SDL\_HINT\_GAMECONTROLLERCONFIG\_FILE**(3)](/SDL_HINT_GAMECONTROLLERCONFIG_FILE/3.md), **•**(3), **SDL\_EVENT\_GAMEPAD\_ADDED**(3)
