softkeys fixed and moved to utf8

master
steffen 13 years ago
parent b2db01d39c
commit d1afa786f9

@ -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 * gui_softkeyboard.c
* *
@ -28,6 +28,7 @@
#include "draw.h" #include "draw.h"
#include "gui.h" #include "gui.h"
#include "system.h" #include "system.h"
#include "utf8.h"
GUISoftkeyboard *softkeyb = NULL; 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) { void gui_softkeyb_show (int enable) {
/* keys which are displayed.. */ /* keys which are displayed.. */
char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X] = { char *line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y] = {
{ "qwertzuiop\\", { "qwertzuiopü",
"asdfghjkl/:", "asdfghjklöä",
"yxcvbnm,.-_" }, "yxcvbnm,.-/" },
{ "QWERTZUIOP?", { "QWERTZUIOPÜ",
"ASDFGHIKL??", "ASDFGHIKLÖÄ",
"YXCVBNM;:#+" }, "YXCVBNM;:+\\" },
{ "0123456789=", { "0123456789=",
" ", "{([])} ",
" " }}; "!\"§$%&<>~ " }};
int i, j; int i, j, x, size;
/* disable software keyboard */ /* disable software keyboard */
if (cfg.softkeyboard == 0 || enable == 0) { if (cfg.softkeyboard == 0 || enable == 0) {
@ -61,8 +62,13 @@ void gui_softkeyb_show (int enable) {
} }
/* reset data */ /* reset data */
for (i = 0; i < GUI_SOFTKEYB_MODE_MAX; i++) for (j = 0; j < 3; j++) 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); 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->enabled = TRUE;
softkeyb->mode = GUI_SOFTKEYB_MODE_NORM; softkeyb->mode = GUI_SOFTKEYB_MODE_NORM;
@ -124,7 +130,7 @@ void gui_softkeyb_draw () {
if (softkeyb->last_col == i && softkeyb->last_line == j) if (softkeyb->last_col == i && softkeyb->last_line == j)
draw_fillrectangle (softkeyb->screen, x1, y1, x2, y2, &color[COLOR_white][0]); draw_fillrectangle (softkeyb->screen, x1, y1, x2, y2, &color[COLOR_white][0]);
draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls); 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]); 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); gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2);
if (x1 <= mp.x && mp.x <= x2 && y1 <= mp.y && mp.y <= y2) { if (x1 <= mp.x && mp.x <= x2 && y1 <= mp.y && mp.y <= y2) {
if (event->event == EGUI_MOUSEPRESSED) { if (event->event == EGUI_MOUSEPRESSED) {
d_printf ("softkey: %d %d %d", softkeyb->mode, j, i);
softkeyb->last_line = j; softkeyb->last_line = j;
softkeyb->last_col = i; 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.event = EGUI_KEYCHAR;
newevent.guiwin_mpos.x = newevent.scr_mpos.x = -1; newevent.guiwin_mpos.x = newevent.scr_mpos.x = -1;
newevent.guiwin_mpos.y = newevent.scr_mpos.y = -1; newevent.guiwin_mpos.y = newevent.scr_mpos.y = -1;

Loading…
Cancel
Save