diff options
Diffstat (limited to 'src/lua/mouse/luaopen_mouse.cpp')
-rw-r--r-- | src/lua/mouse/luaopen_mouse.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lua/mouse/luaopen_mouse.cpp b/src/lua/mouse/luaopen_mouse.cpp new file mode 100644 index 0000000..a013f3d --- /dev/null +++ b/src/lua/mouse/luaopen_mouse.cpp @@ -0,0 +1,27 @@ +#include "lua/luax.h" +#include "SDL2/SDL.h" +namespace jin +{ +namespace lua +{ + static int l_pos(lua_State* L) + { + int x, y; + SDL_GetMouseState(&x, &y); + luax_pushnumber(L, x); + luax_pushnumber(L, y); + return 2; + } + + static const luaL_Reg f[] = { + {"position", l_pos}, + {0, 0} + }; + + int luaopen_mouse(lua_State* L) + { + luax_newlib(L, f); + return 1; + } +} +}
\ No newline at end of file |