summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2004-11-14 23:08:08 +0000
committerJens Arnold <amiconn@rockbox.org>2004-11-14 23:08:08 +0000
commit7b95e6091eae6d2d8aab6d5b66024f5b7cee7dbd (patch)
treee47c4170004eed8d89e353a3beb908fa1bc3a8e5
parentaeedd7d4999e1cf77efff7fbb47361fa39a1638b (diff)
downloadrockbox-7b95e6091eae6d2d8aab6d5b66024f5b7cee7dbd.tar.gz
rockbox-7b95e6091eae6d2d8aab6d5b66024f5b7cee7dbd.zip
Improved keyboard handling for Ondio, avoiding unintuitive key combos: (1) Uses 2 modes, picker and line edit, selectable by moving the cursor vertically. (2) Flips between pages on left/right wrap. No dedicated shift key.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5409 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/recorder/keyboard.c201
1 files changed, 149 insertions, 52 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 126a30cc83..e415166e3e 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -43,14 +43,11 @@
43#define KBD_ABORT BUTTON_OFF 43#define KBD_ABORT BUTTON_OFF
44#define KBD_BACKSPACE BUTTON_F3 44#define KBD_BACKSPACE BUTTON_F3
45#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */ 45#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
46#define KBD_CURSOR_RIGHT (BUTTON_MENU | BUTTON_RIGHT) 46#define KBD_MODES /* Ondio uses 2 modes, picker and line edit */
47#define KBD_CURSOR_LEFT (BUTTON_MENU | BUTTON_LEFT) 47#define KBD_SELECT (BUTTON_MENU | BUTTON_REL) /* backspace in line edit */
48#define KBD_SELECT (BUTTON_MENU | BUTTON_REL)
49#define KBD_SELECT_PRE BUTTON_MENU 48#define KBD_SELECT_PRE BUTTON_MENU
50#define KBD_PAGE_FLIP (BUTTON_MENU | BUTTON_UP) 49#define KBD_DONE (BUTTON_MENU | BUTTON_REPEAT)
51#define KBD_DONE (BUTTON_OFF | BUTTON_REL) 50#define KBD_ABORT BUTTON_OFF
52#define KBD_ABORT (BUTTON_OFF | BUTTON_REPEAT)
53#define KBD_BACKSPACE (BUTTON_MENU | BUTTON_DOWN)
54#endif 51#endif
55 52
56 53
@@ -107,6 +104,9 @@ int kbd_input(char* text, int buflen)
107 int editpos; 104 int editpos;
108 bool redraw = true; 105 bool redraw = true;
109 const char* line[KEYBOARD_LINES]; 106 const char* line[KEYBOARD_LINES];
107#ifdef KBD_MODES
108 bool line_edit = false;
109#endif
110 110
111 char outline[256]; 111 char outline[256];
112 char c = 0; 112 char c = 0;
@@ -138,7 +138,7 @@ int kbd_input(char* text, int buflen)
138 if(redraw) 138 if(redraw)
139 { 139 {
140 lcd_clear_display(); 140 lcd_clear_display();
141 141
142 lcd_setfont(FONT_SYSFIXED); 142 lcd_setfont(FONT_SYSFIXED);
143 143
144 /* draw page */ 144 /* draw page */
@@ -198,7 +198,7 @@ int kbd_input(char* text, int buflen)
198 outline[max_chars - 2] = '\0'; 198 outline[max_chars - 2] = '\0';
199 199
200 lcd_putsxy(font_w,main_y,outline); 200 lcd_putsxy(font_w,main_y,outline);
201 201
202 /* cursor */ 202 /* cursor */
203 lcd_drawline(curpos, main_y, curpos, main_y + font_h); 203 lcd_drawline(curpos, main_y, curpos, main_y + font_h);
204 204
@@ -207,9 +207,13 @@ int kbd_input(char* text, int buflen)
207 buttonbar_set("Shift", "OK", "Del"); 207 buttonbar_set("Shift", "OK", "Del");
208 buttonbar_draw(); 208 buttonbar_draw();
209#endif 209#endif
210 /* highlight the key that has focus */
211 lcd_invertrect(font_w * x, 8 + font_h * y, font_w, font_h);
212 210
211#ifdef KBD_MODES
212 if (!line_edit)
213#endif
214 /* highlight the key that has focus */
215 lcd_invertrect(font_w * x, 8 + font_h * y, font_w, font_h);
216
213 status_draw(true); 217 status_draw(true);
214 218
215 lcd_update(); 219 lcd_update();
@@ -226,62 +230,119 @@ int kbd_input(char* text, int buflen)
226 return -1; 230 return -1;
227 break; 231 break;
228 232
233#ifdef KBD_PAGE_FLIP
229 case KBD_PAGE_FLIP: 234 case KBD_PAGE_FLIP:
230 if (++page == KEYBOARD_PAGES) 235 if (++page == KEYBOARD_PAGES)
231 page = 0; 236 page = 0;
232 kbd_setupkeys(line, page); 237 kbd_setupkeys(line, page);
233 kbd_spellchar(line[y][x]); 238 kbd_spellchar(line[y][x]);
234 break; 239 break;
240#endif
235 241
236 case BUTTON_RIGHT: 242 case BUTTON_RIGHT:
237 case BUTTON_RIGHT | BUTTON_REPEAT: 243 case BUTTON_RIGHT | BUTTON_REPEAT:
238 if (x < (int)strlen(line[y]) - 1) 244#ifdef KBD_MODES
239 x++; 245 if (line_edit) /* right doubles as cursor_right in line_edit */
246 {
247 editpos++;
248 if (editpos > len)
249 editpos = len;
250 else
251 kbd_spellchar(text[editpos]);
252 }
240 else 253 else
241 x = 0; 254#endif
242 kbd_spellchar(line[y][x]); 255 {
256 if (x < (int)strlen(line[y]) - 1)
257 x++;
258 else
259 {
260 x = 0;
261#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
262 if (++page == KEYBOARD_PAGES)
263 page = 0;
264 kbd_setupkeys(line, page);
265#endif
266 }
267 kbd_spellchar(line[y][x]);
268 }
243 break; 269 break;
244 270
245 case BUTTON_LEFT: 271 case BUTTON_LEFT:
246 case BUTTON_LEFT | BUTTON_REPEAT: 272 case BUTTON_LEFT | BUTTON_REPEAT:
247 if (x) 273#ifdef KBD_MODES
248 x--; 274 if (line_edit) /* left doubles as cursor_left in line_edit */
275 {
276 editpos--;
277 if (editpos < 0)
278 editpos = 0;
279 else
280 kbd_spellchar(text[editpos]);
281 }
249 else 282 else
250 x = strlen(line[y]) - 1; 283#endif
251 kbd_spellchar(line[y][x]); 284 {
285 if (x)
286 x--;
287 else
288 {
289#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
290 if (--page < 0)
291 page = (KEYBOARD_PAGES-1);
292 kbd_setupkeys(line, page);
293#endif
294 x = strlen(line[y]) - 1;
295 }
296 kbd_spellchar(line[y][x]);
297 }
252 break; 298 break;
253 299
254 case BUTTON_DOWN: 300 case BUTTON_DOWN:
255 case BUTTON_DOWN | BUTTON_REPEAT: 301 case BUTTON_DOWN | BUTTON_REPEAT:
256 if (y < KEYBOARD_LINES - 1) 302#ifdef KBD_MODES
257 y++; 303 if (line_edit)
304 {
305 y = 0;
306 line_edit = false;
307 }
258 else 308 else
259 y=0; 309 {
260 kbd_spellchar(line[y][x]); 310#endif
311 if (y < KEYBOARD_LINES - 1)
312 y++;
313 else
314#ifndef KBD_MODES
315 y=0;
316#else
317 line_edit = true;
318 }
319 if (!line_edit)
320#endif
321 kbd_spellchar(line[y][x]);
261 break; 322 break;
262 323
263 case BUTTON_UP: 324 case BUTTON_UP:
264 case BUTTON_UP | BUTTON_REPEAT: 325 case BUTTON_UP | BUTTON_REPEAT:
265 if (y) 326#ifdef KBD_MODES
266 y--; 327 if (line_edit)
267 else 328 {
268 y = KEYBOARD_LINES - 1; 329 y = KEYBOARD_LINES - 1;
269 kbd_spellchar(line[y][x]); 330 line_edit = false;
270 break; 331 }
271 332 else
272 case KBD_BACKSPACE:
273 case KBD_BACKSPACE | BUTTON_REPEAT:
274 if (editpos > 0)
275 { 333 {
276 for (i = editpos; i <= (len - 1);i++) 334#endif
277 { 335 if (y)
278 text[i-1] = text[i]; 336 y--;
279 } 337 else
280 text[i-1]='\0'; 338#ifndef KBD_MODES
281 editpos--; 339 y = KEYBOARD_LINES - 1;
282 if (editpos < 0) 340#else
283 editpos=0; 341 line_edit = true;
284 } 342 }
343 if (!line_edit)
344#endif
345 kbd_spellchar(line[y][x]);
285 break; 346 break;
286 347
287 case KBD_DONE: 348 case KBD_DONE:
@@ -295,24 +356,59 @@ int kbd_input(char* text, int buflen)
295 if (lastbutton != KBD_SELECT_PRE) 356 if (lastbutton != KBD_SELECT_PRE)
296 break; 357 break;
297#endif 358#endif
298 if (len<buflen) 359#ifdef KBD_MODES
360 if (line_edit) /* select doubles as backspace in line_edit */
299 { 361 {
300 c = line[y][x]; 362 if (editpos > 0)
301 if ( editpos == len )
302 { 363 {
303 text[len] = c; 364 for (i = editpos; i <= (len - 1);i++)
304 text[len+1] = 0; 365 {
366 text[i-1] = text[i];
367 }
368 text[i-1]='\0';
369 editpos--;
370 if (editpos < 0)
371 editpos=0;
305 } 372 }
306 else 373 }
374 else
375#endif
376 {
377 if (len<buflen)
307 { 378 {
308 for (i = len ; i + 1 > editpos; i--) 379 c = line[y][x];
309 text[i+1] = text[i]; 380 if ( editpos == len )
310 text[editpos] = c; 381 {
382 text[len] = c;
383 text[len+1] = 0;
384 }
385 else
386 {
387 for (i = len ; i + 1 > editpos; i--)
388 text[i+1] = text[i];
389 text[editpos] = c;
390 }
391 editpos++;
311 } 392 }
312 editpos++; 393 if (global_settings.talk_menu) /* voice UI? */
394 talk_spell(text, false); /* speak revised text */
395 }
396 break;
397
398#ifndef KBD_MODES
399 case KBD_BACKSPACE:
400 case KBD_BACKSPACE | BUTTON_REPEAT:
401 if (editpos > 0)
402 {
403 for (i = editpos; i <= (len - 1);i++)
404 {
405 text[i-1] = text[i];
406 }
407 text[i-1]='\0';
408 editpos--;
409 if (editpos < 0)
410 editpos=0;
313 } 411 }
314 if (global_settings.talk_menu) /* voice UI? */
315 talk_spell(text, false); /* speak revised text */
316 break; 412 break;
317 413
318 case KBD_CURSOR_RIGHT: 414 case KBD_CURSOR_RIGHT:
@@ -332,6 +428,7 @@ int kbd_input(char* text, int buflen)
332 else 428 else
333 kbd_spellchar(text[editpos]); 429 kbd_spellchar(text[editpos]);
334 break; 430 break;
431#endif /* !KBD_MODES */
335 432
336 case BUTTON_NONE: 433 case BUTTON_NONE:
337 status_draw(false); 434 status_draw(false);