summaryrefslogtreecommitdiffstats
path: root/apps/recorder
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-07-21 02:33:53 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-07-22 06:48:28 -0400
commitcb94b3ae2ee7a66845895e2c704cdf62ee74ba13 (patch)
tree0b2da61e3d513fdc37d18f075b6c079e85165781 /apps/recorder
parenta5df94beb5cd7fd87828b9532b4a1a4da13ef774 (diff)
downloadrockbox-cb94b3ae2ee7a66845895e2c704cdf62ee74ba13.tar.gz
rockbox-cb94b3ae2ee7a66845895e2c704cdf62ee74ba13.tar.bz2
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
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/keyboard.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index ceb8de00fb..6e91d69b6d 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -82,6 +82,7 @@
struct keyboard_parameters
{
unsigned short kbd_buf[KBD_BUF_SIZE];
+ unsigned short *kbd_buf_ptr;
unsigned short max_line_len;
int default_lines;
int last_k;
@@ -295,7 +296,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
i = pm->last_i;
k -= pm->last_k;
}
- for (pbuf = &pm->kbd_buf[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
+ for (pbuf = &pm->kbd_buf_ptr[i]; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
{
n = i ? (i + pm->max_chars - 1) / pm->max_chars : 1;
if (k < n) break;
@@ -304,7 +305,7 @@ static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
if (y == 0 && i != 0xFEFF)
{
pm->last_k = pm->page*pm->lines - k;
- pm->last_i = pbuf - pm->kbd_buf;
+ pm->last_i = pbuf - pm->kbd_buf_ptr;
}
k = k * pm->max_chars + x;
return (*pbuf != 0xFEFF && k < *pbuf)? pbuf[k+1]: ' ';
@@ -330,7 +331,7 @@ static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
struct edit_state *state, int dir);
-int kbd_input(char* text, int buflen)
+int kbd_input(char* text, int buflen, unsigned short *kbd)
{
bool done = false;
struct keyboard_parameters * const param = kbd_param;
@@ -438,6 +439,12 @@ int kbd_input(char* text, int buflen)
FOR_NB_SCREENS(l)
{
struct keyboard_parameters *pm = &param[l];
+
+ if(kbd) /* user supplied custom layout */
+ pm->kbd_buf_ptr = kbd;
+ else
+ pm->kbd_buf_ptr = pm->kbd_buf; /* internal layout buffer */
+
struct screen *sc = &screens[l];
kbd_calc_params(pm, sc, &state);
}
@@ -743,7 +750,7 @@ static void kbd_calc_params(struct keyboard_parameters *pm,
* since we're going to be adding spaces,
* max width is at least their width */
pm->font_w = font_get_width(font, ' ');
- for (pbuf = pm->kbd_buf; *pbuf != 0xFEFF; pbuf += i)
+ for (pbuf = pm->kbd_buf_ptr; *pbuf != 0xFEFF; pbuf += i)
{
for (i = 0; ++i <= *pbuf; )
{
@@ -807,7 +814,7 @@ recalc_param:
pm->keyboard_margin = DEFAULT_MARGIN;
total_lines = 0;
- for (pbuf = pm->kbd_buf; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
+ for (pbuf = pm->kbd_buf_ptr; (i = *pbuf) != 0xFEFF; pbuf += i + 1)
total_lines += (i ? (i + pm->max_chars - 1) / pm->max_chars : 1);
pm->pages = (total_lines + pm->lines - 1) / pm->lines;