SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)


Check the event queue for messages and optionally return them.

Header File

Defined in <SDL3/SDL_events.h>


int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType);

Function Parameters

SDL_Event * events destination buffer for the retrieved events, may be NULL to leave the events in the queue and return the number of events that would have been stored.
int numevents if action is SDL_ADDEVENT, the number of events to add back to the event queue; if action is SDL_PEEKEVENT or SDL_GETEVENT, the maximum number of events to retrieve.
SDL_EventAction action action to take; see [[#action
Uint32 minType minimum value of the event type to be considered; SDL_EVENT_FIRST is a safe choice.
Uint32 maxType maximum value of the event type to be considered; SDL_EVENT_LAST is a safe choice.

Return Value

(int) Returns the number of events actually stored or a negative error code on failure; call SDL_GetError() for more information.


action may be any of the following:

You may have to call SDL_PumpEvents() before calling this function. Otherwise, the events may not be ready to be filtered when you call SDL_PeepEvents().

This function is thread-safe.


This function is available since SDL 3.0.0.

See Also

CategoryAPI, CategoryAPIFunction, CategoryEvents

[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.