diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-05-01 08:42:28 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2021-05-04 01:52:08 +0000 |
commit | 489a5f3ff72802fac20ca7459620101cd263bd1a (patch) | |
tree | 9410ca4697575cfc67a698d072aa8dd61245c833 /apps/plugins/lua/rocklib.c | |
parent | 4f83e66cd4e00bfa225f54b2c314a3d42d09ca7a (diff) | |
download | rockbox-489a5f3ff72802fac20ca7459620101cd263bd1a.tar.gz rockbox-489a5f3ff72802fac20ca7459620101cd263bd1a.zip |
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
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 12 |
1 files changed, 11 insertions, 1 deletions
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) | |||
143 | 143 | ||
144 | RB_WRAP(kbd_input) | 144 | RB_WRAP(kbd_input) |
145 | { | 145 | { |
146 | /*kbd_input(text, layout)* | ||
147 | note: layout needs special formatting | ||
148 | see includes/create_kbd_layout.lua | ||
149 | or lib/kbd_helper.c | ||
150 | */ | ||
146 | luaL_Buffer b; | 151 | luaL_Buffer b; |
147 | luaL_buffinit(L, &b); | 152 | luaL_buffinit(L, &b); |
148 | 153 | ||
149 | const char *input = lua_tostring(L, 1); | 154 | const char *input = lua_tostring(L, 1); |
155 | size_t layout_len; | ||
156 | const char *layout = lua_tolstring(L, 2, &layout_len); | ||
150 | char *buffer = luaL_prepbuffer(&b); | 157 | char *buffer = luaL_prepbuffer(&b); |
151 | 158 | ||
152 | if(input != NULL) | 159 | if(input != NULL) |
@@ -154,7 +161,10 @@ RB_WRAP(kbd_input) | |||
154 | else | 161 | else |
155 | buffer[0] = '\0'; | 162 | buffer[0] = '\0'; |
156 | 163 | ||
157 | if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, NULL)) | 164 | if(layout_len <= 1 || (unsigned short)layout[layout_len - 1] != 0xFFFE) |
165 | layout = NULL; | ||
166 | |||
167 | if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout)) | ||
158 | { | 168 | { |
159 | luaL_addstring(&b, buffer); | 169 | luaL_addstring(&b, buffer); |
160 | luaL_pushresult(&b); | 170 | luaL_pushresult(&b); |