SDL_GetEventDescription(3)
π SDL_GetEventDescription(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manpage universe, where today's main character is SDL_GetEventDescription β she makes events speak English. no cap.
β¨ NAME β¨
SDL_GetEventDescription β generate an English description of an event. like, she literally translates event structs into human-speak, we love a bilingual queen π«Ά
β¨ SYNOPSIS β¨
#include <SDL3/SDL_events.h>
int SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen);
β¨ DESCRIPTION β¨
so what she does is fill buf with a null-terminated string that might look something like this:
SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
it's giving "event, but make it a sentence." π
β οΈ okay so the exact format of the string is NOT guaranteed. do not come for me. she's intended for logging purposes, to be read by a human, and not parsed by a computer. if you're out here parsing her output, that's on you and it will break, fr fr. π
the returned value follows the same rules as SDL_snprintf(): buf will always be NULL-terminated (unless buflen is zero π« ), and will be truncated if buflen is too small. the return code is the number of bytes needed for the complete string, not counting the NULL-terminator, whether the string was truncated or not.
but here's the glow-up: unlike SDL_snprintf(), this function never returns -1. iconic behavior honestly π
β¨ FUNCTION PARAMETERS β¨
eventβ an event to describe. May beNULL. (yes bestie, she can handle a NULL event, she's built different πΈ)bufβ the buffer to fill with the description string. May beNULL.buflenβ the maximum bytes that can be written tobuf.
β¨ RETURN VALUE β¨
Returns the number of bytes needed for the full string, not counting the null-terminator byte. so it's not "how much I wrote," it's "how much I needed" β she's telling you your buffer's capacity like a supportive bestie with a measuring tape πβ¨
β¨ THREAD SAFETY β¨
it is safe to call this function from any thread. every thread, any thread, all the threads. no drama, no locks, no fighting. we love a peaceful queen ποΈπ
β¨ AVAILABILITY β¨
this function is available since SDL 3.4.0. if you're on anything older, sorry babe, she doesn't exist yet π
and that's the whole page, bestie! you ate that. go log your events and live your truth. π¦β¨
mwah π β brought to you by Simple Directmedia Layer, version SDL 3.4.18, page SDL_GetEventDescription(3). periodt. π
π¦ 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