sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Gamepad

Description

SDL provides a low-level joystick API, which just treats joysticks as an arbitrary pile of buttons, axes, and hat switches. If you're planning to write your own control configuration screen, this can give you a lot of flexibility, but that's a lot of work, and most things that we consider "joysticks" now are actually console-style gamepads. So SDL provides the gamepad API on top of the lower-level joystick functionality.

The difference between a joystick and a gamepad is that a gamepad tells you where a button or axis is on the device. You don't speak to gamepads in terms of arbitrary numbers like "button 3" or "axis 2" but in standard locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or X/O/Square/Triangle, if you will).

One turns a joystick into a gamepad by providing a magic configuration string, which tells SDL the details of a specific device: when you see this specific hardware, if button 2 gets pressed, this is actually D-Pad Up, etc.

SDL has many popular controllers configured out of the box, and users can add their own controller details through an environment variable if it's otherwise unknown to SDL.

In order to use these functions, 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're using SDL gamepad support in a Steam game, you must call SteamAPI_InitEx() before calling init.

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

Gamepads support various optional features such as rumble, color LEDs, touchpad, gyro, etc. The support for these features varies depending on the controller and OS support available. You can check for LED and rumble capabilities at runtime by calling getGamepadProperties and checking the various capability properties. You can check for touchpad by calling getNumGamepadTouchpads and check for gyro and accelerometer by calling gamepadHasSensor.

By default SDL will try to use the most capable driver available, but you can tune which OS drivers to use with the various joystick hints in SDL_hints.h.

Your application should always support gamepad hotplugging. On some platforms like Xbox, Steam Deck, etc., this is a requirement for certification. On other platforms, like macOS and Windows when using Windows.Gaming.Input, controllers may not be available at startup and will come in at some point after you've started processing events. The structure used to identify an SDL gamepad

FFI conventions

Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Gamepad.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.

Full conventions: SDL3.Sys.

Since: 3.2.0

Synopsis

Documentation

Function aliases

addGamepadMapping Source #

Arguments

:: PtrConst CChar
mapping
the mapping string.
-> IO Int32 

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 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"
    
Returns
1 if a new mapping is added, 0 if an existing mapping is updated, -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMappingsFromFile, addGamepadMappingsFromIO, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_AddGamepadMapping. The safe flavor is addGamepadMappingSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMapping, defined at SDL3/SDL_gamepad.h 347:33

Since: 3.2.0

addGamepadMappingSafe Source #

Arguments

:: PtrConst CChar
mapping
the mapping string.
-> IO Int32 

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 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"
    
Returns
1 if a new mapping is added, 0 if an existing mapping is updated, -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMappingsFromFile, addGamepadMappingsFromIO, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_AddGamepadMapping. The unsafe flavor is addGamepadMapping .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMapping, defined at SDL3/SDL_gamepad.h 347:33

Since: 3.2.0

addGamepadMappingsFromIO Source #

Arguments

:: Ptr SDL_IOStream
src
the data stream for the mappings to be added.
-> Bool
closeio
if true, calls closeIO on src before returning, even in the case of an error.
-> IO Int32 

Load a set of gamepad mappings from an SDL_IOStream.

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.

Any new mappings for already plugged in controllers will generate SDL_EVENT_GAMEPAD_ADDED events.

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.

Returns
the number of mappings added or -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, addGamepadMappingsFromFile, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_AddGamepadMappingsFromIO. The safe flavor is addGamepadMappingsFromIOSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMappingsFromIO, defined at SDL3/SDL_gamepad.h 387:33

Since: 3.2.0

addGamepadMappingsFromIOSafe Source #

Arguments

:: Ptr SDL_IOStream
src
the data stream for the mappings to be added.
-> Bool
closeio
if true, calls closeIO on src before returning, even in the case of an error.
-> IO Int32 

Load a set of gamepad mappings from an SDL_IOStream.

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.

Any new mappings for already plugged in controllers will generate SDL_EVENT_GAMEPAD_ADDED events.

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.

Returns
the number of mappings added or -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, addGamepadMappingsFromFile, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_AddGamepadMappingsFromIO. The unsafe flavor is addGamepadMappingsFromIO .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMappingsFromIO, defined at SDL3/SDL_gamepad.h 387:33

Since: 3.2.0

addGamepadMappingsFromFile Source #

Arguments

:: PtrConst CChar
file
the mappings file to load.
-> IO Int32 

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.

Any new mappings for already plugged in controllers will generate SDL_EVENT_GAMEPAD_ADDED events.

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

Returns
the number of mappings added or -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, addGamepadMappingsFromIO, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_AddGamepadMappingsFromFile. The safe flavor is addGamepadMappingsFromFileSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMappingsFromFile, defined at SDL3/SDL_gamepad.h 421:33

Since: 3.2.0

addGamepadMappingsFromFileSafe Source #

Arguments

:: PtrConst CChar
file
the mappings file to load.
-> IO Int32 

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.

Any new mappings for already plugged in controllers will generate SDL_EVENT_GAMEPAD_ADDED events.

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

Returns
the number of mappings added or -1 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, addGamepadMappingsFromIO, getGamepadMapping, getGamepadMappingForGUID, SDL_HINT_GAMECONTROLLERCONFIG, SDL_HINT_GAMECONTROLLERCONFIG_FILE, SDL_EVENT_GAMEPAD_ADDED

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_AddGamepadMappingsFromFile. The unsafe flavor is addGamepadMappingsFromFile .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddGamepadMappingsFromFile, defined at SDL3/SDL_gamepad.h 421:33

Since: 3.2.0

reloadGamepadMappings :: IO Bool Source #

Reinitialize the SDL mapping database to its initial state.

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_ReloadGamepadMappings. The safe flavor is reloadGamepadMappingsSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_ReloadGamepadMappings, defined at SDL3/SDL_gamepad.h 435:34

Since: 3.2.0

reloadGamepadMappingsSafe :: IO Bool Source #

Reinitialize the SDL mapping database to its initial state.

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_ReloadGamepadMappings. The unsafe flavor is reloadGamepadMappings .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_ReloadGamepadMappings, defined at SDL3/SDL_gamepad.h 435:34

Since: 3.2.0

getGamepadMappings Source #

Arguments

:: Ptr CInt
count
a pointer filled in with the number of mappings returned, can be NULL.
-> IO (Ptr (Ptr CChar)) 

Get the current gamepad mappings.

Returns
an array of the mapping strings, NULL-terminated, or NULL on failure; call getError for more information. This is a single allocation that should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadMappings. The safe flavor is getGamepadMappingsSafe .
C declaration
SDL_GetGamepadMappings, defined at SDL3/SDL_gamepad.h 451:37

Since: 3.2.0

getGamepadMappingsSafe Source #

Arguments

:: Ptr CInt
count
a pointer filled in with the number of mappings returned, can be NULL.
-> IO (Ptr (Ptr CChar)) 

Get the current gamepad mappings.

Returns
an array of the mapping strings, NULL-terminated, or NULL on failure; call getError for more information. This is a single allocation that should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadMappings. The unsafe flavor is getGamepadMappings .
C declaration
SDL_GetGamepadMappings, defined at SDL3/SDL_gamepad.h 451:37

Since: 3.2.0

getGamepadMappingForGUID Source #

Arguments

:: SDL_GUID
guid
a structure containing the GUID for which a mapping is desired.
-> IO (Ptr CChar) 

Get the gamepad mapping string for a given GUID.

Returns
a mapping string or NULL on failure; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
getJoystickGUIDForID, getJoystickGUID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadMappingForGUID. The safe flavor is getGamepadMappingForGUIDSafe .
C declaration
SDL_GetGamepadMappingForGUID, defined at SDL3/SDL_gamepad.h 468:36

Since: 3.2.0

getGamepadMappingForGUIDSafe Source #

Arguments

:: SDL_GUID
guid
a structure containing the GUID for which a mapping is desired.
-> IO (Ptr CChar) 

Get the gamepad mapping string for a given GUID.

