diff options
Diffstat (limited to 'apps/player')
-rw-r--r-- | apps/player/icons.h | 31 | ||||
-rw-r--r-- | apps/player/keyboard.c | 313 |
2 files changed, 0 insertions, 344 deletions
diff --git a/apps/player/icons.h b/apps/player/icons.h deleted file mode 100644 index 7bb808863b..0000000000 --- a/apps/player/icons.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Justin Heiner | ||
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 _ICONS_H_ | ||
22 | #define _ICONS_H_ | ||
23 | |||
24 | #include <lcd.h> | ||
25 | |||
26 | /* | ||
27 | * Icons of size 5x7 pixels for the Player LCD | ||
28 | */ | ||
29 | |||
30 | |||
31 | #endif /* _ICONS_H_ */ | ||
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c deleted file mode 100644 index ce84bb6d69..0000000000 --- a/apps/player/keyboard.c +++ /dev/null | |||
@@ -1,313 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
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 "lcd.h" | ||
22 | #include "button.h" | ||
23 | #include "kernel.h" | ||
24 | #include "system.h" | ||
25 | #include "version.h" | ||
26 | #include <string.h> | ||
27 | #include "settings.h" | ||
28 | #include "statusbar.h" | ||
29 | #include "talk.h" | ||
30 | #include "misc.h" | ||
31 | #include "rbunicode.h" | ||
32 | #include "lang.h" | ||
33 | #include "keyboard.h" | ||
34 | #include "splash.h" | ||
35 | |||
36 | #define KBD_BUF_SIZE 64 | ||
37 | #define KEYBOARD_PAGES 3 | ||
38 | |||
39 | static unsigned short *kbd_setupkeys(int page, int* len) | ||
40 | { | ||
41 | static unsigned short kbdline[KBD_BUF_SIZE]; | ||
42 | const unsigned char *p; | ||
43 | int i = 0; | ||
44 | |||
45 | switch (page) | ||
46 | { | ||
47 | case 0: /* Capitals */ | ||
48 | p = "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅ" | ||
49 | "ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ"; | ||
50 | break; | ||
51 | |||
52 | case 1: /* Small */ | ||
53 | p = "abcdefghijklmnopqrstuvwxyzßàáâãä" | ||
54 | "åçèéêëìíîïñòóôõöøùúûüýÿ"; | ||
55 | break; | ||
56 | |||
57 | default: /* Others */ | ||
58 | p = " !\"#$%&'()*+,-./0123456789:;<=>?@[]_{}~"; | ||
59 | break; | ||
60 | } | ||
61 | |||
62 | while (*p) | ||
63 | p = utf8decode(p, &kbdline[i++]); | ||
64 | |||
65 | *len = i; | ||
66 | |||
67 | return kbdline; | ||
68 | } | ||
69 | |||
70 | /* Delimiters for highlighting the character selected for insertion */ | ||
71 | #define KEYBOARD_INSERT_LEFT 0xe110 | ||
72 | #define KEYBOARD_INSERT_RIGHT 0xe10f | ||
73 | |||
74 | #define KEYBOARD_CURSOR 0x7f | ||
75 | #define KEYBOARD_ARROW 0xe10c | ||
76 | |||
77 | /* helper function to spell a char if voice UI is enabled */ | ||
78 | static void kbd_spellchar(unsigned short c) | ||
79 | { | ||
80 | if (global_settings.talk_menu) /* voice UI? */ | ||
81 | { | ||
82 | unsigned char tmp[5]; | ||
83 | /* store char to pass to talk_spell */ | ||
84 | unsigned char* utf8 = utf8encode(c, tmp); | ||
85 | *utf8 = 0; | ||
86 | |||
87 | if(c == ' ') | ||
88 | talk_id(VOICE_BLANK, false); | ||
89 | else | ||
90 | talk_spell(tmp, false); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static void say_edit(void) | ||
95 | { | ||
96 | if (global_settings.talk_menu) | ||
97 | talk_id(VOICE_EDIT, false); | ||
98 | } | ||
99 | |||
100 | int kbd_input(char* text, int buflen, unsigned short *kbd) | ||
101 | { | ||
102 | (void) kbd; | ||
103 | bool done = false; | ||
104 | bool redraw = true; | ||
105 | bool line_edit = false; | ||
106 | int page = 0, x = 0; | ||
107 | int linelen; | ||
108 | |||
109 | int len, len_utf8, i, j; | ||
110 | int editpos, curpos, leftpos; | ||
111 | unsigned short *line = kbd_setupkeys(page, &linelen); | ||
112 | unsigned char temptext[36]; | ||
113 | unsigned char *utf8; | ||
114 | |||
115 | int button, lastbutton = 0; | ||
116 | int ret = 0; /* assume success */ | ||
117 | |||
118 | editpos = utf8length(text); | ||
119 | |||
120 | if (global_settings.talk_menu) /* voice UI? */ | ||
121 | talk_spell(text, true); /* spell initial text */ | ||
122 | |||
123 | while (!done) | ||
124 | { | ||
125 | len = strlen(text); | ||
126 | len_utf8 = utf8length(text); | ||
127 | |||
128 | if (redraw) | ||
129 | { | ||
130 | if (line_edit) | ||
131 | { | ||
132 | lcd_putc(0, 0, ' '); | ||
133 | lcd_putc(0, 1, KEYBOARD_ARROW); | ||
134 | } | ||
135 | else | ||
136 | { | ||
137 | lcd_putc(0, 0, KEYBOARD_ARROW); | ||
138 | lcd_putc(0, 1, ' '); | ||
139 | } | ||
140 | |||
141 | lcd_putc(1, 0, KEYBOARD_INSERT_LEFT); | ||
142 | lcd_putc(2, 0, line[x]); | ||
143 | lcd_putc(3, 0, KEYBOARD_INSERT_RIGHT); | ||
144 | for (i = 1; i < 8; i++) | ||
145 | { | ||
146 | lcd_putc(i + 3, 0, line[(x+i)%linelen]); | ||
147 | } | ||
148 | |||
149 | /* write out the text */ | ||
150 | curpos = MIN(MIN(editpos, 10 - MIN(len_utf8 - editpos, 3)), 9); | ||
151 | leftpos = editpos - curpos; | ||
152 | if (!leftpos) { | ||
153 | utf8 = text + utf8seek(text, leftpos); | ||
154 | i = 0; | ||
155 | j = 0; | ||
156 | } else { | ||
157 | temptext[0] = '<'; | ||
158 | i = 1; | ||
159 | j = 1; | ||
160 | utf8 = text + utf8seek(text, leftpos+1); | ||
161 | } | ||
162 | while (*utf8 && i < 10) { | ||
163 | temptext[j++] = *utf8++; | ||
164 | if ((*utf8 & MASK) != COMP) | ||
165 | i++; | ||
166 | } | ||
167 | temptext[j] = 0; | ||
168 | |||
169 | |||
170 | if (len_utf8 - leftpos > 10) { | ||
171 | utf8 = temptext + utf8seek(temptext, 9); | ||
172 | *utf8++ = '>'; | ||
173 | *utf8 = 0; | ||
174 | } | ||
175 | |||
176 | lcd_remove_cursor(); | ||
177 | lcd_puts(1, 1, temptext); | ||
178 | lcd_put_cursor(curpos + 1, 1, KEYBOARD_CURSOR); | ||
179 | |||
180 | gui_syncstatusbar_draw(&statusbars, true); | ||
181 | } | ||
182 | |||
183 | /* The default action is to redraw */ | ||
184 | redraw = true; | ||
185 | |||
186 | button = button_get_w_tmo(HZ/2); | ||
187 | switch (button) | ||
188 | { | ||
189 | case BUTTON_STOP: /* abort */ | ||
190 | ret = -1; done = true; | ||
191 | break; | ||
192 | |||
193 | case BUTTON_MENU: /* page flip */ | ||
194 | if (++page == KEYBOARD_PAGES) | ||
195 | page = 0; | ||
196 | line = kbd_setupkeys(page, &linelen); | ||
197 | if (x > linelen - 1) | ||
198 | x = linelen - 1; | ||
199 | kbd_spellchar(line[x]); | ||
200 | break; | ||
201 | |||
202 | case BUTTON_ON: /* toggle mode */ | ||
203 | line_edit = !line_edit; | ||
204 | if (line_edit) | ||
205 | say_edit(); | ||
206 | else | ||
207 | kbd_spellchar(line[x]); | ||
208 | break; | ||
209 | |||
210 | case BUTTON_RIGHT: | ||
211 | case BUTTON_RIGHT | BUTTON_REPEAT: | ||
212 | if (line_edit) | ||
213 | { | ||
214 | if (editpos < len_utf8) | ||
215 | { | ||
216 | editpos++; | ||
217 | int c = utf8seek(text, editpos); | ||
218 | kbd_spellchar(text[c]); | ||
219 | } | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | if (++x >= linelen) | ||
224 | x = 0; | ||
225 | kbd_spellchar(line[x]); | ||
226 | } | ||
227 | break; | ||
228 | |||
229 | case BUTTON_LEFT: | ||
230 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
231 | if (line_edit) | ||
232 | { | ||
233 | if (editpos) | ||
234 | { | ||
235 | editpos--; | ||
236 | int c = utf8seek(text, editpos); | ||
237 | kbd_spellchar(text[c]); | ||
238 | } | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | if (--x < 0) | ||
243 | x = linelen - 1; | ||
244 | kbd_spellchar(line[x]); | ||
245 | } | ||
246 | break; | ||
247 | |||
248 | case BUTTON_PLAY | BUTTON_REPEAT: | ||
249 | /* accepts what was entered and continues */ | ||
250 | ret = 0; done = true; | ||
251 | break; | ||
252 | |||
253 | case BUTTON_PLAY | BUTTON_REL: | ||
254 | if (lastbutton != BUTTON_PLAY) | ||
255 | break; | ||
256 | if (line_edit) /* backspace in line_edit */ | ||
257 | { | ||
258 | if (editpos > 0) | ||
259 | { | ||
260 | utf8 = text + utf8seek(text, editpos); | ||
261 | i = 0; | ||
262 | do { | ||
263 | i++; | ||
264 | utf8--; | ||
265 | } while ((*utf8 & MASK) == COMP); | ||
266 | while (utf8[i]) { | ||
267 | *utf8 = utf8[i]; | ||
268 | utf8++; | ||
269 | } | ||
270 | *utf8 = 0; | ||
271 | editpos--; | ||
272 | } | ||
273 | } | ||
274 | else /* inserts the selected char */ | ||
275 | { | ||
276 | utf8 = utf8encode(line[x], temptext); | ||
277 | *utf8 = 0; | ||
278 | j = strlen(temptext); | ||
279 | if (len + j < buflen) | ||
280 | { | ||
281 | int k = len_utf8; | ||
282 | for (i = len+j; k >= editpos; i--) { | ||
283 | text[i] = text[i-j]; | ||
284 | if ((text[i] & MASK) != COMP) | ||
285 | k--; | ||
286 | } | ||
287 | while (j--) | ||
288 | text[i--] = temptext[j]; | ||
289 | editpos++; | ||
290 | } | ||
291 | } | ||
292 | if (global_settings.talk_menu) /* voice UI? */ | ||
293 | talk_spell(text, false); /* speak revised text */ | ||
294 | break; | ||
295 | |||
296 | case BUTTON_NONE: | ||
297 | gui_syncstatusbar_draw(&statusbars, false); | ||
298 | redraw = false; | ||
299 | break; | ||
300 | |||
301 | default: | ||
302 | default_event_handler(button); | ||
303 | break; | ||
304 | } | ||
305 | if (button != BUTTON_NONE) | ||
306 | lastbutton = button; | ||
307 | } | ||
308 | |||
309 | if (ret < 0) | ||
310 | splash(HZ/2, ID2P(LANG_CANCEL)); | ||
311 | return ret; | ||
312 | } | ||
313 | |||