SDL_FilterEvents(3)

πŸ’– SDL_FilterEvents(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one is literally called SDL_FilterEvents and it's lowkey iconic. sit down, grab a strawberry πŸ“, let's go.


✨ NAME ✨

SDL_FilterEvents β€” run a specific filter function on the current event queue, removing any events for which the filter returns false.

like, it does a little vibe check on your event queue and yeets the ones your filter says no to. periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_events.h>

void SDL_FilterEvents(SDL_EventFilter filter, void *userdata);

that's it, that's the whole signature, no cap.


🌸 DESCRIPTION 🌸

so, if you want the full lore, go read SDL_SetEventFilter() β€” this one's whole deal is explained over there.

the BIG difference though, and this is the part that matters: unlike SDL_SetEventFilter(), this function does NOT change the filter permanently. it only uses the filter you hand it until this function returns. that's it. after that, everything goes back to how it was. it's giving "borrowed your hoodie for one night and gave it back" energy 🫢

no lasting commitment, just a quick little pass through the queue. obsessed.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • filter β€” the SDL_EventFilter function to call when an event happens. this is the little bouncer at the door, deciding who gets in and who gets filtered out πŸ‘‘
  • userdata β€” a pointer that is passed to filter. your lil care package, hand-delivered straight to your filter function πŸ’Œ

🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. yes, any thread. go off, multitask, slay. ✨


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on anything older, bestie, that's a no from the compiler 😭


🌈 SEE ALSO 🌈

go read those too, they're the sibling lore, iykyk πŸ’œ


Simple Directmedia Layer made this, and this particular page is from SDL 3.4.18. tysm for reading, love u, bye bestie πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from