SDL_GetJoystickHat(3)
π SDL_GetJoystickHat(3) π
okay bestie so this is a page from the SDL3 FUNCTIONS manual, and today we're learning about POV hats. yes it's a real name, no I will not elaborate. let's get into it π
β¨ NAME β¨
SDL_GetJoystickHat</purpose> β get the current state of a POV hat on a joystick.
like, the little d-pad-ish thingy. you know the one. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_joystick.h>
Uint8 SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
#define SDL_HAT_CENTERED 0x00u
#define SDL_HAT_UP 0x01u
#define SDL_HAT_RIGHT 0x02u
#define SDL_HAT_DOWN 0x04u
#define SDL_HAT_LEFT 0x08u
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
look at those SDL_HAT_* constants, they're giving bitmask royalty π
and yes they combine with | like the little lego bricks they are.
β¨ DESCRIPTION β¨
so what you get back is gonna be one of the SDL_HAT_* values. that's it. that's the whole vibe. the returned value will be one of the SDL_HAT_* values. periodt β¨
β¨ FUNCTION PARAMETERS β¨
joystickβ anSDL_Joystickstructure containing joystick information. your lil joystick info container, your main character π«Άhatβ the hat index to get the state from; indices start at index0. yes bestie, zero-indexed, as all things should be.
β¨ RETURN VALUE β¨
returns the current hat position. that's the tea. π
β¨ THREAD SAFETY β¨
it is safe to call this function from any thread. no cap. go wild, thread it from wherever, it's not gonna be dramatic about it π
β¨ AVAILABILITY β¨
this function is available since SDL 3.2.0. so if you're on something olderβ¦ babe. upgrade. π
β¨ SEE ALSO β¨
SDL_GetNumJoystickHats(3)β go count your hats, bestie π
and that's the whole page!! mwah π written by the lovely humans at <b>Simple Directmedia Layer</b>, version <b>SDL 3.4.18</b>, and this iconic lil doc is dated right along with it. slay, go read your hats. πβ¨
π¦ 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