aboutsummaryrefslogtreecommitdiff
path: root/src/lua/mouse/luaopen_mouse.cpp
blob: a013f3d284f816fb7654a763590b92c0e6eb0d87 (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 "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;
    }
}
}