SDL_HasEvents(3)

πŸ’– SDL_HasEvents β€” a page from the SDL3 FUNCTIONS manual πŸ’–

okay bestie, sit down, hydrate, and let's talk about SDL_HasEvents 🫢 this is a whole function from the SDL3 FUNCTIONS section of the manual and it's lowkey one of the most useful little vibe checks in the whole event system. let's get into it ✨


🌸 NAME 🌸

SDL_HasEvents β€” check for the existence of certain event types in the event queue. like, is anybody home in there?? πŸ‘€


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_events.h>

bool SDL_HasEvents(Uint32 minType, Uint32 maxType);

that's it. that's the whole thing. two Uint32 args, one bool out. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically you're asking the event queue: "hey, do you have any events whose type falls between these two numbers?" and it tells you yes or no. no popping them off, no consuming them, just a peek. a little gossip session with the queue πŸ“

and listen β€” if you only need to check for a single event type, don't do the whole range thing, just use SDL_HasEvent() instead. it's giving "use the right tool" energy fr fr 😌


⭐ FUNCTION PARAMETERS ⭐

  • minType β€” the low end of event type to be queried, inclusive. meaning if an event's type equals minType exactly, it totally counts. see SDL_EventType for the details πŸ‘‘
  • maxType β€” the high end of event type to be queried, inclusive. same deal, the boundary itself is included. again, see SDL_EventType for details 🌈

so like, the range is minType <= type <= maxType, both ends invited to the party πŸŽ‰


πŸ”₯ RETURN VALUE πŸ”₯

returns true if events with type >= minType and <= maxType are present. returns false if not. that's the whole story, no cap πŸ’―


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. yes, ANY. go wild, bestie, no locks required, no anxiety, no "wait should I be doing this here" spiral 😭✨


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. if you're on something older than that, sorry babe, she's not there yet πŸ™ˆ


🌈 SEE ALSO 🌈


⚠️ real talk: this only checks. it does not remove, consume, or drain anything from the queue. peeking is not popping, and the events will still be sitting there waiting for you. handle them, don't just stare at them πŸ‘‘

and that's the page!! Simple Directmedia Layer, SDL 3.4.18, dated SDL_HasEvents(3) β€” love her, know her, use her responsibly πŸŽ€πŸ’– bye bestie, go check those events πŸ¦‹

πŸ“¦ where this page comes from