SDL_GetGamepadJoystick(3)
β¨ SDL_GetGamepadJoystick β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual π this one's called SDL_GetGamepadJoystick and honestly? it's giving "backstage pass to your gamepad's inner joystick" π
π¦ NAME π¦
SDL_GetGamepadJoystick β get the underlying joystick from a gamepad π
like, the joystick that's literally inside your gamepad. the whole vibe. no cap.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_gamepad.h>
SDL_Joystick * SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
that's it. one include, one call, one slay π«Ά
π DESCRIPTION π
so the way that this works is: this function hands you back an SDL_Joystick object, which means you can use all the SDL_Joystick functions on a thing that's actually an SDL_Gamepad πβ¨ iconic crossover event fr fr.
why would you even want that? because it's lowkey useful for grabbing a joystick's position at any given moment β even if it hasn't moved at all. like, key detail: if you were just waiting for events, a joystick that never moves never produces one. and moving it is what would produce an event, which is what would carry the axis' value. so if you want the position right now, no movement required, this is your girl π
π¨ okay now the important part, listen up bestie π¨ The pointer you get back is owned by theSDL_Gamepad. You should not callSDL_CloseJoystick()on it, for example β because doing so will likely cause SDL to crash. π do not do it. not even once. the gamepad owns it, you're just borrowing it, it's giving library book not gift π
π FUNCTION PARAMETERS π
gamepadβ the gamepad object that you want to get a joystick from. yeah. that one. the gamepad. the one you have π«Ά
π RETURN VALUE π
Returns an SDL_Joystick object, or NULL on failure π
if you get NULL? bestie, something went wrong. call SDL_GetError() for more information, she'll tell you what happened π
π§ THREAD SAFETY π§
It is safe to call this function from any thread. periodt. β¨ go wild, thread girlies π¦
β AVAILABILITY β
This function is available since SDL 3.2.0 πΈ (so if you're on something older, no joystick for you, sorry babe π)
and that's the whole page, bestie!! go forth and get that joystick, just don't close it π
this has been Simple Directmedia Layer, SDL 3.4.18, and it's dated right there in the footer with the rest of the SDL_GetGamepadJoystick(3) energy β mwah, take care of your pointers, ily π«Άπβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms