25 lines
755 B
C
25 lines
755 B
C
int engine_luaf_lua_event_get_data(lua_State *L) {
|
|
struct ENGINE_EVENT * event = lua_touserdata(L,1);
|
|
char type = event->type;
|
|
if (type == ENGINE_EVENT_TYPE_UNKNOWN) { goto simple; }
|
|
if (type == ENGINE_EVENT_TYPE_NONE) { goto simple; }
|
|
if (type == ENGINE_EVENT_TYPE_EXIT) { goto simple; }
|
|
if (type == ENGINE_EVENT_TYPE_INPUT_KB) {
|
|
struct ENGINE_EVENT_INPUT_KB * data = event->data;
|
|
lua_pushinteger(L,type);
|
|
lua_pushinteger(L,data->key);
|
|
lua_pushinteger(L,data->pressed);
|
|
return 3;
|
|
}
|
|
|
|
type = ENGINE_EVENT_TYPE_UNKNOWN;
|
|
simple:
|
|
lua_pushinteger(L,type);
|
|
return 1;
|
|
}
|
|
|
|
void engine_lua_init_manual() {
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_lua_event_get_data);
|
|
lua_setglobal (engine_lua_state,"engine_lua_event_get_data");
|
|
}
|