SDL_AddEventWatch(3)
π SDL_AddEventWatch(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_AddEventWatch β literally the function that lets you be nosy about every event the second it shows up. no cap.
β¨ NAME β¨
SDL_AddEventWatch β add a callback to be triggered when an event is added to the event queue. it's giving personal event bodyguard, fr fr.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_events.h>
bool SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);
look at her. two args, one bool, zero drama. π
π¦ DESCRIPTION π¦
so here's the tea: filter will be called when an event happens, and its return value is ignored. like, it can return whatever it wants, nobody's checking. main character behavior honestly.
β οΈ WARNING: Be very careful of what you do in the event filter function, as it may run in a different thread! π this is not a drill. do not go wild in there.
if the quit event is generated by a signal (e.g. SIGINT), it will bypass the internal queue and be delivered to the watch callback immediately, and arrive at the next event poll. iconic shortcut, honestly.
Note: the callback is called for events posted by the user through SDL_PushEvent(), but not for disabled events, nor for events by a filter callback set with SDL_SetEventFilter(), nor for events posted by the user through SDL_PeepEvents(). so like, know your limits bestie. π«Ά
π FUNCTION PARAMETERS π
filterβ anSDL_EventFilterfunction to call when an event happens. your lil event-listening bestie.userdataβ a pointer that is passed tofilter. a little gift basket you hand over sofilterhas context. π
β RETURN VALUE β
Returns true on success or false on failure; call SDL_GetError() for more information. so if it comes back false, go ask SDL_GetError() what's wrong, she always knows. π
π THREAD SAFETY π
It is safe to call this function from any thread. yes, ANY. go off, queen. π
π AVAILABILITY π
This function is available since SDL 3.2.0. vintage-ish but make it fresh. β¨
π₯ SEE ALSO π₯
iykyk β that's the whole friend group right there. πΈ
and that's the page, bestie!! brought to you by Simple Directmedia Layer, running SDL 3.4.18. mwah, go watch some 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