summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/hosted/android/keyboard.c3
-rw-r--r--apps/keyboard.h4
-rw-r--r--apps/menus/playlist_menu.c2
-rw-r--r--apps/onplay.c4
-rw-r--r--apps/player/keyboard.c3
-rw-r--r--apps/playlist_catalog.c2
-rw-r--r--apps/playlist_viewer.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/calendar.c4
-rw-r--r--apps/plugins/dict.c2
-rw-r--r--apps/plugins/frotz/frotz.c4
-rw-r--r--apps/plugins/goban/goban.c6
-rw-r--r--apps/plugins/keybox.c18
-rw-r--r--apps/plugins/lib/SOURCES2
-rw-r--r--apps/plugins/lib/kbd_helper.c63
-rw-r--r--apps/plugins/lib/kbd_helper.h27
-rw-r--r--apps/plugins/lrcplayer.c2
-rw-r--r--apps/plugins/lua/rocklib.c2
-rw-r--r--apps/plugins/otp.c19
-rw-r--r--apps/plugins/puzzles/rockbox.c2
-rw-r--r--apps/plugins/resistor.c6
-rw-r--r--apps/plugins/rockboy/menu.c2
-rw-r--r--apps/plugins/rockpaint.c4
-rw-r--r--apps/plugins/sdl/progs/duke3d/Game/src/console.c2
-rw-r--r--apps/plugins/sdl/progs/quake/keys.c2
-rw-r--r--apps/plugins/search.c2
-rw-r--r--apps/plugins/sokoban.c2
-rw-r--r--apps/plugins/splitedit.c4
-rw-r--r--apps/plugins/sudoku/sudoku.c2
-rw-r--r--apps/plugins/superdom.c2
-rw-r--r--apps/plugins/text_editor.c10
-rw-r--r--apps/plugins/zxbox/snapshot.c2
-rw-r--r--apps/radio/presets.c6
-rw-r--r--apps/recorder/keyboard.c17
-rw-r--r--apps/settings.c2
-rw-r--r--apps/tagtree.c2
-rw-r--r--apps/tree.c2
37 files changed, 173 insertions, 69 deletions
diff --git a/apps/hosted/android/keyboard.c b/apps/hosted/android/keyboard.c
index 9407d970fd..eda951a7c9 100644
--- a/apps/hosted/android/keyboard.c
+++ b/apps/hosted/android/keyboard.c
@@ -82,8 +82,9 @@ static void kdb_init(void)
sleep(HZ/10);
}
-int kbd_input(char* text, int buflen)
+int kbd_input(char* text, int buflen, unsigned short *kbd)
{
+ (void)kbd;
JNIEnv e = *env_ptr;
jstring str = e->NewStringUTF(env_ptr, text);
jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK));
diff --git a/apps/keyboard.h b/apps/keyboard.h
index f68f625c93..a76b49834e 100644
--- a/apps/keyboard.h
+++ b/apps/keyboard.h
@@ -21,7 +21,9 @@
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
-int kbd_input(char* buffer, int buflen);
+/* '*kbd', same format as https://www.rockbox.org/wiki/LoadableKeyboardLayouts */
+
+int kbd_input(char* buffer, int buflen, unsigned short *kbd);
#ifdef HAVE_LCD_BITMAP
int load_kbd(unsigned char* filename);
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c
index c0a0d48d45..b0d9a44a9e 100644
--- a/apps/menus/playlist_menu.c
+++ b/apps/menus/playlist_menu.c
@@ -58,7 +58,7 @@ int save_playlist_screen(struct playlist_info* playlist)
if (dot) /* remove extension */
*dot = '\0';
- if (!kbd_input(temp, sizeof(temp)))
+ if (!kbd_input(temp, sizeof(temp), NULL))
{
len = strlen(temp);
if(len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
diff --git a/apps/onplay.c b/apps/onplay.c
index 7f96246c08..f88953ce62 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1009,7 +1009,7 @@ static int rename_file(void)
if (strlcpy(newname, selection, sizeof (newname)) >= sizeof (newname)) {
/* Too long */
- } else if (kbd_input(newbase, sizeof (newname) - pathlen) < 0) {
+ } else if (kbd_input(newbase, sizeof (newname) - pathlen, NULL) < 0) {
rc = OPRC_CANCELLED;
} else if (!strcmp(oldbase, newbase)) {
rc = OPRC_NOOP; /* No change at all */
@@ -1051,7 +1051,7 @@ static int create_dir(void)
if (pathlen >= sizeof (dirname)) {
/* Too long */
- } else if (kbd_input(basename, sizeof (dirname) - pathlen) < 0) {
+ } else if (kbd_input(basename, sizeof (dirname) - pathlen, NULL) < 0) {
rc = OPRC_CANCELLED;
} else if (check_new_name(basename)) {
rc = mkdir(dirname);
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index 1c6dc9bb0d..ce84bb6d69 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -97,8 +97,9 @@ static void say_edit(void)
talk_id(VOICE_EDIT, false);
}
-int kbd_input(char* text, int buflen)
+int kbd_input(char* text, int buflen, unsigned short *kbd)
{
+ (void) kbd;
bool done = false;
bool redraw = true;
bool line_edit = false;
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 7de907c8d0..1181f73e3f 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -356,7 +356,7 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
else
strlcpy(playlist, m3u8name, MAX_PATH);
- if (kbd_input(playlist, MAX_PATH))
+ if (kbd_input(playlist, MAX_PATH, NULL))
return false;
len = strlen(playlist);
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 751f1e21a7..3e1479139b 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -910,7 +910,7 @@ bool search_playlist(void)
if (!playlist_viewer_init(&viewer, 0, false))
return ret;
- if (kbd_input(search_str, sizeof(search_str)) < 0)
+ if (kbd_input(search_str, sizeof(search_str), NULL) < 0)
return ret;
lcd_clear_display();
playlist_count = playlist_amount_ex(viewer.playlist);
diff --git a/apps/plugin.h b/apps/plugin.h
index 430c15a2a6..acaee27687 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -927,7 +927,7 @@ struct plugin_api {
int (*rand)(void);
void (*qsort)(void *base, size_t nmemb, size_t size,
int(*compar)(const void *, const void *));
- int (*kbd_input)(char* buffer, int buflen);
+ int (*kbd_input)(char* buffer, int buflen, unsigned short *kbd);
struct tm* (*get_time)(void);
int (*set_time)(const struct tm *tm);
struct tm * (*gmtime_r)(const time_t *timep, struct tm *tm);
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index ded0a70d26..11a37191af 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -842,7 +842,7 @@ static void add_memo(struct shown *shown, int type)
{
bool saved = false;
struct memo *memo = &memos[memos_in_memory];
- if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN) == 0)
+ if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN, NULL) == 0)
{
if (memo->message[0])
{
@@ -920,7 +920,7 @@ static bool edit_memo(int change, struct shown *shown)
case 1: /* edit */
if(rb->kbd_input(memos[change].message,
- MAX_CHAR_MEMO_LEN) == 0)
+ MAX_CHAR_MEMO_LEN, NULL) == 0)
save_memo(change, true, shown);
return false;
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c
index 9438c1d022..c7868c09d0 100644
--- a/apps/plugins/dict.c
+++ b/apps/plugins/dict.c
@@ -92,7 +92,7 @@ enum plugin_status plugin_start(const void* parameter)
searchword[0] = '\0';
/* get the word to search */
- if (rb->kbd_input(searchword, sizeof(searchword)) < 0)
+ if (rb->kbd_input(searchword, sizeof(searchword), NULL) < 0)
return PLUGIN_OK; /* input cancelled */
fIndex = rb->open(DICT_INDEX, O_RDONLY); /* index file */
diff --git a/apps/plugins/frotz/frotz.c b/apps/plugins/frotz/frotz.c
index 6dd6098e0b..4c12cfcd10 100644
--- a/apps/plugins/frotz/frotz.c
+++ b/apps/plugins/frotz/frotz.c
@@ -195,7 +195,7 @@ zchar os_read_key(int timeout, bool show_cursor)
return zkey;
inputbuf[0] = '\0';
- r = rb->kbd_input(inputbuf, 5);
+ r = rb->kbd_input(inputbuf, 5, NULL);
rb->lcd_setfont(FONT_SYSFIXED);
dumb_dump_screen();
if (!r)
@@ -226,7 +226,7 @@ zchar os_read_line(int max, zchar *buf, int timeout, int width, int continued)
if (max > width)
max = width;
strcpy(inputbuf, buf);
- r = rb->kbd_input(inputbuf, 256);
+ r = rb->kbd_input(inputbuf, 256, NULL);
rb->lcd_setfont(FONT_SYSFIXED);
dumb_dump_screen();
if (!r)
diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c
index c20724ed70..7b378eebff 100644
--- a/apps/plugins/goban/goban.c
+++ b/apps/plugins/goban/goban.c
@@ -677,7 +677,7 @@ do_main_menu (void)
case MAIN_SAVE_AS:
rb->strcpy (new_save_file, save_file);
- if (!rb->kbd_input (new_save_file, SAVE_FILE_LENGTH))
+ if (!rb->kbd_input(new_save_file, SAVE_FILE_LENGTH, NULL))
{
break;
}
@@ -921,7 +921,7 @@ do_gameinfo_menu (void)
break;
}
- rb->kbd_input (gameinfo_string, gameinfo_string_size);
+ rb->kbd_input(gameinfo_string, gameinfo_string_size, NULL);
sanitize_string (gameinfo_string);
set_game_modified();
break;
@@ -1191,7 +1191,7 @@ do_comment_edit (void)
return false;
}
- if (!rb->kbd_input (cbuffer, sizeof (cbuffer)))
+ if (!rb->kbd_input (cbuffer, sizeof (cbuffer), NULL))
{
/* user didn't edit, no reason to write it back */
return true;
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index 914761e73b..1689321abe 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -196,12 +196,12 @@ static void add_entry(int selected_item)
rb->splash(HZ, "Enter title");
pw_list.entries[i].title[0] = '\0';
- if (rb->kbd_input(pw_list.entries[i].title, FIELD_LEN) < 0)
+ if (rb->kbd_input(pw_list.entries[i].title, FIELD_LEN, NULL) < 0)
return;
rb->splash(HZ, "Enter name");
pw_list.entries[i].name[0] = '\0';
- if (rb->kbd_input(pw_list.entries[i].name, FIELD_LEN) < 0)
+ if (rb->kbd_input(pw_list.entries[i].name, FIELD_LEN, NULL) < 0)
{
pw_list.entries[i].title[0] = '\0';
return;
@@ -209,7 +209,7 @@ static void add_entry(int selected_item)
rb->splash(HZ, "Enter password");
pw_list.entries[i].password[0] = '\0';
- if (rb->kbd_input(pw_list.entries[i].password, FIELD_LEN) < 0)
+ if (rb->kbd_input(pw_list.entries[i].password, FIELD_LEN, NULL) < 0)
{
pw_list.entries[i].title[0] = '\0';
pw_list.entries[i].name[0] = '\0';
@@ -244,7 +244,7 @@ static void edit_title(int selected_item)
if (entry->next)
entry = entry->next;
}
- if (rb->kbd_input(entry->title, FIELD_LEN) == 0)
+ if (rb->kbd_input(entry->title, FIELD_LEN, NULL) == 0)
data_changed = true;
}
@@ -257,7 +257,7 @@ static void edit_name(int selected_item)
if (entry->next)
entry = entry->next;
}
- if (rb->kbd_input(entry->name, FIELD_LEN) == 0)
+ if (rb->kbd_input(entry->name, FIELD_LEN, NULL) == 0)
data_changed = true;
}
@@ -270,7 +270,7 @@ static void edit_pw(int selected_item)
if (entry->next)
entry = entry->next;
}
- if (rb->kbd_input(entry->password, FIELD_LEN) == 0)
+ if (rb->kbd_input(entry->password, FIELD_LEN, NULL) == 0)
data_changed = true;
}
@@ -513,11 +513,11 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw)
if (new_pw)
{
rb->splash(HZ, "Enter new master password");
- if (rb->kbd_input(buf[0], sizeof(buf[0])) < 0)
+ if (rb->kbd_input(buf[0], sizeof(buf[0]), NULL) < 0)
return -1;
rb->splash(HZ, "Confirm master password");
- if (rb->kbd_input(buf[1], sizeof(buf[1])) < 0)
+ if (rb->kbd_input(buf[1], sizeof(buf[1]), NULL) < 0)
return -1;
if (rb->strcmp(buf[0], buf[1]))
@@ -534,7 +534,7 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw)
}
rb->splash(HZ, "Enter master password");
- if (rb->kbd_input(pw_buf, buflen) < 0)
+ if (rb->kbd_input(pw_buf, buflen, NULL) < 0)
return -1;
hash_pw(&pwhash);
return 0;
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES
index 9a7aef51d0..1149f35bac 100644
--- a/apps/plugins/lib/SOURCES
+++ b/apps/plugins/lib/SOURCES
@@ -69,6 +69,8 @@ bmp_smooth_scale.c
pluginlib_albumart.c
#endif
+kbd_helper.c
+
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_TOUCHSCREEN
diff --git a/apps/plugins/lib/kbd_helper.c b/apps/plugins/lib/kbd_helper.c
new file mode 100644
index 0000000000..00191c3532
--- /dev/null
+++ b/apps/plugins/lib/kbd_helper.c
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2020 William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "plugin.h"
+#include "kbd_helper.h"
+
+/* USAGE:
+ unsigned short kbd[64];
+ unsigned short *kbd_p = kbd;
+ if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd)))
+ kbd_p = NULL;
+
+ rb->kbd_input(buf,sizeof(buf), kbd_p);
+*/
+
+/* create a custom keyboard layout for kbd_input
+ * success returns size of buffer used
+ * failure returns 0
+*/
+int kbd_create_layout(char *layout, unsigned short *buf, int bufsz)
+{
+ unsigned short *pbuf;
+ const unsigned char *p = layout;
+ int len = 0;
+ pbuf = buf;
+ while (*p && (pbuf - buf + 8) < bufsz)
+ {
+ p = rb->utf8decode(p, &pbuf[len+1]);
+ if (pbuf[len+1] == '\n')
+ {
+ *pbuf = len;
+ pbuf += len+1;
+ len = 0;
+ }
+ else
+ len++;
+ }
+
+ if (len+1 < bufsz)
+ {
+ *pbuf = len;
+ pbuf[len+1] = 0xFEFF; /* mark end of characters */
+ return len + 1;
+ }
+ return 0;
+}
diff --git a/apps/plugins/lib/kbd_helper.h b/apps/plugins/lib/kbd_helper.h
new file mode 100644
index 0000000000..90443cbf3f
--- /dev/null
+++ b/apps/plugins/lib/kbd_helper.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2020 William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef KBD_HELPER_H
+#define KBD_HELPER_H
+
+/* create a custom keyboard layout for kbd_input */
+int kbd_create_layout(char *layout, unsigned short *buf, int bufsz);
+
+#endif /* KBD_HELPER_H */
diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c
index c7f36968a1..4ae9722ae3 100644
--- a/apps/plugins/lrcplayer.c
+++ b/apps/plugins/lrcplayer.c
@@ -2475,7 +2475,7 @@ static bool lrc_lyrics_menu(void)
#endif
case LRC_MENU_LRC_DIR:
rb->strcpy(temp_buf, prefs.lrc_directory);
- if (!rb->kbd_input(temp_buf, sizeof(prefs.lrc_directory)))
+ if (!rb->kbd_input(temp_buf, sizeof(prefs.lrc_directory), NULL))
rb->strcpy(prefs.lrc_directory, temp_buf);
break;
case MENU_ATTACHED_USB:
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 6820c30dc3..a33fdf7170 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -152,7 +152,7 @@ RB_WRAP(kbd_input)
else
buffer[0] = '\0';
- if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE))
+ if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, NULL))
{
luaL_addstring(&b, buffer);
luaL_pushresult(&b);
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 6dece4ad38..2da1ef83f5 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -411,10 +411,11 @@ static void add_acct_manual(void)
memset(accounts + next_slot, 0, sizeof(struct account_t));
rb->splash(HZ * 1, "Enter account name.");
- if(rb->kbd_input(accounts[next_slot].name, sizeof(accounts[next_slot].name)) < 0)
+ char* buf = accounts[next_slot].name;
+ if(rb->kbd_input(buf, sizeof(accounts[next_slot].name), NULL) < 0)
return;
- if(acct_exists(accounts[next_slot].name))
+ if(acct_exists(buf))
{
rb->splash(HZ * 2, "Duplicate account name!");
return;
@@ -425,7 +426,7 @@ static void add_acct_manual(void)
char temp_buf[SECRET_MAX * 2];
memset(temp_buf, 0, sizeof(temp_buf));
- if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0)
+ if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0)
return;
if((accounts[next_slot].sec_len = base32_decode(accounts[next_slot].secret, SECRET_MAX, temp_buf)) <= 0)
@@ -457,7 +458,7 @@ static void add_acct_manual(void)
temp_buf[1] = '0';
}
- if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0)
+ if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0)
return;
if(!accounts[next_slot].is_totp)
@@ -470,7 +471,7 @@ static void add_acct_manual(void)
memset(temp_buf, 0, sizeof(temp_buf));
temp_buf[0] = '6';
- if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0)
+ if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0)
return;
accounts[next_slot].digits = rb->atoi(temp_buf);
@@ -667,7 +668,7 @@ static void edit_menu(int acct)
case 0: // rename
rb->splash(HZ, "Enter new name.");
rb->strlcpy(data_buf, accounts[acct].name, sizeof(data_buf));
- if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0)
+ if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0)
break;
if(acct_exists(data_buf))
{
@@ -695,7 +696,7 @@ static void edit_menu(int acct)
else
rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].totp_period);
- if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0)
+ if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0)
break;
if(accounts[acct].is_totp)
@@ -709,7 +710,7 @@ static void edit_menu(int acct)
break;
case 3: // digits
rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].digits);
- if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0)
+ if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0)
break;
accounts[acct].digits = rb->atoi(data_buf);
@@ -722,7 +723,7 @@ static void edit_menu(int acct)
memcpy(temp_sec, accounts[acct].secret, accounts[acct].sec_len);
base32_encode(accounts[acct].secret, accounts[acct].sec_len, data_buf, sizeof(data_buf));
- if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0)
+ if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0)
break;
int ret = base32_decode(accounts[acct].secret, sizeof(accounts[acct].secret), data_buf);
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c
index 3bae2e1e64..daeca3ccd7 100644
--- a/apps/plugins/puzzles/rockbox.c
+++ b/apps/plugins/puzzles/rockbox.c
@@ -2411,7 +2411,7 @@ static bool do_configure_item(config_item *cfgs, int idx)
}
rb->strlcpy(newstr, cfg->u.string.sval, MAX_STRLEN);
- if(rb->kbd_input(newstr, MAX_STRLEN) < 0)
+ if(rb->kbd_input(newstr, MAX_STRLEN, NULL) < 0)
{
sfree(newstr);
return false;
diff --git a/apps/plugins/resistor.c b/apps/plugins/resistor.c
index 16374b3d18..ec6a364f23 100644
--- a/apps/plugins/resistor.c
+++ b/apps/plugins/resistor.c
@@ -623,7 +623,7 @@ static void led_resistance_calc(void)
rb->splash(HZ*2, "(First) Input the supply voltage:");
memset(kbd_buffer,0,sizeof(kbd_buffer));
- rb->kbd_input(kbd_buffer, sizeof(kbd_buffer));
+ rb->kbd_input(kbd_buffer, sizeof(kbd_buffer), NULL);
input_voltage = rb->atoi(kbd_buffer);
if(input_voltage == 0) break;
@@ -660,7 +660,7 @@ static void led_resistance_calc(void)
rb->lcd_clear_display();
rb->splash(HZ*2, "Input the foreward current, in mA");
memset(fwd_kbd_buffer,0,sizeof(fwd_kbd_buffer));
- rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer));
+ rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer), NULL);
foreward_current = ((rb->atoi(fwd_kbd_buffer))/10);
break;
}
@@ -817,7 +817,7 @@ static void resistance_to_color(void)
NULL, false);
if(ret<0) break;
- rb->kbd_input(kbd_buffer, sizeof(kbd_buffer));
+ rb->kbd_input(kbd_buffer, sizeof(kbd_buffer), NULL);
/* As stated above somewhere, we (I) need to make a calculator-like
keypad, that keyboard isn't all that fun to use. */
ret = rb->do_menu(&r_to_c_menu_tol, &menu_selection_tol,
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 3cd231c06c..caa8d499cb 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -276,7 +276,7 @@ static bool do_slot(int slot_id, bool is_load) {
if (!is_load)
{
slot_info(desc_buf, sizeof(desc_buf), slot_id, false);
- if ( rb->kbd_input(desc_buf, sizeof(desc_buf)) < 0 )
+ if ( rb->kbd_input(desc_buf, sizeof(desc_buf), NULL) < 0 )
return false;
if ( !strlen(desc_buf) )
strlcpy(desc_buf, "Untitled", sizeof(desc_buf));
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 3759489fe1..35d2f21ba7 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -1794,7 +1794,7 @@ static void draw_text( int x, int y )
{
case TEXT_MENU_TEXT:
rb->lcd_set_foreground(COLOR_BLACK);
- rb->kbd_input( buffer->text.text, MAX_TEXT );
+ rb->kbd_input( buffer->text.text, MAX_TEXT, NULL );
break;
case TEXT_MENU_FONT:
@@ -2790,7 +2790,7 @@ static void goto_menu(void)
rb->lcd_set_foreground(COLOR_BLACK);
if (!filename[0])
rb->strcpy(filename,"/");
- if( !rb->kbd_input( filename, MAX_PATH ) )
+ if( !rb->kbd_input( filename, MAX_PATH, NULL ) )
{
if( !check_extention( filename, ".bmp" ) )
rb->strcat(filename, ".bmp");
diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/console.c b/apps/plugins/sdl/progs/duke3d/Game/src/console.c
index c4a465eda3..47135f85f1 100644
--- a/apps/plugins/sdl/progs/duke3d/Game/src/console.c
+++ b/apps/plugins/sdl/progs/duke3d/Game/src/console.c
@@ -224,7 +224,7 @@ void CONSOLE_HandleInput()
//If console_buffer[0] strlen() != 0
//1. Push the dirty_buffer unto the console_buffer
//2. parse the text
- rb->kbd_input(dirty_buffer, sizeof(dirty_buffer));
+ rb->kbd_input(dirty_buffer, sizeof(dirty_buffer), NULL);
CONSOLE_Printf("%s", dirty_buffer);
console_cursor_pos = 0;
diff --git a/apps/plugins/sdl/progs/quake/keys.c b/apps/plugins/sdl/progs/quake/keys.c
index 896bbaa795..e1285080a8 100644
--- a/apps/plugins/sdl/progs/quake/keys.c
+++ b/apps/plugins/sdl/progs/quake/keys.c
@@ -151,7 +151,7 @@ keyname_t keynames[] =
/* Rockbox hack */
void rb_console(void)
{
- rb->kbd_input(key_lines[edit_line] + 1, MAXCMDLINE-1);
+ rb->kbd_input(key_lines[edit_line] + 1, MAXCMDLINE-1, NULL);
}
/*
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index 831fe70cd4..ff7be343f6 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -111,7 +111,7 @@ static void clear_display(void){
static bool search_init(const char* file){
rb->memset(search_string, 0, sizeof(search_string));
- if (!rb->kbd_input(search_string,sizeof search_string)){
+ if (!rb->kbd_input(search_string,sizeof(search_string), NULL)){
clear_display();
rb->splash(0, "Searching...");
fd = rb->open_utf8(file, O_RDONLY);
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index e4c34930b1..62812e0237 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -1963,7 +1963,7 @@ static bool sokoban_loop(void)
*loc = '.';
}
- if (!rb->kbd_input(buf, MAX_PATH))
+ if (!rb->kbd_input(buf, MAX_PATH, NULL))
save(buf, true);
} else
rb->splash(HZ*2, "Solution too long to save");
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
index 1fd59727fc..539fc85011 100644
--- a/apps/plugins/splitedit.c
+++ b/apps/plugins/splitedit.c
@@ -874,7 +874,7 @@ static void save_editor(struct mp3entry *mp3, int splittime)
break;
case SE_PART1_NAME:
- rb->kbd_input(part1_name, MAX_PATH);
+ rb->kbd_input(part1_name, MAX_PATH, NULL);
break;
case SE_PART2_SAVE:
@@ -882,7 +882,7 @@ static void save_editor(struct mp3entry *mp3, int splittime)
break;
case SE_PART2_NAME:
- rb->kbd_input(part2_name, MAX_PATH);
+ rb->kbd_input(part2_name, MAX_PATH, NULL);
break;
case SE_SAVE:
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c
index 12880bd97b..34a1f6dd07 100644
--- a/apps/plugins/sudoku/sudoku.c
+++ b/apps/plugins/sudoku/sudoku.c
@@ -983,7 +983,7 @@ static int sudoku_edit_menu(struct sudoku_state_t* state)
switch (result) {
case 0: /* Save new game */
- rb->kbd_input(state->filename,MAX_PATH);
+ rb->kbd_input(state->filename,MAX_PATH, NULL);
if (save_sudoku(state)) {
state->editmode=0;
} else {
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index fde11552ca..50027a30c6 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -689,7 +689,7 @@ static int save_game(void)
char savepath[MAX_PATH];
rb->snprintf(savepath, sizeof(savepath), "/Savegame.ssg");
- if(rb->kbd_input(savepath, MAX_PATH))
+ if(rb->kbd_input(savepath, MAX_PATH, NULL))
{
DEBUGF("Keyboard input failed\n");
return -1;
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index 0eb1bb1dcc..0cbb61c774 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -173,7 +173,7 @@ static bool save_changes(int overwrite)
if (newfile || !overwrite)
{
- if(rb->kbd_input(filename,MAX_PATH) < 0)
+ if(rb->kbd_input(filename,MAX_PATH, NULL) < 0)
{
newfile = true;
return false;
@@ -247,7 +247,7 @@ static int do_item_menu(int cur_sel)
ret = MENU_RET_NO_UPDATE;
break;
case 2: /* insert above */
- if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
+ if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN, NULL))
{
do_action(ACTION_INSERT,copy_buffer,cur_sel);
copy_buffer[0]='\0';
@@ -255,7 +255,7 @@ static int do_item_menu(int cur_sel)
}
break;
case 3: /* insert below */
- if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
+ if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN, NULL))
{
do_action(ACTION_INSERT,copy_buffer,cur_sel+1);
copy_buffer[0]='\0';
@@ -425,7 +425,7 @@ enum plugin_status plugin_start(const void* parameter)
switch (rb->do_menu(&menu, NULL, NULL, false))
{
case 0:
- temp_changed = !rb->kbd_input(extension, sizeof(extension));
+ temp_changed = !rb->kbd_input(extension, sizeof(extension), NULL);
break;
case 1:
old_color = color;
@@ -446,7 +446,7 @@ enum plugin_status plugin_start(const void* parameter)
}
else
#endif
- if (!rb->kbd_input(temp_line,MAX_LINE_LEN))
+ if (!rb->kbd_input(temp_line,MAX_LINE_LEN, NULL))
{
if (line_count)
do_action(ACTION_UPDATE,temp_line,cur_sel);
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index 74845bac8e..6d0797bf1e 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -628,7 +628,7 @@ void save_snapshot(void)
name[0]='/';
name[1]='\0';
put_msg("Enter name of snapshot file to save:");
- if (!rb->kbd_input((char*)&name, sizeof name))
+ if (!rb->kbd_input((char*)&name, sizeof(name), NULL))
save_snapshot_file(&name[0]);
}
diff --git a/apps/radio/presets.c b/apps/radio/presets.c
index 98a33d14ad..acd6dc8711 100644
--- a/apps/radio/presets.c
+++ b/apps/radio/presets.c
@@ -277,7 +277,7 @@ int handle_radio_add_preset(void)
{
buf[0] = '\0';
- if (!kbd_input(buf, MAX_FMPRESET_LEN + 1))
+ if (!kbd_input(buf, MAX_FMPRESET_LEN + 1, NULL))
{
struct fmstation * const fms = &presets[num_presets];
strcpy(fms->name, buf);
@@ -307,7 +307,7 @@ static int radio_edit_preset(void)
strcpy(buf, fms->name);
- if (!kbd_input(buf, MAX_FMPRESET_LEN + 1))
+ if (!kbd_input(buf, MAX_FMPRESET_LEN + 1, NULL))
{
strcpy(fms->name, buf);
presets_changed = true;
@@ -372,7 +372,7 @@ int preset_list_save(void)
while(bad_file_name)
{
- if(!kbd_input(filepreset, sizeof(filepreset)))
+ if(!kbd_input(filepreset, sizeof(filepreset), NULL))
{
/* check the name: max MAX_FILENAME (20) chars */
char* p2;
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index ceb8de00fb..6e91d69b6d 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -82,6 +82,7 @@
struct keyboard_parameters
{
unsigned short kbd_buf[KBD_BUF_SIZE];
+ unsigned short *kbd_buf_ptr;
unsigned short max_line_len;
int default_lines;
int last_k;
@@ -295,7 +296,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
i = pm->last_i;
k -= pm->last_k;
}
- for (pbuf = &pm->kbd_buf[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
+ for (pbuf = &pm->kbd_buf_ptr[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
{
n = i ? (i + pm->max_chars - 1) / pm->max_chars : 1;
if (k < n) break;
@@ -304,7 +305,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
if (y == 0 && i != 0xFEFF)
{
pm->last_k = pm->page*pm->lines - k;
- pm->last_i = pbuf - pm->kbd_buf;
+ pm->last_i = pbuf - pm->kbd_buf_ptr;
}
k = k * pm->max_chars + x;
return (*pbuf != 0xFEFF && k < *pbuf)? pbuf[k+1]: ' ';
@@ -330,7 +331,7 @@ static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
struct edit_state *state, int dir);
-int kbd_input(char* text, int buflen)
+int kbd_input(char* text, int buflen, unsigned short *kbd)
{
bool done = false;
struct keyboard_parameters * const param = kbd_param;
@@ -438,6 +439,12 @@ int kbd_input(char* text, int buflen)
FOR_NB_SCREENS(l)
{
struct keyboard_parameters *pm = &param[l];
+
+ if(kbd) /* user supplied custom layout */
+ pm->kbd_buf_ptr = kbd;
+ else
+ pm->kbd_buf_ptr = pm->kbd_buf; /* internal layout buffer */
+
struct screen *sc = &screens[l];
kbd_calc_params(pm, sc, &state);
}
@@ -743,7 +750,7 @@ static void kbd_calc_params(struct keyboard_parameters *pm,
* since we're going to be adding spaces,
* max width is at least their width */
pm->font_w = font_get_width(font, ' ');
- for (pbuf = pm->kbd_buf; *pbuf != 0xFEFF; pbuf += i)
+ for (pbuf = pm->kbd_buf_ptr; *pbuf != 0xFEFF; pbuf += i)
{
for (i = 0; ++i <= *pbuf; )
{
@@ -807,7 +814,7 @@ recalc_param:
pm->keyboard_margin = DEFAULT_MARGIN;
total_lines = 0;
- for (pbuf = pm->kbd_buf; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
+ for (pbuf = pm->kbd_buf_ptr; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
total_lines += (i ? (i + pm->max_chars - 1) / pm->max_chars : 1);
pm->pages = (total_lines + pm->lines - 1) / pm->lines;
diff --git a/apps/settings.c b/apps/settings.c
index ec8382b8a8..046c14628c 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -698,7 +698,7 @@ bool settings_save_config(int options)
/* allow user to modify filename */
while (true) {
- if (!kbd_input(filename, sizeof filename)) {
+ if (!kbd_input(filename, sizeof(filename), NULL)) {
break;
}
else {
diff --git a/apps/tagtree.c b/apps/tagtree.c
index e56c805fa3..0625e860ab 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1905,7 +1905,7 @@ int tagtree_enter(struct tree_context* c)
}
else
{
- rc = kbd_input(searchstring, SEARCHSTR_SIZE);
+ rc = kbd_input(searchstring, SEARCHSTR_SIZE, NULL);
if (rc < 0 || !searchstring[0])
{
tagtree_exit(c);
diff --git a/apps/tree.c b/apps/tree.c
index 311c3ce543..8635f98011 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -950,7 +950,7 @@ int create_playlist(void)
else
snprintf(filename, sizeof filename, "%s/all.m3u8", playlist_dir);
- if (kbd_input(filename, MAX_PATH))
+ if (kbd_input(filename, MAX_PATH, NULL))
return 0;
splashf(0, "%s %s", str(LANG_CREATING), filename);
#endif