diff options
author | Ferenc Wágner <wferi@niif.hu> | 2013-10-07 19:50:05 +0200 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-03-01 17:40:35 +0100 |
commit | 7b5128075df5444fbc462175f5f05140e240efe9 (patch) | |
tree | 4e5ee63afb90a16d7d342ad882aa651f5da0910b /com32 | |
parent | 4bbaf68cbf6c9a4c850f71b19bfb9604b9327efb (diff) | |
download | syslinux-7b5128075df5444fbc462175f5f05140e240efe9.tar.gz |
lua: bind get_key() in the syslinux module
Diffstat (limited to 'com32')
-rw-r--r-- | com32/lua/src/syslinux.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c index 99832330..ab38166b 100644 --- a/com32/lua/src/syslinux.c +++ b/com32/lua/src/syslinux.c @@ -25,6 +25,7 @@ * * ----------------------------------------------------------------------- */ +#include <getkey.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -473,6 +474,19 @@ static int sl_version(lua_State * L) return 1; } +static int sl_get_key (lua_State * L) +{ + int timeout = luaL_checkint (L, 1); + lua_pushinteger (L, get_key (stdin, timeout)); + return 1; +} + +static int sl_KEY_CTRL (lua_State * L) +{ + lua_pushinteger (L, KEY_CTRL (luaL_checkint (L, 1))); + return 1; +} + static const luaL_Reg syslinuxlib[] = { {"run_command", sl_run_command}, {"run_default", sl_run_default}, @@ -494,6 +508,8 @@ static const luaL_Reg syslinuxlib[] = { {"reboot", sl_reboot}, {"derivative", sl_derivative}, {"version", sl_version}, + {"get_key", sl_get_key}, + {"KEY_CTRL", sl_KEY_CTRL}, {NULL, NULL} }; @@ -505,5 +521,38 @@ LUALIB_API int luaopen_syslinux(lua_State * L) luaL_newmetatable(L, SYSLINUX_FILE); luaL_newlib(L, syslinuxlib); + + lua_newtable (L); +#define export_key(x) lua_pushinteger (L, KEY_##x); lua_setfield (L, -2, #x); + export_key (NONE); + export_key (BACKSPACE); + export_key (TAB); + export_key (ENTER); + export_key (ESC); + export_key (DEL); + export_key (F1); + export_key (F2); + export_key (F3); + export_key (F4); + export_key (F5); + export_key (F6); + export_key (F7); + export_key (F8); + export_key (F9); + export_key (F10); + export_key (F11); + export_key (F12); + export_key (UP); + export_key (DOWN); + export_key (LEFT); + export_key (RIGHT); + export_key (PGUP); + export_key (PGDN); + export_key (HOME); + export_key (END); + export_key (INSERT); + export_key (DELETE); + lua_setfield (L, -2, "KEY"); + return 1; } |