summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/keyboard.h24
-rw-r--r--apps/player/keyboard.c117
-rw-r--r--apps/recorder/keyboard.c206
-rw-r--r--uisimulator/x11/Makefile5
4 files changed, 351 insertions, 1 deletions
diff --git a/apps/keyboard.h b/apps/keyboard.h
new file mode 100644
index 0000000000..fa1e11e0ce
--- /dev/null
+++ b/apps/keyboard.h
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _KEYBOARD_H
+#define _KEYBOARD_H
+
+int kbd_input(char* buffer, int buflen);
+
+#endif
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
new file mode 100644
index 0000000000..be0e43b8a9
--- /dev/null
+++ b/apps/player/keyboard.c
@@ -0,0 +1,117 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "lcd.h"
+#include "button.h"
+#include "kernel.h"
+#include "version.h"
+#include "debug_menu.h"
+#include "sprintf.h"
+#include <string.h>
+
+#define KEYBOARD_PAGES 4
+
+static char* kbd_setupkeys(int page)
+{
+ static char* lines[] = {
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ "abcdefghijklmnopqrstuvwxyz",
+ "01234567890!@#$%&/(){}[]<>",
+ "+-*_.,:;!?'"
+ };
+
+ return lines[page];
+}
+
+int kbd_input(char* text, int buflen)
+{
+ bool done = false;
+ int page=0, x=0;
+ char* line = kbd_setupkeys(page);
+ int linelen = strlen(line);
+
+ while(!done)
+ {
+ int i;
+ int len = strlen(text);
+
+ lcd_clear_display();
+
+ /* draw chars */
+ for (i=0; i < 11; i++)
+ lcd_putc(i, 1, line[i+x]);
+
+ /* write out the text */
+ if (len <= 11) {
+ /* if we have enough room */
+ lcd_puts(0, 0, text);
+ }
+ else {
+ /* if we don't have enough room, write out the last bit only */
+ lcd_putc(0, 0, '<');
+ lcd_puts(1, 0, text + len - 10);
+ }
+ lcd_update();
+
+ switch ( button_get(true) ) {
+
+ case BUTTON_MENU:
+ /* Page */
+ if (++page == KEYBOARD_PAGES)
+ page = 0;
+ line = kbd_setupkeys(page);
+ linelen = strlen(line);
+ break;
+
+ case BUTTON_RIGHT:
+ if (x < linelen - 1)
+ x++;
+ else
+ x = 0;
+ break;
+
+ case BUTTON_LEFT:
+ if (x)
+ x--;
+ else
+ x = linelen - 1;
+ break;
+
+ case BUTTON_STOP:
+ /* backspace */
+ if (len)
+ text[len-1] = 0;
+ break;
+
+ case BUTTON_ON:
+ /* F2 accepts what was entered and continues */
+ done = true;
+ break;
+
+ case BUTTON_PLAY:
+ /* PLAY inserts the selected char */
+ if (len<buflen)
+ {
+ text[len] = line[x];
+ text[len+1] = 0;
+ }
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
new file mode 100644
index 0000000000..431bfb6b19
--- /dev/null
+++ b/apps/recorder/keyboard.c
@@ -0,0 +1,206 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "lcd.h"
+#include "button.h"
+#include "kernel.h"
+#include "version.h"
+#include "debug_menu.h"
+#include "sprintf.h"
+#include <string.h>
+
+#include "bmp.h"
+#include "icons.h"
+#include "font.h"
+
+#define KEYBOARD_LINES 4
+#define KEYBOARD_PAGES 3
+
+static void kbd_setupkeys(char* line[KEYBOARD_LINES], int page)
+{
+ switch (page) {
+ case 0:
+ line[0] = "ABCDEFG !?\" @#$%+'";
+ line[1] = "HIJKLMN 789 &_()-`";
+ line[2] = "OPQRSTU 456 §|{}/<";
+ line[3] = "VWXYZ.,0123 ~=[]*>";
+ break;
+
+ case 1:
+ line[0] = "abcdefg ¢£¤¥¦§©®¬";
+ line[1] = "hijklmn «»°ºª¹²³¶";
+ line[2] = "opqrsty ¯±×÷¡¿µ·¨";
+ line[3] = "vwxyz ¼½¾ ";
+ break;
+
+ case 2:
+ line[0] = "ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË";
+ line[1] = "àáâãäåæ ìíîï èéêë";
+ line[2] = "ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ";
+ line[3] = "òóôõöø çðþýÿ ùúûü";
+ break;
+ }
+}
+
+static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw)
+{
+ int x, x2, tw, cx;
+ x = num*(LCD_WIDTH/3);
+ x2 = (num+1)*(LCD_WIDTH/3);
+ tw = fw * strlen(caption);
+ cx = x2 - x;
+ /* center the text */
+ lcd_putsxy((x + (cx/2)) - (tw/2), y, caption);
+ lcd_invertrect(x, y - 1, (x2-x)-1, LCD_HEIGHT-y+1);
+}
+
+int kbd_input(char* text, int buflen)
+{
+ bool done = false;
+ int page = 0;
+
+ int font_w = 0, font_h = 0, i;
+ int x = 0, y = 0;
+ int main_x, main_y, max_chars, margin;
+ int status_y1, status_y2, curpos;
+ int len;
+ char* line[KEYBOARD_LINES];
+
+ char c = 0;
+ struct font* font = font_get(FONT_SYSFIXED);
+
+ font_w = font->maxwidth;
+ font_h = font->height;
+
+ margin = 3;
+ main_y = (KEYBOARD_LINES + 1) * font_h + margin;
+ main_x = 0;
+ status_y1 = LCD_HEIGHT - font_h;
+ status_y2 = LCD_HEIGHT;
+
+ max_chars = LCD_WIDTH / font_w;
+ kbd_setupkeys(line, page);
+
+ while(!done)
+ {
+ lcd_clear_display();
+
+ /* draw page */
+ for (i=0; i < KEYBOARD_LINES; i++)
+ lcd_putsxy(0, i * font_h, line[i]);
+
+ len = strlen(text);
+
+ /* separator */
+ lcd_drawline(0, main_y - margin, LCD_WIDTH, main_y - margin);
+
+ /* write out the text */
+ if (len <= max_chars)
+ {
+ /* if we have enough room */
+ lcd_putsxy(main_x, main_y, text);
+ curpos = main_x + len * font_w;
+ }
+ else
+ {
+ /* if we don't have enough room, write out the last bit only */
+ lcd_putsxy(0, main_y, "<");
+ lcd_invertrect(0, main_y, font_w, font_h);
+
+ lcd_putsxy(font_w, main_y, text + len - (max_chars-1));
+ curpos = main_x + max_chars * font_w;
+ }
+
+ /* cursor */
+ lcd_drawline(curpos, main_y, curpos, main_y + font_h);
+
+ /* draw the status bar */
+ kbd_draw_statusbar_button(0, "Shift", status_y1, font_w);
+ kbd_draw_statusbar_button(1, "Done", status_y1, font_w);
+ kbd_draw_statusbar_button(2, "Del", status_y1, font_w);
+
+ /* highlight the key that has focus */
+ lcd_invertrect(font_w * x, font_h * y, font_w, font_h);
+ lcd_update();
+
+ switch ( button_get(true) ) {
+
+ case BUTTON_OFF:
+ /* abort */
+ return -1;
+ break;
+
+ case BUTTON_F1:
+ /* Page */
+ if (++page == KEYBOARD_PAGES)
+ page = 0;
+ kbd_setupkeys(line, page);
+ break;
+
+ case BUTTON_RIGHT:
+ if (x < (int)strlen(line[y]) - 1)
+ x++;
+ else
+ x = 0;
+ break;
+
+ case BUTTON_LEFT:
+ if (x)
+ x--;
+ else
+ x = strlen(line[y]) - 1;
+ break;
+
+ case BUTTON_DOWN:
+ if (y < KEYBOARD_LINES - 1)
+ y++;
+ else
+ y=0;
+ break;
+
+ case BUTTON_UP:
+ if (y)
+ y--;
+ else
+ y = KEYBOARD_LINES - 1;
+ break;
+
+ case BUTTON_F3:
+ /* backspace */
+ if (len)
+ text[len-1] = 0;
+ break;
+
+ case BUTTON_F2:
+ /* F2 accepts what was entered and continues */
+ done = true;
+ break;
+
+ case BUTTON_PLAY:
+ /* PLAY inserts the selected char */
+ if (len<buflen)
+ {
+ c = line[y][x];
+ text[len] = c;
+ text[len+1] = 0;
+ }
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index ea511474a6..10fc2c532b 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -90,7 +90,7 @@ FIRMSRCS = $(LCDSRSC) sprintf.c id3.c debug.c usb.c mpeg.c power.c\
APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
playlist.c wps.c wps-display.c settings.c status.c icons.c\
- screens.c peakmeter.c viewer.c sleeptimer.c
+ screens.c peakmeter.c viewer.c sleeptimer.c keyboard.c
MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
@@ -170,6 +170,9 @@ $(OBJDIR)/menu.o: $(APPDIR)/menu.c
$(OBJDIR)/main_menu.o: $(APPDIR)/main_menu.c
$(CC) $(APPCFLAGS) -c $< -o $@
+$(OBJDIR)/keyboard.o: $(MACHINEDIR)/keyboard.c
+ $(CC) $(APPCFLAGS) -c $< -o $@
+
$(OBJDIR)/language.o: $(APPDIR)/language.c
$(CC) $(APPCFLAGS) -c $< -o $@