From d1afa786f93c8f2c20a349bc0a61b728c0341ce6 Mon Sep 17 00:00:00 2001 From: steffen Date: Mon, 17 Jun 2013 20:13:37 +0000 Subject: [PATCH] softkeys fixed and moved to utf8 --- gui/gui_softkeyboard.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/gui/gui_softkeyboard.c b/gui/gui_softkeyboard.c index 444b4d3..2842300 100644 --- a/gui/gui_softkeyboard.c +++ b/gui/gui_softkeyboard.c @@ -1,4 +1,4 @@ -/* $Id: gui_softkeyboard.c,v 1.7 2013/06/09 20:11:31 steffen Exp $ */ +/* $Id: gui_softkeyboard.c,v 1.8 2013/06/17 20:13:37 steffen Exp $ */ /*************************************************************************** * gui_softkeyboard.c * @@ -28,6 +28,7 @@ #include "draw.h" #include "gui.h" #include "system.h" +#include "utf8.h" GUISoftkeyboard *softkeyb = NULL; @@ -36,17 +37,17 @@ void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *x2, int *y1, int *y2 void gui_softkeyb_show (int enable) { /* keys which are displayed.. */ - char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X] = { - { "qwertzuiop\\", - "asdfghjkl/:", - "yxcvbnm,.-_" }, - { "QWERTZUIOP?", - "ASDFGHIKL??", - "YXCVBNM;:#+" }, + char *line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y] = { + { "qwertzuiopü", + "asdfghjklöä", + "yxcvbnm,.-/" }, + { "QWERTZUIOPÜ", + "ASDFGHIKLÖÄ", + "YXCVBNM;:+\\" }, { "0123456789=", - " ", - " " }}; - int i, j; + "{([])} ", + "!\"§$%&<>~ " }}; + int i, j, x, size; /* disable software keyboard */ if (cfg.softkeyboard == 0 || enable == 0) { @@ -61,8 +62,13 @@ void gui_softkeyb_show (int enable) { } /* reset data */ - for (i = 0; i < GUI_SOFTKEYB_MODE_MAX; i++) for (j = 0; j < 3; j++) - strncpy (softkeyb->keys[i][j], line[i][j], GUI_SOFTKEYB_X); + for (i = 0; i < GUI_SOFTKEYB_MODE_MAX; i++) for (j = 0; j < 3; j++) { + char *str = line[i][j]; + for (x = 0; x < GUI_SOFTKEYB_X; x++) { + softkeyb->keys[i][j][x] = u8_decode (str, &size); + str += size; + } + } softkeyb->enabled = TRUE; softkeyb->mode = GUI_SOFTKEYB_MODE_NORM; @@ -124,7 +130,7 @@ void gui_softkeyb_draw () { if (softkeyb->last_col == i && softkeyb->last_line == j) draw_fillrectangle (softkeyb->screen, x1, y1, x2, y2, &color[COLOR_white][0]); draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls); - c[0] = softkeyb->keys[softkeyb->mode][j][i]; + u8_encode (&c, softkeyb->keys[softkeyb->mode][j][i]); gfx_draw_text (softkeyb->screen, x1+(x2-x1-12)/2, y1+(y2-y1-12)/2, c, &color[COLOR_white][3]); } } @@ -170,9 +176,11 @@ int gui_softkeyb_event (GUIEvent *event) { gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2); if (x1 <= mp.x && mp.x <= x2 && y1 <= mp.y && mp.y <= y2) { if (event->event == EGUI_MOUSEPRESSED) { + d_printf ("softkey: %d %d %d", softkeyb->mode, j, i); softkeyb->last_line = j; softkeyb->last_col = i; -// newevent.key = softkeyb->keys[softkeyb->mode][j][i]; + newevent.key = softkeyb->keys[softkeyb->mode][j][i]; + newevent.keychar = softkeyb->keys[softkeyb->mode][j][i]; newevent.event = EGUI_KEYCHAR; newevent.guiwin_mpos.x = newevent.scr_mpos.x = -1; newevent.guiwin_mpos.y = newevent.scr_mpos.y = -1;