summaryrefslogtreecommitdiff
path: root/apps/player
diff options
context:
space:
mode:
Diffstat (limited to 'apps/player')
-rw-r--r--apps/player/keyboard.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index 543720fa65..342172d44a 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -23,27 +23,59 @@
23#include "debug_menu.h" 23#include "debug_menu.h"
24#include "sprintf.h" 24#include "sprintf.h"
25#include <string.h> 25#include <string.h>
26#include "lcd-player-charset.h"
26 27
27#define KEYBOARD_PAGES 4 28#include "debug.h"
28 29
29static char* kbd_setupkeys(int page) 30#define KEYBOARD_PAGES 3
31
32unsigned short *lcd_ascii;
33
34static unsigned short* kbd_setupkeys(int page, int* len)
30{ 35{
31 static char* lines[] = { 36 static unsigned short lines[256];
32 "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 37
33 "abcdefghijklmnopqrstuvwxyz", 38 unsigned short ch;
34 "01234567890!@#$%&/(){}[]<>", 39 int i = 0;
35 " +-*_.,:;!?' " 40
36 }; 41 switch (page) {
37 42 case 0: /* Capitals */
38 return lines[page]; 43 for (ch = 'A'; ch <= 'Z'; ch++) lines[i++] = ch;
44 for (ch = 0xc0; ch <= 0xdd; ch++)
45 if (lcd_ascii[ch] != NOCHAR_NEW && lcd_ascii[ch] != NOCHAR_OLD)
46 lines[i++] = ch;
47 break;
48
49 case 1: /* Small */
50 for (ch = 'a'; ch <= 'z'; ch++) lines[i++] = ch;
51 for (ch = 0xdf; ch <= 0xff; ch++)
52 if (lcd_ascii[ch] != NOCHAR_NEW && lcd_ascii[ch] != NOCHAR_OLD)
53 lines[i++] = ch;
54 break;
55
56 case 2: /* Others */
57 for (ch = ' '; ch <= '@'; ch++) lines[i++] = ch;
58 for (ch = 0x5b; ch <= 0x60; ch++)
59 if (lcd_ascii[ch] != NOCHAR_NEW && lcd_ascii[ch] != NOCHAR_OLD)
60 lines[i++] = ch;
61 for (ch = 0x07b; ch <= 0x0bf; ch++)
62 if (lcd_ascii[ch] != NOCHAR_NEW && lcd_ascii[ch] != NOCHAR_OLD)
63 lines[i++] = ch;
64 break;
65 }
66
67 lines[i] = 0;
68 *len = i;
69
70 return lines;
39} 71}
40 72
41int kbd_input(char* text, int buflen) 73int kbd_input(char* text, int buflen)
42{ 74{
43 bool done = false; 75 bool done = false;
44 int page=0, x=0; 76 int page=0, x=0;
45 char* line = kbd_setupkeys(page); 77 int linelen;
46 int linelen = strlen(line); 78 unsigned short* line = kbd_setupkeys(page, &linelen);
47 79
48 while(!done) 80 while(!done)
49 { 81 {
@@ -74,12 +106,16 @@ int kbd_input(char* text, int buflen)
74 106
75 switch ( button_get(true) ) { 107 switch ( button_get(true) ) {
76 108
109 case BUTTON_MENU | BUTTON_STOP:
110 /* abort */
111 return -1;
112 break;
113
77 case BUTTON_MENU: 114 case BUTTON_MENU:
78 /* shift */ 115 /* shift */
79 if (++page == KEYBOARD_PAGES) 116 if (++page == KEYBOARD_PAGES)
80 page = 0; 117 page = 0;
81 line = kbd_setupkeys(page); 118 line = kbd_setupkeys(page, &linelen);
82 linelen = strlen(line);
83 break; 119 break;
84 120
85 case BUTTON_RIGHT: 121 case BUTTON_RIGHT: