SDL 3.0
SDL_gamepad.h File Reference

Include file for SDL gamepad event handling. More...

+ Include dependency graph for SDL_gamepad.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct SDL_Gamepad SDL_Gamepad
 

Enumerations

enum  SDL_GamepadType {
  SDL_GAMEPAD_TYPE_UNKNOWN = 0 ,
  SDL_GAMEPAD_TYPE_STANDARD ,
  SDL_GAMEPAD_TYPE_XBOX360 ,
  SDL_GAMEPAD_TYPE_XBOXONE ,
  SDL_GAMEPAD_TYPE_PS3 ,
  SDL_GAMEPAD_TYPE_PS4 ,
  SDL_GAMEPAD_TYPE_PS5 ,
  SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO ,
  SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT ,
  SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT ,
  SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR ,
  SDL_GAMEPAD_TYPE_MAX
}
 
enum  SDL_GamepadButton {
  SDL_GAMEPAD_BUTTON_INVALID = -1 ,
  SDL_GAMEPAD_BUTTON_A ,
  SDL_GAMEPAD_BUTTON_B ,
  SDL_GAMEPAD_BUTTON_X ,
  SDL_GAMEPAD_BUTTON_Y ,
  SDL_GAMEPAD_BUTTON_BACK ,
  SDL_GAMEPAD_BUTTON_GUIDE ,
  SDL_GAMEPAD_BUTTON_START ,
  SDL_GAMEPAD_BUTTON_LEFT_STICK ,
  SDL_GAMEPAD_BUTTON_RIGHT_STICK ,
  SDL_GAMEPAD_BUTTON_LEFT_SHOULDER ,
  SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER ,
  SDL_GAMEPAD_BUTTON_DPAD_UP ,
  SDL_GAMEPAD_BUTTON_DPAD_DOWN ,
  SDL_GAMEPAD_BUTTON_DPAD_LEFT ,
  SDL_GAMEPAD_BUTTON_DPAD_RIGHT ,
  SDL_GAMEPAD_BUTTON_MISC1 ,
  SDL_GAMEPAD_BUTTON_PADDLE1 ,
  SDL_GAMEPAD_BUTTON_PADDLE2 ,
  SDL_GAMEPAD_BUTTON_PADDLE3 ,
  SDL_GAMEPAD_BUTTON_PADDLE4 ,
  SDL_GAMEPAD_BUTTON_TOUCHPAD ,
  SDL_GAMEPAD_BUTTON_MAX
}
 
enum  SDL_GamepadAxis {
  SDL_GAMEPAD_AXIS_INVALID = -1 ,
  SDL_GAMEPAD_AXIS_LEFTX ,
  SDL_GAMEPAD_AXIS_LEFTY ,
  SDL_GAMEPAD_AXIS_RIGHTX ,
  SDL_GAMEPAD_AXIS_RIGHTY ,
  SDL_GAMEPAD_AXIS_LEFT_TRIGGER ,
  SDL_GAMEPAD_AXIS_RIGHT_TRIGGER ,
  SDL_GAMEPAD_AXIS_MAX
}
 

Functions

int SDL_AddGamepadMapping (const char *mapping)
 
int SDL_AddGamepadMappingsFromRW (SDL_RWops *src, int freesrc)
 
int SDL_AddGamepadMappingsFromFile (const char *file)
 
int SDL_ReloadGamepadMappings (void)
 
int SDL_GetNumGamepadMappings (void)
 
char * SDL_GetGamepadMappingForIndex (int mapping_index)
 
char * SDL_GetGamepadMappingForGUID (SDL_JoystickGUID guid)
 
char * SDL_GetGamepadMapping (SDL_Gamepad *gamepad)
 
int SDL_SetGamepadMapping (SDL_JoystickID instance_id, const char *mapping)
 
SDL_JoystickIDSDL_GetGamepads (int *count)
 
SDL_bool SDL_IsGamepad (SDL_JoystickID instance_id)
 
const char * SDL_GetGamepadInstanceName (SDL_JoystickID instance_id)
 
const char * SDL_GetGamepadInstancePath (SDL_JoystickID instance_id)
 
int SDL_GetGamepadInstancePlayerIndex (SDL_JoystickID instance_id)
 
SDL_JoystickGUID SDL_GetGamepadInstanceGUID (SDL_JoystickID instance_id)
 
Uint16 SDL_GetGamepadInstanceVendor (SDL_JoystickID instance_id)
 
Uint16 SDL_GetGamepadInstanceProduct (SDL_JoystickID instance_id)
 
Uint16 SDL_GetGamepadInstanceProductVersion (SDL_JoystickID instance_id)
 
SDL_GamepadType SDL_GetGamepadInstanceType (SDL_JoystickID instance_id)
 
SDL_GamepadType SDL_GetRealGamepadInstanceType (SDL_JoystickID instance_id)
 
char * SDL_GetGamepadInstanceMapping (SDL_JoystickID instance_id)
 
SDL_GamepadSDL_OpenGamepad (SDL_JoystickID instance_id)
 
SDL_GamepadSDL_GetGamepadFromInstanceID (SDL_JoystickID instance_id)
 
SDL_GamepadSDL_GetGamepadFromPlayerIndex (int player_index)
 
SDL_JoystickID SDL_GetGamepadInstanceID (SDL_Gamepad *gamepad)
 
const char * SDL_GetGamepadName (SDL_Gamepad *gamepad)
 
const char * SDL_GetGamepadPath (SDL_Gamepad *gamepad)
 
