Events, keyboard & mouseSDL 3.2

SDL_RegisterEvents

Reserves event type numbers for your own events, so they never clash with SDL's or a library's.

Signature

Uint32 SDL_RegisterEvents(int numevents);

How it works

Call it once at startup and keep the returned number. If you asked for several, they are consecutive: first, first + 1, …

Parameters

numeventsint

How many event types to reserve.

Return value

The first reserved type, or 0 if none are left (0 is never a valid user type).

Example

example.cpp
1static Uint32 assetLoadedEvent = SDL_RegisterEvents(1);
2// in the loop:
3if (e.type == assetLoadedEvent) upload(static_cast<Mesh*>(e.user.data1));
Official SDL wiki