Returns
a mapping string or NULL on failure; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
getJoystickGUIDForID, getJoystickGUID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadMappingForGUID. The unsafe flavor is getGamepadMappingForGUID .
C declaration
SDL_GetGamepadMappingForGUID, defined at SDL3/SDL_gamepad.h 468:36

Since: 3.2.0

getGamepadMapping Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad you want to get the current mapping for.
-> IO (Ptr CChar) 

Get the current mapping of a gamepad.

Details about mappings are discussed with addGamepadMapping.

Returns
a string that has the gamepad's mapping or NULL if no mapping is available; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, getGamepadMappingForID, getGamepadMappingForGUID, setGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadMapping. The safe flavor is getGamepadMappingSafe .
C declaration
SDL_GetGamepadMapping, defined at SDL3/SDL_gamepad.h 489:36

Since: 3.2.0

getGamepadMappingSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad you want to get the current mapping for.
-> IO (Ptr CChar) 

Get the current mapping of a gamepad.

Details about mappings are discussed with addGamepadMapping.

Returns
a string that has the gamepad's mapping or NULL if no mapping is available; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, getGamepadMappingForID, getGamepadMappingForGUID, setGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadMapping. The unsafe flavor is getGamepadMapping .
C declaration
SDL_GetGamepadMapping, defined at SDL3/SDL_gamepad.h 489:36

Since: 3.2.0

setGamepadMapping Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> PtrConst CChar
mapping
the mapping to use for this device, or NULL to clear the mapping.
-> IO Bool 

Set the current mapping of a joystick or gamepad.

Details about mappings are discussed with addGamepadMapping.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, getGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetGamepadMapping. The safe flavor is setGamepadMappingSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadMapping, defined at SDL3/SDL_gamepad.h 509:34

Since: 3.2.0

setGamepadMappingSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> PtrConst CChar
mapping
the mapping to use for this device, or NULL to clear the mapping.
-> IO Bool 

Set the current mapping of a joystick or gamepad.

Details about mappings are discussed with addGamepadMapping.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
addGamepadMapping, getGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetGamepadMapping. The unsafe flavor is setGamepadMapping .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadMapping, defined at SDL3/SDL_gamepad.h 509:34

Since: 3.2.0

hasGamepad :: IO Bool Source #

Return whether a gamepad is currently connected.

Returns
true if a gamepad is connected, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_HasGamepad. The safe flavor is hasGamepadSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_HasGamepad, defined at SDL3/SDL_gamepad.h 522:34

Since: 3.2.0

hasGamepadSafe :: IO Bool Source #

Return whether a gamepad is currently connected.

Returns
true if a gamepad is connected, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_HasGamepad. The unsafe flavor is hasGamepad .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_HasGamepad, defined at SDL3/SDL_gamepad.h 522:34

Since: 3.2.0

getGamepads Source #

Arguments

:: Ptr CInt
count
a pointer filled in with the number of gamepads returned, may be NULL.
-> IO (Ptr SDL_JoystickID) 

Get a list of currently connected gamepads.

Returns
a 0 terminated array of joystick instance IDs or NULL on failure; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
hasGamepad, openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepads. The safe flavor is getGamepadsSafe .
C declaration
SDL_GetGamepads, defined at SDL3/SDL_gamepad.h 540:46

Since: 3.2.0

getGamepadsSafe Source #

Arguments

:: Ptr CInt
count
a pointer filled in with the number of gamepads returned, may be NULL.
-> IO (Ptr SDL_JoystickID) 

Get a list of currently connected gamepads.

Returns
a 0 terminated array of joystick instance IDs or NULL on failure; call getError for more information. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
hasGamepad, openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepads. The unsafe flavor is getGamepads .
C declaration
SDL_GetGamepads, defined at SDL3/SDL_gamepad.h 540:46

Since: 3.2.0

isGamepad Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Bool 

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

Returns
true if the given joystick is supported by the gamepad interface, false if it isn't or it's an invalid index.
Thread safety
It is safe to call this function from any thread.
See also
getJoysticks, openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_IsGamepad. The safe flavor is isGamepadSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_IsGamepad, defined at SDL3/SDL_gamepad.h 556:34

Since: 3.2.0

isGamepadSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Bool 

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

Returns
true if the given joystick is supported by the gamepad interface, false if it isn't or it's an invalid index.
Thread safety
It is safe to call this function from any thread.
See also
getJoysticks, openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_IsGamepad. The unsafe flavor is isGamepad .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_IsGamepad, defined at SDL3/SDL_gamepad.h 556:34

Since: 3.2.0

getGamepadNameForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (PtrConst CChar) 

Get the implementation dependent name of a gamepad.

This can be called before any gamepads are opened.

Returns
the name of the selected gamepad. If no name can be found, this function returns NULL; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadName, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadNameForID. The safe flavor is getGamepadNameForIDSafe .
C declaration
SDL_GetGamepadNameForID, defined at SDL3/SDL_gamepad.h 574:42

Since: 3.2.0

getGamepadNameForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (PtrConst CChar) 

Get the implementation dependent name of a gamepad.

This can be called before any gamepads are opened.

Returns
the name of the selected gamepad. If no name can be found, this function returns NULL; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadName, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadNameForID. The unsafe flavor is getGamepadNameForID .
C declaration
SDL_GetGamepadNameForID, defined at SDL3/SDL_gamepad.h 574:42

Since: 3.2.0

getGamepadPathForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (PtrConst CChar) 

Get the implementation dependent path of a gamepad.

This can be called before any gamepads are opened.

Returns
the path of the selected gamepad. If no path can be found, this function returns NULL; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPath, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadPathForID. The safe flavor is getGamepadPathForIDSafe .
C declaration
SDL_GetGamepadPathForID, defined at SDL3/SDL_gamepad.h 592:42

Since: 3.2.0

getGamepadPathForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (PtrConst CChar) 

Get the implementation dependent path of a gamepad.

This can be called before any gamepads are opened.

Returns
the path of the selected gamepad. If no path can be found, this function returns NULL; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPath, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadPathForID. The unsafe flavor is getGamepadPathForID .
C declaration
SDL_GetGamepadPathForID, defined at SDL3/SDL_gamepad.h 592:42

Since: 3.2.0

getGamepadPlayerIndexForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Int32 

Get the player index of a gamepad.

This can be called before any gamepads are opened.

Returns
the player index of a gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadPlayerIndexForID. The safe flavor is getGamepadPlayerIndexForIDSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadPlayerIndexForID, defined at SDL3/SDL_gamepad.h 609:33

Since: 3.2.0

getGamepadPlayerIndexForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Int32 

Get the player index of a gamepad.

This can be called before any gamepads are opened.

Returns
the player index of a gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadPlayerIndexForID. The unsafe flavor is getGamepadPlayerIndexForID .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadPlayerIndexForID, defined at SDL3/SDL_gamepad.h 609:33

Since: 3.2.0

getGamepadGUIDForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GUID 

Get the implementation-dependent GUID of a gamepad.

This can be called before any gamepads are opened.

Returns
the GUID of the selected gamepad. If called on an invalid index, this function returns a zero GUID.
Thread safety
It is safe to call this function from any thread.
See also
guidToString, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadGUIDForID. The safe flavor is getGamepadGUIDForIDSafe .
C declaration
SDL_GetGamepadGUIDForID, defined at SDL3/SDL_gamepad.h 627:38

Since: 3.2.0

getGamepadGUIDForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GUID 

Get the implementation-dependent GUID of a gamepad.

This can be called before any gamepads are opened.

Returns
the GUID of the selected gamepad. If called on an invalid index, this function returns a zero GUID.
Thread safety
It is safe to call this function from any thread.
See also
guidToString, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadGUIDForID. The unsafe flavor is getGamepadGUIDForID .
C declaration
SDL_GetGamepadGUIDForID, defined at SDL3/SDL_gamepad.h 627:38

Since: 3.2.0

getGamepadVendorForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the USB vendor ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadVendor, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadVendorForID. The safe flavor is getGamepadVendorForIDSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadVendorForID, defined at SDL3/SDL_gamepad.h 646:36

Since: 3.2.0

getGamepadVendorForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the USB vendor ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadVendor, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadVendorForID. The unsafe flavor is getGamepadVendorForID .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadVendorForID, defined at SDL3/SDL_gamepad.h 646:36

Since: 3.2.0

getGamepadProductForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the USB product ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProduct, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadProductForID. The safe flavor is getGamepadProductForIDSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductForID, defined at SDL3/SDL_gamepad.h 665:36

Since: 3.2.0

getGamepadProductForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the USB product ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProduct, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadProductForID. The unsafe flavor is getGamepadProductForID .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductForID, defined at SDL3/SDL_gamepad.h 665:36

Since: 3.2.0

getGamepadProductVersionForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the product version of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductVersion, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadProductVersionForID. The safe flavor is getGamepadProductVersionForIDSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductVersionForID, defined at SDL3/SDL_gamepad.h 684:36

Since: 3.2.0

getGamepadProductVersionForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO Word16 

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.

Returns
the product version of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductVersion, getGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadProductVersionForID. The unsafe flavor is getGamepadProductVersionForID .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductVersionForID, defined at SDL3/SDL_gamepad.h 684:36

Since: 3.2.0

getGamepadTypeForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GamepadType 

Get the type of a gamepad.

This can be called before any gamepads are opened.

Returns
the gamepad type.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadType, getGamepads, getRealGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadTypeForID. The safe flavor is getGamepadTypeForIDSafe .
C declaration
SDL_GetGamepadTypeForID, defined at SDL3/SDL_gamepad.h 702:45

Since: 3.2.0

getGamepadTypeForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GamepadType 

Get the type of a gamepad.

This can be called before any gamepads are opened.

Returns
the gamepad type.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadType, getGamepads, getRealGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadTypeForID. The unsafe flavor is getGamepadTypeForID .
C declaration
SDL_GetGamepadTypeForID, defined at SDL3/SDL_gamepad.h 702:45

Since: 3.2.0

getRealGamepadTypeForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GamepadType 

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

This can be called before any gamepads are opened.

Returns
the gamepad type.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeForID, getGamepads, getRealGamepadType

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetRealGamepadTypeForID. The safe flavor is getRealGamepadTypeForIDSafe .
C declaration
SDL_GetRealGamepadTypeForID, defined at SDL3/SDL_gamepad.h 720:45

Since: 3.2.0

getRealGamepadTypeForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO SDL_GamepadType 

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

This can be called before any gamepads are opened.

Returns
the gamepad type.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeForID, getGamepads, getRealGamepadType

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetRealGamepadTypeForID. The unsafe flavor is getRealGamepadTypeForID .
C declaration
SDL_GetRealGamepadTypeForID, defined at SDL3/SDL_gamepad.h 720:45

Since: 3.2.0

getGamepadMappingForID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (Ptr CChar) 

Get the mapping of a gamepad.

This can be called before any gamepads are opened.

Returns
the mapping string. Returns NULL if no mapping is available. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
getGamepads, getGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadMappingForID. The safe flavor is getGamepadMappingForIDSafe .
C declaration
SDL_GetGamepadMappingForID, defined at SDL3/SDL_gamepad.h 738:36

Since: 3.2.0

getGamepadMappingForIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (Ptr CChar) 

Get the mapping of a gamepad.

This can be called before any gamepads are opened.

Returns
the mapping string. Returns NULL if no mapping is available. This should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
getGamepads, getGamepadMapping

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadMappingForID. The unsafe flavor is getGamepadMappingForID .
C declaration
SDL_GetGamepadMappingForID, defined at SDL3/SDL_gamepad.h 738:36

Since: 3.2.0

openGamepad Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (Ptr SDL_Gamepad) 

Open a gamepad for use.

Returns
a gamepad identifier or NULL if an error occurred; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
closeGamepad, isGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_OpenGamepad. The safe flavor is openGamepadSafe .
C declaration
SDL_OpenGamepad, defined at SDL3/SDL_gamepad.h 754:43

Since: 3.2.0

openGamepadSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID.
-> IO (Ptr SDL_Gamepad) 

Open a gamepad for use.

Returns
a gamepad identifier or NULL if an error occurred; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
closeGamepad, isGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_OpenGamepad. The unsafe flavor is openGamepad .
C declaration
SDL_OpenGamepad, defined at SDL3/SDL_gamepad.h 754:43

Since: 3.2.0

getGamepadFromID Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID of the gamepad.
-> IO (Ptr SDL_Gamepad) 

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

Returns
an SDL_Gamepad on success or NULL on failure or if it hasn't been opened yet; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadFromID. The safe flavor is getGamepadFromIDSafe .
C declaration
SDL_GetGamepadFromID, defined at SDL3/SDL_gamepad.h 768:43

Since: 3.2.0

getGamepadFromIDSafe Source #

Arguments

:: SDL_JoystickID
instance_id
the joystick instance ID of the gamepad.
-> IO (Ptr SDL_Gamepad) 

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

Returns
an SDL_Gamepad on success or NULL on failure or if it hasn't been opened yet; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadFromID. The unsafe flavor is getGamepadFromID .
C declaration
SDL_GetGamepadFromID, defined at SDL3/SDL_gamepad.h 768:43

Since: 3.2.0

getGamepadFromPlayerIndex Source #

Arguments

:: Int32
player_index
the player index, which different from the instance ID.
-> IO (Ptr SDL_Gamepad) 

Get the SDL_Gamepad associated with a player index.

Returns
the SDL_Gamepad associated with a player index.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex, setGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadFromPlayerIndex. The safe flavor is getGamepadFromPlayerIndexSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadFromPlayerIndex, defined at SDL3/SDL_gamepad.h 783:43

Since: 3.2.0

getGamepadFromPlayerIndexSafe Source #

Arguments

:: Int32
player_index
the player index, which different from the instance ID.
-> IO (Ptr SDL_Gamepad) 

Get the SDL_Gamepad associated with a player index.

Returns
the SDL_Gamepad associated with a player index.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex, setGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadFromPlayerIndex. The unsafe flavor is getGamepadFromPlayerIndex .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadFromPlayerIndex, defined at SDL3/SDL_gamepad.h 783:43

Since: 3.2.0

getGamepadProperties Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO SDL_PropertiesID 

Get the properties associated with an opened gamepad.

These properties are shared with the underlying joystick object.

The following read-only properties are provided by SDL:

  • sDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN: true if this gamepad has an LED that has adjustable brightness
  • sDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN: true if this gamepad has an LED that has adjustable color
  • sDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN: true if this gamepad has a player LED
  • sDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN: true if this gamepad has left/right rumble
  • sDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN: true if this gamepad has simple trigger rumble
Returns
a valid property ID on success or 0 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadProperties. The safe flavor is getGamepadPropertiesSafe .
C declaration
SDL_GetGamepadProperties, defined at SDL3/SDL_gamepad.h 812:46

Since: 3.2.0

getGamepadPropertiesSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO SDL_PropertiesID 

Get the properties associated with an opened gamepad.

These properties are shared with the underlying joystick object.

The following read-only properties are provided by SDL:

  • sDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN: true if this gamepad has an LED that has adjustable brightness
  • sDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN: true if this gamepad has an LED that has adjustable color
  • sDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN: true if this gamepad has a player LED
  • sDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN: true if this gamepad has left/right rumble
  • sDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN: true if this gamepad has simple trigger rumble
Returns
a valid property ID on success or 0 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadProperties. The unsafe flavor is getGamepadProperties .
C declaration
SDL_GetGamepadProperties, defined at SDL3/SDL_gamepad.h 812:46

Since: 3.2.0

getGamepadID Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO SDL_JoystickID 

Get the instance ID of an opened gamepad.

