SDL_GetEventDescription(3)

πŸ“¦
version 3.4.18 Β· 5 versions
, in fedora 43, fedora 44

πŸ’– 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 be NULL. (yes bestie, she can handle a NULL event, she's built different 🌸)
  • buf β€” the buffer to fill with the description string. May be NULL.
  • buflen β€” the maximum bytes that can be written to buf.

✨ 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