From 0f7e4e36aeb95f3e39a940d6e19748d910d40d92 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 22 May 2009 22:44:34 +0000 Subject: Lua: * add action_get_touchscreen_press wrapper * fix kbd_input wrapper * rework luaL_loadfile * add rb.contexts git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21046 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/lua/rocklib.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'apps/plugins/lua/rocklib.c') diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 99bc44c9a4..c99400c938 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -251,6 +251,19 @@ RB_WRAP(get_action) return 1; } +#ifdef HAVE_TOUCHSCREEN +RB_WRAP(action_get_touchscreen_press) +{ + short x, y; + int result = rb->action_get_touchscreen_press(&x, &y); + + lua_pushinteger(L, result); + lua_pushinteger(L, x); + lua_pushinteger(L, y); + return 3; +} +#endif + RB_WRAP(action_userabort) { int timeout = luaL_checkint(L, 1); @@ -261,10 +274,15 @@ RB_WRAP(action_userabort) RB_WRAP(kbd_input) { - char* buffer = (char*)luaL_checkstring(L, 1); - int buflen = luaL_checkint(L, 2); - int result = rb->kbd_input(buffer, buflen); - lua_pushinteger(L, result); + luaL_Buffer b; + luaL_buffinit(L, &b); + + char *buffer = luaL_prepbuffer(&b); + buffer[0] = '\0'; + rb->kbd_input(buffer, LUAL_BUFFERSIZE); + luaL_addsize(&b, strlen(buffer)); + + luaL_pushresult(&b); return 1; } @@ -467,6 +485,9 @@ static const luaL_Reg rocklib[] = #endif R(get_action), R(action_userabort), +#ifdef HAVE_TOUCHSCREEN + R(action_get_touchscreen_press), +#endif R(kbd_input), /* Hardware */ -- cgit v1.2.3