A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+173 -69
+2 -1
apps/hosted/android/keyboard.c
··· 82 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 88 JNIEnv e = *env_ptr; 88 89 jstring str = e->NewStringUTF(env_ptr, text); 89 90 jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK));
+3 -1
apps/keyboard.h
··· 21 21 #ifndef _KEYBOARD_H 22 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 28 #ifdef HAVE_LCD_BITMAP 27 29 int load_kbd(unsigned char* filename);
+1 -1
apps/menus/playlist_menu.c
··· 58 58 if (dot) /* remove extension */ 59 59 *dot = '\0'; 60 60 61 - if (!kbd_input(temp, sizeof(temp))) 61 + if (!kbd_input(temp, sizeof(temp), NULL)) 62 62 { 63 63 len = strlen(temp); 64 64 if(len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
+2 -2
apps/onplay.c
··· 1009 1009 1010 1010 if (strlcpy(newname, selection, sizeof (newname)) >= sizeof (newname)) { 1011 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 1013 rc = OPRC_CANCELLED; 1014 1014 } else if (!strcmp(oldbase, newbase)) { 1015 1015 rc = OPRC_NOOP; /* No change at all */ ··· 1051 1051 1052 1052 if (pathlen >= sizeof (dirname)) { 1053 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 1055 rc = OPRC_CANCELLED; 1056 1056 } else if (check_new_name(basename)) { 1057 1057 rc = mkdir(dirname);
+2 -1
apps/player/keyboard.c
··· 97 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 103 bool done = false; 103 104 bool redraw = true; 104 105 bool line_edit = false;
+1 -1
apps/playlist_catalog.c
··· 356 356 else 357 357 strlcpy(playlist, m3u8name, MAX_PATH); 358 358 359 - if (kbd_input(playlist, MAX_PATH)) 359 + if (kbd_input(playlist, MAX_PATH, NULL)) 360 360 return false; 361 361 362 362 len = strlen(playlist);
+1 -1
apps/playlist_viewer.c
··· 910 910 911 911 if (!playlist_viewer_init(&viewer, 0, false)) 912 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 914 return ret; 915 915 lcd_clear_display(); 916 916 playlist_count = playlist_amount_ex(viewer.playlist);
+1 -1
apps/plugin.h
··· 927 927 int (*rand)(void); 928 928 void (*qsort)(void *base, size_t nmemb, size_t size, 929 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 931 struct tm* (*get_time)(void); 932 932 int (*set_time)(const struct tm *tm); 933 933 struct tm * (*gmtime_r)(const time_t *timep, struct tm *tm);
+2 -2
apps/plugins/calendar.c
··· 842 842 { 843 843 bool saved = false; 844 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 847 if (memo->message[0]) 848 848 { ··· 920 920 921 921 case 1: /* edit */ 922 922 if(rb->kbd_input(memos[change].message, 923 - MAX_CHAR_MEMO_LEN) == 0) 923 + MAX_CHAR_MEMO_LEN, NULL) == 0) 924 924 save_memo(change, true, shown); 925 925 return false; 926 926
+1 -1
apps/plugins/dict.c
··· 92 92 searchword[0] = '\0'; 93 93 94 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 96 return PLUGIN_OK; /* input cancelled */ 97 97 98 98 fIndex = rb->open(DICT_INDEX, O_RDONLY); /* index file */
+2 -2
apps/plugins/frotz/frotz.c
··· 195 195 return zkey; 196 196 197 197 inputbuf[0] = '\0'; 198 - r = rb->kbd_input(inputbuf, 5); 198 + r = rb->kbd_input(inputbuf, 5, NULL); 199 199 rb->lcd_setfont(FONT_SYSFIXED); 200 200 dumb_dump_screen(); 201 201 if (!r) ··· 226 226 if (max > width) 227 227 max = width; 228 228 strcpy(inputbuf, buf); 229 - r = rb->kbd_input(inputbuf, 256); 229 + r = rb->kbd_input(inputbuf, 256, NULL); 230 230 rb->lcd_setfont(FONT_SYSFIXED); 231 231 dumb_dump_screen(); 232 232 if (!r)
+3 -3
apps/plugins/goban/goban.c
··· 677 677 case MAIN_SAVE_AS: 678 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 682 break; 683 683 } ··· 921 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 925 sanitize_string (gameinfo_string); 926 926 set_game_modified(); 927 927 break; ··· 1191 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 1196 /* user didn't edit, no reason to write it back */ 1197 1197 return true;
+9 -9
apps/plugins/keybox.c
··· 196 196 197 197 rb->splash(HZ, "Enter title"); 198 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 200 return; 201 201 202 202 rb->splash(HZ, "Enter name"); 203 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 206 pw_list.entries[i].title[0] = '\0'; 207 207 return; ··· 209 209 210 210 rb->splash(HZ, "Enter password"); 211 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 214 pw_list.entries[i].title[0] = '\0'; 215 215 pw_list.entries[i].name[0] = '\0'; ··· 244 244 if (entry->next) 245 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 248 data_changed = true; 249 249 } 250 250 ··· 257 257 if (entry->next) 258 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 261 data_changed = true; 262 262 } 263 263 ··· 270 270 if (entry->next) 271 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 274 data_changed = true; 275 275 } 276 276 ··· 513 513 if (new_pw) 514 514 { 515 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 517 return -1; 518 518 519 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 521 return -1; 522 522 523 523 if (rb->strcmp(buf[0], buf[1])) ··· 534 534 } 535 535 536 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 538 return -1; 539 539 hash_pw(&pwhash); 540 540 return 0;
+2
apps/plugins/lib/SOURCES
··· 69 69 pluginlib_albumart.c 70 70 #endif 71 71 72 + kbd_helper.c 73 + 72 74 #endif /* HAVE_LCD_BITMAP */ 73 75 74 76 #ifdef HAVE_TOUCHSCREEN
+63
apps/plugins/lib/kbd_helper.c
··· 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 + }
+27
apps/plugins/lib/kbd_helper.h
··· 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 */
+1 -1
apps/plugins/lrcplayer.c
··· 2475 2475 #endif 2476 2476 case LRC_MENU_LRC_DIR: 2477 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 2479 rb->strcpy(prefs.lrc_directory, temp_buf); 2480 2480 break; 2481 2481 case MENU_ATTACHED_USB:
+1 -1
apps/plugins/lua/rocklib.c
··· 152 152 else 153 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 157 luaL_addstring(&b, buffer); 158 158 luaL_pushresult(&b);
+10 -9
apps/plugins/otp.c
··· 411 411 memset(accounts + next_slot, 0, sizeof(struct account_t)); 412 412 413 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 416 return; 416 417 417 - if(acct_exists(accounts[next_slot].name)) 418 + if(acct_exists(buf)) 418 419 { 419 420 rb->splash(HZ * 2, "Duplicate account name!"); 420 421 return; ··· 425 426 char temp_buf[SECRET_MAX * 2]; 426 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 430 return; 430 431 431 432 if((accounts[next_slot].sec_len = base32_decode(accounts[next_slot].secret, SECRET_MAX, temp_buf)) <= 0) ··· 457 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 462 return; 462 463 463 464 if(!accounts[next_slot].is_totp) ··· 470 471 memset(temp_buf, 0, sizeof(temp_buf)); 471 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 475 return; 475 476 476 477 accounts[next_slot].digits = rb->atoi(temp_buf); ··· 667 668 case 0: // rename 668 669 rb->splash(HZ, "Enter new name."); 669 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 672 break; 672 673 if(acct_exists(data_buf)) 673 674 { ··· 695 696 else 696 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 700 break; 700 701 701 702 if(accounts[acct].is_totp) ··· 709 710 break; 710 711 case 3: // digits 711 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 714 break; 714 715 715 716 accounts[acct].digits = rb->atoi(data_buf); ··· 722 723 memcpy(temp_sec, accounts[acct].secret, accounts[acct].sec_len); 723 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 727 break; 727 728 728 729 int ret = base32_decode(accounts[acct].secret, sizeof(accounts[acct].secret), data_buf);
+1 -1
apps/plugins/puzzles/rockbox.c
··· 2411 2411 } 2412 2412 2413 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 2416 sfree(newstr); 2417 2417 return false;
+3 -3
apps/plugins/resistor.c
··· 623 623 624 624 rb->splash(HZ*2, "(First) Input the supply voltage:"); 625 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 627 input_voltage = rb->atoi(kbd_buffer); 628 628 if(input_voltage == 0) break; 629 629 ··· 660 660 rb->lcd_clear_display(); 661 661 rb->splash(HZ*2, "Input the foreward current, in mA"); 662 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 664 foreward_current = ((rb->atoi(fwd_kbd_buffer))/10); 665 665 break; 666 666 } ··· 817 817 NULL, false); 818 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 821 /* As stated above somewhere, we (I) need to make a calculator-like 822 822 keypad, that keyboard isn't all that fun to use. */ 823 823 ret = rb->do_menu(&r_to_c_menu_tol, &menu_selection_tol,
+1 -1
apps/plugins/rockboy/menu.c
··· 276 276 if (!is_load) 277 277 { 278 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 280 return false; 281 281 if ( !strlen(desc_buf) ) 282 282 strlcpy(desc_buf, "Untitled", sizeof(desc_buf));
+2 -2
apps/plugins/rockpaint.c
··· 1794 1794 { 1795 1795 case TEXT_MENU_TEXT: 1796 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 1798 break; 1799 1799 1800 1800 case TEXT_MENU_FONT: ··· 2790 2790 rb->lcd_set_foreground(COLOR_BLACK); 2791 2791 if (!filename[0]) 2792 2792 rb->strcpy(filename,"/"); 2793 - if( !rb->kbd_input( filename, MAX_PATH ) ) 2793 + if( !rb->kbd_input( filename, MAX_PATH, NULL ) ) 2794 2794 { 2795 2795 if( !check_extention( filename, ".bmp" ) ) 2796 2796 rb->strcat(filename, ".bmp");
+1 -1
apps/plugins/sdl/progs/duke3d/Game/src/console.c
··· 224 224 //If console_buffer[0] strlen() != 0 225 225 //1. Push the dirty_buffer unto the console_buffer 226 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 229 CONSOLE_Printf("%s", dirty_buffer); 230 230 console_cursor_pos = 0;
+1 -1
apps/plugins/sdl/progs/quake/keys.c
··· 151 151 /* Rockbox hack */ 152 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 /*
+1 -1
apps/plugins/search.c
··· 111 111 static bool search_init(const char* file){ 112 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 115 clear_display(); 116 116 rb->splash(0, "Searching..."); 117 117 fd = rb->open_utf8(file, O_RDONLY);
+1 -1
apps/plugins/sokoban.c
··· 1963 1963 *loc = '.'; 1964 1964 } 1965 1965 1966 - if (!rb->kbd_input(buf, MAX_PATH)) 1966 + if (!rb->kbd_input(buf, MAX_PATH, NULL)) 1967 1967 save(buf, true); 1968 1968 } else 1969 1969 rb->splash(HZ*2, "Solution too long to save");
+2 -2
apps/plugins/splitedit.c
··· 874 874 break; 875 875 876 876 case SE_PART1_NAME: 877 - rb->kbd_input(part1_name, MAX_PATH); 877 + rb->kbd_input(part1_name, MAX_PATH, NULL); 878 878 break; 879 879 880 880 case SE_PART2_SAVE: ··· 882 882 break; 883 883 884 884 case SE_PART2_NAME: 885 - rb->kbd_input(part2_name, MAX_PATH); 885 + rb->kbd_input(part2_name, MAX_PATH, NULL); 886 886 break; 887 887 888 888 case SE_SAVE:
+1 -1
apps/plugins/sudoku/sudoku.c
··· 983 983 984 984 switch (result) { 985 985 case 0: /* Save new game */ 986 - rb->kbd_input(state->filename,MAX_PATH); 986 + rb->kbd_input(state->filename,MAX_PATH, NULL); 987 987 if (save_sudoku(state)) { 988 988 state->editmode=0; 989 989 } else {
+1 -1
apps/plugins/superdom.c
··· 689 689 char savepath[MAX_PATH]; 690 690 691 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 694 DEBUGF("Keyboard input failed\n"); 695 695 return -1;
+5 -5
apps/plugins/text_editor.c
··· 173 173 174 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 178 newfile = true; 179 179 return false; ··· 247 247 ret = MENU_RET_NO_UPDATE; 248 248 break; 249 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 252 do_action(ACTION_INSERT,copy_buffer,cur_sel); 253 253 copy_buffer[0]='\0'; ··· 255 255 } 256 256 break; 257 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 260 do_action(ACTION_INSERT,copy_buffer,cur_sel+1); 261 261 copy_buffer[0]='\0'; ··· 425 425 switch (rb->do_menu(&menu, NULL, NULL, false)) 426 426 { 427 427 case 0: 428 - temp_changed = !rb->kbd_input(extension, sizeof(extension)); 428 + temp_changed = !rb->kbd_input(extension, sizeof(extension), NULL); 429 429 break; 430 430 case 1: 431 431 old_color = color; ··· 446 446 } 447 447 else 448 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 451 if (line_count) 452 452 do_action(ACTION_UPDATE,temp_line,cur_sel);
+1 -1
apps/plugins/zxbox/snapshot.c
··· 628 628 name[0]='/'; 629 629 name[1]='\0'; 630 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 632 save_snapshot_file(&name[0]); 633 633 } 634 634
+3 -3
apps/radio/presets.c
··· 277 277 { 278 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 282 struct fmstation * const fms = &presets[num_presets]; 283 283 strcpy(fms->name, buf); ··· 307 307 308 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 312 strcpy(fms->name, buf); 313 313 presets_changed = true; ··· 372 372 373 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 377 /* check the name: max MAX_FILENAME (20) chars */ 378 378 char* p2;
+12 -5
apps/recorder/keyboard.c
··· 82 82 struct keyboard_parameters 83 83 { 84 84 unsigned short kbd_buf[KBD_BUF_SIZE]; 85 + unsigned short *kbd_buf_ptr; 85 86 unsigned short max_line_len; 86 87 int default_lines; 87 88 int last_k; ··· 295 296 i = pm->last_i; 296 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 301 n = i ? (i + pm->max_chars - 1) / pm->max_chars : 1; 301 302 if (k < n) break; ··· 304 305 if (y == 0 && i != 0xFEFF) 305 306 { 306 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 310 k = k * pm->max_chars + x; 310 311 return (*pbuf != 0xFEFF && k < *pbuf)? pbuf[k+1]: ' '; ··· 330 331 static void kbd_move_picker_vertical(struct keyboard_parameters *pm, 331 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 336 bool done = false; 336 337 struct keyboard_parameters * const param = kbd_param; ··· 438 439 FOR_NB_SCREENS(l) 439 440 { 440 441 struct keyboard_parameters *pm = &param[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 448 struct screen *sc = &screens[l]; 442 449 kbd_calc_params(pm, sc, &state); 443 450 } ··· 743 750 * since we're going to be adding spaces, 744 751 * max width is at least their width */ 745 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 755 for (i = 0; ++i <= *pbuf; ) 749 756 { ··· 807 814 pm->keyboard_margin = DEFAULT_MARGIN; 808 815 809 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 818 total_lines += (i ? (i + pm->max_chars - 1) / pm->max_chars : 1); 812 819 813 820 pm->pages = (total_lines + pm->lines - 1) / pm->lines;
+1 -1
apps/settings.c
··· 698 698 699 699 /* allow user to modify filename */ 700 700 while (true) { 701 - if (!kbd_input(filename, sizeof filename)) { 701 + if (!kbd_input(filename, sizeof(filename), NULL)) { 702 702 break; 703 703 } 704 704 else {
+1 -1
apps/tagtree.c
··· 1905 1905 } 1906 1906 else 1907 1907 { 1908 - rc = kbd_input(searchstring, SEARCHSTR_SIZE); 1908 + rc = kbd_input(searchstring, SEARCHSTR_SIZE, NULL); 1909 1909 if (rc < 0 || !searchstring[0]) 1910 1910 { 1911 1911 tagtree_exit(c);
+1 -1
apps/tree.c
··· 950 950 else 951 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 954 return 0; 955 955 splashf(0, "%s %s", str(LANG_CREATING), filename); 956 956 #endif