SDL_PushEvent(3)

πŸ’– SDL_PushEvent(3) πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS set β€” like, the official Unix manual vibes but make it cute. We're talking SDL_PushEvent, and no cap, it's exactly what it sounds like: you get to yeet your own event onto the queue. πŸ¦‹


✨ NAME ✨

SDL_PushEvent β€” Add an event to the event queue. πŸ’Œ


✨ SYNOPSIS ✨

#include <SDL3/SDL_events.h>

bool SDL_PushEvent(SDL_Event *event);

✨ DESCRIPTION ✨

Okay so here's the tea, and it's actually kind of iconic: the event queue is a two-way communication channel. Not only can you read events off of it, but you, the user, can also push your own events onto it. Main character energy fr fr. πŸ’…

event is a pointer to the event structure you wish to push onto the queue. The event gets copied into the queue, so once SDL_PushEvent() returns you can go ahead and dispose of the memory that event pointed to β€” it's not your problem anymore, she's independent now. πŸŽ€

Note: Pushing device input events onto the queue doesn't modify the state of the device within SDL. Like, you're just dropping a copy into the queue, you're not actually touching the device itself. No cap.
Note: Events pushed onto the queue with SDL_PushEvent() get passed through the event filter, but events added with SDL_PeepEvents() do NOT. Yes this is a real difference, yes it matters, remember it. 😭

For pushing application-specific events, please use SDL_RegisterEvents() to get an event type that doesn't conflict with other code that also wants its own custom event types. Sharing is caring but event type collisions are not the vibe. 🫢


✨ FUNCTION PARAMETERS ✨

  • event β€” the SDL_Event to be added to the queue. πŸ“

✨ RETURN VALUE ✨

Returns true on success, and false if the event was filtered or on failure. When it's giving failure, call SDL_GetError() for more info. A common reason for error is the event queue being full β€” she's at capacity, bestie, no room at the inn. πŸ’€


✨ THREAD SAFETY ✨

It is safe to call this function from any thread. Go off, multithreaded queen. πŸ‘‘


✨ AVAILABILITY ✨

This function is available since SDL 3.2.0. ⭐


✨ SEE ALSO ✨


and that's the whole page, babe 🌸 this was brought to you by Simple Directmedia Layer, running SDL 3.4.18, and it's SDL_PushEvent(3) forever and ever, periodt. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from