Returns
the instance ID of the specified gamepad on success or 0 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadID. The safe flavor is getGamepadIDSafe .
C declaration
SDL_GetGamepadID, defined at SDL3/SDL_gamepad.h 832:44

Since: 3.2.0

getGamepadIDSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO SDL_JoystickID 

Get the instance ID of an opened gamepad.

Returns
the instance ID of the specified gamepad on success or 0 on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadID. The unsafe flavor is getGamepadID .
C declaration
SDL_GetGamepadID, defined at SDL3/SDL_gamepad.h 832:44

Since: 3.2.0

getGamepadName Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO (PtrConst CChar) 

Get the implementation-dependent name for an opened gamepad.

Returns
the implementation dependent name for the gamepad, or NULL if there is no name or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadNameForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadName. The safe flavor is getGamepadNameSafe .
C declaration
SDL_GetGamepadName, defined at SDL3/SDL_gamepad.h 848:42

Since: 3.2.0

getGamepadNameSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO (PtrConst CChar) 

Get the implementation-dependent name for an opened gamepad.

Returns
the implementation dependent name for the gamepad, or NULL if there is no name or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadNameForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadName. The unsafe flavor is getGamepadName .
C declaration
SDL_GetGamepadName, defined at SDL3/SDL_gamepad.h 848:42

Since: 3.2.0

getGamepadPath Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO (PtrConst CChar) 

Get the implementation-dependent path for an opened gamepad.

Returns
the implementation dependent path for the gamepad, or NULL if there is no path or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPathForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadPath. The safe flavor is getGamepadPathSafe .
C declaration
SDL_GetGamepadPath, defined at SDL3/SDL_gamepad.h 864:42

Since: 3.2.0

getGamepadPathSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO (PtrConst CChar) 

Get the implementation-dependent path for an opened gamepad.

Returns
the implementation dependent path for the gamepad, or NULL if there is no path or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPathForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadPath. The unsafe flavor is getGamepadPath .
C declaration
SDL_GetGamepadPath, defined at SDL3/SDL_gamepad.h 864:42

Since: 3.2.0

getGamepadType Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_GamepadType 

Get the type of an opened gamepad.

Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadType. The safe flavor is getGamepadTypeSafe .
C declaration
SDL_GetGamepadType, defined at SDL3/SDL_gamepad.h 879:45

Since: 3.2.0

getGamepadTypeSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_GamepadType 

Get the type of an opened gamepad.

Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadType. The unsafe flavor is getGamepadType .
C declaration
SDL_GetGamepadType, defined at SDL3/SDL_gamepad.h 879:45

Since: 3.2.0

getRealGamepadType Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_GamepadType 

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

Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getRealGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetRealGamepadType. The safe flavor is getRealGamepadTypeSafe .
C declaration
SDL_GetRealGamepadType, defined at SDL3/SDL_gamepad.h 894:45

Since: 3.2.0

getRealGamepadTypeSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_GamepadType 

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

Returns
the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
getRealGamepadTypeForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetRealGamepadType. The unsafe flavor is getRealGamepadType .
C declaration
SDL_GetRealGamepadType, defined at SDL3/SDL_gamepad.h 894:45

Since: 3.2.0

getGamepadPlayerIndex Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Int32 

Get the player index of an opened gamepad.

For XInput gamepads this returns the XInput user index.

Returns
the player index for gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadPlayerIndex. The safe flavor is getGamepadPlayerIndexSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadPlayerIndex, defined at SDL3/SDL_gamepad.h 910:33

Since: 3.2.0

getGamepadPlayerIndexSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Int32 

Get the player index of an opened gamepad.

For XInput gamepads this returns the XInput user index.

Returns
the player index for gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadPlayerIndex. The unsafe flavor is getGamepadPlayerIndex .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadPlayerIndex, defined at SDL3/SDL_gamepad.h 910:33

Since: 3.2.0

setGamepadPlayerIndex Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to adjust.
-> Int32
player_index
player index to assign to this gamepad, or -1 to clear the player index and turn off player LEDs.
-> IO Bool 

Set the player index of an opened gamepad.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetGamepadPlayerIndex. The safe flavor is setGamepadPlayerIndexSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadPlayerIndex, defined at SDL3/SDL_gamepad.h 927:34

Since: 3.2.0

setGamepadPlayerIndexSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to adjust.
-> Int32
player_index
player index to assign to this gamepad, or -1 to clear the player index and turn off player LEDs.
-> IO Bool 

Set the player index of an opened gamepad.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadPlayerIndex

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetGamepadPlayerIndex. The unsafe flavor is setGamepadPlayerIndex .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadPlayerIndex, defined at SDL3/SDL_gamepad.h 927:34

Since: 3.2.0

getGamepadVendor Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB vendor ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadVendorForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadVendor. The safe flavor is getGamepadVendorSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadVendor, defined at SDL3/SDL_gamepad.h 943:36

Since: 3.2.0

getGamepadVendorSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB vendor ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadVendorForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadVendor. The unsafe flavor is getGamepadVendor .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadVendor, defined at SDL3/SDL_gamepad.h 943:36

Since: 3.2.0

getGamepadProduct Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB product ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadProduct. The safe flavor is getGamepadProductSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProduct, defined at SDL3/SDL_gamepad.h 959:36

Since: 3.2.0

getGamepadProductSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB product ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadProduct. The unsafe flavor is getGamepadProduct .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProduct, defined at SDL3/SDL_gamepad.h 959:36

Since: 3.2.0

getGamepadProductVersion Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB product version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductVersionForID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadProductVersion. The safe flavor is getGamepadProductVersionSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductVersion, defined at SDL3/SDL_gamepad.h 975:36

Since: 3.2.0

getGamepadProductVersionSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the USB product version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadProductVersionForID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadProductVersion. The unsafe flavor is getGamepadProductVersion .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadProductVersion, defined at SDL3/SDL_gamepad.h 975:36

Since: 3.2.0

getGamepadFirmwareVersion Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the gamepad firmware version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadFirmwareVersion. The safe flavor is getGamepadFirmwareVersionSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadFirmwareVersion, defined at SDL3/SDL_gamepad.h 989:36

Since: 3.2.0

getGamepadFirmwareVersionSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word16 

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

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

Returns
the gamepad firmware version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadFirmwareVersion. The unsafe flavor is getGamepadFirmwareVersion .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadFirmwareVersion, defined at SDL3/SDL_gamepad.h 989:36

Since: 3.2.0

getGamepadSerial Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO (PtrConst CChar) 

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

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

Returns
the serial number, or NULL if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadSerial. The safe flavor is getGamepadSerialSafe .
C declaration
SDL_GetGamepadSerial, defined at SDL3/SDL_gamepad.h 1003:42

Since: 3.2.0

getGamepadSerialSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO (PtrConst CChar) 

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

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

Returns
the serial number, or NULL if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadSerial. The unsafe flavor is getGamepadSerial .
C declaration
SDL_GetGamepadSerial, defined at SDL3/SDL_gamepad.h 1003:42

Since: 3.2.0

getGamepadSteamHandle Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word64 

Get the Steam Input handle of an opened gamepad, if available.

Returns an InputHandle_t for the gamepad that can be used with Steam Input API: https://partner.steamgames.com/doc/api/ISteamInput

Returns
the gamepad handle, or 0 if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadSteamHandle. The safe flavor is getGamepadSteamHandleSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSteamHandle, defined at SDL3/SDL_gamepad.h 1018:36

Since: 3.2.0

getGamepadSteamHandleSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO Word64 

Get the Steam Input handle of an opened gamepad, if available.

Returns an InputHandle_t for the gamepad that can be used with Steam Input API: https://partner.steamgames.com/doc/api/ISteamInput

Returns
the gamepad handle, or 0 if unavailable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadSteamHandle. The unsafe flavor is getGamepadSteamHandle .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSteamHandle, defined at SDL3/SDL_gamepad.h 1018:36

Since: 3.2.0

getGamepadConnectionState Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_JoystickConnectionState 

Get the connection state of a gamepad.

