SDL_PeepEvents(3)
β¨ SDL_PeepEvents β¨
ok so bestie, we're in the SDL3 FUNCTIONS section of the SDL_PeepEvents(3) manual and this one is genuinely such a vibe β it's the peeky-looky function for your event queue π
π NAME π
SDL_PeepEvents β check the event queue for messages and optionally return them.
like, it goes in, it looks around, and it maybe brings stuff back. iconic behavior tbh.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_events.h>
int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType);
π¦ DESCRIPTION π¦
action can be literally any of these three, and ngl they each have a whole different personality:
SDL_ADDEVENTβ up tonumeventsevents will be added to the back of the event queue. yes, back. the end. the tail. the line-ends-here spot π«ΆSDL_PEEKEVENTβnumeventsevents at the front of the event queue, within the specified minimum and maximum type, will be returned to the caller and will _not_ be removed from the queue. look-but-don't-touch energy fr fr. π and listen β if you passNULLforevents, thennumeventsis ignored and the total number of matching events will be returned. free little count for you, no notes.SDL_GETEVENTβ up tonumeventsevents at the front of the event queue, within the specified minimum and maximum type, will be returned to the caller and will be removed from the queue. okay so this one actually takes them. gone. bye. snatched. π
heads up bestie!! you may have to callSDL_PumpEvents()before calling this function. otherwise, the events may not be ready to be filtered when you callSDL_PeepEvents(). don't skip the pump, that's the whole ritual β¨
π FUNCTION PARAMETERS π
eventsβ destination buffer for the retrieved events, may beNULLto leave the events in the queue and return the number of events that would have been stored. lowkey a "just tell me how many" mode and honestly? we love a buffer-less option.numeventsβ ifactionisSDL_ADDEVENT, the number of events to add back to the event queue; ifactionisSDL_PEEKEVENTorSDL_GETEVENT, the maximum number of events to retrieve. same name, different job, main character duality tbh πactionβ action to take; see [Remarks](#remarks) for details.minTypeβ minimum value of the event type to be considered;SDL_EVENT_FIRSTis a safe choice. the safe choice!! the little safety blanket π§maxTypeβ maximum value of the event type to be considered;SDL_EVENT_LASTis a safe choice. matching safety blanket, we love a symmetrical queen π
β RETURN VALUE β
Returns the number of events actually stored, or -1 on failure; call SDL_GetError() for more information. so if you see that -1... go ask SDL_GetError() what happened, she always knows π
π₯ THREAD SAFETY π₯
It is safe to call this function from any thread. no cap. every thread. go off π«Ά
π AVAILABILITY π
This function is available since SDL 3.2.0.
π SEE ALSO π
and that's the whole page bestie!! brought to you by Simple Directmedia Layer, running SDL 3.4.18 β mwah, go peek some events, ily πβ¨π
π¦ 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