SDL_SetJoystickVirtualHat(3)
โจ SDL_SetJoystickVirtualHat โจ
okay so bestie, welcome to the SDL3 FUNCTIONS manual, and today's main character is SDL_SetJoystickVirtualHat(3) ๐
she sets the state of a hat on an opened virtual joystick, and honestly? she eats.
๐ NAME ๐
SDL_SetJoystickVirtualHat โ set the state of a hat on an opened virtual joystick. no cap, that's literally the whole job description ๐ซถ
๐ธ SYNOPSIS ๐ธ
#include <SDL3/SDL_joystick.h>
bool SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
๐ฆ DESCRIPTION ๐ฆ
okay so here's the tea, and it's important tea โ โ the values you set here do NOT get applied right away. they're just vibing in limbo until the next call to SDL_UpdateJoysticks. and that call can happen either:
- directly, by you calling it yourself, or
- indirectly, through various other SDL APIs, including โ but not limited to โ
SDL_PollEvent,SDL_PumpEvents,SDL_WaitEventTimeout, andSDL_WaitEvent.
so like. it's giving "queued up, pending, waiting for her moment" ๐ the hat state is not real until the update happens. periodt.
๐ FUNCTION PARAMETERS ๐
joystickโ the virtual joystick on which to set state. your girl. the one you're messing with ๐ฎhatโ the index of the hat on the virtual joystick to update. yes, an index, so you gotta know which hat you mean ๐valueโ the new value for the specified hat. the fresh fit you're dressing it in โจ
๐ RETURN VALUE ๐
returns true on success, or false on failure ๐ญ and if it fails, hit up SDL_GetError() for more information โ she will tell you what went wrong, fr fr.
๐ฅ THREAD SAFETY ๐ฅ
it is safe to call this function from any thread. multithreaded besties, you are SO valid ๐ซถ no locks, no drama, no stress.
โญ AVAILABILITY โญ
this function is available since SDL 3.2.0. if you're on anything older, she simply does not exist yet, sorry babe ๐
๐ SEE ALSO ๐
the whole virtual-joystick friend group, all iconic, all linked:
SDL_SetJoystickVirtualAxis(3)SDL_SetJoystickVirtualButton(3)SDL_SetJoystickVirtualBall(3)SDL_SetJoystickVirtualTouchpad(3)SDL_SetJoystickVirtualSensorData(3)
quick vibe check ๐ remember: set the hat, then call SDL_UpdateJoysticks (or one of the event functions) or it's giving nothing. the hat does not exist until you do.
and that's a wrap on our girl ๐ธ this page comes to you from Simple Directmedia Layer, version SDL 3.4.18, and the date stamped on it โ mwah, chef's kiss ๐ go forth, set your hats, and slay ๐ โจ๐ฆ
๐ฆ 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