SDL_PumpEvents(3)

โœจ SDL_PumpEvents โœจ

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we talk about SDL_PumpEvents โ€” the little function that keeps the event loop hydrated ๐Ÿ’ง


๐Ÿ’– NAME ๐Ÿ’–

SDL_PumpEvents โ€” pump the event loop, gathering events from the input devices ๐ŸŽฎโŒจ๏ธ๐Ÿ–ฑ๏ธ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_events.h>

void SDL_PumpEvents(void);

likeโ€ฆ that's it. that's the whole thing. no args, no return value, just vibes โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so what does it actually do? this function updates the event queue and the internal input device state. two for one, slay ๐Ÿ’…

SDL_PumpEvents() goes around gathering all the pending input info from your devices and drops it into the event queue. and here's the thing โ€” without calls to SDL_PumpEvents(), no events would ever get placed on the queue. literally none. the queue would just sit there empty, rotting, unbothered ๐Ÿ˜ญ

now, most of the time you don't even have to think about it, because the need for calling SDL_PumpEvents() is hidden from you โ€” SDL_PollEvent() and SDL_WaitEvent() implicitly call SDL_PumpEvents() for you. they're the ones doing the heavy lifting behind the scenes, main character energy fr fr ๐Ÿ‘‘

but โ€” and this is the part that matters โ€” if you are not polling or waiting for events (e.g. you are filtering them), then you must call SDL_PumpEvents() yourself to force an event queue update. no shortcuts, no autopilot, you gotta do it manually bestie ๐Ÿซถ


๐Ÿ”ฅ THREAD SAFETY ๐Ÿ”ฅ

this function should only be called on the main thread. do not try it anywhere else, it's not giving multitasking, it's giving chaos ๐Ÿ’€

โญ AVAILABILITY โญ

this function is available since SDL 3.2.0 ๐ŸŽ€ so if you're on anything olderโ€ฆ yeah no, upgrade babes.


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


and that's the whole page, bestie!! brought to you by Simple Directmedia Layer โ€” SDL 3.4.18 edition, the SDL_PumpEvents(3) era ๐Ÿ’– go forth and pump those events, ily, mwah ๐Ÿงšโœจ

๐Ÿ“ฆ where this page comes from