SDL_WaitEventTimeout(3)

πŸ’– SDL_WaitEventTimeout(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we wait for events like it's the group chat and everyone's typing but nobody's sending. this one's called SDL_WaitEventTimeout and honestly? it's giving patient queen energy. ✨


🌸 NAME 🌸

SDL_WaitEventTimeout β€” wait until the specified timeout (in milliseconds) for the next available event.

like. she waits. but only for so long. she has boundaries. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_events.h>

bool SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, fr fr. if event is not NULL, the next event gets removed from the queue and stored in the SDL_Event structure pointed to by event. yes, removed. like it never happened. it's yours now, bestie. 🫢

and because this function may implicitly call SDL_PumpEvents(), you can only call this function in the thread that initialized the video subsystem. no cap. don't try to be cute and call it from some random thread, it's not that girl.

also, lowkey important: the timeout is not guaranteed β€” the actual wait time could be longer due to system scheduling. so if you set it to wait 500ms and it takes 700ms, that's not a bug, that's just the scheduler having main character energy of its own. 😭


🌈 FUNCTION PARAMETERS 🌈

  • event β€” the SDL_Event structure to be filled in with the next event from the queue, or NULL. yeah, NULL is allowed. she's flexible like that. 🌸
  • timeoutMS β€” the maximum number of milliseconds to wait for the next available event. maximum, bestie. see above. ⏳

✨ RETURN VALUE ✨

  • returns true if this got an event β€” slay, we ate πŸŽ‰
  • returns false if the timeout elapsed without any events available β€” nothing came through, it's giving empty inbox πŸ’€

πŸ’œ THREAD SAFETY πŸ’œ

this function should only be called on the main thread. periodt. πŸ‘‘


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older, bestie... update. πŸ™ˆ


πŸ“ SEE ALSO πŸ“


and that's the whole page, no crumbs left. this was Simple Directmedia Layer, specifically SDL 3.4.18, and yes the date is baked into that footer too β€” consider this your cute lil sign-off from the girl who will absolutely explain file descriptors to you at 2am. go forth and wait for events responsibly. bye bestie!! πŸŽ€πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from