From 9edf2ba9fe8524976d2f298767fff0149e8c0d41 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 17 May 2018 19:12:18 +0800 Subject: change file tree --- src/script/mouse/luaopen_mouse.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/script/mouse/luaopen_mouse.cpp (limited to 'src/script/mouse/luaopen_mouse.cpp') diff --git a/src/script/mouse/luaopen_mouse.cpp b/src/script/mouse/luaopen_mouse.cpp new file mode 100644 index 0000000..29819e1 --- /dev/null +++ b/src/script/mouse/luaopen_mouse.cpp @@ -0,0 +1,27 @@ +#include "3rdparty/luax/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 -- cgit v1.1-26-g67d0