Added love.event.clear, because why not. (Issue #202).

This commit is contained in:
rude
2011-03-16 23:23:20 +01:00
parent ffa9e205eb
commit 20364c67bd
4 changed files with 23 additions and 0 deletions
+10
View File
@@ -73,6 +73,16 @@ namespace sdl
return ok && (SDL_PushEvent(&e) == 0);
}
void Event::clear()
{
static SDL_Event e;
while(SDL_PollEvent(&e))
{
// Do nothing with 'e' ...
}
}
bool Event::convert(SDL_Event & e, Message & m)
{
switch(e.type)
+5
View File
@@ -74,6 +74,11 @@ namespace sdl
**/
bool push(Message & message);
/**
* Clears the event queue.
*/
void clear();
private:
bool convert(SDL_Event & e, Message & m);
+7
View File
@@ -177,12 +177,19 @@ namespace sdl
return 1;
}
int w_clear(lua_State * L)
{
instance->clear();
return 0;
}
// List of functions to wrap.
static const luaL_Reg functions[] = {
{ "pump", w_pump },
{ "poll", w_poll },
{ "wait", w_wait },
{ "push", w_push },
{ "clear", w_clear },
{ 0, 0 }
};
+1
View File
@@ -35,6 +35,7 @@ namespace sdl
int w_poll(lua_State * L);
int w_wait(lua_State * L);
int w_push(lua_State * L);
int w_clear(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);