Add mySDL_EventState to work around bizarre SDL event behavior

This commit is contained in:
Glenn Maynard
2003-05-25 23:49:40 +00:00
parent 55c3f4758e
commit 96f86ed5e2
2 changed files with 32 additions and 0 deletions
+29
View File
@@ -509,6 +509,35 @@ bool SDL_GetEvent(SDL_Event &event, int mask)
}
}
/* For some bizarre reason, SDL_EventState flushes all events. This is a pain, so
* avoid it. */
Uint8 mySDL_EventState(Uint8 type, int state)
{
if(state == SDL_QUERY)
return SDL_EventState(type, state);
vector<SDL_Event> events;
while(1)
{
SDL_Event ev;
if(SDL_PollEvent(&ev) <= 0)
break;
/* Don't bother readding it if we're turning this event type off. */
if(state == SDL_IGNORE && ev.type == type)
continue;
events.push_back(ev);
}
Uint8 ret = SDL_EventState(type, state);
/* Put them back. */
for(unsigned i = 0; i < events.size(); ++i)
SDL_PushEvent(&events[i]);
return ret;
}
#include "SDL_image.h" // for setting icon
#include "SDL_rotozoom.h" // for setting icon