Returns
the connection state on success or SDL_JOYSTICK_CONNECTION_INVALID on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadConnectionState. The safe flavor is getGamepadConnectionStateSafe .
C declaration
SDL_GetGamepadConnectionState, defined at SDL3/SDL_gamepad.h 1032:57

Since: 3.2.0

getGamepadConnectionStateSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> IO SDL_JoystickConnectionState 

Get the connection state of a gamepad.

Returns
the connection state on success or SDL_JOYSTICK_CONNECTION_INVALID on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadConnectionState. The unsafe flavor is getGamepadConnectionState .
C declaration
SDL_GetGamepadConnectionState, defined at SDL3/SDL_gamepad.h 1032:57

Since: 3.2.0

getGamepadPowerInfo Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> Ptr CInt
percent
a pointer filled in with the percentage of battery life left, between 0 and 100, or NULL to ignore. This will be filled in with -1 we can't determine a value or there is no battery.
-> IO SDL_PowerState 

Get the battery state of a gamepad.

You should never take a battery status as absolute truth. Batteries (especially failing batteries) are delicate hardware, and the values reported here are best estimates based on what that hardware reports. It's not uncommon for older batteries to lose stored power much faster than it reports, or completely drain when reporting it has 20 percent left, etc.

Returns
the current battery state.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadPowerInfo. The safe flavor is getGamepadPowerInfoSafe .
C declaration
SDL_GetGamepadPowerInfo, defined at SDL3/SDL_gamepad.h 1054:44

Since: 3.2.0

getGamepadPowerInfoSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object to query.
-> Ptr CInt
percent
a pointer filled in with the percentage of battery life left, between 0 and 100, or NULL to ignore. This will be filled in with -1 we can't determine a value or there is no battery.
-> IO SDL_PowerState 

Get the battery state of a gamepad.

You should never take a battery status as absolute truth. Batteries (especially failing batteries) are delicate hardware, and the values reported here are best estimates based on what that hardware reports. It's not uncommon for older batteries to lose stored power much faster than it reports, or completely drain when reporting it has 20 percent left, etc.

Returns
the current battery state.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadPowerInfo. The unsafe flavor is getGamepadPowerInfo .
C declaration
SDL_GetGamepadPowerInfo, defined at SDL3/SDL_gamepad.h 1054:44

Since: 3.2.0

gamepadConnected Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO Bool 

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

Returns
true if the gamepad has been opened and is currently connected, or false if not.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadConnected. The safe flavor is gamepadConnectedSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadConnected, defined at SDL3/SDL_gamepad.h 1068:34

Since: 3.2.0

gamepadConnectedSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO Bool 

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

Returns
true if the gamepad has been opened and is currently connected, or false if not.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadConnected. The unsafe flavor is gamepadConnected .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadConnected, defined at SDL3/SDL_gamepad.h 1068:34

Since: 3.2.0

getGamepadJoystick Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object that you want to get a joystick from.
-> IO (Ptr SDL_Joystick) 

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 closeJoystick on it, for example, since doing so will likely cause SDL to crash.

Returns
an SDL_Joystick object, or NULL on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadJoystick. The safe flavor is getGamepadJoystickSafe .
C declaration
SDL_GetGamepadJoystick, defined at SDL3/SDL_gamepad.h 1090:44

Since: 3.2.0

getGamepadJoystickSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad object that you want to get a joystick from.
-> IO (Ptr SDL_Joystick) 

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 closeJoystick on it, for example, since doing so will likely cause SDL to crash.

Returns
an SDL_Joystick object, or NULL on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadJoystick. The unsafe flavor is getGamepadJoystick .
C declaration
SDL_GetGamepadJoystick, defined at SDL3/SDL_gamepad.h 1090:44

Since: 3.2.0

setGamepadEventsEnabled Source #

Arguments

:: Bool
enabled
whether to process gamepad events or not.
-> IO () 

Set the state of gamepad event processing.

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

Thread safety
It is safe to call this function from any thread.
See also
gamepadEventsEnabled, updateGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetGamepadEventsEnabled. The safe flavor is setGamepadEventsEnabledSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadEventsEnabled, defined at SDL3/SDL_gamepad.h 1107:34

Since: 3.2.0

setGamepadEventsEnabledSafe Source #

Arguments

:: Bool
enabled
whether to process gamepad events or not.
-> IO () 

Set the state of gamepad event processing.

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

Thread safety
It is safe to call this function from any thread.
See also
gamepadEventsEnabled, updateGamepads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetGamepadEventsEnabled. The unsafe flavor is setGamepadEventsEnabled .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadEventsEnabled, defined at SDL3/SDL_gamepad.h 1107:34

Since: 3.2.0

gamepadEventsEnabled :: IO Bool Source #

Query the state of gamepad event processing.

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

Returns
true if gamepad events are being processed, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadEventsEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadEventsEnabled. The safe flavor is gamepadEventsEnabledSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadEventsEnabled, defined at SDL3/SDL_gamepad.h 1123:34

Since: 3.2.0

gamepadEventsEnabledSafe :: IO Bool Source #

Query the state of gamepad event processing.

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

Returns
true if gamepad events are being processed, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadEventsEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadEventsEnabled. The unsafe flavor is gamepadEventsEnabled .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadEventsEnabled, defined at SDL3/SDL_gamepad.h 1123:34

Since: 3.2.0

getGamepadBindings Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Ptr CInt
count
a pointer filled in with the number of bindings returned.
-> IO (Ptr (Ptr SDL_GamepadBinding)) 

Get the SDL joystick layer bindings for a gamepad.

Returns
a NULL terminated array of pointers to bindings or NULL on failure; call getError for more information. This is a single allocation that should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadBindings. The safe flavor is getGamepadBindingsSafe .
C declaration
SDL_GetGamepadBindings, defined at SDL3/SDL_gamepad.h 1139:51

Since: 3.2.0

getGamepadBindingsSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Ptr CInt
count
a pointer filled in with the number of bindings returned.
-> IO (Ptr (Ptr SDL_GamepadBinding)) 

Get the SDL joystick layer bindings for a gamepad.

Returns
a NULL terminated array of pointers to bindings or NULL on failure; call getError for more information. This is a single allocation that should be freed with free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadBindings. The unsafe flavor is getGamepadBindings .
C declaration
SDL_GetGamepadBindings, defined at SDL3/SDL_gamepad.h 1139:51

Since: 3.2.0

updateGamepads :: IO () Source #

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.

Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_UpdateGamepads. The safe flavor is updateGamepadsSafe : routes through joystick update; virtual-device callbacks run synchronously.
C declaration
SDL_UpdateGamepads, defined at SDL3/SDL_gamepad.h 1152:34

Since: 3.2.0

updateGamepadsSafe :: IO () Source #

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.

Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_UpdateGamepads. The unsafe flavor is updateGamepads : routes through joystick update; virtual-device callbacks run synchronously.
C declaration
SDL_UpdateGamepads, defined at SDL3/SDL_gamepad.h 1152:34

Since: 3.2.0

getGamepadTypeFromString Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_GamepadType type.
-> IO SDL_GamepadType 

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.

Returns
the SDL_GamepadType enum corresponding to the input string, or SDL_GAMEPAD_TYPE_UNKNOWN if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForType

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadTypeFromString. The safe flavor is getGamepadTypeFromStringSafe .
C declaration
SDL_GetGamepadTypeFromString, defined at SDL3/SDL_gamepad.h 1172:45

Since: 3.2.0

getGamepadTypeFromStringSafe Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_GamepadType type.
-> IO SDL_GamepadType 

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.

Returns
the SDL_GamepadType enum corresponding to the input string, or SDL_GAMEPAD_TYPE_UNKNOWN if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForType

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadTypeFromString. The unsafe flavor is getGamepadTypeFromString .
C declaration
SDL_GetGamepadTypeFromString, defined at SDL3/SDL_gamepad.h 1172:45

Since: 3.2.0

getGamepadStringForType Source #

Arguments

