From a57fd040027e2ecff353ec8f7c658c7c6554c70e Mon Sep 17 00:00:00 2001 From: p989 Date: Tue, 30 Jun 2009 18:01:31 +0000 Subject: [PATCH] lua: stylus.read --- desmume/src/lua-engine.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/desmume/src/lua-engine.cpp b/desmume/src/lua-engine.cpp index d0ac9d9fb..8db8d484e 100644 --- a/desmume/src/lua-engine.cpp +++ b/desmume/src/lua-engine.cpp @@ -439,6 +439,25 @@ static int joypad_set(lua_State *L) { return 0; } +static int stylus_read(lua_State *L){ + + lua_newtable(L); + + lua_pushinteger(L, nds.touchX >> 4); + lua_setfield(L, -2, "x"); + lua_pushinteger(L, nds.touchY >> 4); + lua_setfield(L, -2, "y"); + lua_pushinteger(L, nds.isTouch); + lua_setfield(L, -2, "touch"); + + return 1; +} + +static int stylus_set(lua_State *L){ + + return 1; +} + #ifdef _WIN32 const char* s_keyToName[256] = { @@ -1625,6 +1644,13 @@ static const struct luaL_reg joypadlib[] = { {NULL,NULL} }; +static const struct luaL_reg styluslib[] = { + {"read", stylus_read}, + {"set", stylus_set}, + + {NULL,NULL} +}; + static const struct luaL_reg inputlib[] = { {"get", input_get}, {NULL,NULL} @@ -1750,6 +1776,7 @@ int LUA_LoadLuaCode(const char *filename) { luaL_register(L, "savestate", savestatelib); luaL_register(L, "movie", movielib); luaL_register(L, "gui", guilib); + luaL_register(L, "stylus", styluslib); lua_pushcfunction(L, base_AND); lua_setfield(L, LUA_GLOBALSINDEX, "AND");