Module fermium::gamecontroller

source ·
Expand description

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

An SDL game controller is an opaque structure.
The list of axes available from a controller
The type of a binding between the underlying joystick and its controller abstraction.
The list of buttons available from a controller.
The SDL joystick layer binding for this controller button/axis mapping.
A game controller’s type, sorted by console.

Constants

The general “invalid” entry.
The number of valid axis possibilities.
Bottom face button.
Right face button.
Also known as “select” on many controllers.
The logo button. Not present on many controllers.
The general “invalid” entry.
Upper left shoulder button.
Pressing in the left stick.
The number of valid controller button possibilities.
Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button.
Xbox Elite paddle P1.
Xbox Elite paddle P3.
Xbox Elite paddle P2.
Xbox Elite paddle P4.
Upper right shoulder button.
Pressing in the right stick.
PS4/PS5 touchpad button.
Left face button.
Top face button.

Functions

Add or update an existing mapping configuration
Load a set of mappings from a file.
Load a set of mappings from a seekable SDL data stream (memory or file).
Close a controller previously opened with SDL_GameControllerOpen.
Enable/disable controller event polling.
Return the SDL_GameController associated with an instance id.
Return the SDL_GameController associated with a player index.
Returns SDL_TRUE if the controller has been opened and currently connected, or SDL_FALSE if it has not.
Get the current state of an axis control on a game controller.
Turn this string into a axis mapping.
Get the SDL joystick layer binding for this controller button mapping.
Get the SDL joystick layer binding for this controller button mapping.
Get the current state of a button on a game controller.
Turn this string into a button mapping.
Get the underlying joystick object used by a controller.
Get the number of supported simultaneous fingers on a touchpad on a game controller.
Get the number of touchpads on a game controller.
Get the player index of an opened game controller, or -1 if it’s not available
Get the USB product ID of an opened controller, if available.
Get the product version of an opened controller, if available.
Get the current state of a game controller sensor.
Get the data rate (number of events per second) of a game controller sensor.
Get the serial number of an opened controller, if available.
Turn this axis enum into a string mapping.
Turn this button enum into a string mapping.
Get the current state of a finger on a touchpad on a game controller.
Return the type of this currently opened controller.
Get the USB vendor ID of an opened controller, if available.
Return whether a game controller has a given axis.
Return whether a game controller has a given button.
Return whether a controller has an LED.
Return whether a game controller has a particular sensor.
Query whether sensor data reporting is enabled for a game controller
Get a mapping string for an open GameController
Get the mapping of a game controller.
Get a mapping string for a GUID
Get the mapping at a particular index.
Return the name for this currently opened controller.
Get the implementation dependent name of a game controller.
Get the number of mappings installed
Open a game controller for use.
Trigger a rumble effect.
Start a rumble effect in the game controller’s triggers.
Send a controller specific effect packet
Update a controller’s LED color.
Set the player index of an opened game controller.
Set whether data reporting for a game controller sensor is enabled
Get the type of a game controller.
Update the current state of the open game controllers.
Is the joystick on this index supported by the game controller interface?

Unions