SDL Wiki
[ front page | index | search | recent changes | git repo | offline html ]

SDL_GetGamepadJoystick

Get the underlying joystick from a gamepad.

Header File

Defined in <SDL3/SDL_gamepad.h>

Syntax

SDL_Joystick * SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);

Function Parameters

SDL_Gamepad * gamepad the gamepad object that you want to get a joystick from.

Return Value

(SDL_Joystick *) Returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() for more information.

Remarks

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

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

Thread Safety

It is safe to call this function from any thread.

Version

This function is available since SDL 3.2.0.


CategoryAPI, CategoryAPIFunction, CategoryGamepad


[ edit | delete | history | feedback | raw ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.