Finally abstracted constants properly. Changed how the event module works; wasn't really abstract before. Removed libs we're not going to use: native, signal.

This commit is contained in:
rude
2009-10-10 11:11:04 +02:00
parent 0a2ae705dd
commit 87e3c4131c
101 changed files with 3225 additions and 33496 deletions
+230 -98
View File
@@ -20,6 +20,9 @@
#include "Event.h"
#include <keyboard/Keyboard.h>
#include <mouse/Mouse.h>
namespace love
{
namespace event
@@ -31,138 +34,267 @@ namespace sdl
return "love.event.sdl";
}
Event::Event()
{
SDL_EnableUNICODE(1);
}
void Event::pump()
{
SDL_PumpEvents();
}
int Event::poll(lua_State * L)
bool Event::poll(Message & message)
{
lua_pushcclosure(L, &poll_i, 0);
return 1;
}
int Event::wait(lua_State * L)
{
SDL_EnableUNICODE(1);
// The union used to get SDL events.
static SDL_Event e;
SDL_WaitEvent(&e);
return Event::pushEvent(L, e);
}
void Event::quit()
{
SDL_Event e;
e.type = Event::EVENT_QUIT;
SDL_PushEvent(&e);
}
int Event::push(lua_State * L)
{
SDL_Event e;
getEvent(L, e);
SDL_PushEvent(&e);
return 0;
}
int Event::poll_i(lua_State * L)
{
SDL_EnableUNICODE(1);
// The union used to get SDL events.
static SDL_Event e;
// Get ONE event.
while(SDL_PollEvent(&e))
{
int args = Event::pushEvent(L, e);
if(args > 0)
return args;
}
// No pending events.
return 0;
if(convert(e, message))
return true;
}
return false;
}
int Event::pushEvent(lua_State * L, SDL_Event & e)
bool Event::wait(Message & message)
{
static SDL_Event e;
bool ok = (SDL_WaitEvent(&e) == 1);
return ok && convert(e, message);
}
bool Event::push(Message & message)
{
static SDL_Event e;
bool ok = convert(message, e);
return ok && (SDL_PushEvent(&e) == 0);
}
bool Event::convert(SDL_Event & e, Message & m)
{
switch(e.type)
{
case SDL_KEYDOWN:
lua_pushinteger(L, e.type);
lua_pushinteger(L, e.key.keysym.sym);
lua_pushinteger(L, e.key.keysym.unicode);
return 3;
m.type = Event::TYPE_KEY_PRESSED;
m.keyboard.u = e.key.keysym.unicode;
return keys.find(e.key.keysym.sym, m.keyboard.k);
case SDL_KEYUP:
lua_pushinteger(L, e.type);
lua_pushinteger(L, e.key.keysym.sym);
return 2;
m.type = Event::TYPE_KEY_RELEASED;
return keys.find(e.key.keysym.sym, m.keyboard.k);
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
lua_pushinteger(L, e.type);
lua_pushinteger(L, e.button.x);
lua_pushinteger(L, e.button.y);
lua_pushinteger(L, e.button.button);
return 4;
m.type = (e.type == SDL_MOUSEBUTTONDOWN) ? Event::TYPE_MOUSE_PRESSED : Event::TYPE_MOUSE_RELEASED;
m.mouse.x = e.button.x;
m.mouse.y = e.button.y;
return buttons.find(e.button.button, m.mouse.b);
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
lua_pushinteger(L, e.type);
lua_pushinteger(L, e.jbutton.which);
lua_pushinteger(L, e.jbutton.button);
return 3;
m.type = (e.type == SDL_JOYBUTTONDOWN) ? Event::TYPE_JOYSTICK_PRESSED : Event::TYPE_JOYSTICK_RELEASED;
m.joystick.button = e.jbutton.button;
m.joystick.index = e.jbutton.which;
return true;
case SDL_QUIT:
lua_pushinteger(L, e.type);
return 1;
default:
break;
m.type = Event::TYPE_QUIT;
return true;
}
return 0;
return false;
}
int Event::getEvent(lua_State * L, SDL_Event & e)
bool Event::convert(Message & m, SDL_Event & e)
{
int type = luaL_checkint(L, 1);
switch(type)
switch(m.type)
{
case EVENT_KEYDOWN:
e.type = type;
e.key.keysym.sym = (SDLKey)luaL_checkint(L, 2);
e.key.keysym.unicode = luaL_checkint(L, 3);
return 3;
case EVENT_KEYUP:
e.type = type;
e.key.keysym.sym = (SDLKey)luaL_checkint(L, 2);
return 2;
case EVENT_MOUSEBUTTONDOWN:
case EVENT_MOUSEBUTTONUP:
e.type = type;
e.button.x = luaL_checkint(L, 2);
e.button.y = luaL_checkint(L, 3);
e.button.button = luaL_checkint(L, 4);
return 4;
case EVENT_JOYBUTTONDOWN:
case EVENT_JOYBUTTONUP:
e.type = type;
e.jbutton.which = luaL_checkint(L, 2);
e.jbutton.button = luaL_checkint(L, 3);
return 3;
case EVENT_QUIT:
e.type = type;
return 1;
default:
e.type = EVENT_NOEVENT;
break;
case Event::TYPE_KEY_PRESSED:
e.type = SDL_KEYDOWN;
e.key.keysym.unicode = (Uint16)m.keyboard.u;
return keys.find(m.keyboard.k, e.key.keysym.sym);;
case Event::TYPE_KEY_RELEASED:
e.type = SDL_KEYUP;
return keys.find(m.keyboard.k, e.key.keysym.sym);
case Event::TYPE_MOUSE_PRESSED:
case Event::TYPE_MOUSE_RELEASED:
e.type = (m.type == Event::TYPE_MOUSE_PRESSED) ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
e.button.x = m.mouse.x;
e.button.y = m.mouse.y;
return buttons.find(m.mouse.b, e.button.button);
case Event::TYPE_JOYSTICK_PRESSED:
case Event::TYPE_JOYSTICK_RELEASED:
e.type = (m.type == Event::TYPE_JOYSTICK_PRESSED) ? SDL_JOYBUTTONDOWN : SDL_JOYBUTTONUP;
e.jbutton.which = m.joystick.index;
e.jbutton.button = m.joystick.button;
return true;
case Event::TYPE_QUIT:
e.type = SDL_QUIT;
return true;
}
return 0;
return true;
}
EnumMap<love::keyboard::Keyboard::Key, SDLKey, love::keyboard::Keyboard::KEY_MAX_ENUM>::Entry Event::keyEntries[] =
{
{ love::keyboard::Keyboard::KEY_BACKSPACE, SDLK_BACKSPACE},
{ love::keyboard::Keyboard::KEY_TAB, SDLK_TAB},
{ love::keyboard::Keyboard::KEY_CLEAR, SDLK_CLEAR},
{ love::keyboard::Keyboard::KEY_RETURN, SDLK_RETURN},
{ love::keyboard::Keyboard::KEY_PAUSE, SDLK_PAUSE},
{ love::keyboard::Keyboard::KEY_ESCAPE, SDLK_ESCAPE },
{ love::keyboard::Keyboard::KEY_SPACE, SDLK_SPACE },
{ love::keyboard::Keyboard::KEY_EXCLAIM, SDLK_EXCLAIM },
{ love::keyboard::Keyboard::KEY_QUOTEDBL, SDLK_QUOTEDBL },
{ love::keyboard::Keyboard::KEY_HASH, SDLK_HASH },
{ love::keyboard::Keyboard::KEY_DOLLAR, SDLK_DOLLAR },
{ love::keyboard::Keyboard::KEY_AMPERSAND, SDLK_AMPERSAND },
{ love::keyboard::Keyboard::KEY_QUOTE, SDLK_QUOTE },
{ love::keyboard::Keyboard::KEY_LEFTPAREN, SDLK_LEFTPAREN },
{ love::keyboard::Keyboard::KEY_RIGHTPAREN, SDLK_RIGHTPAREN },
{ love::keyboard::Keyboard::KEY_ASTERISK, SDLK_ASTERISK },
{ love::keyboard::Keyboard::KEY_PLUS, SDLK_PLUS },
{ love::keyboard::Keyboard::KEY_COMMA, SDLK_COMMA },
{ love::keyboard::Keyboard::KEY_MINUS, SDLK_MINUS },
{ love::keyboard::Keyboard::KEY_PERIOD, SDLK_PERIOD },
{ love::keyboard::Keyboard::KEY_SLASH, SDLK_SLASH },
{ love::keyboard::Keyboard::KEY_0, SDLK_0 },
{ love::keyboard::Keyboard::KEY_1, SDLK_1 },
{ love::keyboard::Keyboard::KEY_2, SDLK_2 },
{ love::keyboard::Keyboard::KEY_3, SDLK_3 },
{ love::keyboard::Keyboard::KEY_4, SDLK_4 },
{ love::keyboard::Keyboard::KEY_5, SDLK_5 },
{ love::keyboard::Keyboard::KEY_6, SDLK_6 },
{ love::keyboard::Keyboard::KEY_7, SDLK_7 },
{ love::keyboard::Keyboard::KEY_8, SDLK_8 },
{ love::keyboard::Keyboard::KEY_9, SDLK_9 },
{ love::keyboard::Keyboard::KEY_COLON, SDLK_COLON },
{ love::keyboard::Keyboard::KEY_SEMICOLON, SDLK_SEMICOLON },
{ love::keyboard::Keyboard::KEY_LESS, SDLK_LESS },
{ love::keyboard::Keyboard::KEY_EQUALS, SDLK_EQUALS },
{ love::keyboard::Keyboard::KEY_GREATER, SDLK_GREATER },
{ love::keyboard::Keyboard::KEY_QUESTION, SDLK_QUESTION },
{ love::keyboard::Keyboard::KEY_AT, SDLK_AT },
{ love::keyboard::Keyboard::KEY_LEFTBRACKET, SDLK_LEFTBRACKET },
{ love::keyboard::Keyboard::KEY_BACKSLASH, SDLK_BACKSLASH },
{ love::keyboard::Keyboard::KEY_RIGHTBRACKET, SDLK_RIGHTBRACKET },
{ love::keyboard::Keyboard::KEY_CARET, SDLK_CARET },
{ love::keyboard::Keyboard::KEY_UNDERSCORE, SDLK_UNDERSCORE },
{ love::keyboard::Keyboard::KEY_BACKQUOTE, SDLK_BACKQUOTE },
{ love::keyboard::Keyboard::KEY_A, SDLK_a },
{ love::keyboard::Keyboard::KEY_B, SDLK_b },
{ love::keyboard::Keyboard::KEY_C, SDLK_c },
{ love::keyboard::Keyboard::KEY_D, SDLK_d },
{ love::keyboard::Keyboard::KEY_E, SDLK_e },
{ love::keyboard::Keyboard::KEY_F, SDLK_f },
{ love::keyboard::Keyboard::KEY_G, SDLK_g },
{ love::keyboard::Keyboard::KEY_H, SDLK_h },
{ love::keyboard::Keyboard::KEY_I, SDLK_i },
{ love::keyboard::Keyboard::KEY_J, SDLK_j },
{ love::keyboard::Keyboard::KEY_K, SDLK_k },
{ love::keyboard::Keyboard::KEY_L, SDLK_l },
{ love::keyboard::Keyboard::KEY_M, SDLK_m },
{ love::keyboard::Keyboard::KEY_N, SDLK_n },
{ love::keyboard::Keyboard::KEY_O, SDLK_o },
{ love::keyboard::Keyboard::KEY_P, SDLK_p },
{ love::keyboard::Keyboard::KEY_Q, SDLK_q },
{ love::keyboard::Keyboard::KEY_R, SDLK_r },
{ love::keyboard::Keyboard::KEY_S, SDLK_s },
{ love::keyboard::Keyboard::KEY_T, SDLK_t },
{ love::keyboard::Keyboard::KEY_U, SDLK_u },
{ love::keyboard::Keyboard::KEY_V, SDLK_v },
{ love::keyboard::Keyboard::KEY_W, SDLK_w },
{ love::keyboard::Keyboard::KEY_X, SDLK_x },
{ love::keyboard::Keyboard::KEY_Y, SDLK_y },
{ love::keyboard::Keyboard::KEY_Z, SDLK_z },
{ love::keyboard::Keyboard::KEY_DELETE, SDLK_DELETE },
{ love::keyboard::Keyboard::KEY_KP0, SDLK_KP0 },
{ love::keyboard::Keyboard::KEY_KP1, SDLK_KP1 },
{ love::keyboard::Keyboard::KEY_KP2, SDLK_KP2 },
{ love::keyboard::Keyboard::KEY_KP3, SDLK_KP3 },
{ love::keyboard::Keyboard::KEY_KP4, SDLK_KP4 },
{ love::keyboard::Keyboard::KEY_KP5, SDLK_KP5 },
{ love::keyboard::Keyboard::KEY_KP6, SDLK_KP6 },
{ love::keyboard::Keyboard::KEY_KP7, SDLK_KP7 },
{ love::keyboard::Keyboard::KEY_KP8, SDLK_KP8 },
{ love::keyboard::Keyboard::KEY_KP9, SDLK_KP9 },
{ love::keyboard::Keyboard::KEY_KP_PERIOD, SDLK_KP_PERIOD },
{ love::keyboard::Keyboard::KEY_KP_DIVIDE, SDLK_KP_DIVIDE },
{ love::keyboard::Keyboard::KEY_KP_MULTIPLY, SDLK_KP_MULTIPLY},
{ love::keyboard::Keyboard::KEY_KP_MINUS, SDLK_KP_MINUS },
{ love::keyboard::Keyboard::KEY_KP_PLUS, SDLK_KP_PLUS },
{ love::keyboard::Keyboard::KEY_KP_ENTER, SDLK_KP_ENTER },
{ love::keyboard::Keyboard::KEY_KP_EQUALS, SDLK_KP_EQUALS },
{ love::keyboard::Keyboard::KEY_UP, SDLK_UP },
{ love::keyboard::Keyboard::KEY_DOWN, SDLK_DOWN },
{ love::keyboard::Keyboard::KEY_RIGHT, SDLK_RIGHT },
{ love::keyboard::Keyboard::KEY_LEFT, SDLK_LEFT },
{ love::keyboard::Keyboard::KEY_INSERT, SDLK_INSERT },
{ love::keyboard::Keyboard::KEY_HOME, SDLK_HOME },
{ love::keyboard::Keyboard::KEY_END, SDLK_END },
{ love::keyboard::Keyboard::KEY_PAGEUP, SDLK_PAGEUP },
{ love::keyboard::Keyboard::KEY_PAGEDOWN, SDLK_PAGEDOWN },
{ love::keyboard::Keyboard::KEY_F1, SDLK_F1 },
{ love::keyboard::Keyboard::KEY_F2, SDLK_F2 },
{ love::keyboard::Keyboard::KEY_F3, SDLK_F3 },
{ love::keyboard::Keyboard::KEY_F4, SDLK_F4 },
{ love::keyboard::Keyboard::KEY_F5, SDLK_F5 },
{ love::keyboard::Keyboard::KEY_F6, SDLK_F6 },
{ love::keyboard::Keyboard::KEY_F7, SDLK_F7 },
{ love::keyboard::Keyboard::KEY_F8, SDLK_F8 },
{ love::keyboard::Keyboard::KEY_F9, SDLK_F9 },
{ love::keyboard::Keyboard::KEY_F10, SDLK_F10 },
{ love::keyboard::Keyboard::KEY_F11, SDLK_F11 },
{ love::keyboard::Keyboard::KEY_F12, SDLK_F12 },
{ love::keyboard::Keyboard::KEY_F13, SDLK_F13 },
{ love::keyboard::Keyboard::KEY_F14, SDLK_F14 },
{ love::keyboard::Keyboard::KEY_F15, SDLK_F15 },
{ love::keyboard::Keyboard::KEY_NUMLOCK, SDLK_NUMLOCK },
{ love::keyboard::Keyboard::KEY_CAPSLOCK, SDLK_CAPSLOCK },
{ love::keyboard::Keyboard::KEY_SCROLLOCK, SDLK_SCROLLOCK },
{ love::keyboard::Keyboard::KEY_RSHIFT, SDLK_RSHIFT },
{ love::keyboard::Keyboard::KEY_LSHIFT, SDLK_LSHIFT },
{ love::keyboard::Keyboard::KEY_RCTRL, SDLK_RCTRL },
{ love::keyboard::Keyboard::KEY_LCTRL, SDLK_LCTRL },
{ love::keyboard::Keyboard::KEY_RALT, SDLK_RALT },
{ love::keyboard::Keyboard::KEY_LALT, SDLK_LALT },
{ love::keyboard::Keyboard::KEY_RMETA, SDLK_RMETA },
{ love::keyboard::Keyboard::KEY_LMETA, SDLK_LMETA },
{ love::keyboard::Keyboard::KEY_LSUPER, SDLK_LSUPER },
{ love::keyboard::Keyboard::KEY_RSUPER, SDLK_RSUPER },
{ love::keyboard::Keyboard::KEY_MODE, SDLK_MODE },
{ love::keyboard::Keyboard::KEY_COMPOSE, SDLK_COMPOSE },
{ love::keyboard::Keyboard::KEY_HELP, SDLK_HELP },
{ love::keyboard::Keyboard::KEY_PRINT, SDLK_PRINT },
{ love::keyboard::Keyboard::KEY_SYSREQ, SDLK_SYSREQ },
{ love::keyboard::Keyboard::KEY_BREAK, SDLK_BREAK },
{ love::keyboard::Keyboard::KEY_MENU, SDLK_MENU },
{ love::keyboard::Keyboard::KEY_POWER, SDLK_POWER },
{ love::keyboard::Keyboard::KEY_EURO, SDLK_EURO },
{ love::keyboard::Keyboard::KEY_UNDO, SDLK_UNDO },
};
EnumMap<love::keyboard::Keyboard::Key, SDLKey, love::keyboard::Keyboard::KEY_MAX_ENUM> Event::keys(Event::keyEntries, sizeof(Event::keyEntries));
EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM>::Entry Event::buttonEntries[] =
{
{ love::mouse::Mouse::BUTTON_LEFT, SDL_BUTTON_LEFT},
{ love::mouse::Mouse::BUTTON_MIDDLE, SDL_BUTTON_MIDDLE},
{ love::mouse::Mouse::BUTTON_RIGHT, SDL_BUTTON_RIGHT},
{ love::mouse::Mouse::BUTTON_WHEELUP, SDL_BUTTON_WHEELUP},
{ love::mouse::Mouse::BUTTON_WHEELDOWN, SDL_BUTTON_WHEELDOWN},
{ love::mouse::Mouse::BUTTON_X1, SDL_BUTTON_X1},
{ love::mouse::Mouse::BUTTON_X2, SDL_BUTTON_X2},
};
EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM> Event::buttons(Event::buttonEntries, sizeof(Event::buttonEntries));
} // sdl
} // event
} // love
+27 -24
View File
@@ -24,6 +24,7 @@
// LOVE
#include <event/Event.h>
#include <common/runtime.h>
#include <common/EnumMap.h>
// SDL
#include <SDL.h>
@@ -34,13 +35,15 @@ namespace event
{
namespace sdl
{
class Event : public event::Event
class Event : public love::event::Event
{
public:
// Implements Module.
const char * getName() const;
Event();
/**
* Pumps the event queue. This function gathers all the pending input information
* from devices and places it on the event queue. Normally not needed if you poll
@@ -48,38 +51,38 @@ namespace sdl
**/
void pump();
/**
* Returns an iterator function for iterating over pending events.
/**
* Checks if there are messages in the queue.
*
* @param message The next message in the queue, if the return value is true.
* @return True if there a message was found, false otherwise.
**/
int poll(lua_State * L);
bool poll(Message & message);
/**
* Waits for the next event (indefinitely). Useful for creating games where
* the screen and game state only needs updating when the user interacts with
* the window.
**/
int wait(lua_State * L);
bool wait(Message & message);
/**
* Push a message onto the event queue.
*
* @param message The message to push onto the queue.
* @return True on success, false if the queue was full.
**/
bool push(Message & message);
/**
* Push a quit event. Calling this does not mean the application
* will exit immediately, it just means an quit event will be issued.
* How to respond to the quit event is up the application.
**/
void quit();
/**
* Pushes an event into the queue.
**/
int push(lua_State * L);
/**
* The iterator function.
**/
static int poll_i(lua_State * L);
private:
static int pushEvent(lua_State * L, SDL_Event & e);
static int getEvent(lua_State * L, SDL_Event & e);
bool convert(SDL_Event & e, Message & m);
bool convert(Message & m, SDL_Event & e);
static EnumMap<love::keyboard::Keyboard::Key, SDLKey, love::keyboard::Keyboard::KEY_MAX_ENUM>::Entry keyEntries[];
static EnumMap<love::keyboard::Keyboard::Key, SDLKey, love::keyboard::Keyboard::KEY_MAX_ENUM> keys;
static EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM>::Entry buttonEntries[];
static EnumMap<love::mouse::Mouse::Button, Uint8, love::mouse::Mouse::BUTTON_MAX_ENUM> buttons;
}; // System
+113 -21
View File
@@ -34,6 +34,100 @@ namespace sdl
{
static Event * instance = 0;
static bool to_message(lua_State * L, Event::Message & msg)
{
const char * str = luaL_checkstring(L, 1);
if(!Event::getConstant(str, msg.type))
return false;
switch(msg.type)
{
case Event::TYPE_KEY_PRESSED:
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
return false;
msg.keyboard.u = (unsigned short)luaL_optint(L, 3, 0);
return true;
case Event::TYPE_KEY_RELEASED:
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
return false;
return true;
case Event::TYPE_MOUSE_PRESSED:
case Event::TYPE_MOUSE_RELEASED:
if(!Event::getConstant(luaL_checkstring(L, 2), msg.mouse.b))
return false;
msg.mouse.x = luaL_checkint(L, 3);
msg.mouse.y = luaL_checkint(L, 4);
return true;
case Event::TYPE_JOYSTICK_PRESSED:
case Event::TYPE_JOYSTICK_RELEASED:
msg.joystick.index = luaL_checkint(L, 2);
msg.joystick.button = luaL_checkint(L, 3);
return true;
case Event::TYPE_QUIT:
return true;
}
return false;
}
static int push_message(lua_State * L, const Event::Message & msg)
{
const char * str = 0;
if(!Event::getConstant(msg.type, str))
return 0;
lua_pushstring(L, str);
switch(msg.type)
{
case Event::TYPE_KEY_PRESSED:
if(!Event::getConstant(msg.keyboard.k, str))
return 0;
lua_pushstring(L, str);
lua_pushinteger(L, msg.keyboard.u);
return 3;
case Event::TYPE_KEY_RELEASED:
if(!Event::getConstant(msg.keyboard.k, str))
return 0;
lua_pushstring(L, str);
return 2;
case Event::TYPE_MOUSE_PRESSED:
case Event::TYPE_MOUSE_RELEASED:
if(!Event::getConstant(msg.mouse.b, str))
return 0;
lua_pushinteger(L, msg.mouse.x);
lua_pushinteger(L, msg.mouse.y);
lua_pushstring(L, str);
return 4;
case Event::TYPE_JOYSTICK_PRESSED:
case Event::TYPE_JOYSTICK_RELEASED:
lua_pushinteger(L, msg.joystick.index);
lua_pushinteger(L, msg.joystick.button);
return 3;
case Event::TYPE_QUIT:
return 1;
}
return 0;
}
static int poll_i(lua_State * L)
{
static Event::Message m;
while(instance->poll(m))
{
int args = push_message(L, m);
if(args > 0)
return args;
}
// No pending events.
return 0;
}
int w_pump(lua_State * L)
{
instance->pump();
@@ -42,23 +136,35 @@ namespace sdl
int w_poll(lua_State * L)
{
return instance->poll(L);
lua_pushcclosure(L, &poll_i, 0);
return 1;
}
int w_wait(lua_State * L)
{
return instance->wait(L);
}
static Event::Message m;
if(instance->wait(m))
{
return push_message(L, m);
}
int w_quit(lua_State * L)
{
instance->quit();
return 0;
}
int w_push(lua_State * L)
{
return instance->push(L);
static Event::Message m;
if(!to_message(L, m))
{
luax_pushboolean(L, false);
return 1;
}
luax_pushboolean(L, instance->push(m));
return 1;
}
// List of functions to wrap.
@@ -66,23 +172,10 @@ namespace sdl
{ "pump", w_pump },
{ "poll", w_poll },
{ "wait", w_wait },
{ "quit", w_quit },
{ "push", w_push },
{ 0, 0 }
};
// List of constants.
static const Constant constants[] = {
{ "event_keypressed", Event::EVENT_KEYDOWN },
{ "event_keyreleased", Event::EVENT_KEYUP },
{ "event_mousepressed", Event::EVENT_MOUSEBUTTONDOWN },
{ "event_mousereleased", Event::EVENT_MOUSEBUTTONUP },
{ "event_joystickpressed", Event::EVENT_JOYBUTTONDOWN },
{ "event_joystickreleased", Event::EVENT_JOYBUTTONUP },
{ "event_quit", Event::EVENT_QUIT },
{ 0, 0 }
};
int luaopen_love_event(lua_State * L)
{
if(instance == 0)
@@ -103,7 +196,6 @@ namespace sdl
w.flags = MODULE_T;
w.functions = functions;
w.types = 0;
w.constants = constants;
return luax_register_module(L, w);
}
-1
View File
@@ -34,7 +34,6 @@ namespace sdl
int w_pump(lua_State * L);
int w_poll(lua_State * L);
int w_wait(lua_State * L);
int w_quit(lua_State * L);
int w_push(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);