forked from len0rd/rockbox
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
This commit is contained in:
parent
4f83e66cd4
commit
489a5f3ff7
4 changed files with 113 additions and 19 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue