aboutsummaryrefslogtreecommitdiff
path: root/src/lua/mouse/luaopen_mouse.cpp
blob: d3488f36ea1798b6827228a5c9c87c11c18dc572 (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
28
29
30
31
#include "lua/luax.h"
#include "libjin/jin.h"

namespace jin
{
namespace lua
{
    using namespace jin::input;

    static int l_pos(lua_State* L)
    {
        static Mouse* mouse = Mouse::get();
        int x, y; 
        mouse->getState(&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;
    }
}
}