Wiki Page Content

Differences between revisions 4 and 5
Revision 4 as of 2016-11-18 21:01:13
Size: 928
Editor: urkle
Comment: clarify (Uint32)-1 cast based on end-user feedback
Revision 5 as of 2016-11-28 21:43:40
Size: 928
Comment: Fixed typo.
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
Note,  (Uint32)-1 means the maximum unsigned 32bit integer value (or 0xFFFFFFFF), but is clearer to write. Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or 0xFFFFFFFF), but is clearer to write.

SDL_RegisterEvents

Use this function to allocate a set of user-defined events, and return the beginning event number for that set of events.

Syntax

Uint32 SDL_RegisterEvents(int numevents)

Function Parameters

numevents

the number of events to be allocated

Return Value

The beginning event number, or (Uint32)-1 if there are not enough user-defined events left.

Code Examples

Uint32 myEventType = SDL_RegisterEvents(1);
if (myEventType != ((Uint32)-1)) {
    SDL_Event event;
    SDL_memset(&event, 0, sizeof(event)); /* or SDL_zero(event) */
    event.type = myEventType;
    event.user.code = my_event_code;
    event.user.data1 = significant_data;
    event.user.data2 = 0;
    SDL_PushEvent(&event);
}

Remarks

Calling this function with numevents <= 0 is an error and will return (Uint32)-1.

Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or 0xFFFFFFFF), but is clearer to write.


CategoryAPI, CategoryEvents

None: SDL_RegisterEvents (last edited 2016-11-28 21:44:50 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit