SDL_UserEvent(3)
π SDL_UserEvent(3) π
okay bestie, welcome to the SDL API Reference, and today's main character is SDL_UserEvent β the event type that is literally yours. nobody else's. not SDL's. yours. π«Ά
β¨ NAME β¨
SDL_UserEvent β a user-defined event type. it's giving "make your own event" energy, and honestly? iconic. π
πΈ STRUCTURE DEFINITION πΈ
typedef struct{
Uint8 type;
int code;
void *data1;
void *data2;
} SDL_UserEvent;
no cap, that's the whole thing. four little fields, infinite possibilities. π
π STRUCTURE DATA π
typeβ ranges fromSDL_USEREVENTthrough toSDL_NUMEVENTS-1. that's your little lane, stay in it. πcodeβ user defined event code. you make it up, you own it. β¨data1β user defined data pointer. a lil void pointer with main character energy. πdata2β user defined data pointer. the sequel. equally user defined. π¦
π« DESCRIPTION π«
so here's the tea: SDL_UserEvent lives inside the user member of the structure SDL_Event. π«§
this event is unique, fr fr β SDL never creates it. only you do. it's not like SDL is gonna spawn one behind your back; that's simply not a thing that happens. π
you get it into the event queue by pushing it with SDL_PushEvent. π¬
and the contents of the structure members? completely up to the programmer. lowkey the most freeing thing in this whole API. the only requirement β and bestie, listen, this one's non-negotiable β is that type is a value from SDL_USEREVENT to SDL_NUMEVENTS-1 (inclusive). that's it. that's the rule. slay. π₯
π EXAMPLES π
here's the vibe, copied exactly so you can steal it:
SDL_Event event;
event.type = SDL_USEREVENT;
event.user.code = my_event_code;
event.user.data1 = significant_data;
event.user.data2 = 0;
SDL_PushEvent(&event);
see how the event.user. prefix is doing all the work? that's the user member of SDL_Event, right there. π
π SEE ALSO π
SDL_EventSDL_PushEvent
go read those too, iykyk. π
aaaand that's a wrap on SDL_UserEvent(3) from the SDL API Reference! this lil gem is brought to you by SDL, dated Tue 11 Sep 2001, 23:00 β yes, the date is literally older than most of the internet, and it still ate. πβ¨ bye bestie, go push some events! ππ¦π
π¦ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 Β· LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms