summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-06-09 12:08:25 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-06-09 12:08:25 +0000
commit89033394445d174867dae614f91747aab826d9fc (patch)
treee0ffdd21e3f30dd1c792ad405d2cf5322bad340a /apps
parent8bdb1c04d3ea9fd6460506ca05de506416e1d750 (diff)
downloadrockbox-89033394445d174867dae614f91747aab826d9fc.tar.gz
rockbox-89033394445d174867dae614f91747aab826d9fc.zip
keyboard: clean up. remove unneeded #ifdefs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26720 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/keyboard.c110
1 files changed, 37 insertions, 73 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index e4632bbc6c..e8894d179b 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -47,24 +47,6 @@
47#define DEFAULT_MARGIN 6 47#define DEFAULT_MARGIN 6
48#define KBD_BUF_SIZE 500 48#define KBD_BUF_SIZE 500
49 49
50#if (CONFIG_KEYPAD == ONDIO_PAD) \
51 || (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
52 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
53 || (CONFIG_KEYPAD == IPOD_4G_PAD) \
54 || (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) \
55 || (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) \
56 || (CONFIG_KEYPAD == IAUDIO_M3_PAD) \
57 || (CONFIG_KEYPAD == IRIVER_H10_PAD) \
58 || (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
59/* no key combos to move the cursor if not in line edit mode */
60#define KBD_MODES /* uses 2 modes, picker and line edit */
61
62#else
63/* certain key combos move the cursor even if not in line edit mode */
64#define KBD_CURSOR_KEYS
65#define KBD_MODES /* uses 2 modes, picker and line edit */
66#endif
67
68#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \ 50#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \
69 || (CONFIG_KEYPAD == IRIVER_H300_PAD) \ 51 || (CONFIG_KEYPAD == IRIVER_H300_PAD) \
70 || (CONFIG_KEYPAD == IPOD_1G2G_PAD) \ 52 || (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
@@ -110,9 +92,7 @@ struct keyboard_parameters
110 int page; 92 int page;
111 int x; 93 int x;
112 int y; 94 int y;
113#ifdef KBD_MODES
114 bool line_edit; 95 bool line_edit;
115#endif
116}; 96};
117 97
118struct edit_state 98struct edit_state
@@ -296,6 +276,8 @@ static void kbd_insert_selected(struct keyboard_parameters *pm,
296 struct edit_state *state); 276 struct edit_state *state);
297static void kbd_backspace(struct edit_state *state); 277static void kbd_backspace(struct edit_state *state);
298static void kbd_move_cursor(struct edit_state *state, int dir); 278static void kbd_move_cursor(struct edit_state *state, int dir);
279static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
280 struct edit_state *state, int dir);
299static void kbd_move_picker_vertical(struct keyboard_parameters *pm, 281static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
300 struct edit_state *state, int dir); 282 struct edit_state *state, int dir);
301 283
@@ -456,28 +438,19 @@ int kbd_input(char* text, int buflen)
456 pm = &param[button_screen]; 438 pm = &param[button_screen];
457 sc = &screens[button_screen]; 439 sc = &screens[button_screen];
458 440
459#if defined(KBD_MODES) || defined(HAVE_MORSE_INPUT)
460 /* Remap some buttons to allow to move 441 /* Remap some buttons to allow to move
461 * cursor in line edit mode and morse mode. */ 442 * cursor in line edit mode and morse mode. */
462#if defined(KBD_MODES) && defined(HAVE_MORSE_INPUT) 443 if (pm->line_edit
463 if (pm->line_edit || state.morse_mode) 444#ifdef HAVE_MORSE_INPUT
464#elif defined(KBD_MODES) 445 || state.morse_mode
465 if (pm->line_edit) 446#endif /* HAVE_MORSE_INPUT */
466#else /* defined(HAVE_MORSE_INPUT) */ 447 )
467 if (state.morse_mode)
468#endif
469 { 448 {
470 if (button == ACTION_KBD_LEFT) 449 if (button == ACTION_KBD_LEFT)
471 button = ACTION_KBD_CURSOR_LEFT; 450 button = ACTION_KBD_CURSOR_LEFT;
472 if (button == ACTION_KBD_RIGHT) 451 if (button == ACTION_KBD_RIGHT)
473 button = ACTION_KBD_CURSOR_RIGHT; 452 button = ACTION_KBD_CURSOR_RIGHT;
474#ifdef KBD_MODES
475 /* select doubles as backspace in line_edit */
476 if (pm->line_edit && button == ACTION_KBD_SELECT)
477 button = ACTION_KBD_BACKSPACE;
478#endif
479 } 453 }
480#endif /* defined(KBD_MODES) || defined(HAVE_MORSE_INPUT) */
481 454
482 switch ( button ) 455 switch ( button )
483 { 456 {
@@ -504,31 +477,11 @@ int kbd_input(char* text, int buflen)
504 break; 477 break;
505 478
506 case ACTION_KBD_RIGHT: 479 case ACTION_KBD_RIGHT:
507 if (++pm->x >= pm->max_chars) 480 kbd_move_picker_horizontal(pm, &state, 1);
508 {
509#ifndef KBD_PAGE_FLIP
510 /* no dedicated flip key - flip page on wrap */
511 if (++pm->page >= pm->pages)
512 pm->page = 0;
513#endif
514 pm->x = 0;
515 }
516
517 state.changed = CHANGED_PICKER;
518 break; 481 break;
519 482
520 case ACTION_KBD_LEFT: 483 case ACTION_KBD_LEFT:
521 if (--pm->x < 0) 484 kbd_move_picker_horizontal(pm, &state, -1);
522 {
523#ifndef KBD_PAGE_FLIP
524 /* no dedicated flip key - flip page on wrap */
525 if (--pm->page < 0)
526 pm->page = pm->pages - 1;
527#endif
528 pm->x = pm->max_chars - 1;
529 }
530
531 state.changed = CHANGED_PICKER;
532 break; 485 break;
533 486
534 case ACTION_KBD_DOWN: 487 case ACTION_KBD_DOWN:
@@ -543,6 +496,7 @@ int kbd_input(char* text, int buflen)
543#ifdef KBD_TOGGLE_INPUT 496#ifdef KBD_TOGGLE_INPUT
544 case ACTION_KBD_MORSE_INPUT: 497 case ACTION_KBD_MORSE_INPUT:
545 state.morse_mode = !state.morse_mode; 498 state.morse_mode = !state.morse_mode;
499 state.changed = CHANGED_PICKER;
546 500
547 FOR_NB_SCREENS(l) 501 FOR_NB_SCREENS(l)
548 { 502 {
@@ -551,7 +505,6 @@ int kbd_input(char* text, int buflen)
551 pm->main_y = pm->old_main_y; 505 pm->main_y = pm->old_main_y;
552 pm->old_main_y = y; 506 pm->old_main_y = y;
553 } 507 }
554 /* FIXME: We should talk something like Morse mode.. */
555 break; 508 break;
556#endif /* KBD_TOGGLE_INPUT */ 509#endif /* KBD_TOGGLE_INPUT */
557 510
@@ -566,6 +519,10 @@ int kbd_input(char* text, int buflen)
566#endif /* HAVE_MORSE_INPUT */ 519#endif /* HAVE_MORSE_INPUT */
567 520
568 case ACTION_KBD_SELECT: 521 case ACTION_KBD_SELECT:
522 /* select doubles as backspace in line_edit */
523 if (pm->line_edit)
524 kbd_backspace(&state);
525 else
569#ifdef HAVE_MORSE_INPUT 526#ifdef HAVE_MORSE_INPUT
570 if (state.morse_mode) 527 if (state.morse_mode)
571 { 528 {
@@ -639,14 +596,13 @@ int kbd_input(char* text, int buflen)
639 { 596 {
640 if (state.changed == CHANGED_PICKER) 597 if (state.changed == CHANGED_PICKER)
641 { 598 {
642#ifdef KBD_MODES
643 if (pm->line_edit) 599 if (pm->line_edit)
644 { 600 {
645 talk_id(VOICE_EDIT, false); 601 talk_id(VOICE_EDIT, false);
646 } 602 }
647 else 603 else
648#endif
649#ifdef HAVE_MORSE_INPUT 604#ifdef HAVE_MORSE_INPUT
605 /* FIXME: We should talk something like Morse mode.. */
650 if (!state.morse_mode) 606 if (!state.morse_mode)
651#endif 607#endif
652 { 608 {
@@ -910,9 +866,7 @@ static void kbd_draw_picker(struct keyboard_parameters *pm,
910 } 866 }
911 } 867 }
912 868
913#ifdef KBD_MODES
914 if (!pm->line_edit) 869 if (!pm->line_edit)
915#endif
916 { 870 {
917 /* highlight the key that has focus */ 871 /* highlight the key that has focus */
918 sc->set_drawmode(DRMODE_COMPLEMENT); 872 sc->set_drawmode(DRMODE_COMPLEMENT);
@@ -999,14 +953,12 @@ static void kbd_draw_edit_line(struct keyboard_parameters *pm,
999 if (state->hangul) /* draw underbar */ 953 if (state->hangul) /* draw underbar */
1000 sc->hline(i - pm->text_w, i, pm->main_y + pm->font_h - 1); 954 sc->hline(i - pm->text_w, i, pm->main_y + pm->font_h - 1);
1001 955
1002#ifdef KBD_MODES
1003 if (pm->line_edit) 956 if (pm->line_edit)
1004 { 957 {
1005 sc->set_drawmode(DRMODE_COMPLEMENT); 958 sc->set_drawmode(DRMODE_COMPLEMENT);
1006 sc->fillrect(0, y + 2, sc_w, pm->font_h + 2); 959 sc->fillrect(0, y + 2, sc_w, pm->font_h + 2);
1007 sc->set_drawmode(DRMODE_SOLID); 960 sc->set_drawmode(DRMODE_SOLID);
1008 } 961 }
1009#endif
1010} 962}
1011 963
1012/* inserts the selected char */ 964/* inserts the selected char */
@@ -1126,22 +1078,40 @@ static void kbd_move_cursor(struct edit_state *state, int dir)
1126 } 1078 }
1127} 1079}
1128 1080
1081static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
1082 struct edit_state *state, int dir)
1083{
1084 state->changed = CHANGED_PICKER;
1085
1086 pm->x += dir;
1087 if (pm->x < 0)
1088 {
1089 if (--pm->page < 0)
1090 pm->page = pm->pages - 1;
1091 pm->x = pm->max_chars - 1;
1092 }
1093 else if (pm->x >= pm->max_chars)
1094 {
1095 if (++pm->page >= pm->pages)
1096 pm->page = 0;
1097 pm->x = 0;
1098 }
1099}
1100
1129static void kbd_move_picker_vertical(struct keyboard_parameters *pm, 1101static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
1130 struct edit_state *state, int dir) 1102 struct edit_state *state, int dir)
1131{ 1103{
1132 (void) state;
1133 state->changed = CHANGED_PICKER; 1104 state->changed = CHANGED_PICKER;
1105
1134#ifdef HAVE_MORSE_INPUT 1106#ifdef HAVE_MORSE_INPUT
1135 if (state->morse_mode) 1107 if (state->morse_mode)
1136 { 1108 {
1137#ifdef KBD_MODES
1138 pm->line_edit = !pm->line_edit; 1109 pm->line_edit = !pm->line_edit;
1139#endif
1140 return; 1110 return;
1141 } 1111 }
1142#endif /* HAVE_MORSE_INPUT */ 1112#endif /* HAVE_MORSE_INPUT */
1113
1143 pm->y += dir; 1114 pm->y += dir;
1144#ifdef KBD_MODES
1145 if (pm->line_edit) 1115 if (pm->line_edit)
1146 { 1116 {
1147 pm->y = (dir > 0 ? 0 : pm->lines - 1); 1117 pm->y = (dir > 0 ? 0 : pm->lines - 1);
@@ -1151,10 +1121,4 @@ static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
1151 { 1121 {
1152 pm->line_edit = true; 1122 pm->line_edit = true;
1153 } 1123 }
1154#else
1155 if (pm->y >= pm->lines)
1156 pm->y = 0;
1157 if (pm->y < 0)
1158 pm->y = pm->lines - 1;
1159#endif
1160} 1124}