General improvements for user custom event registration

* Switched event type to enum (int32)
* Switched polling by mask to polling by type range
* Added SDL_RegisterEvents() to allow dynamic user event registration
* Spread events out to allow inserting new related events without breaking binary compatibility
* Added padding to event structures so they're the same size regardless of 32-bit compiler structure packing settings
* Split SDL_HasEvent() to SDL_HasEvent() for a single event and SDL_HasEvents() for a range of events
* Added SDL_GetEventState() as a shortcut for SDL_EventState(X, SDL_QUERY)
* Added SDL_FlushEvent() and SDL_FlushEvents() to clear events from the event queue
This commit is contained in:
Sam Lantinga 2010-03-25 01:08:26 -07:00
parent e2adaf166a
commit 1fb2a69487
13 changed files with 313 additions and 208 deletions

View file

@ -365,7 +365,7 @@ SDL_SendProximity(int id, int x, int y, int type)
mouse->last_x = x;
mouse->last_y = y;
if (SDL_ProcessEvents[type] == SDL_ENABLE) {
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.proximity.which = (Uint8) index;
event.proximity.x = x;
@ -461,7 +461,7 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
/* Post the event, if desired */
posted = 0;
if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE &&
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE &&
mouse->proximity == SDL_TRUE) {
SDL_Event event;
event.motion.type = SDL_MOUSEMOTION;
@ -493,7 +493,7 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
int index = SDL_GetMouseIndexId(id);
SDL_Mouse *mouse = SDL_GetMouse(index);
int posted;
Uint8 type;
Uint32 type;
if (!mouse) {
return 0;
@ -524,7 +524,7 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
/* Post the event, if desired */
posted = 0;
if (SDL_ProcessEvents[type] == SDL_ENABLE) {
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
event.button.which = (Uint8) index;
@ -550,7 +550,7 @@ SDL_SendMouseWheel(int index, int x, int y)
/* Post the event, if desired */
posted = 0;
if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) {
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_MOUSEWHEEL;
event.wheel.which = (Uint8) index;