1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Bj�rn Stenberg
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 #include "statusbar.h"
31 #include "rbunicode.h"
32 #include "buttonbar.h"
46 #define DEFAULT_MARGIN 6
47 #define KBD_BUF_SIZE 500
49 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
50 (CONFIG_KEYPAD == IRIVER_H300_PAD)
51 #define KBD_CURSOR_KEYS /* certain key combos move the cursor even if not
53 #define KBD_MODES /* I-Rivers can use picker, line edit and cursor keys */
54 #define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */
56 #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
57 #define KBD_MODES /* Ondio uses 2 modes, picker and line edit */
59 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
60 || (CONFIG_KEYPAD == IPOD_4G_PAD)
61 #define KBD_MODES /* iPod uses 2 modes, picker and line edit */
62 #define KBD_MORSE_INPUT
64 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
65 #define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */
67 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
68 #define KBD_MODES /* iAudios use 2 modes, picker and line edit */
70 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
71 #define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */
72 #define KBD_MORSE_INPUT
74 #elif CONFIG_KEYPAD == GIGABEAT_PAD
75 #define KBD_CURSOR_KEYS
77 #define KBD_MORSE_INPUT
79 #elif CONFIG_KEYPAD == SANSA_E200_PAD
80 #define KBD_CURSOR_KEYS
84 struct keyboard_parameters
86 const unsigned char* default_kbd
;
88 unsigned short kbd_buf
[KBD_BUF_SIZE
];
111 unsigned short hlead
, hvowel
, htail
;
114 static struct keyboard_parameters kbd_param
[NB_SCREENS
];
115 static bool kbd_loaded
= false;
117 #ifdef KBD_MORSE_INPUT
118 /* FIXME: We should put this to a configuration file. */
119 static const char *morse_alphabets
=
120 "abcdefghijklmnopqrstuvwxyz1234567890,.?-@ ";
121 static const unsigned char morse_codes
[] = {
122 0x05,0x18,0x1a,0x0c,0x02,0x12,0x0e,0x10,0x04,0x17,0x0d,0x14,0x07,
123 0x06,0x0f,0x16,0x1d,0x0a,0x08,0x03,0x09,0x11,0x0b,0x19,0x1b,0x1c,
124 0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f,
125 0x73,0x55,0x4c,0x61,0x5a,0x80 };
127 static bool morse_mode
= false;
130 /* Loads a custom keyboard into memory
131 call with NULL to reset keyboard */
132 int load_kbd(unsigned char* filename
)
136 unsigned char buf
[4];
138 if (filename
== NULL
)
144 fd
= open(filename
, O_RDONLY
|O_BINARY
);
148 while (read(fd
, buf
, 1) == 1 && i
< KBD_BUF_SIZE
)
150 /* check how many bytes to read for this character */
151 static const unsigned char sizes
[4] = { 0x80, 0xe0, 0xf0, 0xf5 };
154 for (count
= 0; count
< ARRAYLEN(sizes
); count
++)
156 if (buf
[0] < sizes
[count
])
160 if (count
>= ARRAYLEN(sizes
))
161 continue; /* Invalid size. */
163 if (read(fd
, &buf
[1], count
) != (ssize_t
)count
)
171 utf8decode(buf
, &kbd_param
[l
].kbd_buf
[i
]);
173 if (kbd_param
[0].kbd_buf
[i
] != 0xFEFF &&
174 kbd_param
[0].kbd_buf
[i
] != '\r') /*skip BOM & carriage returns */
184 kbd_param
[l
].nchars
= i
;
189 /* helper function to spell a char if voice UI is enabled */
190 static void kbd_spellchar(unsigned short c
)
192 if (global_settings
.talk_menu
) /* voice UI? */
194 unsigned char tmp
[5];
195 /* store char to pass to talk_spell */
196 unsigned char* utf8
= utf8encode(c
, tmp
);
200 talk_id(VOICE_BLANK
, false);
202 talk_spell(tmp
, false);
207 static void say_edit(void)
209 if(global_settings
.talk_menu
)
210 talk_id(VOICE_EDIT
, false);
214 static void kbd_inschar(unsigned char* text
, int buflen
,
215 int* editpos
, unsigned short ch
)
218 unsigned char tmp
[4];
222 k
= utf8length(text
);
223 utf8
= utf8encode(ch
, tmp
);
224 j
= (long)utf8
- (long)tmp
;
226 if (len
+ j
< buflen
)
228 for (i
= len
+j
; k
>= *editpos
; i
--)
231 if ((text
[i
] & MASK
) != COMP
)
242 static void kbd_delchar(unsigned char* text
, int* editpos
)
249 utf8
= text
+ utf8seek(text
, *editpos
);
256 while ((*utf8
& MASK
) == COMP
);
269 /* Lookup k value based on state of param (pm) */
270 static int get_param_k(const struct keyboard_parameters
*pm
)
272 return (pm
->page
*pm
->lines
+ pm
->y
)*pm
->max_chars
+ pm
->x
;
275 int kbd_input(char* text
, int buflen
)
279 /* This seems to keep the sizes for ARM way down */
280 struct keyboard_parameters
* volatile param
= kbd_param
;
282 struct keyboard_parameters
* const param
= kbd_param
;
284 int l
; /* screen loop variable */
286 int editpos
; /* Edit position on all screens */
287 const int statusbar_size
= global_settings
.statusbar
288 ? STATUSBAR_HEIGHT
: 0;
291 bool cur_blink
= true; /* Cursor on/off flag */
292 #ifdef KBD_MORSE_INPUT
293 bool morse_reading
= false;
294 unsigned char morse_code
= 0;
301 struct keyboard_parameters
*pm
= ¶m
[l
];
302 #if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
303 struct screen
*sc
= &screens
[l
];
305 if (sc
->getwidth() >= 160 && sc
->getheight() >= 96)
308 "ABCDEFG abcdefg !?\" @#$%+'\n"
309 "HIJKLMN hijklmn 789 &_()-`\n"
310 "OPQRSTU opqrstu 456 §|{}/<\n"
311 "VWXYZ., vwxyz.,0123 ~=[]*>\n"
312 "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË ¢£¤¥¦§©®\n"
313 "àáâãäåæ ìíîï èéêë «»°ºª¹²³\n"
314 "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
315 "òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
317 pm
->DEFAULT_LINES
= 8;
320 #endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
323 "ABCDEFG !?\" @#$%+'\n"
324 "HIJKLMN 789 &_()-`\n"
325 "OPQRSTU 456 §|{}/<\n"
326 "VWXYZ.,0123 ~=[]*>\n"
328 "abcdefg ¢£¤¥¦§©®¬\n"
329 "hijklmn «»°ºª¹²³¶\n"
330 "opqrstu ¯±×÷¡¿µ·¨\n"
333 "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË\n"
334 "àáâãäåæ ìíîï èéêë\n"
335 "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
338 pm
->DEFAULT_LINES
= 4;
343 #ifdef HAVE_BUTTONBAR
344 struct gui_buttonbar buttonbar
;
345 bool buttonbar_config
= global_settings
.buttonbar
;
347 global_settings
.buttonbar
= true;
348 gui_buttonbar_init(&buttonbar
);
351 gui_buttonbar_set_display(&buttonbar
, &screens
[l
]);
356 struct keyboard_parameters
*pm
= ¶m
[l
];
360 /* Copy default keyboard to buffer */
361 const unsigned char *p
= pm
->default_kbd
;
364 pm
->curfont
= FONT_SYSFIXED
;
367 p
= utf8decode(p
, &pm
->kbd_buf
[i
++]);
373 pm
->curfont
= FONT_UI
;
379 struct keyboard_parameters
*pm
= ¶m
[l
];
380 struct screen
*sc
= &screens
[l
];
383 pm
->font
= font_get(pm
->curfont
);
384 pm
->font_h
= pm
->font
->height
;
386 /* check if FONT_UI fits the screen */
387 if (2*pm
->font_h
+ 3 + statusbar_size
+
388 BUTTONBAR_HEIGHT
> sc
->getheight())
390 pm
->font
= font_get(FONT_SYSFIXED
);
391 pm
->font_h
= pm
->font
->height
;
392 pm
->curfont
= FONT_SYSFIXED
;
395 sc
->setfont(pm
->curfont
);
396 pm
->font_w
= 0; /* reset font width */
397 /* find max width of keyboard glyphs */
398 for (i
= 0; i
< pm
->nchars
; i
++)
400 w
= font_get_width(pm
->font
, pm
->kbd_buf
[i
]);
401 if ( w
> pm
->font_w
)
405 /* Since we're going to be adding spaces, make sure that we check
407 w
= font_get_width( pm
->font
, ' ' );
408 if ( w
> pm
->font_w
)
414 struct keyboard_parameters
*pm
= ¶m
[l
];
415 struct screen
*sc
= &screens
[l
];
418 /* Pad lines with spaces */
419 while (i
< pm
->nchars
)
421 if (pm
->kbd_buf
[i
] == '\n')
423 int k
= sc
->getwidth() / pm
->font_w
424 - i
% ( sc
->getwidth() / pm
->font_w
) - 1;
427 if (k
== sc
->getwidth() / pm
->font_w
- 1)
431 for (j
= i
; j
< pm
->nchars
; j
++)
433 pm
->kbd_buf
[j
] = pm
->kbd_buf
[j
+ 1];
438 if (pm
->nchars
+ k
- 1 >= KBD_BUF_SIZE
)
439 { /* We don't want to overflow the buffer */
440 k
= KBD_BUF_SIZE
- pm
->nchars
;
443 for (j
= pm
->nchars
+ k
- 1; j
> i
+ k
; j
--)
445 pm
->kbd_buf
[j
] = pm
->kbd_buf
[j
-k
];
453 pm
->kbd_buf
[i
++] = ' ';
464 /* Find max width for text string */
468 struct keyboard_parameters
*pm
= ¶m
[l
];
469 struct screen
*sc
= &screens
[l
];
475 int w
= font_get_width(pm
->font
, ch
);
476 utf8
= (unsigned char*)utf8decode(utf8
, &ch
);
482 pm
->max_chars_text
= sc
->getwidth() / text_w
- 2;
484 /* Calculate keyboard grid size */
485 pm
->max_chars
= sc
->getwidth() / pm
->font_w
;
489 pm
->lines
= pm
->DEFAULT_LINES
;
490 pm
->keyboard_margin
= DEFAULT_MARGIN
;
494 pm
->lines
= (sc
->getheight() - BUTTONBAR_HEIGHT
- statusbar_size
)
496 pm
->keyboard_margin
= sc
->getheight() - BUTTONBAR_HEIGHT
-
497 statusbar_size
- (pm
->lines
+1)*pm
->font_h
;
499 if (pm
->keyboard_margin
< 3)
502 pm
->keyboard_margin
+= pm
->font_h
;
505 if (pm
->keyboard_margin
> 6)
506 pm
->keyboard_margin
= 6;
509 pm
->pages
= (pm
->nchars
+ (pm
->lines
*pm
->max_chars
-1))
510 / (pm
->lines
*pm
->max_chars
);
512 if (pm
->pages
== 1 && kbd_loaded
)
513 pm
->lines
= (pm
->nchars
+ pm
->max_chars
- 1) / pm
->max_chars
;
515 pm
->main_y
= pm
->font_h
*pm
->lines
+ pm
->keyboard_margin
+ statusbar_size
;
517 pm
->keyboard_margin
-= pm
->keyboard_margin
/2;
519 #ifdef KBD_MORSE_INPUT
520 pm
->old_main_y
= pm
->main_y
;
522 pm
->main_y
= sc
->getheight() - pm
->font_h
;
526 /* Initial edit position is after last character */
527 editpos
= utf8length(text
);
529 if (global_settings
.talk_menu
) /* voice UI? */
530 talk_spell(text
, true); /* spell initial text */
535 /* These declarations are assigned to the screen on which the key
536 action occurred - pointers save a lot of space over array notation
537 when accessing the same array element countless times */
542 const int button_screen
= 0;
544 struct keyboard_parameters
*pm
;
547 int len_utf8
= utf8length(text
);
550 screens
[l
].clear_display();
552 #ifdef KBD_MORSE_INPUT
557 /* declare scoped pointers inside screen loops - hide the
558 declarations from previous block level */
559 const int w
= 6; /* sysfixed font width */
560 struct keyboard_parameters
*pm
= ¶m
[l
];
561 struct screen
*sc
= &screens
[l
];
564 sc
->setfont(FONT_SYSFIXED
); /* Draw morse code screen with sysfont */
566 pm
->y
= statusbar_size
;
569 /* Draw morse code table with code descriptions. */
570 for (i
= 0; morse_alphabets
[i
] != '\0'; i
++)
575 buf
[0] = morse_alphabets
[i
];
576 sc
->putsxy(pm
->x
, pm
->y
, buf
);
578 for (j
= 0; (morse_codes
[i
] >> j
) > 0x01; j
++) ;
582 for (j
= 0; j
< morse_len
; j
++)
584 if ((morse_codes
[i
] >> (morse_len
-j
-1)) & 0x01)
585 sc
->fillrect(pm
->x
+ j
*4, pm
->y
+ 2, 3, 4);
587 sc
->fillrect(pm
->x
+ j
*4, pm
->y
+ 3, 1, 2);
591 if (pm
->x
>= sc
->getwidth() - w
*6)
594 pm
->y
+= 8; /* sysfixed font height */
600 #endif /* KBD_MORSE_INPUT */
605 struct keyboard_parameters
*pm
= ¶m
[l
];
606 struct screen
*sc
= &screens
[l
];
609 sc
->setfont(pm
->curfont
);
611 k
= pm
->page
*pm
->max_chars
*pm
->lines
;
613 for (i
= j
= 0; j
< pm
->lines
&& k
< pm
->nchars
; k
++)
616 utf8
= utf8encode(pm
->kbd_buf
[k
], outline
);
619 sc
->getstringsize(outline
, &w
, NULL
);
620 sc
->putsxy(i
*pm
->font_w
+ (pm
->font_w
-w
) / 2,
621 j
*pm
->font_h
+ statusbar_size
, outline
);
623 if (++i
>= pm
->max_chars
)
635 struct keyboard_parameters
*pm
= ¶m
[l
];
636 struct screen
*sc
= &screens
[l
];
639 /* Clear text area one pixel above separator line so any overdraw
641 sc
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
642 sc
->fillrect(0, pm
->main_y
- pm
->keyboard_margin
- 1,
643 sc
->getwidth(), pm
->font_h
+ 4);
644 sc
->set_drawmode(DRMODE_SOLID
);
646 sc
->hline(0, sc
->getwidth() - 1, pm
->main_y
- pm
->keyboard_margin
);
648 /* write out the text */
649 sc
->setfont(pm
->curfont
);
651 pm
->curpos
= MIN(editpos
, pm
->max_chars_text
652 - MIN(len_utf8
- editpos
, 2));
653 pm
->leftpos
= editpos
- pm
->curpos
;
654 utf8
= text
+ utf8seek(text
, pm
->leftpos
);
658 while (*utf8
&& i
< pm
->max_chars_text
)
660 outline
[j
++] = *utf8
++;
662 if ((*utf8
& MASK
) != COMP
)
668 sc
->getstringsize(outline
, &w
, NULL
);
669 sc
->putsxy(i
*text_w
+ (text_w
-w
)/2, pm
->main_y
, outline
);
675 /* Draw nicer bitmap arrow if room, else settle for "<". */
676 if (text_w
>= 6 && pm
->font_h
>= 8)
678 screen_put_iconxy(sc
, (text_w
- 6) / 2,
679 pm
->main_y
+ (pm
->font_h
- 8) / 2 ,
680 Icon_Reverse_Cursor
);
685 sc
->getstringsize("<", &w
, NULL
);
686 sc
->putsxy(text_w
- w
, pm
->main_y
, "<");
690 if (len_utf8
- pm
->leftpos
> pm
->max_chars_text
)
692 /* Draw nicer bitmap arrow if room, else settle for ">". */
693 if (text_w
>= 6 && pm
->font_h
>= 8)
695 screen_put_iconxy(sc
, sc
->getwidth() - text_w
+
697 pm
->main_y
+ (pm
->font_h
- 8) / 2,
702 sc
->putsxy(sc
->getwidth() - 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
;
719 #ifdef HAVE_BUTTONBAR
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
->getwidth(), 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
);
771 #ifdef HAVE_BUTTONBAR
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
->getheight() - 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 HAVE_BUTTONBAR
1238 global_settings
.buttonbar
= buttonbar_config
;
1242 screens
[l
].setfont(FONT_UI
);