Index: apps/recorder/keyboard.c =================================================================== --- apps/recorder/keyboard.c (revision 24284) +++ apps/recorder/keyboard.c (working copy) @@ -270,6 +270,62 @@ return (k < pm->nchars)? pm->kbd_buf[k]: ' '; } +#ifdef HAVE_TOUCHSCREEN +static int keyboard_touchscreen(struct keyboard_parameters *pm, + struct screen *sc) +{ + short x, y; + const int button = action_get_touchscreen_press(&x, &y); + const int sc_w = sc->getwidth(), sc_h = sc->getheight(); + if (y >= 0 && y < pm->lines*pm->font_h) + { + if (x/pm->font_w < pm->max_chars) + { + /* picker area */ + pm->x = x/pm->font_w; + pm->y = y/pm->font_h; +#ifdef KBD_MODES + pm->line_edit = false; +#endif + if (button == BUTTON_REL) + return ACTION_KBD_SELECT; + } + else + { + /* button to flip page */ + if (button == BUTTON_REL) + return ACTION_KBD_PAGE_FLIP; + } + } + else if (y >= pm->main_y - pm->keyboard_margin && y < sc_h - pm->font_h) + { + /* edit line */ + if (button & (BUTTON_REPEAT|BUTTON_REL)) + { + if (x < sc_w/2) + return ACTION_KBD_CURSOR_LEFT; + else + return ACTION_KBD_CURSOR_RIGHT; + } + } + else if (y >= sc_h - pm->font_h) + { + /* OK/Del/Cancel button */ + if (button == BUTTON_REL) + { + x /= (sc_w/3); + if (x == 0) + return ACTION_KBD_DONE; + else if (x == 1) + return ACTION_KBD_BACKSPACE; + else + return ACTION_KBD_ABORT; + } + } + return ACTION_NONE; +} +#endif + int kbd_input(char* text, int buflen) { bool done = false; @@ -336,6 +392,9 @@ } char outline[256]; +#ifdef HAVE_TOUCHSCREEN + bool touchscreen_point = (touchscreen_get_mode() == TOUCHSCREEN_POINT); +#endif #ifdef HAVE_BUTTONBAR struct gui_buttonbar buttonbar; bool buttonbar_config = global_settings.buttonbar; @@ -409,6 +468,11 @@ int i = 0; pm->max_chars = sc->getwidth() / pm->font_w; +#ifdef HAVE_TOUCHSCREEN + /* add space for buttons */ + if (l == SCREEN_MAIN) + pm->max_chars--; +#endif /* Pad lines with spaces */ while (i < pm->nchars) @@ -477,6 +541,11 @@ icon_w = get_icon_width(l); sc_w = sc->getwidth(); sc_h = sc->getheight(); +#ifdef HAVE_TOUCHSCREEN + /* add space for buttons */ + if (l == SCREEN_MAIN && touchscreen_point) + sc_h -= pm->font_h; +#endif pm->max_chars_text = (sc_w - icon_w * 2 - 2) / pm->text_w; if(pm->max_chars_text < 3 && icon_w > pm->text_w) pm->max_chars_text = sc_w / pm->text_w - 2; @@ -711,6 +780,43 @@ gui_buttonbar_set(&buttonbar, "Shift", "OK", "Del"); gui_buttonbar_draw(&buttonbar); #endif +#ifdef HAVE_TOUCHSCREEN + if (touchscreen_point) + { + struct keyboard_parameters *pm = ¶m[0]; + struct viewport vp; + viewport_set_defaults(&vp, SCREEN_MAIN); + vp.font = pm->curfont; + vp.flags |= VP_FLAG_ALIGN_CENTER; + lcd_set_viewport(&vp); + /* draw buttons */ + if (pm->pages > 1) + { + /* button to flip page. */ + vp.x = pm->max_chars*pm->font_w; + vp.y = 0; + vp.width = LCD_WIDTH - vp.x; + vp.height = pm->main_y - pm->keyboard_margin; + lcd_vline(0, 0, vp.height); + lcd_putsxy(1, (vp.height - pm->font_h)/2, ">"); + } + /* OK/Del/Cancel buttons */ + vp.x = 0; + vp.y = LCD_HEIGHT - pm->font_h - 1; + vp.width = LCD_WIDTH; + vp.height = pm->font_h + 1; + lcd_hline(0, LCD_WIDTH - 1, 0); + lcd_vline((LCD_WIDTH/3), 0, pm->font_h); + lcd_vline((LCD_WIDTH/3)*2, 0, pm->font_h); + vp.width = LCD_WIDTH/3; + lcd_putsxy(0, 1, "OK"); + vp.x = (LCD_WIDTH/3); + lcd_putsxy(0, 1, "Del"); + vp.x = (LCD_WIDTH/3)*2; + lcd_putsxy(0, 1, "Cancel"); + lcd_set_viewport(NULL); + } +#endif FOR_NB_SCREENS(l) { @@ -745,6 +851,10 @@ #endif pm = ¶m[button_screen]; sc = &screens[button_screen]; +#ifdef HAVE_TOUCHSCREEN + if (button == ACTION_TOUCHSCREEN) + button = keyboard_touchscreen(pm, sc); +#endif #if defined(KBD_MODES) || defined(HAVE_MORSE_INPUT) /* Remap some buttons to allow to move