@@ -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)
@@ -74,6 +74,11 @@ namespace sdl
**/
bool push(Message & message);
+ /**
+ * Clears the event queue.
+ */
+ void clear();
private:
bool convert(SDL_Event & e, Message & m);
@@ -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 }
};
@@ -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);