summaryrefslogtreecommitdiff
path: root/apps/recorder/keyboard.c
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-11-08 13:14:50 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-11-08 13:14:50 +0000
commit92fb1df03aa1d7cd33bb07f7222e36e954409e52 (patch)
tree79c471e6aceac1ca49ca98bdcb10b7f1b084119a /apps/recorder/keyboard.c
parentb92e778fd71dfc86d41e6ddf68cf7b35477bc927 (diff)
downloadrockbox-92fb1df03aa1d7cd33bb07f7222e36e954409e52.tar.gz
rockbox-92fb1df03aa1d7cd33bb07f7222e36e954409e52.zip
FS#10338: Add "use morse input " entry to settings menu
* Remember last used text input mode (keyboard or morse input) in settings. * Add setting "Use Morse Code Input" under Settings -> General Settings -> System. Now it is possible for some of targets without button combo for changing input mode to use morse input by changing the setting. it's not possible for them to change input mode during in the keyboard screen of course. There are still targets without morse input mode. Flyspray: FS#10338 Author: myself, David Johnston git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23567 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/keyboard.c')
-rw-r--r--apps/recorder/keyboard.c138
1 files changed, 74 insertions, 64 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index e6a3c927e3..1e9e8f32ab 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -49,45 +49,47 @@
49#define DEFAULT_MARGIN 6 49#define DEFAULT_MARGIN 6
50#define KBD_BUF_SIZE 500 50#define KBD_BUF_SIZE 500
51 51
52#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 52#if (CONFIG_KEYPAD == ONDIO_PAD) \
53 (CONFIG_KEYPAD == IRIVER_H300_PAD) 53 || (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
54#define KBD_CURSOR_KEYS /* certain key combos move the cursor even if not 54 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
55 in line edit mode */ 55 || (CONFIG_KEYPAD == IPOD_4G_PAD) \
56#define KBD_MODES /* I-Rivers can use picker, line edit and cursor keys */ 56 || (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) \
57#define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */ 57 || (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) \
58 58 || (CONFIG_KEYPAD == IAUDIO_M3_PAD) \
59#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */ 59 || (CONFIG_KEYPAD == IRIVER_H10_PAD)
60#define KBD_MODES /* Ondio uses 2 modes, picker and line edit */ 60/* no key combos to move the cursor if not in line edit mode */
61 61#define KBD_MODES /* uses 2 modes, picker and line edit */
62#elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \ 62
63 || (CONFIG_KEYPAD == IPOD_4G_PAD) 63#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \
64#define KBD_MODES /* iPod uses 2 modes, picker and line edit */ 64 || (CONFIG_KEYPAD == IRIVER_H300_PAD) \
65#define KBD_MORSE_INPUT 65 || (CONFIG_KEYPAD == GIGABEAT_PAD) \
66 66 || (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
67#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD 67 || (CONFIG_KEYPAD == SANSA_E200_PAD) \
68#define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */ 68 || (CONFIG_KEYPAD == SANSA_FUZE_PAD) \
69 69 || (CONFIG_KEYPAD == SANSA_C200_PAD) \
70#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) 70 || (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
71#define KBD_MODES /* iAudios use 2 modes, picker and line edit */ 71/* certain key combos move the cursor even if not in line edit mode */
72
73#elif CONFIG_KEYPAD == IRIVER_H10_PAD
74#define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */
75#define KBD_MORSE_INPUT
76
77#elif CONFIG_KEYPAD == GIGABEAT_PAD
78#define KBD_CURSOR_KEYS 72#define KBD_CURSOR_KEYS
79#define KBD_MODES 73#define KBD_MODES /* uses 2 modes, picker and line edit */
80#define KBD_MORSE_INPUT
81 74
82#elif CONFIG_KEYPAD == SANSA_E200_PAD \ 75#else
83 || CONFIG_KEYPAD == SANSA_FUZE_PAD \ 76#define KBD_CURSOR_KEYS /* certain keys move the cursor, no line edit mode */
84 || CONFIG_KEYPAD == SANSA_C200_PAD \ 77#endif
85 || CONFIG_KEYPAD == SAMSUNG_YH_PAD
86#define KBD_CURSOR_KEYS
87#define KBD_MODES
88 78
89#elif CONFIG_KEYPAD == MROBE100_PAD 79#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \
90#define KBD_MORSE_INPUT 80 || (CONFIG_KEYPAD == IRIVER_H300_PAD) \
81 || (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
82 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
83 || (CONFIG_KEYPAD == IPOD_4G_PAD) \
84 || (CONFIG_KEYPAD == IRIVER_H10_PAD) \
85 || (CONFIG_KEYPAD == GIGABEAT_PAD) \
86 || (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
87 || (CONFIG_KEYPAD == MROBE100_PAD) \
88 || (CONFIG_KEYPAD == SANSA_E200_PAD) \
89 || (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) \
90 || (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
91/* certain key combos toggle input mode between keyboard input and Morse input */
92#define KBD_TOGGLE_INPUT
91#endif 93#endif
92 94
93struct keyboard_parameters 95struct keyboard_parameters
@@ -124,7 +126,7 @@ struct keyboard_parameters
124static struct keyboard_parameters kbd_param[NB_SCREENS]; 126static struct keyboard_parameters kbd_param[NB_SCREENS];
125static bool kbd_loaded = false; 127static bool kbd_loaded = false;
126 128
127#ifdef KBD_MORSE_INPUT 129#ifdef HAVE_MORSE_INPUT
128/* FIXME: We should put this to a configuration file. */ 130/* FIXME: We should put this to a configuration file. */
129static const char *morse_alphabets = 131static const char *morse_alphabets =
130 "abcdefghijklmnopqrstuvwxyz1234567890,.?-@ "; 132 "abcdefghijklmnopqrstuvwxyz1234567890,.?-@ ";
@@ -134,7 +136,6 @@ static const unsigned char morse_codes[] = {
134 0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f, 136 0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f,
135 0x73,0x55,0x4c,0x61,0x5a,0x80 }; 137 0x73,0x55,0x4c,0x61,0x5a,0x80 };
136 138
137static bool morse_mode = false;
138#endif 139#endif
139 140
140/* Loads a custom keyboard into memory 141/* Loads a custom keyboard into memory
@@ -306,7 +307,8 @@ int kbd_input(char* text, int buflen)
306 unsigned char *utf8; 307 unsigned char *utf8;
307 bool cur_blink = true; /* Cursor on/off flag */ 308 bool cur_blink = true; /* Cursor on/off flag */
308 int ret = 0; /* assume success */ 309 int ret = 0; /* assume success */
309#ifdef KBD_MORSE_INPUT 310#ifdef HAVE_MORSE_INPUT
311 bool morse_mode = global_settings.morse_input;
310 bool morse_reading = false; 312 bool morse_reading = false;
311 unsigned char morse_code = 0; 313 unsigned char morse_code = 0;
312 int morse_tick = 0; 314 int morse_tick = 0;
@@ -534,10 +536,10 @@ int kbd_input(char* text, int buflen)
534 pm->main_x = 0; 536 pm->main_x = 0;
535 pm->keyboard_margin -= pm->keyboard_margin/2; 537 pm->keyboard_margin -= pm->keyboard_margin/2;
536 538
537#ifdef KBD_MORSE_INPUT 539#ifdef HAVE_MORSE_INPUT
538 pm->old_main_y = pm->main_y; 540 pm->old_main_y = pm->main_y;
539 if (morse_mode) 541 if (morse_mode)
540 pm->main_y = sc_h - pm->font_h; 542 pm->main_y = sc_h - pm->font_h - BUTTONBAR_HEIGHT;
541#endif 543#endif
542 } 544 }
543 545
@@ -567,7 +569,7 @@ int kbd_input(char* text, int buflen)
567 FOR_NB_SCREENS(l) 569 FOR_NB_SCREENS(l)
568 screens[l].clear_display(); 570 screens[l].clear_display();
569 571
570#ifdef KBD_MORSE_INPUT 572#ifdef HAVE_MORSE_INPUT
571 if (morse_mode) 573 if (morse_mode)
572 { 574 {
573 FOR_NB_SCREENS(l) 575 FOR_NB_SCREENS(l)
@@ -615,7 +617,7 @@ int kbd_input(char* text, int buflen)
615 } 617 }
616 } 618 }
617 else 619 else
618#endif /* KBD_MORSE_INPUT */ 620#endif /* HAVE_MORSE_INPUT */
619 { 621 {
620 /* draw page */ 622 /* draw page */
621 FOR_NB_SCREENS(l) 623 FOR_NB_SCREENS(l)
@@ -752,7 +754,7 @@ int kbd_input(char* text, int buflen)
752 sc->getwidth(), pm->font_h + 2); 754 sc->getwidth(), pm->font_h + 2);
753 else /* highlight the key that has focus */ 755 else /* highlight the key that has focus */
754#endif 756#endif
755#ifdef KBD_MORSE_INPUT 757#ifdef HAVE_MORSE_INPUT
756 if(!morse_mode) 758 if(!morse_mode)
757#endif 759#endif
758 sc->fillrect(pm->font_w*pm->x, 760 sc->fillrect(pm->font_w*pm->x,
@@ -771,14 +773,14 @@ int kbd_input(char* text, int buflen)
771 pm = &param[button_screen]; 773 pm = &param[button_screen];
772 sc = &screens[button_screen]; 774 sc = &screens[button_screen];
773 775
774#if defined(KBD_MODES) || defined(KBD_MORSE_INPUT) 776#if defined(KBD_MODES) || defined(HAVE_MORSE_INPUT)
775 /* Remap some buttons to allow to move 777 /* Remap some buttons to allow to move
776 * cursor in line edit mode and morse mode. */ 778 * cursor in line edit mode and morse mode. */
777#if defined(KBD_MODES) && defined(KBD_MORSE_INPUT) 779#if defined(KBD_MODES) && defined(HAVE_MORSE_INPUT)
778 if (pm->line_edit || morse_mode) 780 if (pm->line_edit || morse_mode)
779#elif defined(KBD_MODES) 781#elif defined(KBD_MODES)
780 if (pm->line_edit) 782 if (pm->line_edit)
781#else /* defined(KBD_MORSE_INPUT) */ 783#else /* defined(HAVE_MORSE_INPUT) */
782 if (morse_mode) 784 if (morse_mode)
783#endif 785#endif
784 { 786 {
@@ -787,7 +789,7 @@ int kbd_input(char* text, int buflen)
787 if (button == ACTION_KBD_RIGHT) 789 if (button == ACTION_KBD_RIGHT)
788 button = ACTION_KBD_CURSOR_RIGHT; 790 button = ACTION_KBD_CURSOR_RIGHT;
789 } 791 }
790#endif /* defined(KBD_MODES) || defined(KBD_MORSE_INPUT) */ 792#endif /* defined(KBD_MODES) || defined(HAVE_MORSE_INPUT) */
791 793
792 switch ( button ) 794 switch ( button )
793 { 795 {
@@ -798,7 +800,7 @@ int kbd_input(char* text, int buflen)
798 800
799 case ACTION_KBD_PAGE_FLIP: 801 case ACTION_KBD_PAGE_FLIP:
800 { 802 {
801#ifdef KBD_MORSE_INPUT 803#ifdef HAVE_MORSE_INPUT
802 if (morse_mode) 804 if (morse_mode)
803 break; 805 break;
804#endif 806#endif
@@ -810,7 +812,7 @@ int kbd_input(char* text, int buflen)
810 break; 812 break;
811 } 813 }
812 814
813#ifdef KBD_MORSE_INPUT 815#if defined(HAVE_MORSE_INPUT) && defined(KBD_TOGGLE_INPUT)
814 case ACTION_KBD_MORSE_INPUT: 816 case ACTION_KBD_MORSE_INPUT:
815 morse_mode = !morse_mode; 817 morse_mode = !morse_mode;
816 818
@@ -822,7 +824,7 @@ int kbd_input(char* text, int buflen)
822 if (morse_mode) 824 if (morse_mode)
823 { 825 {
824 pm->old_main_y = pm->main_y; 826 pm->old_main_y = pm->main_y;
825 pm->main_y = sc->getheight() - pm->font_h; 827 pm->main_y = sc->getheight() - pm->font_h - BUTTONBAR_HEIGHT;
826 } 828 }
827 else 829 else
828 { 830 {
@@ -831,7 +833,7 @@ int kbd_input(char* text, int buflen)
831 } 833 }
832 /* FIXME: We should talk something like Morse mode.. */ 834 /* FIXME: We should talk something like Morse mode.. */
833 break; 835 break;
834#endif /* KBD_MORSE_INPUT */ 836#endif /* KBD_TOGGLE_INPUT */
835 837
836 case ACTION_KBD_RIGHT: 838 case ACTION_KBD_RIGHT:
837 if (++pm->x >= pm->max_chars) 839 if (++pm->x >= pm->max_chars)
@@ -864,7 +866,7 @@ int kbd_input(char* text, int buflen)
864 break; 866 break;
865 867
866 case ACTION_KBD_DOWN: 868 case ACTION_KBD_DOWN:
867#ifdef KBD_MORSE_INPUT 869#ifdef HAVE_MORSE_INPUT
868#ifdef KBD_MODES 870#ifdef KBD_MODES
869 if (morse_mode) 871 if (morse_mode)
870 { 872 {
@@ -877,7 +879,7 @@ int kbd_input(char* text, int buflen)
877 if (morse_mode) 879 if (morse_mode)
878 break; 880 break;
879#endif 881#endif
880#endif /* KBD_MORSE_INPUT */ 882#endif /* HAVE_MORSE_INPUT */
881 { 883 {
882#ifdef KBD_MODES 884#ifdef KBD_MODES
883 if (pm->line_edit) 885 if (pm->line_edit)
@@ -907,7 +909,7 @@ int kbd_input(char* text, int buflen)
907 break; 909 break;
908 910
909 case ACTION_KBD_UP: 911 case ACTION_KBD_UP:
910#ifdef KBD_MORSE_INPUT 912#ifdef HAVE_MORSE_INPUT
911#ifdef KBD_MODES 913#ifdef KBD_MODES
912 if (morse_mode) 914 if (morse_mode)
913 { 915 {
@@ -920,7 +922,7 @@ int kbd_input(char* text, int buflen)
920 if (morse_mode) 922 if (morse_mode)
921 break; 923 break;
922#endif 924#endif
923#endif /* KBD_MORSE_INPUT */ 925#endif /* HAVE_MORSE_INPUT */
924 { 926 {
925#ifdef KBD_MODES 927#ifdef KBD_MODES
926 if (pm->line_edit) 928 if (pm->line_edit)
@@ -955,7 +957,7 @@ int kbd_input(char* text, int buflen)
955 done = true; 957 done = true;
956 break; 958 break;
957 959
958#ifdef KBD_MORSE_INPUT 960#ifdef HAVE_MORSE_INPUT
959 case ACTION_KBD_MORSE_SELECT: 961 case ACTION_KBD_MORSE_SELECT:
960 if (morse_mode && morse_reading) 962 if (morse_mode && morse_reading)
961 { 963 {
@@ -965,10 +967,10 @@ int kbd_input(char* text, int buflen)
965 } 967 }
966 968
967 break; 969 break;
968#endif /* KBD_MORSE_INPUT */ 970#endif /* HAVE_MORSE_INPUT */
969 971
970 case ACTION_KBD_SELECT: 972 case ACTION_KBD_SELECT:
971#ifdef KBD_MORSE_INPUT 973#ifdef HAVE_MORSE_INPUT
972#ifdef KBD_MODES 974#ifdef KBD_MODES
973 if (morse_mode && !pm->line_edit) 975 if (morse_mode && !pm->line_edit)
974#else 976#else
@@ -984,7 +986,7 @@ int kbd_input(char* text, int buflen)
984 } 986 }
985 break; 987 break;
986 } 988 }
987#endif /* KBD_MORSE_INPUT */ 989#endif /* HAVE_MORSE_INPUT */
988 990
989 /* inserts the selected char */ 991 /* inserts the selected char */
990#ifdef KBD_MODES 992#ifdef KBD_MODES
@@ -1088,7 +1090,7 @@ int kbd_input(char* text, int buflen)
1088 /* speak revised text */ 1090 /* speak revised text */
1089 break; 1091 break;
1090 1092
1091#if !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) 1093#ifdef KBD_CURSOR_KEYS
1092 case ACTION_KBD_BACKSPACE: 1094 case ACTION_KBD_BACKSPACE:
1093 if (pm->hangul) 1095 if (pm->hangul)
1094 { 1096 {
@@ -1114,7 +1116,7 @@ int kbd_input(char* text, int buflen)
1114 if (global_settings.talk_menu) /* voice UI? */ 1116 if (global_settings.talk_menu) /* voice UI? */
1115 talk_spell(text, false); /* speak revised text */ 1117 talk_spell(text, false); /* speak revised text */
1116 break; 1118 break;
1117#endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */ 1119#endif /* KBD_CURSOR_KEYS */
1118 1120
1119 case ACTION_KBD_CURSOR_RIGHT: 1121 case ACTION_KBD_CURSOR_RIGHT:
1120 pm->hangul = false; 1122 pm->hangul = false;
@@ -1145,7 +1147,7 @@ int kbd_input(char* text, int buflen)
1145 break; 1147 break;
1146 1148
1147 case BUTTON_NONE: 1149 case BUTTON_NONE:
1148#ifdef KBD_MORSE_INPUT 1150#ifdef HAVE_MORSE_INPUT
1149 if (morse_reading) 1151 if (morse_reading)
1150 { 1152 {
1151 int j; 1153 int j;
@@ -1172,7 +1174,7 @@ int kbd_input(char* text, int buflen)
1172 if (global_settings.talk_menu) /* voice UI? */ 1174 if (global_settings.talk_menu) /* voice UI? */
1173 talk_spell(text, false); /* speak revised text */ 1175 talk_spell(text, false); /* speak revised text */
1174 } 1176 }
1175#endif /* KBD_MORSE_INPUT */ 1177#endif /* HAVE_MORSE_INPUT */
1176 break; 1178 break;
1177 1179
1178 default: 1180 default:
@@ -1198,6 +1200,14 @@ int kbd_input(char* text, int buflen)
1198 if (ret < 0) 1200 if (ret < 0)
1199 splash(HZ/2, ID2P(LANG_CANCEL)); 1201 splash(HZ/2, ID2P(LANG_CANCEL));
1200 1202
1203#ifdef HAVE_MORSE_INPUT
1204 if(global_settings.morse_input != morse_mode)
1205 {
1206 global_settings.morse_input = morse_mode;
1207 settings_save();
1208 }
1209#endif /* HAVE_MORSE_INPUT */
1210
1201 FOR_NB_SCREENS(l) 1211 FOR_NB_SCREENS(l)
1202 screens[l].setfont(FONT_UI); 1212 screens[l].setfont(FONT_UI);
1203 viewportmanager_set_statusbar(oldbars); 1213 viewportmanager_set_statusbar(oldbars);