2002-12-04 15:04:43 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2006-10-21 10:33:53 +00:00
|
|
|
|
* Copyright (C) 2002 by Bj<EFBFBD>rn Stenberg
|
2002-12-04 15:04:43 +00:00
|
|
|
|
*
|
|
|
|
|
* 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 "kernel.h"
|
2005-02-07 00:56:26 +00:00
|
|
|
|
#include "system.h"
|
2002-12-04 15:04:43 +00:00
|
|
|
|
#include "version.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "font.h"
|
2003-03-10 15:09:27 +00:00
|
|
|
|
#include "screens.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#include "statusbar.h"
|
2004-05-21 06:29:55 +00:00
|
|
|
|
#include "talk.h"
|
|
|
|
|
#include "settings.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
|
#include "misc.h"
|
2005-12-06 13:27:15 +00:00
|
|
|
|
#include "rbunicode.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#include "buttonbar.h"
|
2005-12-02 19:41:09 +00:00
|
|
|
|
#include "logf.h"
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#include "hangul.h"
|
2006-08-22 13:21:13 +00:00
|
|
|
|
#include "action.h"
|
2007-04-16 09:14:36 +00:00
|
|
|
|
#include "icon.h"
|
2007-10-10 02:28:58 +00:00
|
|
|
|
#include "pcmbuf.h"
|
|
|
|
|
#include "lang.h"
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifndef O_BINARY
|
|
|
|
|
#define O_BINARY 0
|
|
|
|
|
#endif
|
2005-10-08 07:12:28 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
|
#define BUTTONBAR_HEIGHT 8
|
2005-10-08 07:12:28 +00:00
|
|
|
|
#else
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#define BUTTONBAR_HEIGHT 0
|
|
|
|
|
#endif
|
2005-10-08 07:12:28 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#define DEFAULT_MARGIN 6
|
|
|
|
|
#define KBD_BUF_SIZE 500
|
2004-10-22 17:00:30 +00:00
|
|
|
|
|
2005-06-29 12:47:24 +00:00
|
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2007-03-05 02:07:17 +00:00
|
|
|
|
#define KBD_CURSOR_KEYS /* certain key combos move the cursor even if not
|
|
|
|
|
in line edit mode */
|
|
|
|
|
#define KBD_MODES /* I-Rivers can use picker, line edit and cursor keys */
|
2006-08-22 13:21:13 +00:00
|
|
|
|
#define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#define KBD_MODES /* Ondio uses 2 modes, picker and line edit */
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
2007-10-10 06:19:54 +00:00
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
|
|
|
|
|
|| (CONFIG_KEYPAD == IPOD_4G_PAD)
|
2005-11-19 03:19:12 +00:00
|
|
|
|
#define KBD_MODES /* iPod uses 2 modes, picker and line edit */
|
2006-12-18 16:57:48 +00:00
|
|
|
|
#define KBD_MORSE_INPUT
|
2005-11-12 16:07:17 +00:00
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
|
|
|
|
#define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */
|
|
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-01-18 11:09:06 +00:00
|
|
|
|
#define KBD_MODES /* iAudio X5 uses 2 modes, picker and line edit */
|
2006-02-24 15:42:52 +00:00
|
|
|
|
|
2006-08-03 20:17:25 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
|
#define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */
|
2007-01-04 14:36:04 +00:00
|
|
|
|
#define KBD_MORSE_INPUT
|
2007-03-04 21:59:00 +00:00
|
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
2007-05-04 17:15:55 +00:00
|
|
|
|
#define KBD_CURSOR_KEYS
|
|
|
|
|
#define KBD_MODES
|
2007-03-04 21:59:00 +00:00
|
|
|
|
#define KBD_MORSE_INPUT
|
2007-06-03 16:27:23 +00:00
|
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
|
|
|
|
#define KBD_CURSOR_KEYS
|
|
|
|
|
#define KBD_MODES
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-03-06 07:59:25 +00:00
|
|
|
|
struct keyboard_parameters
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
const unsigned char* default_kbd;
|
|
|
|
|
int DEFAULT_LINES;
|
|
|
|
|
unsigned short kbd_buf[KBD_BUF_SIZE];
|
|
|
|
|
int nchars;
|
|
|
|
|
int font_w;
|
|
|
|
|
int font_h;
|
|
|
|
|
struct font* font;
|
|
|
|
|
int curfont;
|
|
|
|
|
int main_x;
|
|
|
|
|
int main_y;
|
|
|
|
|
int max_chars;
|
|
|
|
|
int max_chars_text;
|
|
|
|
|
int lines;
|
|
|
|
|
int pages;
|
|
|
|
|
int keyboard_margin;
|
|
|
|
|
int old_main_y;
|
|
|
|
|
int curpos;
|
|
|
|
|
int leftpos;
|
|
|
|
|
int page;
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
bool line_edit;
|
|
|
|
|
#endif
|
|
|
|
|
bool hangul;
|
|
|
|
|
unsigned short hlead, hvowel, htail;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
2007-03-06 07:59:25 +00:00
|
|
|
|
static struct keyboard_parameters kbd_param[NB_SCREENS];
|
2006-03-29 16:21:42 +00:00
|
|
|
|
static bool kbd_loaded = false;
|
|
|
|
|
|
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
/* FIXME: We should put this to a configuration file. */
|
2006-04-22 09:43:43 +00:00
|
|
|
|
static const char *morse_alphabets =
|
2005-12-21 12:46:50 +00:00
|
|
|
|
"abcdefghijklmnopqrstuvwxyz1234567890,.?-@ ";
|
2005-12-02 19:41:09 +00:00
|
|
|
|
static const unsigned char morse_codes[] = {
|
|
|
|
|
0x05,0x18,0x1a,0x0c,0x02,0x12,0x0e,0x10,0x04,0x17,0x0d,0x14,0x07,
|
|
|
|
|
0x06,0x0f,0x16,0x1d,0x0a,0x08,0x03,0x09,0x11,0x0b,0x19,0x1b,0x1c,
|
2005-12-21 12:46:50 +00:00
|
|
|
|
0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f,
|
2005-12-04 08:45:24 +00:00
|
|
|
|
0x73,0x55,0x4c,0x61,0x5a,0x80 };
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
|
|
|
|
static bool morse_mode = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* Loads a custom keyboard into memory
|
|
|
|
|
call with NULL to reset keyboard */
|
|
|
|
|
int load_kbd(unsigned char* filename)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int fd, l;
|
2006-07-23 18:33:43 +00:00
|
|
|
|
int i = 0;
|
2006-07-23 18:54:00 +00:00
|
|
|
|
unsigned char buf[4];
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (filename == NULL)
|
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_loaded = false;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fd = open(filename, O_RDONLY|O_BINARY);
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
while (read(fd, buf, 1) == 1 && i < KBD_BUF_SIZE)
|
|
|
|
|
{
|
|
|
|
|
/* check how many bytes to read for this character */
|
|
|
|
|
static const unsigned char sizes[4] = { 0x80, 0xe0, 0xf0, 0xf5 };
|
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
|
|
for (count = 0; count < ARRAYLEN(sizes); count++)
|
|
|
|
|
{
|
|
|
|
|
if (buf[0] < sizes[count])
|
|
|
|
|
break;
|
2006-07-23 18:33:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (count >= ARRAYLEN(sizes))
|
|
|
|
|
continue; /* Invalid size. */
|
|
|
|
|
|
|
|
|
|
if (read(fd, &buf[1], count) != (ssize_t)count)
|
|
|
|
|
{
|
2006-07-23 18:33:43 +00:00
|
|
|
|
close(fd);
|
|
|
|
|
kbd_loaded = false;
|
|
|
|
|
return 1;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-07-23 18:54:00 +00:00
|
|
|
|
|
2006-07-23 18:33:43 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2007-03-06 07:59:25 +00:00
|
|
|
|
utf8decode(buf, &kbd_param[l].kbd_buf[i]);
|
2006-07-23 18:54:00 +00:00
|
|
|
|
|
2007-03-06 07:59:25 +00:00
|
|
|
|
if (kbd_param[0].kbd_buf[i] != 0xFEFF &&
|
|
|
|
|
kbd_param[0].kbd_buf[i] != '\r') /*skip BOM & carriage returns */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
2006-07-23 18:33:43 +00:00
|
|
|
|
i++;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
kbd_loaded = true;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2007-03-06 07:59:25 +00:00
|
|
|
|
kbd_param[l].nchars = i;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
return 0;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-21 06:29:55 +00:00
|
|
|
|
/* helper function to spell a char if voice UI is enabled */
|
2006-03-29 16:21:42 +00:00
|
|
|
|
static void kbd_spellchar(unsigned short c)
|
2004-05-21 06:29:55 +00:00
|
|
|
|
{
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2004-05-21 06:29:55 +00:00
|
|
|
|
{
|
2007-10-10 06:02:08 +00:00
|
|
|
|
unsigned char tmp[5];
|
|
|
|
|
/* store char to pass to talk_spell */
|
|
|
|
|
unsigned char* utf8 = utf8encode(c, tmp);
|
|
|
|
|
*utf8 = 0;
|
|
|
|
|
|
|
|
|
|
if(c == ' ')
|
|
|
|
|
talk_id(VOICE_BLANK, false);
|
2007-10-10 06:19:54 +00:00
|
|
|
|
else
|
2007-10-10 06:02:08 +00:00
|
|
|
|
talk_spell(tmp, false);
|
2004-05-21 06:29:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-10 02:28:58 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
static void say_edit(void)
|
|
|
|
|
{
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if(global_settings.talk_menu)
|
2007-10-10 02:28:58 +00:00
|
|
|
|
talk_id(VOICE_EDIT, false);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
static void kbd_inschar(unsigned char* text, int buflen,
|
|
|
|
|
int* editpos, unsigned short ch)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
|
|
|
|
int i, j, k, len;
|
|
|
|
|
unsigned char tmp[4];
|
|
|
|
|
unsigned char* utf8;
|
|
|
|
|
|
|
|
|
|
len = strlen(text);
|
|
|
|
|
k = utf8length(text);
|
|
|
|
|
utf8 = utf8encode(ch, tmp);
|
|
|
|
|
j = (long)utf8 - (long)tmp;
|
|
|
|
|
|
|
|
|
|
if (len + j < buflen)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
|
|
|
|
for (i = len+j; k >= *editpos; i--)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
|
|
|
|
text[i] = text[i-j];
|
|
|
|
|
if ((text[i] & MASK) != COMP)
|
|
|
|
|
k--;
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
while (j--)
|
|
|
|
|
text[i--] = tmp[j];
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
(*editpos)++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-17 19:51:30 +00:00
|
|
|
|
static void kbd_delchar(unsigned char* text, int* editpos)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
unsigned char* utf8;
|
|
|
|
|
|
|
|
|
|
if (*editpos > 0)
|
|
|
|
|
{
|
|
|
|
|
utf8 = text + utf8seek(text, *editpos);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
i++;
|
|
|
|
|
utf8--;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
|
|
|
|
while ((*utf8 & MASK) == COMP);
|
|
|
|
|
|
|
|
|
|
while (utf8[i])
|
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
*utf8 = utf8[i];
|
|
|
|
|
utf8++;
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
*utf8 = 0;
|
|
|
|
|
(*editpos)--;
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* Lookup k value based on state of param (pm) */
|
|
|
|
|
static int get_param_k(const struct keyboard_parameters *pm)
|
|
|
|
|
{
|
|
|
|
|
return (pm->page*pm->lines + pm->y)*pm->max_chars + pm->x;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
int kbd_input(char* text, int buflen)
|
|
|
|
|
{
|
2005-12-04 07:37:24 +00:00
|
|
|
|
bool done = false;
|
2007-03-06 08:19:00 +00:00
|
|
|
|
#ifdef CPU_ARM
|
|
|
|
|
/* This seems to keep the sizes for ARM way down */
|
2007-03-06 07:59:25 +00:00
|
|
|
|
struct keyboard_parameters * volatile param = kbd_param;
|
2007-03-06 08:19:00 +00:00
|
|
|
|
#else
|
|
|
|
|
struct keyboard_parameters * const param = kbd_param;
|
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int l; /* screen loop variable */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int text_w = 0;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int editpos; /* Edit position on all screens */
|
|
|
|
|
const int statusbar_size = global_settings.statusbar
|
|
|
|
|
? STATUSBAR_HEIGHT : 0;
|
|
|
|
|
unsigned short ch;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
unsigned char *utf8;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
bool cur_blink = true; /* Cursor on/off flag */
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
bool morse_reading = false;
|
|
|
|
|
unsigned char morse_code = 0;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int morse_tick = 0;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
char buf[2];
|
2006-07-23 17:16:38 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
#if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
|
2007-03-06 05:55:23 +00:00
|
|
|
|
struct screen *sc = &screens[l];
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
if (sc->width >= 160 && sc->height >= 96)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->default_kbd =
|
|
|
|
|
"ABCDEFG abcdefg !?\" @#$%+'\n"
|
|
|
|
|
"HIJKLMN hijklmn 789 &_()-`\n"
|
|
|
|
|
"OPQRSTU opqrstu 456 §|{}/<\n"
|
|
|
|
|
"VWXYZ., vwxyz.,0123 ~=[]*>\n"
|
|
|
|
|
"ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË ¢£¤¥¦§©®\n"
|
|
|
|
|
"àáâãäåæ ìíîï èéêë «»°ºª¹²³\n"
|
|
|
|
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
|
|
|
|
|
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
|
|
|
|
|
|
|
|
|
|
pm->DEFAULT_LINES = 8;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
|
2006-12-17 22:53:25 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->default_kbd =
|
|
|
|
|
"ABCDEFG !?\" @#$%+'\n"
|
|
|
|
|
"HIJKLMN 789 &_()-`\n"
|
|
|
|
|
"OPQRSTU 456 §|{}/<\n"
|
|
|
|
|
"VWXYZ.,0123 ~=[]*>\n"
|
|
|
|
|
|
|
|
|
|
"abcdefg ¢£¤¥¦§©®¬\n"
|
|
|
|
|
"hijklmn «»°ºª¹²³¶\n"
|
|
|
|
|
"opqrstu ¯±×÷¡¿µ·¨\n"
|
|
|
|
|
"vwxyz., :;¼½¾ \n"
|
|
|
|
|
|
|
|
|
|
"ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË\n"
|
|
|
|
|
"àáâãäåæ ìíîï èéêë\n"
|
|
|
|
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
|
|
|
|
|
"òóôõöø çðþýÿ ùúûü";
|
|
|
|
|
|
|
|
|
|
pm->DEFAULT_LINES = 4;
|
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2003-03-10 15:09:27 +00:00
|
|
|
|
char outline[256];
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
|
struct gui_buttonbar buttonbar;
|
2006-03-11 22:31:53 +00:00
|
|
|
|
bool buttonbar_config = global_settings.buttonbar;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-11 22:31:53 +00:00
|
|
|
|
global_settings.buttonbar = true;
|
2005-11-20 01:02:14 +00:00
|
|
|
|
gui_buttonbar_init(&buttonbar);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
gui_buttonbar_set_display(&buttonbar, &screens[l]);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
|
|
|
|
|
if ( !kbd_loaded )
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
|
|
|
|
/* Copy default keyboard to buffer */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
const unsigned char *p = pm->default_kbd;
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
pm->curfont = FONT_SYSFIXED;
|
|
|
|
|
|
2006-07-23 17:16:38 +00:00
|
|
|
|
while (*p != 0)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
p = utf8decode(p, &pm->kbd_buf[i++]);
|
|
|
|
|
|
|
|
|
|
pm->nchars = i;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
|
|
|
|
pm->curfont = FONT_UI;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
int i, w;
|
|
|
|
|
|
|
|
|
|
pm->font = font_get(pm->curfont);
|
|
|
|
|
pm->font_h = pm->font->height;
|
|
|
|
|
|
|
|
|
|
/* check if FONT_UI fits the screen */
|
|
|
|
|
if (2*pm->font_h + 3 + statusbar_size + BUTTONBAR_HEIGHT > sc->height)
|
|
|
|
|
{
|
|
|
|
|
pm->font = font_get(FONT_SYSFIXED);
|
|
|
|
|
pm->font_h = pm->font->height;
|
|
|
|
|
pm->curfont = FONT_SYSFIXED;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->setfont(pm->curfont);
|
2007-08-19 21:33:57 +00:00
|
|
|
|
pm->font_w = 0; /* reset font width */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* find max width of keyboard glyphs */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
for (i = 0; i < pm->nchars; i++)
|
|
|
|
|
{
|
2007-08-19 21:33:57 +00:00
|
|
|
|
w = font_get_width(pm->font, pm->kbd_buf[i]);
|
|
|
|
|
if ( w > pm->font_w )
|
|
|
|
|
pm->font_w = w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-23 17:16:38 +00:00
|
|
|
|
/* Since we're going to be adding spaces, make sure that we check
|
|
|
|
|
* their width too */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
w = font_get_width( pm->font, ' ' );
|
|
|
|
|
if ( w > pm->font_w )
|
|
|
|
|
pm->font_w = w;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-23 17:16:38 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
2006-07-23 17:16:38 +00:00
|
|
|
|
/* Pad lines with spaces */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
while (i < pm->nchars)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->kbd_buf[i] == '\n')
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k = sc->width / pm->font_w
|
|
|
|
|
- i % ( sc->width / pm->font_w ) - 1;
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
if (k == sc->width / pm->font_w - 1)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->nchars--;
|
|
|
|
|
|
|
|
|
|
for (j = i; j < pm->nchars; j++)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 07:59:25 +00:00
|
|
|
|
pm->kbd_buf[j] = pm->kbd_buf[j + 1];
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->nchars + k - 1 >= KBD_BUF_SIZE)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{ /* We don't want to overflow the buffer */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
k = KBD_BUF_SIZE - pm->nchars;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
for (j = pm->nchars + k - 1; j > i + k; j--)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->kbd_buf[j] = pm->kbd_buf[j-k];
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
pm->nchars += k;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
k++;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
while (k--)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->kbd_buf[i++] = ' ';
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
2006-07-23 17:16:38 +00:00
|
|
|
|
i++;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* Find max width for text string */
|
2006-03-29 16:21:42 +00:00
|
|
|
|
utf8 = text;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
|
|
|
|
|
text_w = pm->font_w;
|
|
|
|
|
|
|
|
|
|
while (*utf8)
|
|
|
|
|
{
|
|
|
|
|
int w = font_get_width(pm->font, ch);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
utf8 = (unsigned char*)utf8decode(utf8, &ch);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (w > text_w)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
text_w = w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
pm->max_chars_text = sc->width / text_w - 2;
|
|
|
|
|
|
|
|
|
|
/* Calculate keyboard grid size */
|
|
|
|
|
pm->max_chars = sc->width / pm->font_w;
|
|
|
|
|
|
|
|
|
|
if (!kbd_loaded)
|
|
|
|
|
{
|
|
|
|
|
pm->lines = pm->DEFAULT_LINES;
|
|
|
|
|
pm->keyboard_margin = DEFAULT_MARGIN;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pm->lines = (sc->height - BUTTONBAR_HEIGHT - statusbar_size)
|
|
|
|
|
/ pm->font_h - 1;
|
|
|
|
|
pm->keyboard_margin = sc->height - BUTTONBAR_HEIGHT -
|
|
|
|
|
statusbar_size - (pm->lines+1)*pm->font_h;
|
|
|
|
|
|
|
|
|
|
if (pm->keyboard_margin < 3)
|
|
|
|
|
{
|
|
|
|
|
pm->lines--;
|
|
|
|
|
pm->keyboard_margin += pm->font_h;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
if (pm->keyboard_margin > 6)
|
|
|
|
|
pm->keyboard_margin = 6;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->pages = (pm->nchars + (pm->lines*pm->max_chars-1))
|
|
|
|
|
/ (pm->lines*pm->max_chars);
|
|
|
|
|
|
|
|
|
|
if (pm->pages == 1 && kbd_loaded)
|
|
|
|
|
pm->lines = (pm->nchars + pm->max_chars - 1) / pm->max_chars;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->main_y = pm->font_h*pm->lines + pm->keyboard_margin + statusbar_size;
|
|
|
|
|
pm->main_x = 0;
|
|
|
|
|
pm->keyboard_margin -= pm->keyboard_margin/2;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->old_main_y = pm->main_y;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (morse_mode)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->main_y = sc->height - pm->font_h;
|
2005-12-04 08:45:24 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* Initial edit position is after last character */
|
|
|
|
|
editpos = utf8length(text);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2005-12-02 19:41:09 +00:00
|
|
|
|
talk_spell(text, true); /* spell initial text */
|
2004-05-21 06:29:55 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
while (!done)
|
2002-12-04 15:04:43 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* These declarations are assigned to the screen on which the key
|
|
|
|
|
action occurred - pointers save a lot of space over array notation
|
|
|
|
|
when accessing the same array element countless times */
|
|
|
|
|
int button;
|
|
|
|
|
#if NB_SCREENS > 1
|
|
|
|
|
int button_screen;
|
|
|
|
|
#else
|
|
|
|
|
const int button_screen = 0;
|
|
|
|
|
#endif
|
|
|
|
|
struct keyboard_parameters *pm;
|
|
|
|
|
struct screen *sc;
|
|
|
|
|
|
|
|
|
|
int len_utf8 = utf8length(text);
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].clear_display();
|
2005-12-06 13:27:15 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-04-22 13:06:57 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2005-12-02 19:41:09 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* declare scoped pointers inside screen loops - hide the
|
|
|
|
|
declarations from previous block level */
|
|
|
|
|
const int w = 6; /* sysfixed font width */
|
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
sc->setfont(FONT_SYSFIXED); /* Draw morse code screen with sysfont */
|
|
|
|
|
pm->x = 0;
|
|
|
|
|
pm->y = statusbar_size;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
buf[1] = '\0';
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* Draw morse code table with code descriptions. */
|
|
|
|
|
for (i = 0; morse_alphabets[i] != '\0'; i++)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int morse_len;
|
|
|
|
|
int j;
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
buf[0] = morse_alphabets[i];
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->putsxy(pm->x, pm->y, buf);
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
for (j = 0; (morse_codes[i] >> j) > 0x01; j++) ;
|
|
|
|
|
morse_len = j;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->x += w + 3;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
for (j = 0; j < morse_len; j++)
|
|
|
|
|
{
|
|
|
|
|
if ((morse_codes[i] >> (morse_len-j-1)) & 0x01)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->fillrect(pm->x + j*4, pm->y + 2, 3, 4);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->fillrect(pm->x + j*4, pm->y + 3, 1, 2);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->x += w*5 - 3;
|
|
|
|
|
if (pm->x >= sc->width - w*6)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->x = 0;
|
|
|
|
|
pm->y += 8; /* sysfixed font height */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2005-12-02 19:41:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
|
|
|
|
/* draw page */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
|
|
sc->setfont(pm->curfont);
|
|
|
|
|
|
|
|
|
|
k = pm->page*pm->max_chars*pm->lines;
|
|
|
|
|
|
|
|
|
|
for (i = j = 0; j < pm->lines && k < pm->nchars; k++)
|
|
|
|
|
{
|
|
|
|
|
int w;
|
|
|
|
|
utf8 = utf8encode(pm->kbd_buf[k], outline);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
*utf8 = 0;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
sc->getstringsize(outline, &w, NULL);
|
|
|
|
|
sc->putsxy(i*pm->font_w + (pm->font_w-w) / 2,
|
|
|
|
|
j*pm->font_h + statusbar_size, outline);
|
|
|
|
|
|
|
|
|
|
if (++i >= pm->max_chars)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
i = 0;
|
|
|
|
|
j++;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-04-22 13:06:57 +00:00
|
|
|
|
/* separator */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
int i = 0, j = 0;
|
|
|
|
|
|
|
|
|
|
/* Clear text area one pixel above separator line so any overdraw
|
|
|
|
|
doesn't collide */
|
|
|
|
|
sc->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
|
|
|
|
|
sc->fillrect(0, pm->main_y - pm->keyboard_margin - 1,
|
|
|
|
|
sc->width, pm->font_h + 4);
|
|
|
|
|
sc->set_drawmode(DRMODE_SOLID);
|
2006-04-22 13:06:57 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->hline(0, sc->width - 1, pm->main_y - pm->keyboard_margin);
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* write out the text */
|
|
|
|
|
sc->setfont(pm->curfont);
|
|
|
|
|
|
|
|
|
|
pm->curpos = MIN(editpos, pm->max_chars_text
|
2006-07-19 12:07:51 +00:00
|
|
|
|
- MIN(len_utf8 - editpos, 2));
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->leftpos = editpos - pm->curpos;
|
|
|
|
|
utf8 = text + utf8seek(text, pm->leftpos);
|
|
|
|
|
|
|
|
|
|
text_w = pm->font_w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
while (*utf8 && i < pm->max_chars_text)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
outline[j++] = *utf8++;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
if ((*utf8 & MASK) != COMP)
|
|
|
|
|
{
|
|
|
|
|
int w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
outline[j] = 0;
|
|
|
|
|
j=0;
|
|
|
|
|
i++;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->getstringsize(outline, &w, NULL);
|
|
|
|
|
sc->putsxy(i*text_w + (text_w-w)/2, pm->main_y, outline);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2005-12-06 13:27:15 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->leftpos > 0)
|
|
|
|
|
{
|
|
|
|
|
/* Draw nicer bitmap arrow if room, else settle for "<". */
|
|
|
|
|
if (text_w >= 6 && pm->font_h >= 8)
|
|
|
|
|
{
|
2007-04-16 09:14:36 +00:00
|
|
|
|
screen_put_iconxy(sc, (text_w - 6) / 2,
|
|
|
|
|
pm->main_y + (pm->font_h - 8) / 2 ,
|
|
|
|
|
Icon_Reverse_Cursor);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int w;
|
|
|
|
|
sc->getstringsize("<", &w, NULL);
|
|
|
|
|
sc->putsxy(text_w - w, pm->main_y, "<");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len_utf8 - pm->leftpos > pm->max_chars_text)
|
|
|
|
|
{
|
|
|
|
|
/* Draw nicer bitmap arrow if room, else settle for ">". */
|
|
|
|
|
if (text_w >= 6 && pm->font_h >= 8)
|
|
|
|
|
{
|
2007-04-16 09:14:36 +00:00
|
|
|
|
screen_put_iconxy(sc, sc->width - text_w + (text_w - 6) / 2,
|
|
|
|
|
pm->main_y + (pm->font_h - 8) / 2,
|
|
|
|
|
Icon_Cursor);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sc->putsxy(sc->width - text_w, pm->main_y, ">");
|
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* cursor */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
i = (pm->curpos + 1) * text_w;
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (cur_blink)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->vline(i, pm->main_y, pm->main_y + pm->font_h - 1);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->hangul) /* draw underbar */
|
|
|
|
|
sc->hline(pm->curpos*text_w, (pm->curpos+1)*text_w,
|
|
|
|
|
pm->main_y + pm->font_h - 1);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
cur_blink = !cur_blink;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
2006-04-22 13:06:57 +00:00
|
|
|
|
/* draw the button bar */
|
|
|
|
|
gui_buttonbar_set(&buttonbar, "Shift", "OK", "Del");
|
|
|
|
|
gui_buttonbar_draw(&buttonbar);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
|
|
|
|
|
sc->set_drawmode(DRMODE_COMPLEMENT);
|
2006-04-22 09:43:43 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->line_edit)
|
|
|
|
|
sc->fillrect(0, pm->main_y - pm->keyboard_margin + 2,
|
|
|
|
|
sc->width, pm->font_h + 2);
|
|
|
|
|
else /* highlight the key that has focus */
|
2006-04-22 13:06:57 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
sc->fillrect(pm->font_w*pm->x,
|
|
|
|
|
statusbar_size + pm->font_h*pm->y,
|
|
|
|
|
pm->font_w, pm->font_h);
|
|
|
|
|
sc->set_drawmode(DRMODE_SOLID);
|
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-04-22 13:06:57 +00:00
|
|
|
|
gui_syncstatusbar_draw(&statusbars, true);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2007-03-06 05:43:04 +00:00
|
|
|
|
screens[l].update();
|
|
|
|
|
|
|
|
|
|
button = get_action(CONTEXT_KEYBOARD, HZ/2);
|
2007-03-06 05:55:23 +00:00
|
|
|
|
#if NB_SCREENS > 1
|
2007-03-06 05:43:04 +00:00
|
|
|
|
button_screen = (get_action_statuscode(NULL) & ACTION_REMOTE) ? 1 : 0;
|
|
|
|
|
#endif
|
|
|
|
|
pm = ¶m[button_screen];
|
|
|
|
|
sc = &screens[button_screen];
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#if defined KBD_MORSE_INPUT && !defined KBD_MODES
|
2005-12-04 08:45:24 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
|
|
|
|
/* Remap some buttons for morse mode. */
|
2006-08-22 13:21:13 +00:00
|
|
|
|
if (button == ACTION_KBD_LEFT)
|
|
|
|
|
button = ACTION_KBD_CURSOR_LEFT;
|
|
|
|
|
if (button == ACTION_KBD_RIGHT)
|
|
|
|
|
button = ACTION_KBD_CURSOR_RIGHT;
|
2005-12-04 08:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
switch ( button )
|
|
|
|
|
{
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_ABORT:
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_UI);
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-03-11 22:31:53 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
|
global_settings.buttonbar=buttonbar_config;
|
|
|
|
|
#endif
|
2003-01-15 13:48:54 +00:00
|
|
|
|
return -1;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_PAGE_FLIP:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
|
|
|
|
int k;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
break;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (++pm->page >= pm->pages)
|
|
|
|
|
pm->page = 0;
|
|
|
|
|
|
|
|
|
|
k = get_param_k(pm);
|
|
|
|
|
kbd_spellchar(pm->kbd_buf[k]);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_MORSE_INPUT:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
morse_mode = !morse_mode;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
struct keyboard_parameters *pm = ¶m[l];
|
|
|
|
|
struct screen *sc = &screens[l];
|
|
|
|
|
|
|
|
|
|
pm->x = pm->y = pm->page = 0;
|
|
|
|
|
|
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
|
|
|
|
pm->old_main_y = pm->main_y;
|
|
|
|
|
pm->main_y = sc->height - pm->font_h;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pm->main_y = pm->old_main_y;
|
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* FIXME: We should talk something like Morse mode.. */
|
|
|
|
|
break;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2006-08-22 13:21:13 +00:00
|
|
|
|
|
|
|
|
|
case ACTION_KBD_RIGHT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* allow cursor change in non line edit morse mode */
|
|
|
|
|
if (pm->line_edit || morse_mode)
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* right doubles as cursor_right in line_edit */
|
|
|
|
|
if (pm->line_edit)
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
|
if (editpos < len_utf8)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int c = utf8seek(text, ++editpos);
|
2005-12-06 13:27:15 +00:00
|
|
|
|
kbd_spellchar(text[c]);
|
2007-10-10 05:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-10-19 15:31:42 +00:00
|
|
|
|
else if (global_settings.talk_menu)
|
2007-10-10 03:57:42 +00:00
|
|
|
|
pcmbuf_beep(1000, 150, 1500);
|
2007-10-10 05:56:53 +00:00
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MODES */
|
2006-04-22 09:43:43 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k;
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (++pm->x >= pm->max_chars)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifndef KBD_PAGE_FLIP
|
2005-10-08 07:12:28 +00:00
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (++pm->page >= pm->pages)
|
|
|
|
|
pm->page = 0;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->x = 0;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
k = get_param_k(pm);
|
|
|
|
|
kbd_spellchar(pm->kbd_buf[k]);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2006-08-22 13:21:13 +00:00
|
|
|
|
|
|
|
|
|
case ACTION_KBD_LEFT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* allow cursor change in non line edit morse mode */
|
|
|
|
|
if (pm->line_edit || morse_mode)
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
/* left doubles as cursor_left in line_edit */
|
|
|
|
|
if (pm->line_edit)
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (editpos > 0)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int c = utf8seek(text, --editpos);
|
2005-12-06 13:27:15 +00:00
|
|
|
|
kbd_spellchar(text[c]);
|
2007-10-10 05:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-10-19 15:31:42 +00:00
|
|
|
|
else if (global_settings.talk_menu)
|
2007-10-10 03:57:42 +00:00
|
|
|
|
pcmbuf_beep(1000, 150, 1500);
|
2007-10-10 05:56:53 +00:00
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MODES */
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k;
|
2007-02-10 22:39:45 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (--pm->x < 0)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifndef KBD_PAGE_FLIP
|
2005-10-08 07:12:28 +00:00
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (--pm->page < 0)
|
|
|
|
|
pm->page = pm->pages - 1;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->x = pm->max_chars - 1;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
k = get_param_k(pm);
|
|
|
|
|
kbd_spellchar(pm->kbd_buf[k]);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_DOWN:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (morse_mode)
|
2007-10-10 02:28:58 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->line_edit = !pm->line_edit;
|
2007-10-10 02:28:58 +00:00
|
|
|
|
if(pm->line_edit)
|
|
|
|
|
say_edit();
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
else
|
|
|
|
|
#else
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (pm->line_edit)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->y = 0;
|
|
|
|
|
pm->line_edit = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
if (++pm->y >= pm->lines)
|
|
|
|
|
#ifdef KBD_MODES
|
2007-10-10 02:28:58 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->line_edit = true;
|
2007-10-10 02:28:58 +00:00
|
|
|
|
say_edit();
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#else
|
|
|
|
|
pm->y = 0;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (!pm->line_edit)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k = get_param_k(pm);
|
|
|
|
|
kbd_spellchar(pm->kbd_buf[k]);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_UP:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (morse_mode)
|
2007-10-10 02:28:58 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->line_edit = !pm->line_edit;
|
2007-10-10 02:28:58 +00:00
|
|
|
|
if(pm->line_edit)
|
|
|
|
|
say_edit();
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
else
|
|
|
|
|
#else
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2003-03-10 15:09:27 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (pm->line_edit)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->y = pm->lines - 1;
|
|
|
|
|
pm->line_edit = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
2007-01-04 14:36:04 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (--pm->y < 0)
|
|
|
|
|
#ifdef KBD_MODES
|
2007-10-10 02:28:58 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->line_edit = true;
|
2007-10-10 02:28:58 +00:00
|
|
|
|
say_edit();
|
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->y = pm->lines - 1;
|
|
|
|
|
#endif
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (!pm->line_edit)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k = get_param_k(pm);
|
|
|
|
|
kbd_spellchar(pm->kbd_buf[k]);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_DONE:
|
2004-10-22 17:00:30 +00:00
|
|
|
|
/* accepts what was entered and continues */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_MORSE_SELECT:
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode && morse_reading)
|
|
|
|
|
{
|
|
|
|
|
morse_code <<= 1;
|
|
|
|
|
if ((current_tick - morse_tick) > HZ/5)
|
|
|
|
|
morse_code |= 0x01;
|
|
|
|
|
}
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2005-12-02 19:41:09 +00:00
|
|
|
|
break;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_SELECT:
|
|
|
|
|
case ACTION_KBD_SELECT_REM:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2007-01-04 14:36:04 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (morse_mode && !pm->line_edit)
|
2007-01-04 14:36:04 +00:00
|
|
|
|
#else
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
2007-01-04 14:36:04 +00:00
|
|
|
|
#endif
|
2005-12-02 19:41:09 +00:00
|
|
|
|
{
|
|
|
|
|
morse_tick = current_tick;
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (!morse_reading)
|
|
|
|
|
{
|
|
|
|
|
morse_reading = true;
|
|
|
|
|
morse_code = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
/* inserts the selected char */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->line_edit)
|
|
|
|
|
{ /* select doubles as backspace in line_edit */
|
|
|
|
|
if (pm->hangul)
|
|
|
|
|
{
|
|
|
|
|
if (pm->htail)
|
|
|
|
|
pm->htail = 0;
|
|
|
|
|
else if (pm->hvowel)
|
|
|
|
|
pm->hvowel = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
if (pm->hangul)
|
|
|
|
|
{
|
|
|
|
|
if (pm->hvowel)
|
|
|
|
|
ch = hangul_join(pm->hlead, pm->hvowel, pm->htail);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
ch = pm->hlead;
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MODES */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* find input char */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int k = get_param_k(pm);
|
|
|
|
|
ch = (k < pm->nchars) ? pm->kbd_buf[k] : ' ';
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* check for hangul input */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (ch >= 0x3131 && ch <= 0x3163)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
unsigned short tmp;
|
|
|
|
|
|
|
|
|
|
if (!pm->hangul)
|
|
|
|
|
{
|
|
|
|
|
pm->hlead = pm->hvowel = pm->htail = 0;
|
|
|
|
|
pm->hangul = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!pm->hvowel)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hvowel = ch;
|
|
|
|
|
}
|
|
|
|
|
else if (!pm->htail)
|
|
|
|
|
{
|
|
|
|
|
pm->htail = ch;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
else
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{ /* previous hangul complete */
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* check whether tail is actually lead of next char */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
tmp = hangul_join(pm->htail, ch, 0);
|
|
|
|
|
|
|
|
|
|
if (tmp != 0xfffd)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
tmp = hangul_join(pm->hlead, pm->hvowel, 0);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2006-03-31 13:59:04 +00:00
|
|
|
|
kbd_inschar(text, buflen, &editpos, tmp);
|
|
|
|
|
/* insert dummy char */
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ' ');
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hlead = pm->htail;
|
|
|
|
|
pm->hvowel = ch;
|
|
|
|
|
pm->htail = 0;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
else
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hvowel = pm->htail = 0;
|
|
|
|
|
pm->hlead = ch;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* combine into hangul */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
tmp = hangul_join(pm->hlead, pm->hvowel, pm->htail);
|
|
|
|
|
|
|
|
|
|
if (tmp != 0xfffd)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2006-03-31 13:59:04 +00:00
|
|
|
|
ch = tmp;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hvowel = pm->htail = 0;
|
|
|
|
|
pm->hlead = ch;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
{
|
|
|
|
|
pm->hangul = false;
|
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* insert char */
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2006-07-23 17:16:38 +00:00
|
|
|
|
talk_spell(text, false);
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* speak revised text */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2007-03-05 02:07:17 +00:00
|
|
|
|
#if !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS)
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_BACKSPACE:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->hangul)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->htail)
|
|
|
|
|
pm->htail = 0;
|
|
|
|
|
else if (pm->hvowel)
|
|
|
|
|
pm->hvowel = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
if (pm->hangul)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (pm->hvowel)
|
|
|
|
|
ch = hangul_join(pm->hlead, pm->hvowel, pm->htail);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
else
|
2007-03-06 05:43:04 +00:00
|
|
|
|
ch = pm->hlead;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2005-02-07 00:56:26 +00:00
|
|
|
|
talk_spell(text, false); /* speak revised text */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2003-03-10 15:09:27 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_CURSOR_RIGHT:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
|
if (editpos < len_utf8)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int c = utf8seek(text, ++editpos);
|
2005-12-06 13:27:15 +00:00
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2007-10-10 06:19:54 +00:00
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-10-19 15:31:42 +00:00
|
|
|
|
else if (global_settings.talk_menu)
|
2007-10-10 06:19:54 +00:00
|
|
|
|
pcmbuf_beep(1000, 150, 1500);
|
|
|
|
|
#endif
|
2003-03-10 15:09:27 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_CURSOR_LEFT:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
pm->hangul = false;
|
2006-08-22 13:21:13 +00:00
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (editpos > 0)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int c = utf8seek(text, --editpos);
|
2005-12-06 13:27:15 +00:00
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2007-10-10 06:19:54 +00:00
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-10-19 15:31:42 +00:00
|
|
|
|
else if (global_settings.talk_menu)
|
2007-10-10 06:19:54 +00:00
|
|
|
|
pcmbuf_beep(1000, 150, 1500);
|
|
|
|
|
#endif
|
2003-03-10 15:09:27 +00:00
|
|
|
|
break;
|
2007-03-05 02:07:17 +00:00
|
|
|
|
#endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */
|
2003-03-10 15:09:27 +00:00
|
|
|
|
|
2003-11-04 12:36:55 +00:00
|
|
|
|
case BUTTON_NONE:
|
2005-11-20 01:02:14 +00:00
|
|
|
|
gui_syncstatusbar_draw(&statusbars, false);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_reading)
|
|
|
|
|
{
|
2007-03-06 05:43:04 +00:00
|
|
|
|
int j;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
logf("Morse: 0x%02x", morse_code);
|
|
|
|
|
morse_reading = false;
|
|
|
|
|
|
|
|
|
|
for (j = 0; morse_alphabets[j] != '\0'; j++)
|
|
|
|
|
{
|
|
|
|
|
if (morse_codes[j] == morse_code)
|
|
|
|
|
break ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (morse_alphabets[j] == '\0')
|
|
|
|
|
{
|
|
|
|
|
logf("Morse code not found");
|
|
|
|
|
break ;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* turn off hangul input */
|
2007-03-06 05:43:04 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
param[l].hangul = false;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_inschar(text, buflen, &editpos, morse_alphabets[j]);
|
|
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2005-12-02 19:41:09 +00:00
|
|
|
|
talk_spell(text, false); /* speak revised text */
|
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
#endif /* KBD_MORSE_INPUT */
|
2003-11-04 12:36:55 +00:00
|
|
|
|
break;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2007-03-06 05:43:04 +00:00
|
|
|
|
if (default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_SYSFIXED);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
}
|
2004-07-26 16:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2007-03-06 05:43:04 +00:00
|
|
|
|
} /* end switch */
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
if (button != BUTTON_NONE)
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
|
|
|
|
cur_blink = true;
|
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-03-11 22:31:53 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
2007-03-06 05:43:04 +00:00
|
|
|
|
global_settings.buttonbar = buttonbar_config;
|
2006-03-11 22:31:53 +00:00
|
|
|
|
#endif
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_UI);
|
2007-03-06 05:43:04 +00:00
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|