SDL_JoyHatEvent(3)

✨ SDL_JoyHatEvent ✨

okay bestie, this is a page from the SDL API Reference β€” it's SDL_JoyHatEvent(3), and it's literally the manual for the little struct that tells you when someone yanks a hat around on a joystick. yes. a hat. on a joystick. we love a retro peripheral moment πŸŽ©πŸ’–


πŸŽ€ NAME πŸŽ€

SDL_JoyHatEvent β€” the joystick hat position change event structure. that's it, that's the whole name, she's straightforward and we respect her 🫢


🧚 STRUCTURE DEFINITION 🧚

here's the whole fit, no cap:

typedef struct{
  Uint8 type;
  Uint8 which;
  Uint8 hat;
  Uint8 value;
} SDL_JoyHatEvent;

four Uint8s and a dream πŸ’…


🌸 STRUCTURE DATA 🌸

  • type β€” it's SDL_JOY πŸ‘‘
  • which β€” the joystick device index (which joystick is doing all this)
  • hat β€” the joystick hat index (which hat on that joystick)
  • value β€” the hat position

πŸ’– DESCRIPTION πŸ’–

so SDL_JoyHatEvent is a member of the SDL_Event union, and it's the one that shows up when an event of type SDL_JOYHATMOTION gets reported. main character energy fr fr ✨

an SDL_JOYHATMOTION event happens whenevs a user moves a hat on the joystick. the field which is the index of the joystick that reported the event, and hat is the index of the hat (for a way more detailed explanation, go peek at the Joystick section β€” iykyk). and value is the current position of the hat.

now value is a logically OR'd combination of these following values, and honestly their meanings should be pretty obvious 😌:

  • SDL_HAT_CENTERED
  • SDL_HAT_UP
  • SDL_HAT_RIGHT
  • SDL_HAT_DOWN
  • SDL_HAT_LEFT

and these defines are also provided (the diagonal girlies 🌈):

  • SDL_HAT_RIGHTUP
  • SDL_HAT_RIGHTDOWN
  • SDL_HAT_LEFTUP
  • SDL_HAT_LEFTDOWN

πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_Event
  • Joystick Functions
  • SDL_JoystickEventState
  • SDL_JoystickGetHat

and that's the whole page, bestie β€” go read up on your hats, periodt πŸŽ€βœ¨

this was SDL, and the page is dated Tue 11 Sep 2001, 22:59 β€” a true vintage icon, we stan a timestamp πŸ’œπŸ¦‹

πŸ“¦ where this page comes from