SDL_JoyHatEvent(3type)
β¨ SDL_JoyHatEvent β¨
okay bestie so you're in the SDL3 DATATYPES section of the manual and you clicked on SDL_JoyHatEvent β that's the joystick hat position change event structure, and you'll also catch it lurking as event.jhat.*. π
πΈ NAME πΈ
SDL_JoyHatEvent β joystick hat position change event structure (event.jhat.*)
π SYNOPSIS π
#include <SDL3/SDL_events.h>
typedef struct SDL_JoyHatEvent
{
SDL_EventType type; /**< SDL_EVENT_JOYSTICK_HAT_MOTION */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
Uint8 hat; /**< The joystick hat index */
Uint8 value; /**< The hat position value.
* \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
* \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
* \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
*
* Note that zero means the POV is centered.
*/
Uint8 padding1;
Uint8 padding2;
} SDL_JoyHatEvent;
π¦ DESCRIPTION π¦
So like, this struct is what slides into your event queue when somebody yanks a joystick hat around β the lil' POV switch on top of a flight stick, yk? it's giving "the hat moved" and nothing else. π
Here's the cast of characters, field by field:
SDL_EventType typeβ bestie this one is literallySDL_EVENT_JOYSTICK_HAT_MOTION, no cap. That's the vibe check that tells you which event you're holding. β¨Uint32 reservedβ reserved, mind your business, don't touch it. πUint64 timestampβ in nanoseconds, populated usingSDL_GetTicksNS(). so when did it happen? this. this is when. β±οΈSDL_JoystickID whichβ the joystick instance id. which joystick said that? this is which. iconic honestly. πUint8 hatβ the joystick hat index. (yes there can be several hats. a whole hat collection. slay. π§)Uint8 valueβ the hat position value. and here's the tea, it cross-references a bunch of constants:SDL_HAT_LEFTUP,SDL_HAT_UP,SDL_HAT_RIGHTUPSDL_HAT_LEFT,SDL_HAT_CENTERED,SDL_HAT_RIGHTSDL_HAT_LEFTDOWN,SDL_HAT_DOWN,SDL_HAT_RIGHTDOWN
β οΈ and note, bestie: zero means the POV is centered. that's the important one, don't forget it. π
Uint8 padding1β padding. structural. not for you. πUint8 padding2β also padding. also not for you. π
π« AVAILABILITY π«
This struct is available since SDL 3.2.0. so if you're on something older, it's not gonna be there, fr fr. π
and that's the whole page, bestie β you ate that, honestly. π
this lil' writeup is part of Simple Directmedia Layer, SDL 3.4.18, and it lives in the manual as SDL_JoyHatEvent(3type). go forth and read your hat events πβ¨π
π¦ 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