:: SDL_GamepadType
type
an enum value for a given SDL_GamepadType.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadType enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadStringForType. The safe flavor is getGamepadStringForTypeSafe .
C declaration
SDL_GetGamepadStringForType, defined at SDL3/SDL_gamepad.h 1188:42

Since: 3.2.0

getGamepadStringForTypeSafe Source #

Arguments

:: SDL_GamepadType
type
an enum value for a given SDL_GamepadType.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadType enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTypeFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadStringForType. The unsafe flavor is getGamepadStringForType .
C declaration
SDL_GetGamepadStringForType, defined at SDL3/SDL_gamepad.h 1188:42

Since: 3.2.0

getGamepadAxisFromString Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_Gamepad axis.
-> IO SDL_GamepadAxis 

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.

Returns
the SDL_GamepadAxis enum corresponding to the input string, or SDL_GAMEPAD_AXIS_INVALID if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadAxisFromString. The safe flavor is getGamepadAxisFromStringSafe .
C declaration
SDL_GetGamepadAxisFromString, defined at SDL3/SDL_gamepad.h 1212:45

Since: 3.2.0

getGamepadAxisFromStringSafe Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_Gamepad axis.
-> IO SDL_GamepadAxis 

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.

Returns
the SDL_GamepadAxis enum corresponding to the input string, or SDL_GAMEPAD_AXIS_INVALID if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadAxisFromString. The unsafe flavor is getGamepadAxisFromString .
C declaration
SDL_GetGamepadAxisFromString, defined at SDL3/SDL_gamepad.h 1212:45

Since: 3.2.0

getGamepadStringForAxis Source #

Arguments

:: SDL_GamepadAxis
axis
an enum value for a given SDL_GamepadAxis.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadAxis enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAxisFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadStringForAxis. The safe flavor is getGamepadStringForAxisSafe .
C declaration
SDL_GetGamepadStringForAxis, defined at SDL3/SDL_gamepad.h 1228:42

Since: 3.2.0

getGamepadStringForAxisSafe Source #

Arguments

:: SDL_GamepadAxis
axis
an enum value for a given SDL_GamepadAxis.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadAxis enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAxisFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadStringForAxis. The unsafe flavor is getGamepadStringForAxis .
C declaration
SDL_GetGamepadStringForAxis, defined at SDL3/SDL_gamepad.h 1228:42

Since: 3.2.0

gamepadHasAxis Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadAxis
axis
an axis enum value (an SDL_GamepadAxis value).
-> IO Bool 

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.

Returns
true if the gamepad has this axis, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasButton, getGamepadAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadHasAxis. The safe flavor is gamepadHasAxisSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasAxis, defined at SDL3/SDL_gamepad.h 1247:34

Since: 3.2.0

gamepadHasAxisSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadAxis
axis
an axis enum value (an SDL_GamepadAxis value).
-> IO Bool 

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.

Returns
true if the gamepad has this axis, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasButton, getGamepadAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadHasAxis. The unsafe flavor is gamepadHasAxis .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasAxis, defined at SDL3/SDL_gamepad.h 1247:34

Since: 3.2.0

getGamepadAxis Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadAxis
axis
an axis index (one of the SDL_GamepadAxis values).
-> IO Int16 

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

The axis indices start at index 0.

For thumbsticks, the state is a value ranging from -32768 (up/left) to 32767 (down/right).

Triggers range from 0 when released to 32767 when fully pressed, and never return a negative value. Note that this differs from the value reported by the lower-level getJoystickAxis, which normally uses the full range.

Note that for invalid gamepads or axes, this will return 0. Zero is also a valid value in normal operation; usually it means a centered axis.

Returns
axis state.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasAxis, getGamepadButton

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadAxis. The safe flavor is getGamepadAxisSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadAxis, defined at SDL3/SDL_gamepad.h 1275:36

Since: 3.2.0

getGamepadAxisSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadAxis
axis
an axis index (one of the SDL_GamepadAxis values).
-> IO Int16 

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

The axis indices start at index 0.

For thumbsticks, the state is a value ranging from -32768 (up/left) to 32767 (down/right).

Triggers range from 0 when released to 32767 when fully pressed, and never return a negative value. Note that this differs from the value reported by the lower-level getJoystickAxis, which normally uses the full range.

Note that for invalid gamepads or axes, this will return 0. Zero is also a valid value in normal operation; usually it means a centered axis.

Returns
axis state.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasAxis, getGamepadButton

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadAxis. The unsafe flavor is getGamepadAxis .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadAxis, defined at SDL3/SDL_gamepad.h 1275:36

Since: 3.2.0

getGamepadButtonFromString Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_Gamepad button.
-> IO SDL_GamepadButton 

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.

Returns
the SDL_GamepadButton enum corresponding to the input string, or SDL_GAMEPAD_BUTTON_INVALID if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForButton

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadButtonFromString. The safe flavor is getGamepadButtonFromStringSafe .
C declaration
SDL_GetGamepadButtonFromString, defined at SDL3/SDL_gamepad.h 1295:47

Since: 3.2.0

getGamepadButtonFromStringSafe Source #

Arguments

:: PtrConst CChar
str
string representing a SDL_Gamepad button.
-> IO SDL_GamepadButton 

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.

Returns
the SDL_GamepadButton enum corresponding to the input string, or SDL_GAMEPAD_BUTTON_INVALID if no match was found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadStringForButton

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadButtonFromString. The unsafe flavor is getGamepadButtonFromString .
C declaration
SDL_GetGamepadButtonFromString, defined at SDL3/SDL_gamepad.h 1295:47

Since: 3.2.0

getGamepadStringForButton Source #

Arguments

:: SDL_GamepadButton
button
an enum value for a given SDL_GamepadButton.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadButton enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadStringForButton. The safe flavor is getGamepadStringForButtonSafe .
C declaration
SDL_GetGamepadStringForButton, defined at SDL3/SDL_gamepad.h 1311:42

Since: 3.2.0

getGamepadStringForButtonSafe Source #

Arguments

:: SDL_GamepadButton
button
an enum value for a given SDL_GamepadButton.
-> IO (PtrConst CChar) 

Convert from an SDL_GamepadButton enum to a string.

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.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonFromString

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadStringForButton. The unsafe flavor is getGamepadStringForButton .
C declaration
SDL_GetGamepadStringForButton, defined at SDL3/SDL_gamepad.h 1311:42

Since: 3.2.0

gamepadHasButton Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button enum value (an SDL_GamepadButton value).
-> IO Bool 

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.

Returns
true if the gamepad has this button, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadHasButton. The safe flavor is gamepadHasButtonSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasButton, defined at SDL3/SDL_gamepad.h 1329:34

Since: 3.2.0

gamepadHasButtonSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button enum value (an SDL_GamepadButton value).
-> IO Bool 

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.

Returns
true if the gamepad has this button, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadHasButton. The unsafe flavor is gamepadHasButton .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasButton, defined at SDL3/SDL_gamepad.h 1329:34

Since: 3.2.0

getGamepadButton Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO Bool 

Get the current state of a button on a gamepad.

Returns
true if the button is pressed, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasButton, getGamepadAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadButton. The safe flavor is getGamepadButtonSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadButton, defined at SDL3/SDL_gamepad.h 1345:34

Since: 3.2.0

getGamepadButtonSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO Bool 

Get the current state of a button on a gamepad.

Returns
true if the button is pressed, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasButton, getGamepadAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadButton. The unsafe flavor is getGamepadButton .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadButton, defined at SDL3/SDL_gamepad.h 1345:34

Since: 3.2.0

getGamepadButtonLabelForType Source #

Arguments

:: SDL_GamepadType
type
the type of gamepad to check.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO SDL_GamepadButtonLabel 

Get the label of a button on a gamepad.

Returns
the SDL_GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonLabel

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadButtonLabelForType. The safe flavor is getGamepadButtonLabelForTypeSafe .
C declaration
SDL_GetGamepadButtonLabelForType, defined at SDL3/SDL_gamepad.h 1360:52

Since: 3.2.0

getGamepadButtonLabelForTypeSafe Source #

Arguments

:: SDL_GamepadType
type
the type of gamepad to check.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO SDL_GamepadButtonLabel 

Get the label of a button on a gamepad.

Returns
the SDL_GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonLabel

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadButtonLabelForType. The unsafe flavor is getGamepadButtonLabelForType .
C declaration
SDL_GetGamepadButtonLabelForType, defined at SDL3/SDL_gamepad.h 1360:52

Since: 3.2.0

getGamepadButtonLabel Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO SDL_GamepadButtonLabel 

Get the label of a button on a gamepad.

Returns
the SDL_GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonLabelForType

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadButtonLabel. The safe flavor is getGamepadButtonLabelSafe .
C declaration
SDL_GetGamepadButtonLabel, defined at SDL3/SDL_gamepad.h 1375:52

Since: 3.2.0

getGamepadButtonLabelSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> SDL_GamepadButton
button
a button index (one of the SDL_GamepadButton values).
-> IO SDL_GamepadButtonLabel 

Get the label of a button on a gamepad.

Returns
the SDL_GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadButtonLabelForType

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadButtonLabel. The unsafe flavor is getGamepadButtonLabel .
C declaration
SDL_GetGamepadButtonLabel, defined at SDL3/SDL_gamepad.h 1375:52

Since: 3.2.0

getNumGamepadTouchpads Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> IO Int32 

Get the number of touchpads on a gamepad.

Returns
number of touchpads.
Thread safety
It is safe to call this function from any thread.
See also
getNumGamepadTouchpadFingers

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetNumGamepadTouchpads. The safe flavor is getNumGamepadTouchpadsSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetNumGamepadTouchpads, defined at SDL3/SDL_gamepad.h 1389:33

Since: 3.2.0

getNumGamepadTouchpadsSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> IO Int32 

Get the number of touchpads on a gamepad.

Returns
number of touchpads.
Thread safety
It is safe to call this function from any thread.
See also
getNumGamepadTouchpadFingers

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetNumGamepadTouchpads. The unsafe flavor is getNumGamepadTouchpads .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetNumGamepadTouchpads, defined at SDL3/SDL_gamepad.h 1389:33

Since: 3.2.0

getNumGamepadTouchpadFingers Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Int32
touchpad
a touchpad.
-> IO Int32 

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

Returns
number of supported simultaneous fingers.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTouchpadFinger, getNumGamepadTouchpads

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetNumGamepadTouchpadFingers. The safe flavor is getNumGamepadTouchpadFingersSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetNumGamepadTouchpadFingers, defined at SDL3/SDL_gamepad.h 1406:33

Since: 3.2.0

getNumGamepadTouchpadFingersSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Int32
touchpad
a touchpad.
-> IO Int32 

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

Returns
number of supported simultaneous fingers.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadTouchpadFinger, getNumGamepadTouchpads

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetNumGamepadTouchpadFingers. The unsafe flavor is getNumGamepadTouchpadFingers .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetNumGamepadTouchpadFingers, defined at SDL3/SDL_gamepad.h 1406:33

Since: 3.2.0

getGamepadTouchpadFinger Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Int32
touchpad
a touchpad.
-> Int32
finger
a finger.
-> Ptr CBool
down
a pointer filled with true if the finger is down, false otherwise, may be NULL.
-> Ptr CFloat
x
a pointer filled with the x position, normalized 0 to 1, with the origin in the upper left, may be NULL.
-> Ptr CFloat
y
a pointer filled with the y position, normalized 0 to 1, with the origin in the upper left, may be NULL.
-> Ptr CFloat
pressure
a pointer filled with pressure value, may be NULL.
-> IO Bool 

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getNumGamepadTouchpadFingers

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadTouchpadFinger. The safe flavor is getGamepadTouchpadFingerSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadTouchpadFinger, defined at SDL3/SDL_gamepad.h 1430:34

Since: 3.2.0

getGamepadTouchpadFingerSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad.
-> Int32
touchpad
a touchpad.
-> Int32
finger
a finger.
-> Ptr CBool
down
a pointer filled with true if the finger is down, false otherwise, may be NULL.
-> Ptr CFloat
x
a pointer filled with the x position, normalized 0 to 1, with the origin in the upper left, may be NULL.
-> Ptr CFloat
y
a pointer filled with the y position, normalized 0 to 1, with the origin in the upper left, may be NULL.
-> Ptr CFloat
pressure
a pointer filled with pressure value, may be NULL.
-> IO Bool 

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getNumGamepadTouchpadFingers

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadTouchpadFinger. The unsafe flavor is getGamepadTouchpadFinger .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadTouchpadFinger, defined at SDL3/SDL_gamepad.h 1430:34

Since: 3.2.0

gamepadHasSensor Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Bool 

Return whether a gamepad has a particular sensor.

Returns
true if the sensor exists, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadSensorData, getGamepadSensorDataRate, setGamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadHasSensor. The safe flavor is gamepadHasSensorSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasSensor, defined at SDL3/SDL_gamepad.h 1447:34

Since: 3.2.0

gamepadHasSensorSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Bool 

Return whether a gamepad has a particular sensor.

Returns
true if the sensor exists, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadSensorData, getGamepadSensorDataRate, setGamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadHasSensor. The unsafe flavor is gamepadHasSensor .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadHasSensor, defined at SDL3/SDL_gamepad.h 1447:34

Since: 3.2.0

setGamepadSensorEnabled Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to update.
-> SDL_SensorType
type
the type of sensor to enable/disable.
-> Bool
enabled
whether data reporting should be enabled.
-> IO Bool 

Set whether data reporting for a gamepad sensor is enabled.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasSensor, gamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetGamepadSensorEnabled. The safe flavor is setGamepadSensorEnabledSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadSensorEnabled, defined at SDL3/SDL_gamepad.h 1465:34

Since: 3.2.0

setGamepadSensorEnabledSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to update.
-> SDL_SensorType
type
the type of sensor to enable/disable.
-> Bool
enabled
whether data reporting should be enabled.
-> IO Bool 

Set whether data reporting for a gamepad sensor is enabled.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
gamepadHasSensor, gamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetGamepadSensorEnabled. The unsafe flavor is setGamepadSensorEnabled .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadSensorEnabled, defined at SDL3/SDL_gamepad.h 1465:34

Since: 3.2.0

gamepadSensorEnabled Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Bool 

Query whether sensor data reporting is enabled for a gamepad.

Returns
true if the sensor is enabled, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GamepadSensorEnabled. The safe flavor is gamepadSensorEnabledSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadSensorEnabled, defined at SDL3/SDL_gamepad.h 1480:34

Since: 3.2.0

gamepadSensorEnabledSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Bool 

Query whether sensor data reporting is enabled for a gamepad.

Returns
true if the sensor is enabled, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
setGamepadSensorEnabled

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GamepadSensorEnabled. The unsafe flavor is gamepadSensorEnabled .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GamepadSensorEnabled, defined at SDL3/SDL_gamepad.h 1480:34

Since: 3.2.0

getGamepadSensorDataRate Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Float 

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

Returns
the data rate, or 0.0f if the data rate is not available.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadSensorDataRate. The safe flavor is getGamepadSensorDataRateSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSensorDataRate, defined at SDL3/SDL_gamepad.h 1493:35

Since: 3.2.0

getGamepadSensorDataRateSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> IO Float 

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

Returns
the data rate, or 0.0f if the data rate is not available.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadSensorDataRate. The unsafe flavor is getGamepadSensorDataRate .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSensorDataRate, defined at SDL3/SDL_gamepad.h 1493:35

Since: 3.2.0

getGamepadSensorData Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> Ptr CFloat
data
a pointer filled with the current sensor state.
-> Int32
num_values
the number of values to write to data.
-> IO Bool 

Get the current state of a gamepad sensor.

The number of values and interpretation of the data is sensor dependent. See the remarks in SDL_SensorType for details for each type of sensor.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadSensorData. The safe flavor is getGamepadSensorDataSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSensorData, defined at SDL3/SDL_gamepad.h 1512:34

