Module fermium::gamecontroller[][src]

The SDL “game controller” API lets you view any joystick as being (approximately) an XBox 360 controller.

This sounds silly at first, but is actually pretty useful in the common case. It sorts out a lot of the button and axis stuff for you.

In order to use these functions, SDL_Init must have been called with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system for game controllers, and load appropriate drivers.

If you would like to receive joystick updates while the application is in the background, you should set the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint before calling SDL_Init.

See Also: joystick

Structs

SDL_GameController

An SDL game controller is an opaque structure.

SDL_GameControllerAxis

The list of axes available from a controller

SDL_GameControllerBindType

The type of a binding between the underlying joystick and its controller abstraction.

SDL_GameControllerButton

The list of buttons available from a controller.

SDL_GameControllerButtonBind

The SDL joystick layer binding for this controller button/axis mapping.

SDL_GameControllerButtonBind_hat_data
SDL_GameControllerType

A game controller’s type, sorted by console.

Constants

SDL_CONTROLLER_AXIS_INVALID

The general “invalid” entry.

SDL_CONTROLLER_AXIS_LEFTX

Left-stick X

SDL_CONTROLLER_AXIS_LEFTY

Left-stick Y

SDL_CONTROLLER_AXIS_MAX

The number of valid axis possibilities.

SDL_CONTROLLER_AXIS_RIGHTX

Right-stick X

SDL_CONTROLLER_AXIS_RIGHTY

Right-stick Y

SDL_CONTROLLER_AXIS_TRIGGERLEFT

Left trigger

SDL_CONTROLLER_AXIS_TRIGGERRIGHT

Right trigger

SDL_CONTROLLER_BINDTYPE_AXIS
SDL_CONTROLLER_BINDTYPE_BUTTON
SDL_CONTROLLER_BINDTYPE_HAT
SDL_CONTROLLER_BINDTYPE_NONE
SDL_CONTROLLER_BUTTON_A

Bottom face button.

SDL_CONTROLLER_BUTTON_B

Right face button.

SDL_CONTROLLER_BUTTON_BACK

Also known as “select” on many controllers.

SDL_CONTROLLER_BUTTON_DPAD_DOWN

Arrow-pad down.

SDL_CONTROLLER_BUTTON_DPAD_LEFT

Arrow-pad left.

SDL_CONTROLLER_BUTTON_DPAD_RIGHT

Arrow-pad right.

SDL_CONTROLLER_BUTTON_DPAD_UP

Arrow-pad up.

SDL_CONTROLLER_BUTTON_GUIDE

The logo button. Not present on many controllers.

SDL_CONTROLLER_BUTTON_INVALID

The general “invalid” entry.

SDL_CONTROLLER_BUTTON_LEFTSHOULDER

Upper left shoulder button.

SDL_CONTROLLER_BUTTON_LEFTSTICK

Pressing in the left stick.

SDL_CONTROLLER_BUTTON_MAX

The number of valid controller button possibilities.

SDL_CONTROLLER_BUTTON_MISC1

Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button.

SDL_CONTROLLER_BUTTON_PADDLE1

Xbox Elite paddle P1.

SDL_CONTROLLER_BUTTON_PADDLE2

Xbox Elite paddle P3.

SDL_CONTROLLER_BUTTON_PADDLE3

Xbox Elite paddle P2.

SDL_CONTROLLER_BUTTON_PADDLE4

Xbox Elite paddle P4.

SDL_CONTROLLER_BUTTON_RIGHTSHOULDER

Upper right shoulder button.

SDL_CONTROLLER_BUTTON_RIGHTSTICK

Pressing in the right stick.

SDL_CONTROLLER_BUTTON_START

Start button.

SDL_CONTROLLER_BUTTON_TOUCHPAD

PS4/PS5 touchpad button.

SDL_CONTROLLER_BUTTON_X

Left face button.

SDL_CONTROLLER_BUTTON_Y

Top face button.

SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
SDL_CONTROLLER_TYPE_PS3
SDL_CONTROLLER_TYPE_PS4
SDL_CONTROLLER_TYPE_PS5
SDL_CONTROLLER_TYPE_UNKNOWN
SDL_CONTROLLER_TYPE_VIRTUAL
SDL_CONTROLLER_TYPE_XBOX360
SDL_CONTROLLER_TYPE_XBOXONE

Functions

SDL_GameControllerAddMapping

Add or update an existing mapping configuration

SDL_GameControllerAddMappingsFromFile

Load a set of mappings from a file.

SDL_GameControllerAddMappingsFromRW

Load a set of mappings from a seekable SDL data stream (memory or file).

SDL_GameControllerClose

Close a controller previously opened with SDL_GameControllerOpen.

SDL_GameControllerEventState

Enable/disable controller event polling.

SDL_GameControllerFromInstanceID

Return the SDL_GameController associated with an instance id.

SDL_GameControllerFromPlayerIndex

Return the SDL_GameController associated with a player index.

SDL_GameControllerGetAttached

Returns SDL_TRUE if the controller has been opened and currently connected, or SDL_FALSE if it has not.

SDL_GameControllerGetAxis

Get the current state of an axis control on a game controller.

SDL_GameControllerGetAxisFromString

Turn this string into a axis mapping.

SDL_GameControllerGetBindForAxis

Get the SDL joystick layer binding for this controller button mapping.

SDL_GameControllerGetBindForButton

Get the SDL joystick layer binding for this controller button mapping.

SDL_GameControllerGetButton

Get the current state of a button on a game controller.

SDL_GameControllerGetButtonFromString

Turn this string into a button mapping.

SDL_GameControllerGetJoystick

Get the underlying joystick object used by a controller.

SDL_GameControllerGetNumTouchpadFingers

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

SDL_GameControllerGetNumTouchpads

Get the number of touchpads on a game controller.

SDL_GameControllerGetPlayerIndex

Get the player index of an opened game controller, or -1 if it’s not available

SDL_GameControllerGetProduct

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

SDL_GameControllerGetProductVersion

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

SDL_GameControllerGetSensorData

Get the current state of a game controller sensor.

SDL_GameControllerGetSerial

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

SDL_GameControllerGetStringForAxis

Turn this axis enum into a string mapping.

SDL_GameControllerGetStringForButton

Turn this button enum into a string mapping.

SDL_GameControllerGetTouchpadFinger

Get the current state of a finger on a touchpad on a game controller.

SDL_GameControllerGetType

Return the type of this currently opened controller.

SDL_GameControllerGetVendor

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

SDL_GameControllerHasAxis

Return whether a game controller has a given axis.

SDL_GameControllerHasButton

Return whether a game controller has a given button.

SDL_GameControllerHasLED

Return whether a controller has an LED.

SDL_GameControllerHasSensor

Return whether a game controller has a particular sensor.

SDL_GameControllerIsSensorEnabled

Query whether sensor data reporting is enabled for a game controller

SDL_GameControllerMapping

Get a mapping string for an open GameController

SDL_GameControllerMappingForDeviceIndex

Get the mapping of a game controller.

SDL_GameControllerMappingForGUID

Get a mapping string for a GUID

SDL_GameControllerMappingForIndex

Get the mapping at a particular index.

SDL_GameControllerName

Return the name for this currently opened controller.

SDL_GameControllerNameForIndex

Get the implementation dependent name of a game controller.

SDL_GameControllerNumMappings

Get the number of mappings installed

SDL_GameControllerOpen

Open a game controller for use.

SDL_GameControllerRumble

Trigger a rumble effect.

SDL_GameControllerRumbleTriggers

Start a rumble effect in the game controller’s triggers.

SDL_GameControllerSetLED

Update a controller’s LED color.

SDL_GameControllerSetPlayerIndex

Set the player index of an opened game controller.

SDL_GameControllerSetSensorEnabled

Set whether data reporting for a game controller sensor is enabled

SDL_GameControllerTypeForIndex

Get the type of a game controller.

SDL_GameControllerUpdate

Update the current state of the open game controllers.

SDL_IsGameController

Is the joystick on this index supported by the game controller interface?

Unions

SDL_GameControllerButtonBind_value_data