SDL_GamepadType SDL_GetGamepadType (SDL_Gamepad *gamepad)
 
SDL_GamepadType SDL_GetRealGamepadType (SDL_Gamepad *gamepad)
 
int SDL_GetGamepadPlayerIndex (SDL_Gamepad *gamepad)
 
int SDL_SetGamepadPlayerIndex (SDL_Gamepad *gamepad, int player_index)
 
Uint16 SDL_GetGamepadVendor (SDL_Gamepad *gamepad)
 
Uint16 SDL_GetGamepadProduct (SDL_Gamepad *gamepad)
 
Uint16 SDL_GetGamepadProductVersion (SDL_Gamepad *gamepad)
 
Uint16 SDL_GetGamepadFirmwareVersion (SDL_Gamepad *gamepad)
 
const char * SDL_GetGamepadSerial (SDL_Gamepad *gamepad)
 
SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel (SDL_Gamepad *gamepad)
 
SDL_bool SDL_GamepadConnected (SDL_Gamepad *gamepad)
 
SDL_JoystickSDL_GetGamepadJoystick (SDL_Gamepad *gamepad)
 
void SDL_SetGamepadEventsEnabled (SDL_bool enabled)
 
SDL_bool SDL_GamepadEventsEnabled (void)
 
void SDL_UpdateGamepads (void)
 
SDL_GamepadType SDL_GetGamepadTypeFromString (const char *str)
 
const char * SDL_GetGamepadStringForType (SDL_GamepadType type)
 
SDL_GamepadAxis SDL_GetGamepadAxisFromString (const char *str)
 
const char * SDL_GetGamepadStringForAxis (SDL_GamepadAxis axis)
 
SDL_bool SDL_GamepadHasAxis (SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
 
Sint16 SDL_GetGamepadAxis (SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
 
SDL_GamepadButton SDL_GetGamepadButtonFromString (const char *str)
 
const char * SDL_GetGamepadStringForButton (SDL_GamepadButton button)
 
SDL_bool SDL_GamepadHasButton (SDL_Gamepad *gamepad, SDL_GamepadButton button)
 
Uint8 SDL_GetGamepadButton (SDL_Gamepad *gamepad, SDL_GamepadButton button)
 
int SDL_GetNumGamepadTouchpads (SDL_Gamepad *gamepad)
 
int SDL_GetNumGamepadTouchpadFingers (SDL_Gamepad *gamepad, int touchpad)
 
int SDL_GetGamepadTouchpadFinger (SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure)
 
SDL_bool SDL_GamepadHasSensor (SDL_Gamepad *gamepad, SDL_SensorType type)
 
int SDL_SetGamepadSensorEnabled (SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled)
 
SDL_bool SDL_GamepadSensorEnabled (SDL_Gamepad *gamepad, SDL_SensorType type)
 
float SDL_GetGamepadSensorDataRate (SDL_Gamepad *gamepad, SDL_SensorType type)
 
int SDL_GetGamepadSensorData (SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values)
 
int SDL_RumbleGamepad (SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
 
int SDL_RumbleGamepadTriggers (SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
 
SDL_bool SDL_GamepadHasLED (SDL_Gamepad *gamepad)
 
SDL_bool SDL_GamepadHasRumble (SDL_Gamepad *gamepad)
 
SDL_bool SDL_GamepadHasRumbleTriggers (SDL_Gamepad *gamepad)
 
int SDL_SetGamepadLED (SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue)
 
int SDL_SendGamepadEffect (SDL_Gamepad *gamepad, const void *data, int size)
 
void SDL_CloseGamepad (SDL_Gamepad *gamepad)
 
const char * SDL_GetGamepadAppleSFSymbolsNameForButton (SDL_Gamepad *gamepad, SDL_GamepadButton button)
 
const char * SDL_GetGamepadAppleSFSymbolsNameForAxis (SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
 

Detailed Description

Include file for SDL gamepad event handling.

In order to use these functions, SDL_Init() must have been called with the SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and load appropriate drivers.

If you would like to receive gamepad updates while the application is in the background, you should set the following hint before calling SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS

Definition in file SDL_gamepad.h.

Typedef Documentation

◆ SDL_Gamepad

typedef struct SDL_Gamepad SDL_Gamepad

Definition at line 59 of file SDL_gamepad.h.

Enumeration Type Documentation

◆ SDL_GamepadAxis

The list of axes available on a gamepad

Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though advanced UI will allow users to set or autodetect the dead zone, which varies between gamepads.

Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.

Enumerator
SDL_GAMEPAD_AXIS_INVALID 
SDL_GAMEPAD_AXIS_LEFTX 
SDL_GAMEPAD_AXIS_LEFTY 
SDL_GAMEPAD_AXIS_RIGHTX 
SDL_GAMEPAD_AXIS_RIGHTY 
SDL_GAMEPAD_AXIS_LEFT_TRIGGER 
SDL_GAMEPAD_AXIS_RIGHT_TRIGGER 
SDL_GAMEPAD_AXIS_MAX 

Definition at line 116 of file SDL_gamepad.h.

117{
SDL_GamepadAxis
Definition: SDL_gamepad.h:117
@ SDL_GAMEPAD_AXIS_RIGHTX
Definition: SDL_gamepad.h:121
@ SDL_GAMEPAD_AXIS_MAX
Definition: SDL_gamepad.h:125
@ SDL_GAMEPAD_AXIS_RIGHT_TRIGGER
Definition: SDL_gamepad.h:124
@ SDL_GAMEPAD_AXIS_LEFTX
Definition: SDL_gamepad.h:119
@ SDL_GAMEPAD_AXIS_INVALID
Definition: SDL_gamepad.h:118
@ SDL_GAMEPAD_AXIS_LEFTY
Definition: SDL_gamepad.h:120
@ SDL_GAMEPAD_AXIS_LEFT_TRIGGER
Definition: SDL_gamepad.h:123
@ SDL_GAMEPAD_AXIS_RIGHTY
Definition: SDL_gamepad.h:122

◆ SDL_GamepadButton

The list of buttons available on a gamepad

Enumerator
SDL_GAMEPAD_BUTTON_INVALID 
SDL_GAMEPAD_BUTTON_A 
SDL_GAMEPAD_BUTTON_B 
SDL_GAMEPAD_BUTTON_X 
SDL_GAMEPAD_BUTTON_Y 
SDL_GAMEPAD_BUTTON_BACK 
SDL_GAMEPAD_BUTTON_GUIDE 
SDL_GAMEPAD_BUTTON_START 
SDL_GAMEPAD_BUTTON_LEFT_STICK 
SDL_GAMEPAD_BUTTON_RIGHT_STICK 
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER 
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER 
SDL_GAMEPAD_BUTTON_DPAD_UP 
SDL_GAMEPAD_BUTTON_DPAD_DOWN 
SDL_GAMEPAD_BUTTON_DPAD_LEFT 
SDL_GAMEPAD_BUTTON_DPAD_RIGHT 
SDL_GAMEPAD_BUTTON_MISC1 
SDL_GAMEPAD_BUTTON_PADDLE1 
SDL_GAMEPAD_BUTTON_PADDLE2 
SDL_GAMEPAD_BUTTON_PADDLE3 
SDL_GAMEPAD_BUTTON_PADDLE4 
SDL_GAMEPAD_BUTTON_TOUCHPAD 
SDL_GAMEPAD_BUTTON_MAX 

Definition at line 80 of file SDL_gamepad.h.

81{
98 SDL_GAMEPAD_BUTTON_MISC1, /* Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button) */
99 SDL_GAMEPAD_BUTTON_PADDLE1, /* Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
100 SDL_GAMEPAD_BUTTON_PADDLE2, /* Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
101 SDL_GAMEPAD_BUTTON_PADDLE3, /* Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
102 SDL_GAMEPAD_BUTTON_PADDLE4, /* Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
103 SDL_GAMEPAD_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
SDL_GamepadButton
Definition: SDL_gamepad.h:81
@ SDL_GAMEPAD_BUTTON_PADDLE4
Definition: SDL_gamepad.h:102
@ SDL_GAMEPAD_BUTTON_PADDLE2
Definition: SDL_gamepad.h:100
@ SDL_GAMEPAD_BUTTON_GUIDE
Definition: SDL_gamepad.h:88
@ SDL_GAMEPAD_BUTTON_LEFT_STICK
Definition: SDL_gamepad.h:90
@ SDL_GAMEPAD_BUTTON_TOUCHPAD
Definition: SDL_gamepad.h:103
@ SDL_GAMEPAD_BUTTON_PADDLE1
Definition: SDL_gamepad.h:99
@ SDL_GAMEPAD_BUTTON_LEFT_SHOULDER
Definition: SDL_gamepad.h:92
@ SDL_GAMEPAD_BUTTON_DPAD_DOWN
Definition: SDL_gamepad.h:95
@ SDL_GAMEPAD_BUTTON_MAX
Definition: SDL_gamepad.h:104
@ SDL_GAMEPAD_BUTTON_INVALID
Definition: SDL_gamepad.h:82
@ SDL_GAMEPAD_BUTTON_MISC1
Definition: SDL_gamepad.h:98
@ SDL_GAMEPAD_BUTTON_B
Definition: SDL_gamepad.h:84
@ SDL_GAMEPAD_BUTTON_A
Definition: SDL_gamepad.h:83
@ SDL_GAMEPAD_BUTTON_PADDLE3
Definition: SDL_gamepad.h:101
@ SDL_GAMEPAD_BUTTON_BACK
Definition: SDL_gamepad.h:87
@ SDL_GAMEPAD_BUTTON_DPAD_UP
Definition: SDL_gamepad.h:94
@ SDL_GAMEPAD_BUTTON_RIGHT_STICK
Definition: SDL_gamepad.h:91
@ SDL_GAMEPAD_BUTTON_START
Definition: SDL_gamepad.h:89
@ SDL_GAMEPAD_BUTTON_DPAD_RIGHT
Definition: SDL_gamepad.h:97
@ SDL_GAMEPAD_BUTTON_Y
Definition: SDL_gamepad.h:86
@ SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER
Definition: SDL_gamepad.h:93
@ SDL_GAMEPAD_BUTTON_X
Definition: SDL_gamepad.h:85
@ SDL_GAMEPAD_BUTTON_DPAD_LEFT
Definition: SDL_gamepad.h:96

◆ SDL_GamepadType

Enumerator
SDL_GAMEPAD_TYPE_UNKNOWN 
SDL_GAMEPAD_TYPE_STANDARD 
SDL_GAMEPAD_TYPE_XBOX360 
SDL_GAMEPAD_TYPE_XBOXONE 
SDL_GAMEPAD_TYPE_PS3 
SDL_GAMEPAD_TYPE_PS4 
SDL_GAMEPAD_TYPE_PS5 
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO 
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT 
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT 
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR 
SDL_GAMEPAD_TYPE_MAX 

Definition at line 61 of file SDL_gamepad.h.

62{
SDL_GamepadType
Definition: SDL_gamepad.h:62
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
Definition: SDL_gamepad.h:71
@ SDL_GAMEPAD_TYPE_PS5
Definition: SDL_gamepad.h:69
@ SDL_GAMEPAD_TYPE_UNKNOWN
Definition: SDL_gamepad.h:63
@ SDL_GAMEPAD_TYPE_MAX
Definition: SDL_gamepad.h:74
@ SDL_GAMEPAD_TYPE_XBOX360
Definition: SDL_gamepad.h:65
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
Definition: SDL_gamepad.h:72
@ SDL_GAMEPAD_TYPE_XBOXONE
Definition: SDL_gamepad.h:66
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO
Definition: SDL_gamepad.h:70
@ SDL_GAMEPAD_TYPE_PS4
Definition: SDL_gamepad.h:68
@ SDL_GAMEPAD_TYPE_PS3
Definition: SDL_gamepad.h:67
@ SDL_GAMEPAD_TYPE_STANDARD
Definition: SDL_gamepad.h:64
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
Definition: SDL_gamepad.h:73

Function Documentation

◆ SDL_AddGamepadMapping()

int SDL_AddGamepadMapping ( const char *  mapping)

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

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 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.

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"
Parameters
mappingthe 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.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadMapping
SDL_GetGamepadMappingForGUID

◆ SDL_AddGamepadMappingsFromFile()

int SDL_AddGamepadMappingsFromFile ( const char *  file)

Load a set of gamepad mappings from a file.

You can call this function several times, if needed, to load different database files.

If a new mapping is loaded for an already known gamepad GUID, the later version will overwrite the one currently loaded.

Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).

Parameters
filethe mappings file to load
Returns
the number of mappings added or -1 on error; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_AddGamepadMapping
SDL_AddGamepadMappingsFromRW
SDL_GetGamepadMappingForGUID

◆ SDL_AddGamepadMappingsFromRW()

int SDL_AddGamepadMappingsFromRW ( SDL_RWops src,
int  freesrc 
)

Load a set of gamepad mappings from a seekable SDL data stream.

You can call this function several times, if needed, to load different database files.

If a new mapping is loaded for an already known gamepad GUID, the later version will overwrite the one currently loaded.

Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).

This function will load the text database entirely in memory before processing it, so take this into consideration if you are in a memory constrained environment.

Parameters
srcthe data stream for the mappings to be added
freesrcnon-zero to close the stream after being read
Returns
the number of mappings added or -1 on error; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_AddGamepadMapping
SDL_AddGamepadMappingsFromFile
SDL_GetGamepadMappingForGUID

◆ SDL_CloseGamepad()

void SDL_CloseGamepad ( SDL_Gamepad gamepad)

Close a gamepad previously opened with SDL_OpenGamepad().

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Since
This function is available since SDL 3.0.0.
See also
SDL_OpenGamepad

◆ SDL_GamepadConnected()

SDL_bool SDL_GamepadConnected ( SDL_Gamepad gamepad)

Check if a gamepad has been opened and is currently connected.

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Returns
SDL_TRUE if the gamepad has been opened and is currently connected, or SDL_FALSE if not.
Since
This function is available since SDL 3.0.0.
See also
SDL_CloseGamepad
SDL_OpenGamepad

◆ SDL_GamepadEventsEnabled()

SDL_bool SDL_GamepadEventsEnabled ( void  )

Query the state of gamepad event processing.

If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself and check the state of the gamepad when you want gamepad information.

Returns
SDL_TRUE if gamepad events are being processed, SDL_FALSE otherwise.
Since
This function is available since SDL 3.0.0.
See also
SDL_SetGamepadEventsEnabled

◆ SDL_GamepadHasAxis()

SDL_bool SDL_GamepadHasAxis ( SDL_Gamepad gamepad,
SDL_GamepadAxis  axis 
)

Query whether a gamepad has a given axis.

This merely reports whether the gamepad's mapping defined this axis, as that is all the information SDL has about the physical device.

Parameters
gamepada gamepad
axisan axis enum value (an SDL_GamepadAxis value)
Returns
SDL_TRUE if the gamepad has this axis, SDL_FALSE otherwise.
Since
This function is available since SDL 3.0.0.

◆ SDL_GamepadHasButton()

SDL_bool SDL_GamepadHasButton ( SDL_Gamepad gamepad,
SDL_GamepadButton  button 
)

Query whether a gamepad has a given button.

This merely reports whether the gamepad's mapping defined this button, as that is all the information SDL has about the physical device.

Parameters
gamepada gamepad
buttona button enum value (an SDL_GamepadButton value)
Returns
SDL_TRUE if the gamepad has this button, SDL_FALSE otherwise.
Since
This function is available since SDL 3.0.0.

◆ SDL_GamepadHasLED()

SDL_bool SDL_GamepadHasLED ( SDL_Gamepad gamepad)

Query whether a gamepad has an LED.

Parameters
gamepadThe gamepad to query
Returns
SDL_TRUE, or SDL_FALSE if this gamepad does not have a modifiable LED
Since
This function is available since SDL 3.0.0.

◆ SDL_GamepadHasRumble()

SDL_bool SDL_GamepadHasRumble ( SDL_Gamepad gamepad)

Query whether a gamepad has rumble support.

Parameters
gamepadThe gamepad to query
Returns
SDL_TRUE, or SDL_FALSE if this gamepad does not have rumble support
Since
This function is available since SDL 3.0.0.
See also
SDL_RumbleGamepad

◆ SDL_GamepadHasRumbleTriggers()

SDL_bool SDL_GamepadHasRumbleTriggers ( SDL_Gamepad gamepad)

Query whether a gamepad has rumble support on triggers.

Parameters
gamepadThe gamepad to query
Returns
SDL_TRUE, or SDL_FALSE if this gamepad does not have trigger rumble support
Since
This function is available since SDL 3.0.0.
See also
SDL_RumbleGamepadTriggers

◆ SDL_GamepadHasSensor()

SDL_bool SDL_GamepadHasSensor ( SDL_Gamepad gamepad,
SDL_SensorType  type 
)

Return whether a gamepad has a particular sensor.

Parameters
gamepadThe gamepad to query
typeThe type of sensor to query
Returns
SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
Since
This function is available since SDL 3.0.0.

◆ SDL_GamepadSensorEnabled()

SDL_bool SDL_GamepadSensorEnabled ( SDL_Gamepad gamepad,
SDL_SensorType  type 
)

Query whether sensor data reporting is enabled for a gamepad.

Parameters
gamepadThe gamepad to query
typeThe type of sensor to query
Returns
SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadAppleSFSymbolsNameForAxis()

const char * SDL_GetGamepadAppleSFSymbolsNameForAxis ( SDL_Gamepad gamepad,
SDL_GamepadAxis  axis 
)

Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.

Parameters
gamepadthe gamepad to query
axisan axis on the gamepad
Returns
the sfSymbolsName or NULL if the name can't be found
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadAppleSFSymbolsNameForButton

◆ SDL_GetGamepadAppleSFSymbolsNameForButton()

const char * SDL_GetGamepadAppleSFSymbolsNameForButton ( SDL_Gamepad gamepad,
SDL_GamepadButton  button 
)

Return the sfSymbolsName for a given button on a gamepad on Apple platforms.

Parameters
gamepadthe gamepad to query
buttona button on the gamepad
Returns
the sfSymbolsName or NULL if the name can't be found
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadAppleSFSymbolsNameForAxis

◆ SDL_GetGamepadAxis()

Sint16 SDL_GetGamepadAxis ( SDL_Gamepad gamepad,
SDL_GamepadAxis  axis 
)

Get the current state of an axis control on a gamepad.

The axis indices start at index 0.

The state is a value ranging from -32768 to 32767. Triggers, however, range from 0 to 32767 (they never return a negative value).

Parameters
gamepada gamepad
axisan axis index (one of the SDL_GamepadAxis values)
Returns
axis state (including 0) on success or 0 (also) on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadButton

◆ SDL_GetGamepadAxisFromString()

SDL_GamepadAxis SDL_GetGamepadAxisFromString ( const char *  str)

Convert a string into SDL_GamepadAxis enum.

This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.

Note specially that "righttrigger" and "lefttrigger" map to SDL_GAMEPAD_AXIS_RIGHT_TRIGGER and SDL_GAMEPAD_AXIS_LEFT_TRIGGER, respectively.

Parameters
strstring representing a SDL_Gamepad axis
Returns
the SDL_GamepadAxis enum corresponding to the input string, or SDL_GAMEPAD_AXIS_INVALID if no match was found.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadStringForAxis

◆ SDL_GetGamepadButton()

Uint8 SDL_GetGamepadButton ( SDL_Gamepad gamepad,
SDL_GamepadButton  button 
)

Get the current state of a button on a gamepad.

Parameters
gamepada gamepad
buttona button index (one of the SDL_GamepadButton values)
Returns
1 for pressed state or 0 for not pressed state or error; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadAxis

◆ SDL_GetGamepadButtonFromString()

SDL_GamepadButton SDL_GetGamepadButtonFromString ( const char *  str)

Convert a string into an SDL_GamepadButton enum.

This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.

Parameters
strstring representing a SDL_Gamepad axis
Returns
the SDL_GamepadButton enum corresponding to the input string, or SDL_GAMEPAD_AXIS_INVALID if no match was found.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadFirmwareVersion()

Uint16 SDL_GetGamepadFirmwareVersion ( SDL_Gamepad gamepad)

Get the firmware version of an opened gamepad, if available.

If the firmware version isn't available this function returns 0.

Parameters
gamepadthe gamepad object to query.
Returns
the gamepad firmware version, or zero if unavailable.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadFromInstanceID()

SDL_Gamepad * SDL_GetGamepadFromInstanceID ( SDL_JoystickID  instance_id)

Get the SDL_Gamepad associated with a joystick instance ID, if it has been opened.

Parameters
instance_idthe joystick instance ID of the gamepad
Returns
an SDL_Gamepad on success or NULL on failure or if it hasn't been opened yet; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadFromPlayerIndex()

SDL_Gamepad * SDL_GetGamepadFromPlayerIndex ( int  player_index)

Get the SDL_Gamepad associated with a player index.

Parameters
player_indexthe player index, which different from the instance ID
Returns
the SDL_Gamepad associated with a player index.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadPlayerIndex
SDL_SetGamepadPlayerIndex

◆ SDL_GetGamepadInstanceGUID()

SDL_JoystickGUID SDL_GetGamepadInstanceGUID ( SDL_JoystickID  instance_id)

Get the implementation-dependent GUID of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the GUID of the selected gamepad. If called on an invalid index, this function returns a zero GUID
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadGUID
SDL_GetGamepadGUIDString

◆ SDL_GetGamepadInstanceID()

SDL_JoystickID SDL_GetGamepadInstanceID ( SDL_Gamepad gamepad)

Get the instance ID of an opened gamepad.

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Returns
the instance ID of the specified gamepad on success or 0 on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_OpenGamepad

◆ SDL_GetGamepadInstanceMapping()

char * SDL_GetGamepadInstanceMapping ( SDL_JoystickID  instance_id)

Get the mapping of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadInstanceName()

const char * SDL_GetGamepadInstanceName ( SDL_JoystickID  instance_id)

Get the implementation dependent name of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the name of the selected gamepad. If no name can be found, this function returns NULL; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadName
SDL_OpenGamepad

◆ SDL_GetGamepadInstancePath()

const char * SDL_GetGamepadInstancePath ( SDL_JoystickID  instance_id)

Get the implementation dependent path of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the path of the selected gamepad. If no path can be found, this function returns NULL; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadPath
SDL_OpenGamepad

◆ SDL_GetGamepadInstancePlayerIndex()

int SDL_GetGamepadInstancePlayerIndex ( SDL_JoystickID  instance_id)

Get the player index of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the player index of a gamepad, or -1 if it's not available
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadPlayerIndex
SDL_OpenGamepad

◆ SDL_GetGamepadInstanceProduct()

Uint16 SDL_GetGamepadInstanceProduct ( SDL_JoystickID  instance_id)

Get the USB product ID of a gamepad, if available.

This can be called before any gamepads are opened. If the product ID isn't available this function returns 0.

Parameters
instance_idthe joystick instance ID
Returns
the USB product ID of the selected gamepad. If called on an invalid index, this function returns zero
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadInstanceProductVersion()

Uint16 SDL_GetGamepadInstanceProductVersion ( SDL_JoystickID  instance_id)

Get the product version of a gamepad, if available.

This can be called before any gamepads are opened. If the product version isn't available this function returns 0.

Parameters
instance_idthe joystick instance ID
Returns
the product version of the selected gamepad. If called on an invalid index, this function returns zero
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadInstanceType()

SDL_GamepadType SDL_GetGamepadInstanceType ( SDL_JoystickID  instance_id)

Get the type of a gamepad.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the gamepad type.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadInstanceVendor()

Uint16 SDL_GetGamepadInstanceVendor ( SDL_JoystickID  instance_id)

Get the USB vendor ID of a gamepad, if available.

This can be called before any gamepads are opened. If the vendor ID isn't available this function returns 0.

Parameters
instance_idthe joystick instance ID
Returns
the USB vendor ID of the selected gamepad. If called on an invalid index, this function returns zero
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadJoystick()

SDL_Joystick * SDL_GetGamepadJoystick ( SDL_Gamepad gamepad)

Get the underlying joystick from a gamepad

This function will give you a SDL_Joystick object, which allows you to use the SDL_Joystick functions with a SDL_Gamepad object. This would be useful for getting a joystick's position at any given time, even if it hasn't moved (moving it would produce an event, which would have the axis' value).

The pointer returned is owned by the SDL_Gamepad. You should not call SDL_CloseJoystick() on it, for example, since doing so will likely cause SDL to crash.

Parameters
gamepadthe gamepad object that you want to get a joystick from
Returns
an SDL_Joystick object; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadMapping()

char * SDL_GetGamepadMapping ( SDL_Gamepad gamepad)

Get the current mapping of a gamepad.

The returned string must be freed with SDL_free().

Details about mappings are discussed with SDL_AddGamepadMapping().

Parameters
gamepadthe gamepad you want to get the current mapping for
Returns
a string that has the gamepad's mapping or NULL if no mapping is available; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_AddGamepadMapping
SDL_GetGamepadMappingForGUID
SDL_SetGamepadMapping

◆ SDL_GetGamepadMappingForGUID()

char * SDL_GetGamepadMappingForGUID ( SDL_JoystickGUID  guid)

Get the gamepad mapping string for a given GUID.

The returned string must be freed with SDL_free().

Parameters
guida structure containing the GUID for which a mapping is desired
Returns
a mapping string or NULL on error; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetJoystickInstanceGUID
SDL_GetJoystickGUID

◆ SDL_GetGamepadMappingForIndex()

char * SDL_GetGamepadMappingForIndex ( int  mapping_index)

Get the mapping at a particular index.

Parameters
mapping_indexmapping index
Returns
the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadName()

const char * SDL_GetGamepadName ( SDL_Gamepad gamepad)

Get the implementation-dependent name for an opened gamepad.

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Returns
the implementation dependent name for the gamepad, or NULL if there is no name or the identifier passed is invalid.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadInstanceName
SDL_OpenGamepad

◆ SDL_GetGamepadPath()

const char * SDL_GetGamepadPath ( SDL_Gamepad gamepad)

Get the implementation-dependent path for an opened gamepad.

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Returns
the implementation dependent path for the gamepad, or NULL if there is no path or the identifier passed is invalid.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadInstancePath

◆ SDL_GetGamepadPlayerIndex()

int SDL_GetGamepadPlayerIndex ( SDL_Gamepad gamepad)

Get the player index of an opened gamepad.

For XInput gamepads this returns the XInput user index.

Parameters
gamepadthe gamepad object to query.
Returns
the player index for gamepad, or -1 if it's not available.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadPowerLevel()

SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel ( SDL_Gamepad gamepad)

Get the battery level of a gamepad, if available.

Parameters
gamepada gamepad identifier previously returned by SDL_OpenGamepad()
Returns
the current battery level as SDL_JoystickPowerLevel on success or SDL_JOYSTICK_POWER_UNKNOWN if it is unknown
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadProduct()

Uint16 SDL_GetGamepadProduct ( SDL_Gamepad gamepad)

Get the USB product ID of an opened gamepad, if available.

If the product ID isn't available this function returns 0.

Parameters
gamepadthe gamepad object to query.
Returns
the USB product ID, or zero if unavailable.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadProductVersion()

Uint16 SDL_GetGamepadProductVersion ( SDL_Gamepad gamepad)

Get the product version of an opened gamepad, if available.

If the product version isn't available this function returns 0.

Parameters
gamepadthe gamepad object to query.
Returns
the USB product version, or zero if unavailable.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepads()

SDL_JoystickID * SDL_GetGamepads ( int *  count)

Get a list of currently connected gamepads.

Parameters
counta pointer filled in with the number of gamepads returned
Returns
a 0 terminated array of joystick instance IDs which should be freed with SDL_free(), or NULL on error; call SDL_GetError() for more details.
Since
This function is available since SDL 3.0.0.
See also
SDL_OpenGamepad

◆ SDL_GetGamepadSensorData()

int SDL_GetGamepadSensorData ( SDL_Gamepad gamepad,
SDL_SensorType  type,
float *  data,
int  num_values 
)

Get the current state of a gamepad sensor.

The number of values and interpretation of the data is sensor dependent. See SDL_sensor.h for the details for each type of sensor.

Parameters
gamepadThe gamepad to query
typeThe type of sensor to query
dataA pointer filled with the current sensor state
num_valuesThe number of values to write to data
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadSensorDataRate()

float SDL_GetGamepadSensorDataRate ( SDL_Gamepad gamepad,
SDL_SensorType  type 
)

Get the data rate (number of events per second) of a gamepad sensor.

Parameters
gamepadThe gamepad to query
typeThe type of sensor to query
Returns
the data rate, or 0.0f if the data rate is not available.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadSerial()

const char * SDL_GetGamepadSerial ( SDL_Gamepad gamepad)

Get the serial number of an opened gamepad, if available.

Returns the serial number of the gamepad, or NULL if it is not available.

Parameters
gamepadthe gamepad object to query.
Returns
the serial number, or NULL if unavailable.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadStringForAxis()

const char * SDL_GetGamepadStringForAxis ( SDL_GamepadAxis  axis)

Convert from an SDL_GamepadAxis enum to a string.

The caller should not SDL_free() the returned string.

Parameters
axisan enum value for a given SDL_GamepadAxis
Returns
a string for the given axis, or NULL if an invalid axis is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadAxisFromString

◆ SDL_GetGamepadStringForButton()

const char * SDL_GetGamepadStringForButton ( SDL_GamepadButton  button)

Convert from an SDL_GamepadButton enum to a string.

The caller should not SDL_free() the returned string.

Parameters
buttonan enum value for a given SDL_GamepadButton
Returns
a string for the given button, or NULL if an invalid button is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadButtonFromString

◆ SDL_GetGamepadStringForType()

const char * SDL_GetGamepadStringForType ( SDL_GamepadType  type)

Convert from an SDL_GamepadType enum to a string.

The caller should not SDL_free() the returned string.

Parameters
typean enum value for a given SDL_GamepadType
Returns
a string for the given type, or NULL if an invalid type is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadTypeFromString

◆ SDL_GetGamepadTouchpadFinger()

int SDL_GetGamepadTouchpadFinger ( SDL_Gamepad gamepad,
int  touchpad,
int  finger,
Uint8 state,
float *  x,
float *  y,
float *  pressure 
)

Get the current state of a finger on a touchpad on a gamepad.

Parameters
gamepada gamepad
touchpada touchpad
fingera finger
statefilled with state
xfilled with x position
yfilled with y position
pressurefilled with pressure value
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetGamepadType()

SDL_GamepadType SDL_GetGamepadType ( SDL_Gamepad gamepad)

Get the type of an opened gamepad.

Parameters
gamepadthe gamepad object to query.
Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadInstanceType

◆ SDL_GetGamepadTypeFromString()

SDL_GamepadType SDL_GetGamepadTypeFromString ( const char *  str)

Convert a string into SDL_GamepadType enum.

This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.

Parameters
strstring representing a SDL_GamepadType type
Returns
the SDL_GamepadType enum corresponding to the input string, or SDL_GAMEPAD_TYPE_UNKNOWN if no match was found.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetGamepadStringForType

◆ SDL_GetGamepadVendor()

Uint16 SDL_GetGamepadVendor ( SDL_Gamepad gamepad)

Get the USB vendor ID of an opened gamepad, if available.

If the vendor ID isn't available this function returns 0.

Parameters
gamepadthe gamepad object to query.
Returns
the USB vendor ID, or zero if unavailable.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetNumGamepadMappings()

int SDL_GetNumGamepadMappings ( void  )

Get the number of mappings installed.

Returns
the number of mappings.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetNumGamepadTouchpadFingers()

int SDL_GetNumGamepadTouchpadFingers ( SDL_Gamepad gamepad,
int  touchpad 
)

Get the number of supported simultaneous fingers on a touchpad on a game gamepad.

Parameters
gamepada gamepad
touchpada touchpad
Returns
number of supported simultaneous fingers
Since
This function is available since SDL 3.0.0.

◆ SDL_GetNumGamepadTouchpads()

int SDL_GetNumGamepadTouchpads ( SDL_Gamepad gamepad)

Get the number of touchpads on a gamepad.

Parameters
gamepada gamepad
Returns
number of touchpads
Since
This function is available since SDL 3.0.0.

◆ SDL_GetRealGamepadInstanceType()

SDL_GamepadType SDL_GetRealGamepadInstanceType ( SDL_JoystickID  instance_id)

Get the type of a gamepad, ignoring any mapping override.

This can be called before any gamepads are opened.

Parameters
instance_idthe joystick instance ID
Returns
the gamepad type.
Since
This function is available since SDL 3.0.0.

◆ SDL_GetRealGamepadType()

SDL_GamepadType SDL_GetRealGamepadType ( SDL_Gamepad gamepad)

Get the type of an opened gamepad, ignoring any mapping override.

Parameters
gamepadthe gamepad object to query.
Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Since
This function is available since SDL 3.0.0.
See also
SDL_GetRealGamepadInstanceType

◆ SDL_IsGamepad()

SDL_bool SDL_IsGamepad ( SDL_JoystickID  instance_id)

Check if the given joystick is supported by the gamepad interface.

Parameters
instance_idthe joystick instance ID
Returns
SDL_TRUE if the given joystick is supported by the gamepad interface, SDL_FALSE if it isn't or it's an invalid index.
Since
This function is available since SDL 3.0.0.
See also
SDL_OpenGamepad

◆ SDL_OpenGamepad()

SDL_Gamepad * SDL_OpenGamepad ( SDL_JoystickID  instance_id)

Open a gamepad for use.

Parameters
instance_idthe joystick instance ID
Returns
a gamepad identifier or NULL if an error occurred; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_CloseGamepad
SDL_IsGamepad

◆ SDL_ReloadGamepadMappings()

int SDL_ReloadGamepadMappings ( void  )

Reinitialize the SDL mapping database to its initial state.

This will generate gamepad events as needed if device mappings change.

Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_RumbleGamepad()

int SDL_RumbleGamepad ( SDL_Gamepad gamepad,
Uint16  low_frequency_rumble,
Uint16  high_frequency_rumble,
Uint32  duration_ms 
)

Start a rumble effect on a gamepad.

Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.

Parameters
gamepadThe gamepad to vibrate
low_frequency_rumbleThe intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
high_frequency_rumbleThe intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
duration_msThe duration of the rumble effect, in milliseconds
Returns
0, or -1 if rumble isn't supported on this gamepad
Since
This function is available since SDL 3.0.0.
See also
SDL_GamepadHasRumble

◆ SDL_RumbleGamepadTriggers()

int SDL_RumbleGamepadTriggers ( SDL_Gamepad gamepad,
Uint16  left_rumble,
Uint16  right_rumble,
Uint32  duration_ms 
)

Start a rumble effect in the gamepad's triggers.

Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.

Note that this is rumbling of the triggers and not the gamepad as a whole. This is currently only supported on Xbox One gamepads. If you want the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.

Parameters
gamepadThe gamepad to vibrate
left_rumbleThe intensity of the left trigger rumble motor, from 0 to 0xFFFF
right_rumbleThe intensity of the right trigger rumble motor, from 0 to 0xFFFF
duration_msThe duration of the rumble effect, in milliseconds
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_GamepadHasRumbleTriggers

◆ SDL_SendGamepadEffect()

int SDL_SendGamepadEffect ( SDL_Gamepad gamepad,
const void *  data,
int  size 
)

Send a gamepad specific effect packet

Parameters
gamepadThe gamepad to affect
dataThe data to send to the gamepad
sizeThe size of the data to send to the gamepad
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_SetGamepadEventsEnabled()

void SDL_SetGamepadEventsEnabled ( SDL_bool  enabled)

Set the state of gamepad event processing.

If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself and check the state of the gamepad when you want gamepad information.

Parameters
enabledwhether to process gamepad events or not
Since
This function is available since SDL 3.0.0.
See also
SDL_GamepadEventsEnabled

◆ SDL_SetGamepadLED()

int SDL_SetGamepadLED ( SDL_Gamepad gamepad,
Uint8  red,
Uint8  green,
Uint8  blue 
)

Update a gamepad's LED color.

Parameters
gamepadThe gamepad to update
redThe intensity of the red LED
greenThe intensity of the green LED
blueThe intensity of the blue LED
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_SetGamepadMapping()

int SDL_SetGamepadMapping ( SDL_JoystickID  instance_id,
const char *  mapping 
)

Set the current mapping of a joystick or gamepad.

Details about mappings are discussed with SDL_AddGamepadMapping().

Parameters
instance_idthe joystick instance ID
mappingthe mapping to use for this device, or NULL to clear the mapping
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_AddGamepadMapping
SDL_GetGamepadMapping

◆ SDL_SetGamepadPlayerIndex()

int SDL_SetGamepadPlayerIndex ( SDL_Gamepad gamepad,
int  player_index 
)

Set the player index of an opened gamepad.

Parameters
gamepadthe gamepad object to adjust.
player_indexPlayer index to assign to this gamepad, or -1 to clear the player index and turn off player LEDs.
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_SetGamepadSensorEnabled()

int SDL_SetGamepadSensorEnabled ( SDL_Gamepad gamepad,
SDL_SensorType  type,
SDL_bool  enabled 
)

Set whether data reporting for a gamepad sensor is enabled.

Parameters
gamepadThe gamepad to update
typeThe type of sensor to enable/disable
enabledWhether data reporting should be enabled
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.

◆ SDL_UpdateGamepads()

void SDL_UpdateGamepads ( void  )

Manually pump gamepad updates if not using the loop.

This function is called automatically by the event loop if events are enabled. Under such circumstances, it will not be necessary to call this function.

Since
This function is available since SDL 3.0.0.