diff options
Diffstat (limited to 'apps/player/keyboard.c')
-rw-r--r-- | apps/player/keyboard.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c index b33dcebbdf..42c09098a0 100644 --- a/apps/player/keyboard.c +++ b/apps/player/keyboard.c | |||
@@ -76,10 +76,11 @@ static unsigned short* kbd_setupkeys(int page, int* len) | |||
76 | 76 | ||
77 | #define MENU_LINE_INPUT 0 | 77 | #define MENU_LINE_INPUT 0 |
78 | #define MENU_LINE_NEWCHARS 1 | 78 | #define MENU_LINE_NEWCHARS 1 |
79 | #define MENU_LINE_DELETE 2 | 79 | #define MENU_LINE_BACKSPACE 2 |
80 | #define MENU_LINE_ACCEPT 3 | 80 | #define MENU_LINE_DELETE 3 |
81 | #define MENU_LINE_QUIT 4 | 81 | #define MENU_LINE_ACCEPT 4 |
82 | #define MENU_LINE_LAST 4 | 82 | #define MENU_LINE_QUIT 5 |
83 | #define MENU_LINE_LAST 5 | ||
83 | 84 | ||
84 | int kbd_input(char* text, int buflen) | 85 | int kbd_input(char* text, int buflen) |
85 | { | 86 | { |
@@ -91,7 +92,6 @@ int kbd_input(char* text, int buflen) | |||
91 | int cursor_pos=0; | 92 | int cursor_pos=0; |
92 | int button_pressed; | 93 | int button_pressed; |
93 | unsigned char temptext[12]; | 94 | unsigned char temptext[12]; |
94 | bool cursor_on=true; /* Blinking cursor control */ | ||
95 | int old_cursor_pos=0; /* Windowed cursor movement */ | 95 | int old_cursor_pos=0; /* Windowed cursor movement */ |
96 | int left_pos=0; | 96 | int left_pos=0; |
97 | 97 | ||
@@ -110,17 +110,11 @@ int kbd_input(char* text, int buflen) | |||
110 | p=0; | 110 | p=0; |
111 | i = left_pos; | 111 | i = left_pos; |
112 | while (p<10 && line[i]) { | 112 | while (p<10 && line[i]) { |
113 | if (i == cursor_pos && cursor_on) | 113 | temptext[p++]=text[i++]; |
114 | { | ||
115 | temptext[p++]=KEYBOARD_CURSOR; | ||
116 | i++; | ||
117 | } else { | ||
118 | temptext[p++]=text[i++]; | ||
119 | } | ||
120 | } | 114 | } |
121 | temptext[p]=0; | 115 | temptext[p]=0; |
122 | lcd_puts(1, 0, temptext); | 116 | lcd_puts(1, 0, temptext); |
123 | cursor_on = !cursor_on; | 117 | lcd_put_cursor(cursor_pos-left_pos+1, 0, 0x7f); |
124 | old_cursor_pos=cursor_pos; | 118 | old_cursor_pos=cursor_pos; |
125 | 119 | ||
126 | switch (menu_line) { | 120 | switch (menu_line) { |
@@ -136,6 +130,9 @@ int kbd_input(char* text, int buflen) | |||
136 | temptext[p]=0; | 130 | temptext[p]=0; |
137 | lcd_puts(1, 1, temptext); | 131 | lcd_puts(1, 1, temptext); |
138 | break; | 132 | break; |
133 | case MENU_LINE_BACKSPACE: | ||
134 | lcd_puts_scroll(1, 1, "Backspace"); | ||
135 | break; | ||
139 | case MENU_LINE_DELETE: | 136 | case MENU_LINE_DELETE: |
140 | lcd_puts_scroll(1, 1, "Delete"); | 137 | lcd_puts_scroll(1, 1, "Delete"); |
141 | break; | 138 | break; |
@@ -143,7 +140,7 @@ int kbd_input(char* text, int buflen) | |||
143 | lcd_puts_scroll(1, 1, "Accept"); | 140 | lcd_puts_scroll(1, 1, "Accept"); |
144 | break; | 141 | break; |
145 | case MENU_LINE_QUIT: | 142 | case MENU_LINE_QUIT: |
146 | lcd_puts_scroll(1, 1, "Cancel"); | 143 | lcd_puts_scroll(1, 1, "Abort"); |
147 | break; | 144 | break; |
148 | } | 145 | } |
149 | if (menu_line==MENU_LINE_INPUT) { | 146 | if (menu_line==MENU_LINE_INPUT) { |
@@ -156,7 +153,7 @@ int kbd_input(char* text, int buflen) | |||
156 | 153 | ||
157 | lcd_update(); | 154 | lcd_update(); |
158 | 155 | ||
159 | button_pressed=button_get_w_tmo(HZ/2); | 156 | button_pressed=button_get(true); |
160 | switch (menu_line) | 157 | switch (menu_line) |
161 | { | 158 | { |
162 | case MENU_LINE_INPUT: | 159 | case MENU_LINE_INPUT: |
@@ -167,14 +164,12 @@ int kbd_input(char* text, int buflen) | |||
167 | if (cursor_pos<len) | 164 | if (cursor_pos<len) |
168 | cursor_pos++; | 165 | cursor_pos++; |
169 | button_pressed=BUTTON_NONE; | 166 | button_pressed=BUTTON_NONE; |
170 | cursor_on=true; | ||
171 | break; | 167 | break; |
172 | case BUTTON_DOWN: | 168 | case BUTTON_DOWN: |
173 | case BUTTON_DOWN | BUTTON_REPEAT: | 169 | case BUTTON_DOWN | BUTTON_REPEAT: |
174 | if (cursor_pos>0) | 170 | if (cursor_pos>0) |
175 | cursor_pos--; | 171 | cursor_pos--; |
176 | button_pressed=BUTTON_NONE; | 172 | button_pressed=BUTTON_NONE; |
177 | cursor_on=true; | ||
178 | break; | 173 | break; |
179 | } | 174 | } |
180 | break; | 175 | break; |
@@ -214,6 +209,27 @@ int kbd_input(char* text, int buflen) | |||
214 | } | 209 | } |
215 | break; | 210 | break; |
216 | 211 | ||
212 | case MENU_LINE_BACKSPACE: | ||
213 | switch (button_pressed) { | ||
214 | case BUTTON_ON: | ||
215 | case BUTTON_PLAY: | ||
216 | case BUTTON_PLAY | BUTTON_REPEAT: | ||
217 | button_pressed=BUTTON_NONE; | ||
218 | if (0 < cursor_pos) { | ||
219 | for (i=--cursor_pos; i<=len; i++) { | ||
220 | text[i]=text[i+1]; | ||
221 | } | ||
222 | } | ||
223 | break; | ||
224 | case BUTTON_STOP: | ||
225 | case BUTTON_STOP | BUTTON_REPEAT: | ||
226 | button_pressed=BUTTON_NONE; | ||
227 | for (i=cursor_pos; i<=len; i++) { | ||
228 | text[i]=text[i+1]; | ||
229 | } | ||
230 | break; | ||
231 | } | ||
232 | break; | ||
217 | case MENU_LINE_DELETE: | 233 | case MENU_LINE_DELETE: |
218 | switch (button_pressed) { | 234 | switch (button_pressed) { |
219 | case BUTTON_ON: | 235 | case BUTTON_ON: |
@@ -270,12 +286,16 @@ int kbd_input(char* text, int buflen) | |||
270 | case BUTTON_RIGHT | BUTTON_REPEAT: | 286 | case BUTTON_RIGHT | BUTTON_REPEAT: |
271 | if (menu_line<MENU_LINE_LAST) | 287 | if (menu_line<MENU_LINE_LAST) |
272 | menu_line++; | 288 | menu_line++; |
289 | else | ||
290 | menu_line=0; | ||
273 | break; | 291 | break; |
274 | 292 | ||
275 | case BUTTON_LEFT: | 293 | case BUTTON_LEFT: |
276 | case BUTTON_LEFT | BUTTON_REPEAT: | 294 | case BUTTON_LEFT | BUTTON_REPEAT: |
277 | if (menu_line>0) | 295 | if (menu_line>0) |
278 | menu_line--; | 296 | menu_line--; |
297 | else | ||
298 | menu_line=MENU_LINE_LAST; | ||
279 | break; | 299 | break; |
280 | } | 300 | } |
281 | } | 301 | } |