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
This commit is contained in:
William Wilgus 2020-07-21 02:33:53 -04:00
parent a5df94beb5
commit cb94b3ae2e
37 changed files with 173 additions and 69 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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"))

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -69,6 +69,8 @@ bmp_smooth_scale.c
pluginlib_albumart.c
#endif
kbd_helper.c
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_TOUCHSCREEN

View File

@ -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;
}

View File

@ -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 */

View File

@ -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:

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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));

View File

@ -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");

View File

@ -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;

View File

@ -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);
}
/*

View File

@ -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);

View File

@ -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");

View File

@ -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:

View File

@ -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 {

View File

@ -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;

View File

@ -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);

View File

@ -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]);
}

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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);

View File

@ -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