summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/player/keyboard.c31
-rw-r--r--apps/recorder/keyboard.c85
2 files changed, 41 insertions, 75 deletions
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index 6467ed60f1..fb06a0dc7b 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -102,7 +102,6 @@ int kbd_input(char* text, int buflen)
102 int editpos, curpos, leftpos; 102 int editpos, curpos, leftpos;
103 unsigned short* line = kbd_setupkeys(page, &linelen); 103 unsigned short* line = kbd_setupkeys(page, &linelen);
104 unsigned char temptext[12]; 104 unsigned char temptext[12];
105 char c;
106 105
107 int button, lastbutton = 0; 106 int button, lastbutton = 0;
108 107
@@ -130,11 +129,11 @@ int kbd_input(char* text, int buflen)
130 129
131 /* Draw insert chars */ 130 /* Draw insert chars */
132 temptext[0] = KEYBOARD_INSERT_LEFT; 131 temptext[0] = KEYBOARD_INSERT_LEFT;
133 temptext[1] = line[x%linelen]; 132 temptext[1] = line[x];
134 temptext[2] = KEYBOARD_INSERT_RIGHT; 133 temptext[2] = KEYBOARD_INSERT_RIGHT;
135 for (i = 1; i < 8; i++) 134 for (i = 1; i < 8; i++)
136 { 135 {
137 temptext[i+2] = line[(i+x)%linelen]; 136 temptext[i+2] = line[(x+i)%linelen];
138 } 137 }
139 temptext[i+2] = 0; 138 temptext[i+2] = 0;
140 lcd_puts(1, 0, temptext); 139 lcd_puts(1, 0, temptext);
@@ -194,9 +193,7 @@ int kbd_input(char* text, int buflen)
194 } 193 }
195 else 194 else
196 { 195 {
197 if (x < linelen - 1) 196 if (++x >= linelen)
198 x++;
199 else
200 x = 0; 197 x = 0;
201 kbd_spellchar(line[x]); 198 kbd_spellchar(line[x]);
202 } 199 }
@@ -214,9 +211,7 @@ int kbd_input(char* text, int buflen)
214 } 211 }
215 else 212 else
216 { 213 {
217 if (x) 214 if (--x < 0)
218 x--;
219 else
220 x = linelen - 1; 215 x = linelen - 1;
221 kbd_spellchar(line[x]); 216 kbd_spellchar(line[x]);
222 } 217 }
@@ -242,20 +237,12 @@ int kbd_input(char* text, int buflen)
242 } 237 }
243 else /* inserts the selected char */ 238 else /* inserts the selected char */
244 { 239 {
245 if (len < buflen) 240 if (len + 1 < buflen)
246 { 241 {
247 c = line[x]; 242 for (i = len ; i > editpos; i--)
248 if (editpos == len) 243 text[i] = text[i-1];
249 { 244 text[len+1] = 0;
250 text[len] = c; 245 text[editpos] = line[x];
251 text[len+1] = 0;
252 }
253 else
254 {
255 for (i = len ; i >= editpos; i--)
256 text[i+1] = text[i];
257 text[editpos] = c;
258 }
259 editpos++; 246 editpos++;
260 } 247 }
261 } 248 }
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 832bb995ba..6c47c3ad81 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -33,7 +33,7 @@
33 33
34#define KEYBOARD_LINES 4 34#define KEYBOARD_LINES 4
35#define KEYBOARD_PAGES 3 35#define KEYBOARD_PAGES 3
36 36#define KEYBOARD_MARGIN 3
37 37
38#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 38#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
39 (CONFIG_KEYPAD == IRIVER_H300_PAD) 39 (CONFIG_KEYPAD == IRIVER_H300_PAD)
@@ -74,33 +74,22 @@
74 74
75#endif 75#endif
76 76
77static const char * const kbdpages[KEYBOARD_PAGES][KEYBOARD_LINES] = {
78 { "ABCDEFG !?\" @#$%+'",
79 "HIJKLMN 789 &_()-`",
80 "OPQRSTU 456 §|{}/<",
81 "VWXYZ.,0123 ~=[]*>" },
77 82
78static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page) 83 { "abcdefg ¢£¤¥¦§©®¬",
79{ 84 "hijklmn «»°ºª¹²³¶",
80 switch (page) 85 "opqrstu ¯±×÷¡¿µ·¨",
81 { 86 "vwxyz., ¼½¾ " },
82 case 0: 87
83 line[0] = "ABCDEFG !?\" @#$%+'"; 88 { "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË",
84 line[1] = "HIJKLMN 789 &_()-`"; 89 "àáâãäåæ ìíîï èéêë",
85 line[2] = "OPQRSTU 456 §|{}/<"; 90 "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ",
86 line[3] = "VWXYZ.,0123 ~=[]*>"; 91 "òóôõöø çðþýÿ ùúûü" },
87 break; 92};
88
89 case 1:
90 line[0] = "abcdefg ¢£¤¥¦§©®¬";
91 line[1] = "hijklmn «»°ºª¹²³¶";
92 line[2] = "opqrstu ¯±×÷¡¿µ·¨";
93 line[3] = "vwxyz., ¼½¾ ";
94 break;
95
96 case 2:
97 line[0] = "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË";
98 line[1] = "àáâãäåæ ìíîï èéêë";
99 line[2] = "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ";
100 line[3] = "òóôõöø çðþýÿ ùúûü";
101 break;
102 }
103}
104 93
105/* helper function to spell a char if voice UI is enabled */ 94/* helper function to spell a char if voice UI is enabled */
106static void kbd_spellchar(char c) 95static void kbd_spellchar(char c)
@@ -121,18 +110,17 @@ int kbd_input(char* text, int buflen)
121 110
122 int font_w = 0, font_h = 0, i; 111 int font_w = 0, font_h = 0, i;
123 int x = 0, y = 0; 112 int x = 0, y = 0;
124 int main_x, main_y, max_chars, margin; 113 int main_x, main_y, max_chars;
125 int status_y1, status_y2; 114 int status_y1, status_y2;
126 int len; 115 int len;
127 int editpos, curpos, leftpos; 116 int editpos, curpos, leftpos;
128 bool redraw = true; 117 bool redraw = true;
129 const char* line[KEYBOARD_LINES]; 118 const char * const *line;
130#ifdef KBD_MODES 119#ifdef KBD_MODES
131 bool line_edit = false; 120 bool line_edit = false;
132#endif 121#endif
133 122
134 char outline[256]; 123 char outline[256];
135 char c = 0;
136 struct font* font = font_get(FONT_SYSFIXED); 124 struct font* font = font_get(FONT_SYSFIXED);
137 int button, lastbutton = 0; 125 int button, lastbutton = 0;
138 126
@@ -140,8 +128,7 @@ int kbd_input(char* text, int buflen)
140 font_w = font->maxwidth; 128 font_w = font->maxwidth;
141 font_h = font->height; 129 font_h = font->height;
142 130
143 margin = 3; 131 main_y = (KEYBOARD_LINES + 1) * font_h + (2*KEYBOARD_MARGIN);
144 main_y = (KEYBOARD_LINES + 1) * font_h + margin*2;
145 main_x = 0; 132 main_x = 0;
146 status_y1 = LCD_HEIGHT - font_h; 133 status_y1 = LCD_HEIGHT - font_h;
147 status_y2 = LCD_HEIGHT; 134 status_y2 = LCD_HEIGHT;
@@ -149,7 +136,7 @@ int kbd_input(char* text, int buflen)
149 editpos = strlen(text); 136 editpos = strlen(text);
150 137
151 max_chars = LCD_WIDTH / font_w - 2; /* leave room for < and > */ 138 max_chars = LCD_WIDTH / font_w - 2; /* leave room for < and > */
152 kbd_setupkeys(line, page); 139 line = kbdpages[0];
153 140
154 if (global_settings.talk_menu) /* voice UI? */ 141 if (global_settings.talk_menu) /* voice UI? */
155 talk_spell(text, true); /* spell initial text */ 142 talk_spell(text, true); /* spell initial text */
@@ -169,7 +156,7 @@ int kbd_input(char* text, int buflen)
169 lcd_putsxy(0, 8+i * font_h, line[i]); 156 lcd_putsxy(0, 8+i * font_h, line[i]);
170 157
171 /* separator */ 158 /* separator */
172 lcd_hline(0, LCD_WIDTH - 1, main_y - margin); 159 lcd_hline(0, LCD_WIDTH - 1, main_y - KEYBOARD_MARGIN);
173 160
174 /* write out the text */ 161 /* write out the text */
175 curpos = MIN(editpos, max_chars - MIN(len - editpos, 2)); 162 curpos = MIN(editpos, max_chars - MIN(len - editpos, 2));
@@ -221,10 +208,10 @@ int kbd_input(char* text, int buflen)
221 break; 208 break;
222 209
223#ifdef KBD_PAGE_FLIP 210#ifdef KBD_PAGE_FLIP
224 case KBD_PAGE_FLIP: 211 case KBD_PAGE_FLIP:
225 if (++page == KEYBOARD_PAGES) 212 if (++page == KEYBOARD_PAGES)
226 page = 0; 213 page = 0;
227 kbd_setupkeys(line, page); 214 line = kbdpages[page];
228 kbd_spellchar(line[y][x]); 215 kbd_spellchar(line[y][x]);
229 break; 216 break;
230#endif 217#endif
@@ -242,7 +229,7 @@ int kbd_input(char* text, int buflen)
242 } 229 }
243 else 230 else
244#endif 231#endif
245 { 232 {
246 if (x < (int)strlen(line[y]) - 1) 233 if (x < (int)strlen(line[y]) - 1)
247 x++; 234 x++;
248 else 235 else
@@ -251,7 +238,7 @@ int kbd_input(char* text, int buflen)
251#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */ 238#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
252 if (++page == KEYBOARD_PAGES) 239 if (++page == KEYBOARD_PAGES)
253 page = 0; 240 page = 0;
254 kbd_setupkeys(line, page); 241 line = kbdpages[page];
255#endif 242#endif
256 } 243 }
257 kbd_spellchar(line[y][x]); 244 kbd_spellchar(line[y][x]);
@@ -271,7 +258,7 @@ int kbd_input(char* text, int buflen)
271 } 258 }
272 else 259 else
273#endif 260#endif
274 { 261 {
275 if (x) 262 if (x)
276 x--; 263 x--;
277 else 264 else
@@ -279,7 +266,7 @@ int kbd_input(char* text, int buflen)
279#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */ 266#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
280 if (--page < 0) 267 if (--page < 0)
281 page = (KEYBOARD_PAGES-1); 268 page = (KEYBOARD_PAGES-1);
282 kbd_setupkeys(line, page); 269 line = kbdpages[page];
283#endif 270#endif
284 x = strlen(line[y]) - 1; 271 x = strlen(line[y]) - 1;
285 } 272 }
@@ -364,20 +351,12 @@ int kbd_input(char* text, int buflen)
364 else 351 else
365#endif 352#endif
366 { 353 {
367 if (len < buflen) 354 if (len + 1 < buflen)
368 { 355 {
369 c = line[y][x]; 356 for (i = len ; i > editpos; i--)
370 if (editpos == len) 357 text[i] = text[i-1];
371 { 358 text[len+1] = 0;
372 text[len] = c; 359 text[editpos] = line[y][x];
373 text[len+1] = 0;
374 }
375 else
376 {
377 for (i = len ; i >= editpos; i--)
378 text[i+1] = text[i];
379 text[editpos] = c;
380 }
381 editpos++; 360 editpos++;
382 } 361 }
383 } 362 }