1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #include "statusbar.h"
29 #include "rbunicode.h"
30 #include "buttonbar.h"
42 #if CONFIG_KEYPAD == RECORDER_PAD
43 #define BUTTONBAR_HEIGHT 8
45 #define BUTTONBAR_HEIGHT 0
48 #define DEFAULT_MARGIN 6
49 #define KBD_BUF_SIZE 500
51 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
52 (CONFIG_KEYPAD == IRIVER_H300_PAD)
53 #define KBD_CURSOR_KEYS /* certain key combos move the cursor even if not
55 #define KBD_MODES /* I-Rivers can use picker, line edit and cursor keys */
56 #define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */
58 #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
59 #define KBD_MODES /* Ondio uses 2 modes, picker and line edit */
61 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
62 || (CONFIG_KEYPAD == IPOD_4G_PAD)
63 #define KBD_MODES /* iPod uses 2 modes, picker and line edit */
64 #define KBD_MORSE_INPUT
66 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
67 #define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */
69 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
70 #define KBD_MODES /* iAudio X5 uses 2 modes, picker and line edit */
72 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
73 #define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */
74 #define KBD_MORSE_INPUT
76 #elif CONFIG_KEYPAD == GIGABEAT_PAD
77 #define KBD_CURSOR_KEYS
79 #define KBD_MORSE_INPUT
81 #elif CONFIG_KEYPAD == SANSA_E200_PAD
82 #define KBD_CURSOR_KEYS
86 struct keyboard_parameters
88 const unsigned char* default_kbd
;
90 unsigned short kbd_buf
[KBD_BUF_SIZE
];
113 unsigned short hlead
, hvowel
, htail
;
116 static struct keyboard_parameters kbd_param
[NB_SCREENS
];
117 static bool kbd_loaded
= false;
119 #ifdef KBD_MORSE_INPUT
120 /* FIXME: We should put this to a configuration file. */
121 static const char *morse_alphabets
=
122 "abcdefghijklmnopqrstuvwxyz1234567890,.?-@ ";
123 static const unsigned char morse_codes
[] = {
124 0x05,0x18,0x1a,0x0c,0x02,0x12,0x0e,0x10,0x04,0x17,0x0d,0x14,0x07,
125 0x06,0x0f,0x16,0x1d,0x0a,0x08,0x03,0x09,0x11,0x0b,0x19,0x1b,0x1c,
126 0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f,
127 0x73,0x55,0x4c,0x61,0x5a,0x80 };
129 static bool morse_mode
= false;
132 /* Loads a custom keyboard into memory
133 call with NULL to reset keyboard */
134 int load_kbd(unsigned char* filename
)
138 unsigned char buf
[4];
140 if (filename
== NULL
)
146 fd
= open(filename
, O_RDONLY
|O_BINARY
);
150 while (read(fd
, buf
, 1) == 1 && i
< KBD_BUF_SIZE
)
152 /* check how many bytes to read for this character */
153 static const unsigned char sizes
[4] = { 0x80, 0xe0, 0xf0, 0xf5 };
156 for (count
= 0; count
< ARRAYLEN(sizes
); count
++)
158 if (buf
[0] < sizes
[count
])
162 if (count
>= ARRAYLEN(sizes
))
163 continue; /* Invalid size. */
165 if (read(fd
, &buf
[1], count
) != (ssize_t
)count
)
173 utf8decode(buf
, &kbd_param
[l
].kbd_buf
[i
]);
175 if (kbd_param
[0].kbd_buf
[i
] != 0xFEFF &&
176 kbd_param
[0].kbd_buf
[i
] != '\r') /*skip BOM & carriage returns */
186 kbd_param
[l
].nchars
= i
;
191 /* helper function to spell a char if voice UI is enabled */
192 static void kbd_spellchar(unsigned short c
)
194 if (global_settings
.talk_menu
) /* voice UI? */
196 unsigned char tmp
[5];
197 /* store char to pass to talk_spell */
198 unsigned char* utf8
= utf8encode(c
, tmp
);
202 talk_id(VOICE_BLANK
, false);
204 talk_spell(tmp
, false);
209 static void say_edit(void)
211 if(global_settings
.talk_menu
)
212 talk_id(VOICE_EDIT
, false);
216 static void kbd_inschar(unsigned char* text
, int buflen
,
217 int* editpos
, unsigned short ch
)
220 unsigned char tmp
[4];
224 k
= utf8length(text
);
225 utf8
= utf8encode(ch
, tmp
);
226 j
= (long)utf8
- (long)tmp
;
228 if (len
+ j
< buflen
)
230 for (i
= len
+j
; k
>= *editpos
; i
--)
233 if ((text
[i
] & MASK
) != COMP
)
244 static void kbd_delchar(unsigned char* text
, int* editpos
)
251 utf8
= text
+ utf8seek(text
, *editpos
);
258 while ((*utf8
& MASK
) == COMP
);
271 /* Lookup k value based on state of param (pm) */
272 static int get_param_k(const struct keyboard_parameters
*pm
)
274 return (pm
->page
*pm
->lines
+ pm
->y
)*pm
->max_chars
+ pm
->x
;
277 int kbd_input(char* text
, int buflen
)
281 /* This seems to keep the sizes for ARM way down */
282 struct keyboard_parameters
* volatile param
= kbd_param
;
284 struct keyboard_parameters
* const param
= kbd_param
;
286 int l
; /* screen loop variable */
288 int editpos
; /* Edit position on all screens */
289 const int statusbar_size
= global_settings
.statusbar
290 ? STATUSBAR_HEIGHT
: 0;
293 bool cur_blink
= true; /* Cursor on/off flag */
294 #ifdef KBD_MORSE_INPUT
295 bool morse_reading
= false;
296 unsigned char morse_code
= 0;
303 struct keyboard_parameters
*pm
= ¶m
[l
];
304 #if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
305 struct screen
*sc
= &screens
[l
];
307 if (sc
->width
>= 160 && sc
->height
>= 96)
310 "ABCDEFG abcdefg !?\" @#$%+'\n"
311 "HIJKLMN hijklmn 789 &_()-`\n"
312 "OPQRSTU opqrstu 456 §|{}/<\n"
313 "VWXYZ., vwxyz.,0123 ~=[]*>\n"
314 "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË ¢£¤¥¦§©®\n"
315 "àáâãäåæ ìíîï èéêë «»°ºª¹²³\n"
316 "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
317 "òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
319 pm
->DEFAULT_LINES
= 8;
322 #endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
325 "ABCDEFG !?\" @#$%+'\n"
326 "HIJKLMN 789 &_()-`\n"
327 "OPQRSTU 456 §|{}/<\n"
328 "VWXYZ.,0123 ~=[]*>\n"
330 "abcdefg ¢£¤¥¦§©®¬\n"
331 "hijklmn «»°ºª¹²³¶\n"
332 "opqrstu ¯±×÷¡¿µ·¨\n"
335 "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË\n"
336 "àáâãäåæ ìíîï èéêë\n"
337 "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
340 pm
->DEFAULT_LINES
= 4;
346 struct gui_buttonbar buttonbar
;
347 bool buttonbar_config
= global_settings
.buttonbar
;
349 global_settings
.buttonbar
= true;
350 gui_buttonbar_init(&buttonbar
);
353 gui_buttonbar_set_display(&buttonbar
, &screens
[l
]);
358 struct keyboard_parameters
*pm
= ¶m
[l
];
362 /* Copy default keyboard to buffer */
363 const unsigned char *p
= pm
->default_kbd
;
366 pm
->curfont
= FONT_SYSFIXED
;
369 p
= utf8decode(p
, &pm
->kbd_buf
[i
++]);
375 pm
->curfont
= FONT_UI
;
381 struct keyboard_parameters
*pm
= ¶m
[l
];
382 struct screen
*sc
= &screens
[l
];
385 pm
->font
= font_get(pm
->curfont
);
386 pm
->font_h
= pm
->font
->height
;
388 /* check if FONT_UI fits the screen */
389 if (2*pm
->font_h
+ 3 + statusbar_size
+ BUTTONBAR_HEIGHT
> sc
->height
)
391 pm
->font
= font_get(FONT_SYSFIXED
);
392 pm
->font_h
= pm
->font
->height
;
393 pm
->curfont
= FONT_SYSFIXED
;
396 sc
->setfont(pm
->curfont
);
397 pm
->font_w
= 0; /* reset font width */
398 /* find max width of keyboard glyphs */
399 for (i
= 0; i
< pm
->nchars
; i
++)
401 w
= font_get_width(pm
->font
, pm
->kbd_buf
[i
]);
402 if ( w
> pm
->font_w
)
406 /* Since we're going to be adding spaces, make sure that we check
408 w
= font_get_width( pm
->font
, ' ' );
409 if ( w
> pm
->font_w
)
415 struct keyboard_parameters
*pm
= ¶m
[l
];
416 struct screen
*sc
= &screens
[l
];
419 /* Pad lines with spaces */
420 while (i
< pm
->nchars
)
422 if (pm
->kbd_buf
[i
] == '\n')
424 int k
= sc
->width
/ pm
->font_w
425 - i
% ( sc
->width
/ pm
->font_w
) - 1;
428 if (k
== sc
->width
/ pm
->font_w
- 1)
432 for (j
= i
; j
< pm
->nchars
; j
++)
434 pm
->kbd_buf
[j
] = pm
->kbd_buf
[j
+ 1];
439 if (pm
->nchars
+ k
- 1 >= KBD_BUF_SIZE
)
440 { /* We don't want to overflow the buffer */
441 k
= KBD_BUF_SIZE
- pm
->nchars
;
444 for (j
= pm
->nchars
+ k
- 1; j
> i
+ k
; j
--)
446 pm
->kbd_buf
[j
] = pm
->kbd_buf
[j
-k
];
454 pm
->kbd_buf
[i
++] = ' ';
465 /* Find max width for text string */
469 struct keyboard_parameters
*pm
= ¶m
[l
];
470 struct screen
*sc
= &screens
[l
];
476 int w
= font_get_width(pm
->font
, ch
);
477 utf8
= (unsigned char*)utf8decode(utf8
, &ch
);
483 pm
->max_chars_text
= sc
->width
/ text_w
- 2;
485 /* Calculate keyboard grid size */
486 pm
->max_chars
= sc
->width
/ pm
->font_w
;
490 pm
->lines
= pm
->DEFAULT_LINES
;
491 pm
->keyboard_margin
= DEFAULT_MARGIN
;
495 pm
->lines
= (sc
->height
- BUTTONBAR_HEIGHT
- statusbar_size
)
497 pm
->keyboard_margin
= sc
->height
- BUTTONBAR_HEIGHT
-
498 statusbar_size
- (pm
->lines
+1)*pm
->font_h
;
500 if (pm
->keyboard_margin
< 3)
503 pm
->keyboard_margin
+= pm
->font_h
;
506 if (pm
->keyboard_margin
> 6)
507 pm
->keyboard_margin
= 6;
510 pm
->pages
= (pm
->nchars
+ (pm
->lines
*pm
->max_chars
-1))
511 / (pm
->lines
*pm
->max_chars
);
513 if (pm
->pages
== 1 && kbd_loaded
)
514 pm
->lines
= (pm
->nchars
+ pm
->max_chars
- 1) / pm
->max_chars
;
516 pm
->main_y
= pm
->font_h
*pm
->lines
+ pm
->keyboard_margin
+ statusbar_size
;
518 pm
->keyboard_margin
-= pm
->keyboard_margin
/2;
520 #ifdef KBD_MORSE_INPUT
521 pm
->old_main_y
= pm
->main_y
;
523 pm
->main_y
= sc
->height
- pm
->font_h
;
527 /* Initial edit position is after last character */
528 editpos
= utf8length(text
);
530 if (global_settings
.talk_menu
) /* voice UI? */
531 talk_spell(text
, true); /* spell initial text */
536 /* These declarations are assigned to the screen on which the key
537 action occurred - pointers save a lot of space over array notation
538 when accessing the same array element countless times */
543 const int button_screen
= 0;
545 struct keyboard_parameters
*pm
;
548 int len_utf8
= utf8length(text
);
551 screens
[l
].clear_display();
553 #ifdef KBD_MORSE_INPUT
558 /* declare scoped pointers inside screen loops - hide the
559 declarations from previous block level */
560 const int w
= 6; /* sysfixed font width */
561 struct keyboard_parameters
*pm
= ¶m
[l
];
562 struct screen
*sc
= &screens
[l
];
565 sc
->setfont(FONT_SYSFIXED
); /* Draw morse code screen with sysfont */
567 pm
->y
= statusbar_size
;
570 /* Draw morse code table with code descriptions. */
571 for (i
= 0; morse_alphabets
[i
] != '\0'; i
++)
576 buf
[0] = morse_alphabets
[i
];
577 sc
->putsxy(pm
->x
, pm
->y
, buf
);
579 for (j
= 0; (morse_codes
[i
] >> j
) > 0x01; j
++) ;
583 for (j
= 0; j
< morse_len
; j
++)
585 if ((morse_codes
[i
] >> (morse_len
-j
-1)) & 0x01)
586 sc
->fillrect(pm
->x
+ j
*4, pm
->y
+ 2, 3, 4);
588 sc
->fillrect(pm
->x
+ j
*4, pm
->y
+ 3, 1, 2);
592 if (pm
->x
>= sc
->width
- w
*6)
595 pm
->y
+= 8; /* sysfixed font height */
601 #endif /* KBD_MORSE_INPUT */
606 struct keyboard_parameters
*pm
= ¶m
[l
];
607 struct screen
*sc
= &screens
[l
];
610 sc
->setfont(pm
->curfont
);
612 k
= pm
->page
*pm
->max_chars
*pm
->lines
;
614 for (i
= j
= 0; j
< pm
->lines
&& k
< pm
->nchars
; k
++)
617 utf8
= utf8encode(pm
->kbd_buf
[k
], outline
);
620 sc
->getstringsize(outline
, &w
, NULL
);
621 sc
->putsxy(i
*pm
->font_w
+ (pm
->font_w
-w
) / 2,
622 j
*pm
->font_h
+ statusbar_size
, outline
);
624 if (++i
>= pm
->max_chars
)
636 struct keyboard_parameters
*pm
= ¶m
[l
];
637 struct screen
*sc
= &screens
[l
];
640 /* Clear text area one pixel above separator line so any overdraw
642 sc
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
643 sc
->fillrect(0, pm
->main_y
- pm
->keyboard_margin
- 1,
644 sc
->width
, pm
->font_h
+ 4);
645 sc
->set_drawmode(DRMODE_SOLID
);
647 sc
->hline(0, sc
->width
- 1, pm
->main_y
- pm
->keyboard_margin
);
649 /* write out the text */
650 sc
->setfont(pm
->curfont
);
652 pm
->curpos
= MIN(editpos
, pm
->max_chars_text
653 - MIN(len_utf8
- editpos
, 2));
654 pm
->leftpos
= editpos
- pm
->curpos
;
655 utf8
= text
+ utf8seek(text
, pm
->leftpos
);
659 while (*utf8
&& i
< pm
->max_chars_text
)
661 outline
[j
++] = *utf8
++;
663 if ((*utf8
& MASK
) != COMP
)
669 sc
->getstringsize(outline
, &w
, NULL
);
670 sc
->putsxy(i
*text_w
+ (text_w
-w
)/2, pm
->main_y
, outline
);
676 /* Draw nicer bitmap arrow if room, else settle for "<". */
677 if (text_w
>= 6 && pm
->font_h
>= 8)
679 screen_put_iconxy(sc
, (text_w
- 6) / 2,
680 pm
->main_y
+ (pm
->font_h
- 8) / 2 ,
681 Icon_Reverse_Cursor
);
686 sc
->getstringsize("<", &w
, NULL
);
687 sc
->putsxy(text_w
- w
, pm
->main_y
, "<");
691 if (len_utf8
- pm
->leftpos
> pm
->max_chars_text
)
693 /* Draw nicer bitmap arrow if room, else settle for ">". */
694 if (text_w
>= 6 && pm
->font_h
>= 8)
696 screen_put_iconxy(sc
, sc
->width
- text_w
+ (text_w
- 6) / 2,
697 pm
->main_y
+ (pm
->font_h
- 8) / 2,
702 sc
->putsxy(sc
->width
- text_w
, pm
->main_y
, ">");
707 i
= (pm
->curpos
+ 1) * text_w
;
710 sc
->vline(i
, pm
->main_y
, pm
->main_y
+ pm
->font_h
- 1);
712 if (pm
->hangul
) /* draw underbar */
713 sc
->hline(pm
->curpos
*text_w
, (pm
->curpos
+1)*text_w
,
714 pm
->main_y
+ pm
->font_h
- 1);
717 cur_blink
= !cur_blink
;
720 /* draw the button bar */
721 gui_buttonbar_set(&buttonbar
, "Shift", "OK", "Del");
722 gui_buttonbar_draw(&buttonbar
);
727 struct keyboard_parameters
*pm
= ¶m
[l
];
728 struct screen
*sc
= &screens
[l
];
730 sc
->set_drawmode(DRMODE_COMPLEMENT
);
733 sc
->fillrect(0, pm
->main_y
- pm
->keyboard_margin
+ 2,
734 sc
->width
, pm
->font_h
+ 2);
735 else /* highlight the key that has focus */
737 sc
->fillrect(pm
->font_w
*pm
->x
,
738 statusbar_size
+ pm
->font_h
*pm
->y
,
739 pm
->font_w
, pm
->font_h
);
740 sc
->set_drawmode(DRMODE_SOLID
);
743 gui_syncstatusbar_draw(&statusbars
, true);
747 button
= get_action(CONTEXT_KEYBOARD
, HZ
/2);
749 button_screen
= (get_action_statuscode(NULL
) & ACTION_REMOTE
) ? 1 : 0;
751 pm
= ¶m
[button_screen
];
752 sc
= &screens
[button_screen
];
754 #if defined KBD_MORSE_INPUT && !defined KBD_MODES
757 /* Remap some buttons for morse mode. */
758 if (button
== ACTION_KBD_LEFT
)
759 button
= ACTION_KBD_CURSOR_LEFT
;
760 if (button
== ACTION_KBD_RIGHT
)
761 button
= ACTION_KBD_CURSOR_RIGHT
;
767 case ACTION_KBD_ABORT
:
769 screens
[l
].setfont(FONT_UI
);
772 global_settings
.buttonbar
=buttonbar_config
;
777 case ACTION_KBD_PAGE_FLIP
:
780 #ifdef KBD_MORSE_INPUT
784 if (++pm
->page
>= pm
->pages
)
788 kbd_spellchar(pm
->kbd_buf
[k
]);
792 #ifdef KBD_MORSE_INPUT
793 case ACTION_KBD_MORSE_INPUT
:
794 morse_mode
= !morse_mode
;
798 struct keyboard_parameters
*pm
= ¶m
[l
];
799 struct screen
*sc
= &screens
[l
];
801 pm
->x
= pm
->y
= pm
->page
= 0;
805 pm
->old_main_y
= pm
->main_y
;
806 pm
->main_y
= sc
->height
- pm
->font_h
;
810 pm
->main_y
= pm
->old_main_y
;
813 /* FIXME: We should talk something like Morse mode.. */
815 #endif /* KBD_MORSE_INPUT */
817 case ACTION_KBD_RIGHT
:
819 #ifdef KBD_MORSE_INPUT
820 /* allow cursor change in non line edit morse mode */
821 if (pm
->line_edit
|| morse_mode
)
823 /* right doubles as cursor_right in line_edit */
829 if (editpos
< len_utf8
)
831 int c
= utf8seek(text
, ++editpos
);
832 kbd_spellchar(text
[c
]);
834 #if CONFIG_CODEC == SWCODEC
835 else if (global_settings
.talk_menu
)
836 pcmbuf_beep(1000, 150, 1500);
840 #endif /* KBD_MODES */
843 #ifdef KBD_MORSE_INPUT
847 if (++pm
->x
>= pm
->max_chars
)
849 #ifndef KBD_PAGE_FLIP
850 /* no dedicated flip key - flip page on wrap */
851 if (++pm
->page
>= pm
->pages
)
858 kbd_spellchar(pm
->kbd_buf
[k
]);
862 case ACTION_KBD_LEFT
:
864 #ifdef KBD_MORSE_INPUT
865 /* allow cursor change in non line edit morse mode */
866 if (pm
->line_edit
|| morse_mode
)
868 /* left doubles as cursor_left in line_edit */
876 int c
= utf8seek(text
, --editpos
);
877 kbd_spellchar(text
[c
]);
879 #if CONFIG_CODEC == SWCODEC
880 else if (global_settings
.talk_menu
)
881 pcmbuf_beep(1000, 150, 1500);
885 #endif /* KBD_MODES */
888 #ifdef KBD_MORSE_INPUT
894 #ifndef KBD_PAGE_FLIP
895 /* no dedicated flip key - flip page on wrap */
897 pm
->page
= pm
->pages
- 1;
899 pm
->x
= pm
->max_chars
- 1;
903 kbd_spellchar(pm
->kbd_buf
[k
]);
907 case ACTION_KBD_DOWN
:
908 #ifdef KBD_MORSE_INPUT
912 pm
->line_edit
= !pm
->line_edit
;
921 #endif /* KBD_MORSE_INPUT */
927 pm
->line_edit
= false;
931 if (++pm
->y
>= pm
->lines
)
934 pm
->line_edit
= true;
945 int k
= get_param_k(pm
);
946 kbd_spellchar(pm
->kbd_buf
[k
]);
951 #ifdef KBD_MORSE_INPUT
955 pm
->line_edit
= !pm
->line_edit
;
964 #endif /* KBD_MORSE_INPUT */
969 pm
->y
= pm
->lines
- 1;
970 pm
->line_edit
= false;
977 pm
->line_edit
= true;
981 pm
->y
= pm
->lines
- 1;
988 int k
= get_param_k(pm
);
989 kbd_spellchar(pm
->kbd_buf
[k
]);
993 case ACTION_KBD_DONE
:
994 /* accepts what was entered and continues */
998 #ifdef KBD_MORSE_INPUT
999 case ACTION_KBD_MORSE_SELECT
:
1000 if (morse_mode
&& morse_reading
)
1003 if ((current_tick
- morse_tick
) > HZ
/5)
1008 #endif /* KBD_MORSE_INPUT */
1010 case ACTION_KBD_SELECT
:
1011 case ACTION_KBD_SELECT_REM
:
1012 #ifdef KBD_MORSE_INPUT
1014 if (morse_mode
&& !pm
->line_edit
)
1019 morse_tick
= current_tick
;
1023 morse_reading
= true;
1028 #endif /* KBD_MORSE_INPUT */
1030 /* inserts the selected char */
1033 { /* select doubles as backspace in line_edit */
1038 else if (pm
->hvowel
)
1044 kbd_delchar(text
, &editpos
);
1049 ch
= hangul_join(pm
->hlead
, pm
->hvowel
, pm
->htail
);
1052 kbd_inschar(text
, buflen
, &editpos
, ch
);
1056 #endif /* KBD_MODES */
1058 /* find input char */
1059 int k
= get_param_k(pm
);
1060 ch
= (k
< pm
->nchars
) ? pm
->kbd_buf
[k
] : ' ';
1062 /* check for hangul input */
1063 if (ch
>= 0x3131 && ch
<= 0x3163)
1069 pm
->hlead
= pm
->hvowel
= pm
->htail
= 0;
1077 else if (!pm
->htail
)
1082 { /* previous hangul complete */
1083 /* check whether tail is actually lead of next char */
1084 tmp
= hangul_join(pm
->htail
, ch
, 0);
1088 tmp
= hangul_join(pm
->hlead
, pm
->hvowel
, 0);
1089 kbd_delchar(text
, &editpos
);
1090 kbd_inschar(text
, buflen
, &editpos
, tmp
);
1091 /* insert dummy char */
1092 kbd_inschar(text
, buflen
, &editpos
, ' ');
1093 pm
->hlead
= pm
->htail
;
1099 pm
->hvowel
= pm
->htail
= 0;
1104 /* combine into hangul */
1105 tmp
= hangul_join(pm
->hlead
, pm
->hvowel
, pm
->htail
);
1109 kbd_delchar(text
, &editpos
);
1114 pm
->hvowel
= pm
->htail
= 0;
1124 kbd_inschar(text
, buflen
, &editpos
, ch
);
1127 if (global_settings
.talk_menu
) /* voice UI? */
1128 talk_spell(text
, false);
1130 /* speak revised text */
1133 #if !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS)
1134 case ACTION_KBD_BACKSPACE
:
1139 else if (pm
->hvowel
)
1145 kbd_delchar(text
, &editpos
);
1150 ch
= hangul_join(pm
->hlead
, pm
->hvowel
, pm
->htail
);
1153 kbd_inschar(text
, buflen
, &editpos
, ch
);
1156 if (global_settings
.talk_menu
) /* voice UI? */
1157 talk_spell(text
, false); /* speak revised text */
1160 case ACTION_KBD_CURSOR_RIGHT
:
1163 if (editpos
< len_utf8
)
1165 int c
= utf8seek(text
, ++editpos
);
1166 kbd_spellchar(text
[c
]);
1168 #if CONFIG_CODEC == SWCODEC
1169 else if (global_settings
.talk_menu
)
1170 pcmbuf_beep(1000, 150, 1500);
1174 case ACTION_KBD_CURSOR_LEFT
:
1179 int c
= utf8seek(text
, --editpos
);
1180 kbd_spellchar(text
[c
]);
1182 #if CONFIG_CODEC == SWCODEC
1183 else if (global_settings
.talk_menu
)
1184 pcmbuf_beep(1000, 150, 1500);
1187 #endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */
1190 gui_syncstatusbar_draw(&statusbars
, false);
1191 #ifdef KBD_MORSE_INPUT
1195 logf("Morse: 0x%02x", morse_code
);
1196 morse_reading
= false;
1198 for (j
= 0; morse_alphabets
[j
] != '\0'; j
++)
1200 if (morse_codes
[j
] == morse_code
)
1204 if (morse_alphabets
[j
] == '\0')
1206 logf("Morse code not found");
1210 /* turn off hangul input */
1212 param
[l
].hangul
= false;
1213 kbd_inschar(text
, buflen
, &editpos
, morse_alphabets
[j
]);
1215 if (global_settings
.talk_menu
) /* voice UI? */
1216 talk_spell(text
, false); /* speak revised text */
1218 #endif /* KBD_MORSE_INPUT */
1222 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
1225 screens
[l
].setfont(FONT_SYSFIXED
);
1231 if (button
!= BUTTON_NONE
)
1237 #ifdef HAS_BUTTONBAR
1238 global_settings
.buttonbar
= buttonbar_config
;
1242 screens
[l
].setfont(FONT_UI
);