diff options
author | William Wilgus <wilgus.william@gmail.com> | 2020-07-21 02:33:53 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2020-07-22 06:48:28 -0400 |
commit | cb94b3ae2ee7a66845895e2c704cdf62ee74ba13 (patch) | |
tree | 0b2da61e3d513fdc37d18f075b6c079e85165781 | |
parent | a5df94beb5cd7fd87828b9532b4a1a4da13ef774 (diff) | |
download | rockbox-cb94b3ae2ee7a66845895e2c704cdf62ee74ba13.tar.gz rockbox-cb94b3ae2ee7a66845895e2c704cdf62ee74ba13.zip |
keyboard add ability to specify temporary custom layouts
rb core allows you to load custom keyboard layouts
this patch adds the ability to load a keyboard layout in a buffer
the custom layout is temporary and does not overwrite the current layout
use like so:
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);
Change-Id: I7be2bd4a1b4797a147fa70228a9749dc56ac052a
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) | |||
82 | sleep(HZ/10); | 82 | sleep(HZ/10); |
83 | } | 83 | } |
84 | 84 | ||
85 | int kbd_input(char* text, int buflen) | 85 | int kbd_input(char* text, int buflen, unsigned short *kbd) |
86 | { | 86 | { |
87 | (void)kbd; | ||
87 | JNIEnv e = *env_ptr; | 88 | JNIEnv e = *env_ptr; |
88 | jstring str = e->NewStringUTF(env_ptr, text); | 89 | jstring str = e->NewStringUTF(env_ptr, text); |
89 | jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK)); | 90 | 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 @@ | |||
21 | #ifndef _KEYBOARD_H | 21 | #ifndef _KEYBOARD_H |
22 | #define _KEYBOARD_H | 22 | #define _KEYBOARD_H |
23 | 23 | ||
24 | int kbd_input(char* buffer, int buflen); | 24 | /* '*kbd', same format as https://www.rockbox.org/wiki/LoadableKeyboardLayouts */ |
25 | |||
26 | int kbd_input(char* buffer, int buflen, unsigned short *kbd); | ||
25 | 27 | ||
26 | #ifdef HAVE_LCD_BITMAP | 28 | #ifdef HAVE_LCD_BITMAP |
27 | int load_kbd(unsigned char* filename); | 29 | 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) | |||
58 | if (dot) /* remove extension */ | 58 | if (dot) /* remove extension */ |
59 | *dot = '\0'; | 59 | *dot = '\0'; |
60 | 60 | ||
61 | if (!kbd_input(temp, sizeof(temp))) | 61 | if (!kbd_input(temp, sizeof(temp), NULL)) |
62 | { | 62 | { |
63 | len = strlen(temp); | 63 | len = strlen(temp); |
64 | if(len > 4 && !strcasecmp(&temp[len-4], ".m3u")) | 64 | 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) | |||
1009 | 1009 | ||
1010 | if (strlcpy(newname, selection, sizeof (newname)) >= sizeof (newname)) { | 1010 | if (strlcpy(newname, selection, sizeof (newname)) >= sizeof (newname)) { |
1011 | /* Too long */ | 1011 | /* Too long */ |
1012 | } else if (kbd_input(newbase, sizeof (newname) - pathlen) < 0) { | 1012 | } else if (kbd_input(newbase, sizeof (newname) - pathlen, NULL) < 0) { |
1013 | rc = OPRC_CANCELLED; | 1013 | rc = OPRC_CANCELLED; |
1014 | } else if (!strcmp(oldbase, newbase)) { | 1014 | } else if (!strcmp(oldbase, newbase)) { |
1015 | rc = OPRC_NOOP; /* No change at all */ | 1015 | rc = OPRC_NOOP; /* No change at all */ |
@@ -1051,7 +1051,7 @@ static int create_dir(void) | |||
1051 | 1051 | ||
1052 | if (pathlen >= sizeof (dirname)) { | 1052 | if (pathlen >= sizeof (dirname)) { |
1053 | /* Too long */ | 1053 | /* Too long */ |
1054 | } else if (kbd_input(basename, sizeof (dirname) - pathlen) < 0) { | 1054 | } else if (kbd_input(basename, sizeof (dirname) - pathlen, NULL) < 0) { |
1055 | rc = OPRC_CANCELLED; | 1055 | rc = OPRC_CANCELLED; |
1056 | } else if (check_new_name(basename)) { | 1056 | } else if (check_new_name(basename)) { |
1057 | rc = mkdir(dirname); | 1057 | 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) | |||
97 | talk_id(VOICE_EDIT, false); | 97 | talk_id(VOICE_EDIT, false); |
98 | } | 98 | } |
99 | 99 | ||
100 | int kbd_input(char* text, int buflen) | 100 | int kbd_input(char* text, int buflen, unsigned short *kbd) |
101 | { | 101 | { |
102 | (void) kbd; | ||
102 | bool done = false; | 103 | bool done = false; |
103 | bool redraw = true; | 104 | bool redraw = true; |
104 | bool line_edit = false; | 105 | 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, | |||
356 | else | 356 | else |
357 | strlcpy(playlist, m3u8name, MAX_PATH); | 357 | strlcpy(playlist, m3u8name, MAX_PATH); |
358 | 358 | ||
359 | if (kbd_input(playlist, MAX_PATH)) | 359 | if (kbd_input(playlist, MAX_PATH, NULL)) |
360 | return false; | 360 | return false; |
361 | 361 | ||
362 | len = strlen(playlist); | 362 | 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) | |||
910 | 910 | ||
911 | if (!playlist_viewer_init(&viewer, 0, false)) | 911 | if (!playlist_viewer_init(&viewer, 0, false)) |
912 | return ret; | 912 | return ret; |
913 | if (kbd_input(search_str, sizeof(search_str)) < 0) | 913 | if (kbd_input(search_str, sizeof(search_str), NULL) < 0) |
914 | return ret; | 914 | return ret; |
915 | lcd_clear_display(); | 915 | lcd_clear_display(); |
916 | playlist_count = playlist_amount_ex(viewer.playlist); | 916 | 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 { | |||
927 | int (*rand)(void); | 927 | int (*rand)(void); |
928 | void (*qsort)(void *base, size_t nmemb, size_t size, | 928 | void (*qsort)(void *base, size_t nmemb, size_t size, |
929 | int(*compar)(const void *, const void *)); | 929 | int(*compar)(const void *, const void *)); |
930 | int (*kbd_input)(char* buffer, int buflen); | 930 | int (*kbd_input)(char* buffer, int buflen, unsigned short *kbd); |
931 | struct tm* (*get_time)(void); | 931 | struct tm* (*get_time)(void); |
932 | int (*set_time)(const struct tm *tm); | 932 | int (*set_time)(const struct tm *tm); |
933 | struct tm * (*gmtime_r)(const time_t *timep, struct tm *tm); | 933 | 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) | |||
842 | { | 842 | { |
843 | bool saved = false; | 843 | bool saved = false; |
844 | struct memo *memo = &memos[memos_in_memory]; | 844 | struct memo *memo = &memos[memos_in_memory]; |
845 | if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN) == 0) | 845 | if (rb->kbd_input(memo->message, MAX_CHAR_MEMO_LEN, NULL) == 0) |
846 | { | 846 | { |
847 | if (memo->message[0]) | 847 | if (memo->message[0]) |
848 | { | 848 | { |
@@ -920,7 +920,7 @@ static bool edit_memo(int change, struct shown *shown) | |||
920 | 920 | ||
921 | case 1: /* edit */ | 921 | case 1: /* edit */ |
922 | if(rb->kbd_input(memos[change].message, | 922 | if(rb->kbd_input(memos[change].message, |
923 | MAX_CHAR_MEMO_LEN) == 0) | 923 | MAX_CHAR_MEMO_LEN, NULL) == 0) |
924 | save_memo(change, true, shown); | 924 | save_memo(change, true, shown); |
925 | return false; | 925 | return false; |
926 | 926 | ||
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) | |||
92 | searchword[0] = '\0'; | 92 | searchword[0] = '\0'; |
93 | 93 | ||
94 | /* get the word to search */ | 94 | /* get the word to search */ |
95 | if (rb->kbd_input(searchword, sizeof(searchword)) < 0) | 95 | if (rb->kbd_input(searchword, sizeof(searchword), NULL) < 0) |
96 | return PLUGIN_OK; /* input cancelled */ | 96 | return PLUGIN_OK; /* input cancelled */ |
97 | 97 | ||
98 | fIndex = rb->open(DICT_INDEX, O_RDONLY); /* index file */ | 98 | 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) | |||
195 | return zkey; | 195 | return zkey; |
196 | 196 | ||
197 | inputbuf[0] = '\0'; | 197 | inputbuf[0] = '\0'; |
198 | r = rb->kbd_input(inputbuf, 5); | 198 | r = rb->kbd_input(inputbuf, 5, NULL); |
199 | rb->lcd_setfont(FONT_SYSFIXED); | 199 | rb->lcd_setfont(FONT_SYSFIXED); |
200 | dumb_dump_screen(); | 200 | dumb_dump_screen(); |
201 | if (!r) | 201 | if (!r) |
@@ -226,7 +226,7 @@ zchar os_read_line(int max, zchar *buf, int timeout, int width, int continued) | |||
226 | if (max > width) | 226 | if (max > width) |
227 | max = width; | 227 | max = width; |
228 | strcpy(inputbuf, buf); | 228 | strcpy(inputbuf, buf); |
229 | r = rb->kbd_input(inputbuf, 256); | 229 | r = rb->kbd_input(inputbuf, 256, NULL); |
230 | rb->lcd_setfont(FONT_SYSFIXED); | 230 | rb->lcd_setfont(FONT_SYSFIXED); |
231 | dumb_dump_screen(); | 231 | dumb_dump_screen(); |
232 | if (!r) | 232 | 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) | |||
677 | case MAIN_SAVE_AS: | 677 | case MAIN_SAVE_AS: |
678 | rb->strcpy (new_save_file, save_file); | 678 | rb->strcpy (new_save_file, save_file); |
679 | 679 | ||
680 | if (!rb->kbd_input (new_save_file, SAVE_FILE_LENGTH)) | 680 | if (!rb->kbd_input(new_save_file, SAVE_FILE_LENGTH, NULL)) |
681 | { | 681 | { |
682 | break; | 682 | break; |
683 | } | 683 | } |
@@ -921,7 +921,7 @@ do_gameinfo_menu (void) | |||
921 | break; | 921 | break; |
922 | } | 922 | } |
923 | 923 | ||
924 | rb->kbd_input (gameinfo_string, gameinfo_string_size); | 924 | rb->kbd_input(gameinfo_string, gameinfo_string_size, NULL); |
925 | sanitize_string (gameinfo_string); | 925 | sanitize_string (gameinfo_string); |
926 | set_game_modified(); | 926 | set_game_modified(); |
927 | break; | 927 | break; |
@@ -1191,7 +1191,7 @@ do_comment_edit (void) | |||
1191 | return false; | 1191 | return false; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | if (!rb->kbd_input (cbuffer, sizeof (cbuffer))) | 1194 | if (!rb->kbd_input (cbuffer, sizeof (cbuffer), NULL)) |
1195 | { | 1195 | { |
1196 | /* user didn't edit, no reason to write it back */ | 1196 | /* user didn't edit, no reason to write it back */ |
1197 | return true; | 1197 | 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) | |||
196 | 196 | ||
197 | rb->splash(HZ, "Enter title"); | 197 | rb->splash(HZ, "Enter title"); |
198 | pw_list.entries[i].title[0] = '\0'; | 198 | pw_list.entries[i].title[0] = '\0'; |
199 | if (rb->kbd_input(pw_list.entries[i].title, FIELD_LEN) < 0) | 199 | if (rb->kbd_input(pw_list.entries[i].title, FIELD_LEN, NULL) < 0) |
200 | return; | 200 | return; |
201 | 201 | ||
202 | rb->splash(HZ, "Enter name"); | 202 | rb->splash(HZ, "Enter name"); |
203 | pw_list.entries[i].name[0] = '\0'; | 203 | pw_list.entries[i].name[0] = '\0'; |
204 | if (rb->kbd_input(pw_list.entries[i].name, FIELD_LEN) < 0) | 204 | if (rb->kbd_input(pw_list.entries[i].name, FIELD_LEN, NULL) < 0) |
205 | { | 205 | { |
206 | pw_list.entries[i].title[0] = '\0'; | 206 | pw_list.entries[i].title[0] = '\0'; |
207 | return; | 207 | return; |
@@ -209,7 +209,7 @@ static void add_entry(int selected_item) | |||
209 | 209 | ||
210 | rb->splash(HZ, "Enter password"); | 210 | rb->splash(HZ, "Enter password"); |
211 | pw_list.entries[i].password[0] = '\0'; | 211 | pw_list.entries[i].password[0] = '\0'; |
212 | if (rb->kbd_input(pw_list.entries[i].password, FIELD_LEN) < 0) | 212 | if (rb->kbd_input(pw_list.entries[i].password, FIELD_LEN, NULL) < 0) |
213 | { | 213 | { |
214 | pw_list.entries[i].title[0] = '\0'; | 214 | pw_list.entries[i].title[0] = '\0'; |
215 | pw_list.entries[i].name[0] = '\0'; | 215 | pw_list.entries[i].name[0] = '\0'; |
@@ -244,7 +244,7 @@ static void edit_title(int selected_item) | |||
244 | if (entry->next) | 244 | if (entry->next) |
245 | entry = entry->next; | 245 | entry = entry->next; |
246 | } | 246 | } |
247 | if (rb->kbd_input(entry->title, FIELD_LEN) == 0) | 247 | if (rb->kbd_input(entry->title, FIELD_LEN, NULL) == 0) |
248 | data_changed = true; | 248 | data_changed = true; |
249 | } | 249 | } |
250 | 250 | ||
@@ -257,7 +257,7 @@ static void edit_name(int selected_item) | |||
257 | if (entry->next) | 257 | if (entry->next) |
258 | entry = entry->next; | 258 | entry = entry->next; |
259 | } | 259 | } |
260 | if (rb->kbd_input(entry->name, FIELD_LEN) == 0) | 260 | if (rb->kbd_input(entry->name, FIELD_LEN, NULL) == 0) |
261 | data_changed = true; | 261 | data_changed = true; |
262 | } | 262 | } |
263 | 263 | ||
@@ -270,7 +270,7 @@ static void edit_pw(int selected_item) | |||
270 | if (entry->next) | 270 | if (entry->next) |
271 | entry = entry->next; | 271 | entry = entry->next; |
272 | } | 272 | } |
273 | if (rb->kbd_input(entry->password, FIELD_LEN) == 0) | 273 | if (rb->kbd_input(entry->password, FIELD_LEN, NULL) == 0) |
274 | data_changed = true; | 274 | data_changed = true; |
275 | } | 275 | } |
276 | 276 | ||
@@ -513,11 +513,11 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw) | |||
513 | if (new_pw) | 513 | if (new_pw) |
514 | { | 514 | { |
515 | rb->splash(HZ, "Enter new master password"); | 515 | rb->splash(HZ, "Enter new master password"); |
516 | if (rb->kbd_input(buf[0], sizeof(buf[0])) < 0) | 516 | if (rb->kbd_input(buf[0], sizeof(buf[0]), NULL) < 0) |
517 | return -1; | 517 | return -1; |
518 | 518 | ||
519 | rb->splash(HZ, "Confirm master password"); | 519 | rb->splash(HZ, "Confirm master password"); |
520 | if (rb->kbd_input(buf[1], sizeof(buf[1])) < 0) | 520 | if (rb->kbd_input(buf[1], sizeof(buf[1]), NULL) < 0) |
521 | return -1; | 521 | return -1; |
522 | 522 | ||
523 | if (rb->strcmp(buf[0], buf[1])) | 523 | if (rb->strcmp(buf[0], buf[1])) |
@@ -534,7 +534,7 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw) | |||
534 | } | 534 | } |
535 | 535 | ||
536 | rb->splash(HZ, "Enter master password"); | 536 | rb->splash(HZ, "Enter master password"); |
537 | if (rb->kbd_input(pw_buf, buflen) < 0) | 537 | if (rb->kbd_input(pw_buf, buflen, NULL) < 0) |
538 | return -1; | 538 | return -1; |
539 | hash_pw(&pwhash); | 539 | hash_pw(&pwhash); |
540 | return 0; | 540 | 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 | |||
69 | pluginlib_albumart.c | 69 | pluginlib_albumart.c |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | kbd_helper.c | ||
73 | |||
72 | #endif /* HAVE_LCD_BITMAP */ | 74 | #endif /* HAVE_LCD_BITMAP */ |
73 | 75 | ||
74 | #ifdef HAVE_TOUCHSCREEN | 76 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2020 William Wilgus | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "plugin.h" | ||
22 | #include "kbd_helper.h" | ||
23 | |||
24 | /* USAGE: | ||
25 | unsigned short kbd[64]; | ||
26 | unsigned short *kbd_p = kbd; | ||
27 | if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd))) | ||
28 | kbd_p = NULL; | ||
29 | |||
30 | rb->kbd_input(buf,sizeof(buf), kbd_p); | ||
31 | */ | ||
32 | |||
33 | /* create a custom keyboard layout for kbd_input | ||
34 | * success returns size of buffer used | ||
35 | * failure returns 0 | ||
36 | */ | ||
37 | int kbd_create_layout(char *layout, unsigned short *buf, int bufsz) | ||
38 | { | ||
39 | unsigned short *pbuf; | ||
40 | const unsigned char *p = layout; | ||
41 | int len = 0; | ||
42 | pbuf = buf; | ||
43 | while (*p && (pbuf - buf + 8) < bufsz) | ||
44 | { | ||
45 | p = rb->utf8decode(p, &pbuf[len+1]); | ||
46 | if (pbuf[len+1] == '\n') | ||
47 | { | ||
48 | *pbuf = len; | ||
49 | pbuf += len+1; | ||
50 | len = 0; | ||
51 | } | ||
52 | else | ||
53 | len++; | ||
54 | } | ||
55 | |||
56 | if (len+1 < bufsz) | ||
57 | { | ||
58 | *pbuf = len; | ||
59 | pbuf[len+1] = 0xFEFF; /* mark end of characters */ | ||
60 | return len + 1; | ||
61 | } | ||
62 | return 0; | ||
63 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2020 William Wilgus | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef KBD_HELPER_H | ||
22 | #define KBD_HELPER_H | ||
23 | |||
24 | /* create a custom keyboard layout for kbd_input */ | ||
25 | int kbd_create_layout(char *layout, unsigned short *buf, int bufsz); | ||
26 | |||
27 | #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) | |||
2475 | #endif | 2475 | #endif |
2476 | case LRC_MENU_LRC_DIR: | 2476 | case LRC_MENU_LRC_DIR: |
2477 | rb->strcpy(temp_buf, prefs.lrc_directory); | 2477 | rb->strcpy(temp_buf, prefs.lrc_directory); |
2478 | if (!rb->kbd_input(temp_buf, sizeof(prefs.lrc_directory))) | 2478 | if (!rb->kbd_input(temp_buf, sizeof(prefs.lrc_directory), NULL)) |
2479 | rb->strcpy(prefs.lrc_directory, temp_buf); | 2479 | rb->strcpy(prefs.lrc_directory, temp_buf); |
2480 | break; | 2480 | break; |
2481 | case MENU_ATTACHED_USB: | 2481 | 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) | |||
152 | else | 152 | else |
153 | buffer[0] = '\0'; | 153 | buffer[0] = '\0'; |
154 | 154 | ||
155 | if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE)) | 155 | if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, NULL)) |
156 | { | 156 | { |
157 | luaL_addstring(&b, buffer); | 157 | luaL_addstring(&b, buffer); |
158 | luaL_pushresult(&b); | 158 | 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) | |||
411 | memset(accounts + next_slot, 0, sizeof(struct account_t)); | 411 | memset(accounts + next_slot, 0, sizeof(struct account_t)); |
412 | 412 | ||
413 | rb->splash(HZ * 1, "Enter account name."); | 413 | rb->splash(HZ * 1, "Enter account name."); |
414 | if(rb->kbd_input(accounts[next_slot].name, sizeof(accounts[next_slot].name)) < 0) | 414 | char* buf = accounts[next_slot].name; |
415 | if(rb->kbd_input(buf, sizeof(accounts[next_slot].name), NULL) < 0) | ||
415 | return; | 416 | return; |
416 | 417 | ||
417 | if(acct_exists(accounts[next_slot].name)) | 418 | if(acct_exists(buf)) |
418 | { | 419 | { |
419 | rb->splash(HZ * 2, "Duplicate account name!"); | 420 | rb->splash(HZ * 2, "Duplicate account name!"); |
420 | return; | 421 | return; |
@@ -425,7 +426,7 @@ static void add_acct_manual(void) | |||
425 | char temp_buf[SECRET_MAX * 2]; | 426 | char temp_buf[SECRET_MAX * 2]; |
426 | memset(temp_buf, 0, sizeof(temp_buf)); | 427 | memset(temp_buf, 0, sizeof(temp_buf)); |
427 | 428 | ||
428 | if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) | 429 | if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) |
429 | return; | 430 | return; |
430 | 431 | ||
431 | if((accounts[next_slot].sec_len = base32_decode(accounts[next_slot].secret, SECRET_MAX, temp_buf)) <= 0) | 432 | 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) | |||
457 | temp_buf[1] = '0'; | 458 | temp_buf[1] = '0'; |
458 | } | 459 | } |
459 | 460 | ||
460 | if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) | 461 | if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) |
461 | return; | 462 | return; |
462 | 463 | ||
463 | if(!accounts[next_slot].is_totp) | 464 | if(!accounts[next_slot].is_totp) |
@@ -470,7 +471,7 @@ static void add_acct_manual(void) | |||
470 | memset(temp_buf, 0, sizeof(temp_buf)); | 471 | memset(temp_buf, 0, sizeof(temp_buf)); |
471 | temp_buf[0] = '6'; | 472 | temp_buf[0] = '6'; |
472 | 473 | ||
473 | if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) | 474 | if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) |
474 | return; | 475 | return; |
475 | 476 | ||
476 | accounts[next_slot].digits = rb->atoi(temp_buf); | 477 | accounts[next_slot].digits = rb->atoi(temp_buf); |
@@ -667,7 +668,7 @@ static void edit_menu(int acct) | |||
667 | case 0: // rename | 668 | case 0: // rename |
668 | rb->splash(HZ, "Enter new name."); | 669 | rb->splash(HZ, "Enter new name."); |
669 | rb->strlcpy(data_buf, accounts[acct].name, sizeof(data_buf)); | 670 | rb->strlcpy(data_buf, accounts[acct].name, sizeof(data_buf)); |
670 | if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) | 671 | if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) |
671 | break; | 672 | break; |
672 | if(acct_exists(data_buf)) | 673 | if(acct_exists(data_buf)) |
673 | { | 674 | { |
@@ -695,7 +696,7 @@ static void edit_menu(int acct) | |||
695 | else | 696 | else |
696 | rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].totp_period); | 697 | rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].totp_period); |
697 | 698 | ||
698 | if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) | 699 | if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) |
699 | break; | 700 | break; |
700 | 701 | ||
701 | if(accounts[acct].is_totp) | 702 | if(accounts[acct].is_totp) |
@@ -709,7 +710,7 @@ static void edit_menu(int acct) | |||
709 | break; | 710 | break; |
710 | case 3: // digits | 711 | case 3: // digits |
711 | rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].digits); | 712 | rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].digits); |
712 | if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) | 713 | if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) |
713 | break; | 714 | break; |
714 | 715 | ||
715 | accounts[acct].digits = rb->atoi(data_buf); | 716 | accounts[acct].digits = rb->atoi(data_buf); |
@@ -722,7 +723,7 @@ static void edit_menu(int acct) | |||
722 | memcpy(temp_sec, accounts[acct].secret, accounts[acct].sec_len); | 723 | memcpy(temp_sec, accounts[acct].secret, accounts[acct].sec_len); |
723 | base32_encode(accounts[acct].secret, accounts[acct].sec_len, data_buf, sizeof(data_buf)); | 724 | base32_encode(accounts[acct].secret, accounts[acct].sec_len, data_buf, sizeof(data_buf)); |
724 | 725 | ||
725 | if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) | 726 | if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) |
726 | break; | 727 | break; |
727 | 728 | ||
728 | int ret = base32_decode(accounts[acct].secret, sizeof(accounts[acct].secret), data_buf); | 729 | 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) | |||
2411 | } | 2411 | } |
2412 | 2412 | ||
2413 | rb->strlcpy(newstr, cfg->u.string.sval, MAX_STRLEN); | 2413 | rb->strlcpy(newstr, cfg->u.string.sval, MAX_STRLEN); |
2414 | if(rb->kbd_input(newstr, MAX_STRLEN) < 0) | 2414 | if(rb->kbd_input(newstr, MAX_STRLEN, NULL) < 0) |
2415 | { | 2415 | { |
2416 | sfree(newstr); | 2416 | sfree(newstr); |
2417 | return false; | 2417 | 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) | |||
623 | 623 | ||
624 | rb->splash(HZ*2, "(First) Input the supply voltage:"); | 624 | rb->splash(HZ*2, "(First) Input the supply voltage:"); |
625 | memset(kbd_buffer,0,sizeof(kbd_buffer)); | 625 | memset(kbd_buffer,0,sizeof(kbd_buffer)); |
626 | rb->kbd_input(kbd_buffer, sizeof(kbd_buffer)); | 626 | rb->kbd_input(kbd_buffer, sizeof(kbd_buffer), NULL); |
627 | input_voltage = rb->atoi(kbd_buffer); | 627 | input_voltage = rb->atoi(kbd_buffer); |
628 | if(input_voltage == 0) break; | 628 | if(input_voltage == 0) break; |
629 | 629 | ||
@@ -660,7 +660,7 @@ static void led_resistance_calc(void) | |||
660 | rb->lcd_clear_display(); | 660 | rb->lcd_clear_display(); |
661 | rb->splash(HZ*2, "Input the foreward current, in mA"); | 661 | rb->splash(HZ*2, "Input the foreward current, in mA"); |
662 | memset(fwd_kbd_buffer,0,sizeof(fwd_kbd_buffer)); | 662 | memset(fwd_kbd_buffer,0,sizeof(fwd_kbd_buffer)); |
663 | rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer)); | 663 | rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer), NULL); |
664 | foreward_current = ((rb->atoi(fwd_kbd_buffer))/10); | 664 | foreward_current = ((rb->atoi(fwd_kbd_buffer))/10); |
665 | break; | 665 | break; |
666 | } | 666 | } |
@@ -817,7 +817,7 @@ static void resistance_to_color(void) | |||
817 | NULL, false); | 817 | NULL, false); |
818 | if(ret<0) break; | 818 | if(ret<0) break; |
819 | 819 | ||
820 | rb->kbd_input(kbd_buffer, sizeof(kbd_buffer)); | 820 | rb->kbd_input(kbd_buffer, sizeof(kbd_buffer), NULL); |
821 | /* As stated above somewhere, we (I) need to make a calculator-like | 821 | /* As stated above somewhere, we (I) need to make a calculator-like |
822 | keypad, that keyboard isn't all that fun to use. */ | 822 | keypad, that keyboard isn't all that fun to use. */ |
823 | ret = rb->do_menu(&r_to_c_menu_tol, &menu_selection_tol, | 823 | 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) { | |||
276 | if (!is_load) | 276 | if (!is_load) |
277 | { | 277 | { |
278 | slot_info(desc_buf, sizeof(desc_buf), slot_id, false); | 278 | slot_info(desc_buf, sizeof(desc_buf), slot_id, false); |
279 | if ( rb->kbd_input(desc_buf, sizeof(desc_buf)) < 0 ) | 279 | if ( rb->kbd_input(desc_buf, sizeof(desc_buf), NULL) < 0 ) |
280 | return false; | 280 | return false; |
281 | if ( !strlen(desc_buf) ) | 281 | if ( !strlen(desc_buf) ) |
282 | strlcpy(desc_buf, "Untitled", sizeof(desc_buf)); | 282 | 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 ) | |||
1794 | { | 1794 | { |
1795 | case TEXT_MENU_TEXT: | 1795 | case TEXT_MENU_TEXT: |
1796 | rb->lcd_set_foreground(COLOR_BLACK); | 1796 | rb->lcd_set_foreground(COLOR_BLACK); |
1797 | rb->kbd_input( buffer->text.text, MAX_TEXT ); | 1797 | rb->kbd_input( buffer->text.text, MAX_TEXT, NULL ); |
1798 | break; | 1798 | break; |
1799 | 1799 | ||
1800 | case TEXT_MENU_FONT: | 1800 | case TEXT_MENU_FONT: |
@@ -2790,7 +2790,7 @@ static void goto_menu(void) | |||
2790 | rb->lcd_set_foreground(COLOR_BLACK); | 2790 | rb->lcd_set_foreground(COLOR_BLACK); |
2791 | if (!filename[0]) | 2791 | if (!filename[0]) |
2792 | rb->strcpy(filename,"/"); | 2792 | rb->strcpy(filename,"/"); |
2793 | if( !rb->kbd_input( filename, MAX_PATH ) ) | 2793 | if( !rb->kbd_input( filename, MAX_PATH, NULL ) ) |
2794 | { | 2794 | { |
2795 | if( !check_extention( filename, ".bmp" ) ) | 2795 | if( !check_extention( filename, ".bmp" ) ) |
2796 | rb->strcat(filename, ".bmp"); | 2796 | 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() | |||
224 | //If console_buffer[0] strlen() != 0 | 224 | //If console_buffer[0] strlen() != 0 |
225 | //1. Push the dirty_buffer unto the console_buffer | 225 | //1. Push the dirty_buffer unto the console_buffer |
226 | //2. parse the text | 226 | //2. parse the text |
227 | rb->kbd_input(dirty_buffer, sizeof(dirty_buffer)); | 227 | rb->kbd_input(dirty_buffer, sizeof(dirty_buffer), NULL); |
228 | 228 | ||
229 | CONSOLE_Printf("%s", dirty_buffer); | 229 | CONSOLE_Printf("%s", dirty_buffer); |
230 | console_cursor_pos = 0; | 230 | 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[] = | |||
151 | /* Rockbox hack */ | 151 | /* Rockbox hack */ |
152 | void rb_console(void) | 152 | void rb_console(void) |
153 | { | 153 | { |
154 | rb->kbd_input(key_lines[edit_line] + 1, MAXCMDLINE-1); | 154 | rb->kbd_input(key_lines[edit_line] + 1, MAXCMDLINE-1, NULL); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
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){ | |||
111 | static bool search_init(const char* file){ | 111 | static bool search_init(const char* file){ |
112 | rb->memset(search_string, 0, sizeof(search_string)); | 112 | rb->memset(search_string, 0, sizeof(search_string)); |
113 | 113 | ||
114 | if (!rb->kbd_input(search_string,sizeof search_string)){ | 114 | if (!rb->kbd_input(search_string,sizeof(search_string), NULL)){ |
115 | clear_display(); | 115 | clear_display(); |
116 | rb->splash(0, "Searching..."); | 116 | rb->splash(0, "Searching..."); |
117 | fd = rb->open_utf8(file, O_RDONLY); | 117 | 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) | |||
1963 | *loc = '.'; | 1963 | *loc = '.'; |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | if (!rb->kbd_input(buf, MAX_PATH)) | 1966 | if (!rb->kbd_input(buf, MAX_PATH, NULL)) |
1967 | save(buf, true); | 1967 | save(buf, true); |
1968 | } else | 1968 | } else |
1969 | rb->splash(HZ*2, "Solution too long to save"); | 1969 | 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) | |||
874 | break; | 874 | break; |
875 | 875 | ||
876 | case SE_PART1_NAME: | 876 | case SE_PART1_NAME: |
877 | rb->kbd_input(part1_name, MAX_PATH); | 877 | rb->kbd_input(part1_name, MAX_PATH, NULL); |
878 | break; | 878 | break; |
879 | 879 | ||
880 | case SE_PART2_SAVE: | 880 | case SE_PART2_SAVE: |
@@ -882,7 +882,7 @@ static void save_editor(struct mp3entry *mp3, int splittime) | |||
882 | break; | 882 | break; |
883 | 883 | ||
884 | case SE_PART2_NAME: | 884 | case SE_PART2_NAME: |
885 | rb->kbd_input(part2_name, MAX_PATH); | 885 | rb->kbd_input(part2_name, MAX_PATH, NULL); |
886 | break; | 886 | break; |
887 | 887 | ||
888 | case SE_SAVE: | 888 | 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) | |||
983 | 983 | ||
984 | switch (result) { | 984 | switch (result) { |
985 | case 0: /* Save new game */ | 985 | case 0: /* Save new game */ |
986 | rb->kbd_input(state->filename,MAX_PATH); | 986 | rb->kbd_input(state->filename,MAX_PATH, NULL); |
987 | if (save_sudoku(state)) { | 987 | if (save_sudoku(state)) { |
988 | state->editmode=0; | 988 | state->editmode=0; |
989 | } else { | 989 | } 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) | |||
689 | char savepath[MAX_PATH]; | 689 | char savepath[MAX_PATH]; |
690 | 690 | ||
691 | rb->snprintf(savepath, sizeof(savepath), "/Savegame.ssg"); | 691 | rb->snprintf(savepath, sizeof(savepath), "/Savegame.ssg"); |
692 | if(rb->kbd_input(savepath, MAX_PATH)) | 692 | if(rb->kbd_input(savepath, MAX_PATH, NULL)) |
693 | { | 693 | { |
694 | DEBUGF("Keyboard input failed\n"); | 694 | DEBUGF("Keyboard input failed\n"); |
695 | return -1; | 695 | 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) | |||
173 | 173 | ||
174 | if (newfile || !overwrite) | 174 | if (newfile || !overwrite) |
175 | { | 175 | { |
176 | if(rb->kbd_input(filename,MAX_PATH) < 0) | 176 | if(rb->kbd_input(filename,MAX_PATH, NULL) < 0) |
177 | { | 177 | { |
178 | newfile = true; | 178 | newfile = true; |
179 | return false; | 179 | return false; |
@@ -247,7 +247,7 @@ static int do_item_menu(int cur_sel) | |||
247 | ret = MENU_RET_NO_UPDATE; | 247 | ret = MENU_RET_NO_UPDATE; |
248 | break; | 248 | break; |
249 | case 2: /* insert above */ | 249 | case 2: /* insert above */ |
250 | if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) | 250 | if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN, NULL)) |
251 | { | 251 | { |
252 | do_action(ACTION_INSERT,copy_buffer,cur_sel); | 252 | do_action(ACTION_INSERT,copy_buffer,cur_sel); |
253 | copy_buffer[0]='\0'; | 253 | copy_buffer[0]='\0'; |
@@ -255,7 +255,7 @@ static int do_item_menu(int cur_sel) | |||
255 | } | 255 | } |
256 | break; | 256 | break; |
257 | case 3: /* insert below */ | 257 | case 3: /* insert below */ |
258 | if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) | 258 | if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN, NULL)) |
259 | { | 259 | { |
260 | do_action(ACTION_INSERT,copy_buffer,cur_sel+1); | 260 | do_action(ACTION_INSERT,copy_buffer,cur_sel+1); |
261 | copy_buffer[0]='\0'; | 261 | copy_buffer[0]='\0'; |
@@ -425,7 +425,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
425 | switch (rb->do_menu(&menu, NULL, NULL, false)) | 425 | switch (rb->do_menu(&menu, NULL, NULL, false)) |
426 | { | 426 | { |
427 | case 0: | 427 | case 0: |
428 | temp_changed = !rb->kbd_input(extension, sizeof(extension)); | 428 | temp_changed = !rb->kbd_input(extension, sizeof(extension), NULL); |
429 | break; | 429 | break; |
430 | case 1: | 430 | case 1: |
431 | old_color = color; | 431 | old_color = color; |
@@ -446,7 +446,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
446 | } | 446 | } |
447 | else | 447 | else |
448 | #endif | 448 | #endif |
449 | if (!rb->kbd_input(temp_line,MAX_LINE_LEN)) | 449 | if (!rb->kbd_input(temp_line,MAX_LINE_LEN, NULL)) |
450 | { | 450 | { |
451 | if (line_count) | 451 | if (line_count) |
452 | do_action(ACTION_UPDATE,temp_line,cur_sel); | 452 | 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) | |||
628 | name[0]='/'; | 628 | name[0]='/'; |
629 | name[1]='\0'; | 629 | name[1]='\0'; |
630 | put_msg("Enter name of snapshot file to save:"); | 630 | put_msg("Enter name of snapshot file to save:"); |
631 | if (!rb->kbd_input((char*)&name, sizeof name)) | 631 | if (!rb->kbd_input((char*)&name, sizeof(name), NULL)) |
632 | save_snapshot_file(&name[0]); | 632 | save_snapshot_file(&name[0]); |
633 | } | 633 | } |
634 | 634 | ||
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) | |||
277 | { | 277 | { |
278 | buf[0] = '\0'; | 278 | buf[0] = '\0'; |
279 | 279 | ||
280 | if (!kbd_input(buf, MAX_FMPRESET_LEN + 1)) | 280 | if (!kbd_input(buf, MAX_FMPRESET_LEN + 1, NULL)) |
281 | { | 281 | { |
282 | struct fmstation * const fms = &presets[num_presets]; | 282 | struct fmstation * const fms = &presets[num_presets]; |
283 | strcpy(fms->name, buf); | 283 | strcpy(fms->name, buf); |
@@ -307,7 +307,7 @@ static int radio_edit_preset(void) | |||
307 | 307 | ||
308 | strcpy(buf, fms->name); | 308 | strcpy(buf, fms->name); |
309 | 309 | ||
310 | if (!kbd_input(buf, MAX_FMPRESET_LEN + 1)) | 310 | if (!kbd_input(buf, MAX_FMPRESET_LEN + 1, NULL)) |
311 | { | 311 | { |
312 | strcpy(fms->name, buf); | 312 | strcpy(fms->name, buf); |
313 | presets_changed = true; | 313 | presets_changed = true; |
@@ -372,7 +372,7 @@ int preset_list_save(void) | |||
372 | 372 | ||
373 | while(bad_file_name) | 373 | while(bad_file_name) |
374 | { | 374 | { |
375 | if(!kbd_input(filepreset, sizeof(filepreset))) | 375 | if(!kbd_input(filepreset, sizeof(filepreset), NULL)) |
376 | { | 376 | { |
377 | /* check the name: max MAX_FILENAME (20) chars */ | 377 | /* check the name: max MAX_FILENAME (20) chars */ |
378 | char* p2; | 378 | 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 @@ | |||
82 | struct keyboard_parameters | 82 | struct keyboard_parameters |
83 | { | 83 | { |
84 | unsigned short kbd_buf[KBD_BUF_SIZE]; | 84 | unsigned short kbd_buf[KBD_BUF_SIZE]; |
85 | unsigned short *kbd_buf_ptr; | ||
85 | unsigned short max_line_len; | 86 | unsigned short max_line_len; |
86 | int default_lines; | 87 | int default_lines; |
87 | int last_k; | 88 | int last_k; |
@@ -295,7 +296,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y) | |||
295 | i = pm->last_i; | 296 | i = pm->last_i; |
296 | k -= pm->last_k; | 297 | k -= pm->last_k; |
297 | } | 298 | } |
298 | for (pbuf = &pm->kbd_buf[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1) | 299 | for (pbuf = &pm->kbd_buf_ptr[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1) |
299 | { | 300 | { |
300 | n = i ? (i + pm->max_chars - 1) / pm->max_chars : 1; | 301 | n = i ? (i + pm->max_chars - 1) / pm->max_chars : 1; |
301 | if (k < n) break; | 302 | if (k < n) break; |
@@ -304,7 +305,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y) | |||
304 | if (y == 0 && i != 0xFEFF) | 305 | if (y == 0 && i != 0xFEFF) |
305 | { | 306 | { |
306 | pm->last_k = pm->page*pm->lines - k; | 307 | pm->last_k = pm->page*pm->lines - k; |
307 | pm->last_i = pbuf - pm->kbd_buf; | 308 | pm->last_i = pbuf - pm->kbd_buf_ptr; |
308 | } | 309 | } |
309 | k = k * pm->max_chars + x; | 310 | k = k * pm->max_chars + x; |
310 | return (*pbuf != 0xFEFF && k < *pbuf)? pbuf[k+1]: ' '; | 311 | return (*pbuf != 0xFEFF && k < *pbuf)? pbuf[k+1]: ' '; |
@@ -330,7 +331,7 @@ static void kbd_move_picker_horizontal(struct keyboard_parameters *pm, | |||
330 | static void kbd_move_picker_vertical(struct keyboard_parameters *pm, | 331 | static void kbd_move_picker_vertical(struct keyboard_parameters *pm, |
331 | struct edit_state *state, int dir); | 332 | struct edit_state *state, int dir); |
332 | 333 | ||
333 | int kbd_input(char* text, int buflen) | 334 | int kbd_input(char* text, int buflen, unsigned short *kbd) |
334 | { | 335 | { |
335 | bool done = false; | 336 | bool done = false; |
336 | struct keyboard_parameters * const param = kbd_param; | 337 | struct keyboard_parameters * const param = kbd_param; |
@@ -438,6 +439,12 @@ int kbd_input(char* text, int buflen) | |||
438 | FOR_NB_SCREENS(l) | 439 | FOR_NB_SCREENS(l) |
439 | { | 440 | { |
440 | struct keyboard_parameters *pm = ¶m[l]; | 441 | struct keyboard_parameters *pm = ¶m[l]; |
442 | |||
443 | if(kbd) /* user supplied custom layout */ | ||
444 | pm->kbd_buf_ptr = kbd; | ||
445 | else | ||
446 | pm->kbd_buf_ptr = pm->kbd_buf; /* internal layout buffer */ | ||
447 | |||
441 | struct screen *sc = &screens[l]; | 448 | struct screen *sc = &screens[l]; |
442 | kbd_calc_params(pm, sc, &state); | 449 | kbd_calc_params(pm, sc, &state); |
443 | } | 450 | } |
@@ -743,7 +750,7 @@ static void kbd_calc_params(struct keyboard_parameters *pm, | |||
743 | * since we're going to be adding spaces, | 750 | * since we're going to be adding spaces, |
744 | * max width is at least their width */ | 751 | * max width is at least their width */ |
745 | pm->font_w = font_get_width(font, ' '); | 752 | pm->font_w = font_get_width(font, ' '); |
746 | for (pbuf = pm->kbd_buf; *pbuf != 0xFEFF; pbuf += i) | 753 | for (pbuf = pm->kbd_buf_ptr; *pbuf != 0xFEFF; pbuf += i) |
747 | { | 754 | { |
748 | for (i = 0; ++i <= *pbuf; ) | 755 | for (i = 0; ++i <= *pbuf; ) |
749 | { | 756 | { |
@@ -807,7 +814,7 @@ recalc_param: | |||
807 | pm->keyboard_margin = DEFAULT_MARGIN; | 814 | pm->keyboard_margin = DEFAULT_MARGIN; |
808 | 815 | ||
809 | total_lines = 0; | 816 | total_lines = 0; |
810 | for (pbuf = pm->kbd_buf; (i = *pbuf) != 0xFEFF; pbuf += i + 1) | 817 | for (pbuf = pm->kbd_buf_ptr; (i = *pbuf) != 0xFEFF; pbuf += i + 1) |
811 | total_lines += (i ? (i + pm->max_chars - 1) / pm->max_chars : 1); | 818 | total_lines += (i ? (i + pm->max_chars - 1) / pm->max_chars : 1); |
812 | 819 | ||
813 | pm->pages = (total_lines + pm->lines - 1) / pm->lines; | 820 | 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) | |||
698 | 698 | ||
699 | /* allow user to modify filename */ | 699 | /* allow user to modify filename */ |
700 | while (true) { | 700 | while (true) { |
701 | if (!kbd_input(filename, sizeof filename)) { | 701 | if (!kbd_input(filename, sizeof(filename), NULL)) { |
702 | break; | 702 | break; |
703 | } | 703 | } |
704 | else { | 704 | 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) | |||
1905 | } | 1905 | } |
1906 | else | 1906 | else |
1907 | { | 1907 | { |
1908 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); | 1908 | rc = kbd_input(searchstring, SEARCHSTR_SIZE, NULL); |
1909 | if (rc < 0 || !searchstring[0]) | 1909 | if (rc < 0 || !searchstring[0]) |
1910 | { | 1910 | { |
1911 | tagtree_exit(c); | 1911 | 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) | |||
950 | else | 950 | else |
951 | snprintf(filename, sizeof filename, "%s/all.m3u8", playlist_dir); | 951 | snprintf(filename, sizeof filename, "%s/all.m3u8", playlist_dir); |
952 | 952 | ||
953 | if (kbd_input(filename, MAX_PATH)) | 953 | if (kbd_input(filename, MAX_PATH, NULL)) |
954 | return 0; | 954 | return 0; |
955 | splashf(0, "%s %s", str(LANG_CREATING), filename); | 955 | splashf(0, "%s %s", str(LANG_CREATING), filename); |
956 | #endif | 956 | #endif |