From 489a5f3ff72802fac20ca7459620101cd263bd1a Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 1 May 2021 08:42:28 -0400 Subject: lua add ability to use custom kbd layouts bring custom keyboard layouts to lua conversion to the proper format requires create_kbd_layout.lua just pass a lua string with your desired layout Change-Id: I14a392410846311a4f3cf8dda0e88d39834d0418 --- apps/plugins/lua/rocklib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'apps/plugins/lua/rocklib.c') diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 81b6f4ce2a..050fbc73b2 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -143,10 +143,17 @@ RB_WRAP(touchscreen_mode) RB_WRAP(kbd_input) { + /*kbd_input(text, layout)* + note: layout needs special formatting + see includes/create_kbd_layout.lua + or lib/kbd_helper.c + */ luaL_Buffer b; luaL_buffinit(L, &b); const char *input = lua_tostring(L, 1); + size_t layout_len; + const char *layout = lua_tolstring(L, 2, &layout_len); char *buffer = luaL_prepbuffer(&b); if(input != NULL) @@ -154,7 +161,10 @@ RB_WRAP(kbd_input) else buffer[0] = '\0'; - if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, NULL)) + if(layout_len <= 1 || (unsigned short)layout[layout_len - 1] != 0xFFFE) + layout = NULL; + + if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout)) { luaL_addstring(&b, buffer); luaL_pushresult(&b); -- cgit v1.2.3