Since: 3.2.0

getGamepadSensorDataSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_SensorType
type
the type of sensor to query.
-> Ptr CFloat
data
a pointer filled with the current sensor state.
-> Int32
num_values
the number of values to write to data.
-> IO Bool 

Get the current state of a gamepad sensor.

The number of values and interpretation of the data is sensor dependent. See the remarks in SDL_SensorType for details for each type of sensor.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadSensorData. The unsafe flavor is getGamepadSensorData .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetGamepadSensorData, defined at SDL3/SDL_gamepad.h 1512:34

Since: 3.2.0

rumbleGamepad Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to vibrate.
-> Word16
low_frequency_rumble
the intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF.
-> Word16
high_frequency_rumble
the intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF.
-> Word32
duration_ms
the duration of the rumble effect, in milliseconds.
-> IO Bool 

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.

This function requires you to process SDL events or call updateJoysticks to update rumble state.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_RumbleGamepad. The safe flavor is rumbleGamepadSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_RumbleGamepad, defined at SDL3/SDL_gamepad.h 1536:34

Since: 3.2.0

rumbleGamepadSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to vibrate.
-> Word16
low_frequency_rumble
the intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF.
-> Word16
high_frequency_rumble
the intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF.
-> Word32
duration_ms
the duration of the rumble effect, in milliseconds.
-> IO Bool 

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.

This function requires you to process SDL events or call updateJoysticks to update rumble state.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_RumbleGamepad. The unsafe flavor is rumbleGamepad .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_RumbleGamepad, defined at SDL3/SDL_gamepad.h 1536:34

Since: 3.2.0

rumbleGamepadTriggers Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to vibrate.
-> Word16
left_rumble
the intensity of the left trigger rumble motor, from 0 to 0xFFFF.
-> Word16
right_rumble
the intensity of the right trigger rumble motor, from 0 to 0xFFFF.
-> Word32
duration_ms
the duration of the rumble effect, in milliseconds.
-> IO Bool 

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

This function requires you to process SDL events or call updateJoysticks to update rumble state.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
rumbleGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_RumbleGamepadTriggers. The safe flavor is rumbleGamepadTriggersSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_RumbleGamepadTriggers, defined at SDL3/SDL_gamepad.h 1566:34

Since: 3.2.0

rumbleGamepadTriggersSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to vibrate.
-> Word16
left_rumble
the intensity of the left trigger rumble motor, from 0 to 0xFFFF.
-> Word16
right_rumble
the intensity of the right trigger rumble motor, from 0 to 0xFFFF.
-> Word32
duration_ms
the duration of the rumble effect, in milliseconds.
-> IO Bool 

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

This function requires you to process SDL events or call updateJoysticks to update rumble state.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
rumbleGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_RumbleGamepadTriggers. The unsafe flavor is rumbleGamepadTriggers .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_RumbleGamepadTriggers, defined at SDL3/SDL_gamepad.h 1566:34

Since: 3.2.0

setGamepadLED Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to update.
-> Word8
red
the intensity of the red LED.
-> Word8
green
the intensity of the green LED.
-> Word8
blue
the intensity of the blue LED.
-> IO Bool 

Update a gamepad's LED color.

An example of a joystick LED is the light on the back of a PlayStation 4's DualShock 4 controller.

For gamepads with a single color LED, the maximum of the RGB values will be used as the LED brightness.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetGamepadLED. The safe flavor is setGamepadLEDSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadLED, defined at SDL3/SDL_gamepad.h 1588:34

Since: 3.2.0

setGamepadLEDSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to update.
-> Word8
red
the intensity of the red LED.
-> Word8
green
the intensity of the green LED.
-> Word8
blue
the intensity of the blue LED.
-> IO Bool 

Update a gamepad's LED color.

An example of a joystick LED is the light on the back of a PlayStation 4's DualShock 4 controller.

For gamepads with a single color LED, the maximum of the RGB values will be used as the LED brightness.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetGamepadLED. The unsafe flavor is setGamepadLED .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetGamepadLED, defined at SDL3/SDL_gamepad.h 1588:34

Since: 3.2.0

sendGamepadEffect Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to affect.
-> PtrConst Void
data
the data to send to the gamepad.
-> Int32
size
the size of the data to send to the gamepad.
-> IO Bool 

Send a gamepad specific effect packet.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SendGamepadEffect. The safe flavor is sendGamepadEffectSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SendGamepadEffect, defined at SDL3/SDL_gamepad.h 1603:34

Since: 3.2.0

sendGamepadEffectSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to affect.
-> PtrConst Void
data
the data to send to the gamepad.
-> Int32
size
the size of the data to send to the gamepad.
-> IO Bool 

Send a gamepad specific effect packet.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SendGamepadEffect. The unsafe flavor is sendGamepadEffect .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SendGamepadEffect, defined at SDL3/SDL_gamepad.h 1603:34

Since: 3.2.0

closeGamepad Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO () 

Close a gamepad previously opened with openGamepad.

Thread safety
It is safe to call this function from any thread.
See also
openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CloseGamepad. The safe flavor is closeGamepadSafe .
C declaration
SDL_CloseGamepad, defined at SDL3/SDL_gamepad.h 1617:34

Since: 3.2.0

closeGamepadSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
a gamepad identifier previously returned by openGamepad.
-> IO () 

Close a gamepad previously opened with openGamepad.

Thread safety
It is safe to call this function from any thread.
See also
openGamepad

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CloseGamepad. The unsafe flavor is closeGamepad .
C declaration
SDL_CloseGamepad, defined at SDL3/SDL_gamepad.h 1617:34

Since: 3.2.0

getGamepadAppleSFSymbolsNameForButton Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_GamepadButton
button
a button on the gamepad.
-> IO (PtrConst CChar) 

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

Returns
the sfSymbolsName or NULL if the name can't be found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAppleSFSymbolsNameForAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadAppleSFSymbolsNameForButton. The safe flavor is getGamepadAppleSFSymbolsNameForButtonSafe .
C declaration
SDL_GetGamepadAppleSFSymbolsNameForButton, defined at SDL3/SDL_gamepad.h 1633:42

Since: 3.2.0

getGamepadAppleSFSymbolsNameForButtonSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_GamepadButton
button
a button on the gamepad.
-> IO (PtrConst CChar) 

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

Returns
the sfSymbolsName or NULL if the name can't be found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAppleSFSymbolsNameForAxis

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadAppleSFSymbolsNameForButton. The unsafe flavor is getGamepadAppleSFSymbolsNameForButton .
C declaration
SDL_GetGamepadAppleSFSymbolsNameForButton, defined at SDL3/SDL_gamepad.h 1633:42

Since: 3.2.0

getGamepadAppleSFSymbolsNameForAxis Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_GamepadAxis
axis
an axis on the gamepad.
-> IO (PtrConst CChar) 

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

Returns
the sfSymbolsName or NULL if the name can't be found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAppleSFSymbolsNameForButton

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetGamepadAppleSFSymbolsNameForAxis. The safe flavor is getGamepadAppleSFSymbolsNameForAxisSafe .
C declaration
SDL_GetGamepadAppleSFSymbolsNameForAxis, defined at SDL3/SDL_gamepad.h 1648:42

Since: 3.2.0

getGamepadAppleSFSymbolsNameForAxisSafe Source #

Arguments

:: Ptr SDL_Gamepad
gamepad
the gamepad to query.
-> SDL_GamepadAxis
axis
an axis on the gamepad.
-> IO (PtrConst CChar) 

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

Returns
the sfSymbolsName or NULL if the name can't be found.
Thread safety
It is safe to call this function from any thread.
See also
getGamepadAppleSFSymbolsNameForButton

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetGamepadAppleSFSymbolsNameForAxis. The unsafe flavor is getGamepadAppleSFSymbolsNameForAxis .
C declaration
SDL_GetGamepadAppleSFSymbolsNameForAxis, defined at SDL3/SDL_gamepad.h 1648:42

Since: 3.2.0