mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Lua: return nil when kbd_input() gets aborted and make it possible to preset the input string (based on FS#10455 by Christophe Gragnic)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22008 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
07a6aac401
commit
1fde0dd8e4
1 changed files with 14 additions and 4 deletions
|
@ -394,12 +394,22 @@ RB_WRAP(kbd_input)
|
|||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
|
||||
const char *input = luaL_optstring(L, 1, NULL);
|
||||
char *buffer = luaL_prepbuffer(&b);
|
||||
buffer[0] = '\0';
|
||||
rb->kbd_input(buffer, LUAL_BUFFERSIZE);
|
||||
luaL_addsize(&b, strlen(buffer));
|
||||
|
||||
if(input != NULL)
|
||||
rb->strlcpy(buffer, input, LUAL_BUFFERSIZE);
|
||||
else
|
||||
buffer[0] = '\0';
|
||||
|
||||
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE))
|
||||
{
|
||||
luaL_addsize(&b, strlen(buffer));
|
||||
luaL_pushresult(&b);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue