mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Added love.event.clear, because why not. (Issue #202).
This commit is contained in:
@@ -73,6 +73,16 @@ namespace sdl
|
|||||||
return ok && (SDL_PushEvent(&e) == 0);
|
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)
|
bool Event::convert(SDL_Event & e, Message & m)
|
||||||
{
|
{
|
||||||
switch(e.type)
|
switch(e.type)
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ namespace sdl
|
|||||||
**/
|
**/
|
||||||
bool push(Message & message);
|
bool push(Message & message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the event queue.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool convert(SDL_Event & e, Message & m);
|
bool convert(SDL_Event & e, Message & m);
|
||||||
|
|||||||
@@ -177,12 +177,19 @@ namespace sdl
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_clear(lua_State * L)
|
||||||
|
{
|
||||||
|
instance->clear();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// List of functions to wrap.
|
// List of functions to wrap.
|
||||||
static const luaL_Reg functions[] = {
|
static const luaL_Reg functions[] = {
|
||||||
{ "pump", w_pump },
|
{ "pump", w_pump },
|
||||||
{ "poll", w_poll },
|
{ "poll", w_poll },
|
||||||
{ "wait", w_wait },
|
{ "wait", w_wait },
|
||||||
{ "push", w_push },
|
{ "push", w_push },
|
||||||
|
{ "clear", w_clear },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace sdl
|
|||||||
int w_poll(lua_State * L);
|
int w_poll(lua_State * L);
|
||||||
int w_wait(lua_State * L);
|
int w_wait(lua_State * L);
|
||||||
int w_push(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);
|
extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user