Skip to main content

SDL_GetEventDescription

Function SDL_GetEventDescription 

Source
pub unsafe extern "C" fn SDL_GetEventDescription(
    event: *const SDL_Event,
    buf: *mut c_char,
    buflen: c_int,
) -> c_int
Expand description

Generate an English description of an event.

This will 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)

The exact format of the string is not guaranteed; it is intended for logging purposes, to be read by a human, and not parsed by a computer.

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. Unlike SDL_snprintf(), though, this function never returns -1.

Parameter: event an event to describe. May be NULL. Parameter: buf the buffer to fill with the description string. May be NULL. Parameter: buflen the maximum bytes that can be written to buf. Returns: number of bytes needed for the full string, not counting the null-terminator byte.

Thread Safety: It is safe to call this function from any thread.

Available Since: This function is available since SDL 3.4.0.