aboutsummaryrefslogtreecommitdiff
path: root/src/script/mouse/luaopen_mouse.cpp
blob: 29819e122a59eb9bc1a779c02f98d2a30d4fe2e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
    }
}
}