2006-09-15 11:11:16 +00:00
|
|
|
#include "zxconfig.h"
|
2012-02-15 21:32:43 +00:00
|
|
|
#include "zxbox_keyb.h"
|
2006-09-15 11:11:16 +00:00
|
|
|
|
2011-05-01 13:48:28 +00:00
|
|
|
//#define ZX_WRITE_OUT_TEXT
|
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
#ifndef O_BINARY
|
|
|
|
#define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEFAULT_MARGIN 6
|
|
|
|
#define KBD_BUF_SIZE 500
|
|
|
|
#define kbd_loaded false
|
|
|
|
#define statusbar_size 0
|
|
|
|
|
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_OFF
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_MENU
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_SCROLL_BACK
|
|
|
|
#define KBD_DOWN BUTTON_SCROLL_FWD
|
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
/* TODO: Check keyboard mappings */
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_REC
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
2007-05-19 23:38:09 +00:00
|
|
|
#define KBD_ABORT BUTTON_POWER
|
2006-09-15 11:11:16 +00:00
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2008-05-02 00:38:11 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
|
|
|
|
/* TODO: Check keyboard mappings */
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_REW
|
|
|
|
#define KBD_ABORT BUTTON_FF
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_SCROLL_UP
|
|
|
|
#define KBD_DOWN BUTTON_SCROLL_DOWN
|
|
|
|
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
2008-05-31 08:48:06 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_C200_PAD) || \
|
2008-11-28 00:37:28 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
|
2008-12-12 19:50:49 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_M200_PAD) || \
|
2009-01-04 23:33:15 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_FUZE_PAD) || \
|
2011-11-16 14:08:01 +00:00
|
|
|
(CONFIG_KEYPAD == MROBE100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CONNECT_PAD)
|
2006-10-26 13:38:09 +00:00
|
|
|
|
|
|
|
/* TODO: Check keyboard mappings */
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2008-03-22 14:20:04 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_RC_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_RC_REC
|
|
|
|
#define KBD_LEFT BUTTON_RC_REW
|
|
|
|
#define KBD_RIGHT BUTTON_RC_FF
|
|
|
|
#define KBD_UP BUTTON_RC_VOL_UP
|
|
|
|
#define KBD_DOWN BUTTON_RC_VOL_DOWN
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2008-03-22 22:03:34 +00:00
|
|
|
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
|
2008-12-08 09:51:42 +00:00
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
2008-12-04 21:28:56 +00:00
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2014-03-21 21:16:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT (BUTTON_PLAY|BUTTON_REL)
|
|
|
|
#define KBD_ABORT (BUTTON_PLAY|BUTTON_REPEAT)
|
|
|
|
#define KBD_LEFT BUTTON_BACK
|
|
|
|
#define KBD_RIGHT BUTTON_MENU
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_MENU
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2010-11-03 03:23:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_MENU
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_MENU
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_PREV
|
|
|
|
#define KBD_RIGHT BUTTON_NEXT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2014-05-22 21:34:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \
|
2016-01-23 14:54:08 +00:00
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YH92X_PAD)
|
2009-08-04 03:08:32 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_REW
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2010-02-14 21:56:53 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_OK
|
|
|
|
#define KBD_ABORT BUTTON_CANCEL
|
|
|
|
#define KBD_LEFT BUTTON_PREV
|
|
|
|
#define KBD_RIGHT BUTTON_NEXT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
|
2010-11-02 10:44:34 +00:00
|
|
|
#define KBD_SELECT BUTTON_FUNC
|
2010-04-26 21:40:00 +00:00
|
|
|
#define KBD_ABORT BUTTON_REC
|
|
|
|
#define KBD_LEFT BUTTON_VOL_DOWN
|
|
|
|
#define KBD_RIGHT BUTTON_VOL_UP
|
2010-11-02 10:44:34 +00:00
|
|
|
#define KBD_UP BUTTON_REW
|
|
|
|
#define KBD_DOWN BUTTON_FF
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_ENTER
|
|
|
|
#define KBD_ABORT BUTTON_MENU
|
|
|
|
#define KBD_LEFT BUTTON_REW
|
|
|
|
#define KBD_RIGHT BUTTON_FF
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2011-12-24 12:34:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD || \
|
|
|
|
CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
|
2011-10-02 17:35:14 +00:00
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2012-04-06 16:17:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == HM60X_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == HM801_PAD)
|
2012-03-23 18:32:50 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2014-06-30 18:24:15 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SONY_NWZ_PAD)
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2014-07-17 08:40:17 +00:00
|
|
|
#elif (CONFIG_KEYPAD == CREATIVE_ZEN_PAD)
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2018-03-02 20:53:55 +00:00
|
|
|
#elif (CONFIG_KEYPAD == AGPTEK_ROCKER_PAD)
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2018-06-28 10:24:26 +00:00
|
|
|
#elif CONFIG_KEYPAD == XDUOO_X3_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_PREV
|
|
|
|
#define KBD_RIGHT BUTTON_NEXT
|
|
|
|
#define KBD_UP BUTTON_HOME
|
|
|
|
#define KBD_DOWN BUTTON_OPTION
|
2018-11-05 12:01:55 +00:00
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == XDUOO_X3II_PAD || CONFIG_KEYPAD == XDUOO_X20_PAD
|
2018-11-05 12:01:55 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_PREV
|
|
|
|
#define KBD_RIGHT BUTTON_NEXT
|
2020-10-03 22:17:11 +00:00
|
|
|
#define KBD_UP BUTTON_HOME
|
|
|
|
#define KBD_DOWN BUTTON_OPTION
|
|
|
|
|
2021-02-27 22:07:37 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_LINUX_PAD
|
2020-10-03 22:17:11 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_PREV
|
|
|
|
#define KBD_RIGHT BUTTON_NEXT
|
2018-11-05 12:01:55 +00:00
|
|
|
#define KBD_UP BUTTON_HOME
|
|
|
|
#define KBD_DOWN BUTTON_OPTION
|
2018-06-28 10:24:26 +00:00
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == IHIFI_770_PAD || CONFIG_KEYPAD == IHIFI_800_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
#define KBD_ABORT BUTTON_POWER
|
|
|
|
#define KBD_LEFT BUTTON_HOME
|
|
|
|
#define KBD_RIGHT BUTTON_VOL_DOWN
|
|
|
|
#define KBD_UP BUTTON_PREV
|
|
|
|
#define KBD_DOWN BUTTON_NEXT
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == EROSQ_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
2020-10-08 13:47:40 +00:00
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_SCROLL_BACK
|
|
|
|
#define KBD_RIGHT BUTTON_SCROLL_FWD
|
2018-06-29 20:09:28 +00:00
|
|
|
#define KBD_UP BUTTON_PREV
|
|
|
|
#define KBD_DOWN BUTTON_NEXT
|
|
|
|
|
2021-02-27 22:08:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_PAD
|
|
|
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
#define KBD_ABORT BUTTON_BACK
|
|
|
|
#define KBD_LEFT BUTTON_LEFT
|
|
|
|
#define KBD_RIGHT BUTTON_RIGHT
|
|
|
|
#define KBD_UP BUTTON_UP
|
|
|
|
#define KBD_DOWN BUTTON_DOWN
|
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef KBD_SELECT
|
|
|
|
#define KBD_SELECT BUTTON_CENTER
|
|
|
|
#endif
|
|
|
|
#ifndef KBD_ABORT
|
|
|
|
#define KBD_ABORT BUTTON_TOPLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef KBD_LEFT
|
|
|
|
#define KBD_LEFT BUTTON_MIDLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef KBD_RIGHT
|
|
|
|
#define KBD_RIGHT BUTTON_MIDRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef KBD_UP
|
|
|
|
#define KBD_UP BUTTON_TOPMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef KBD_DOWN
|
|
|
|
#define KBD_DOWN BUTTON_BOTTOMMIDDLE
|
|
|
|
#endif
|
|
|
|
#endif
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
struct keyboard_parameters {
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct keyboard_parameters param[NB_SCREENS];
|
|
|
|
|
|
|
|
int zx_kbd_input(char* text/*, int buflen*/)
|
|
|
|
{
|
|
|
|
bool done = false;
|
2011-10-15 19:35:02 +00:00
|
|
|
int i, j, k, w;
|
2006-09-15 11:11:16 +00:00
|
|
|
int text_w = 0;
|
2011-05-01 13:48:28 +00:00
|
|
|
#ifdef ZX_WRITE_OUT_TEXT
|
|
|
|
int editpos, len_utf8;
|
|
|
|
#endif
|
2006-09-15 11:11:16 +00:00
|
|
|
/* int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;*/
|
|
|
|
unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
|
|
|
|
/*bool hangul = false;*/
|
|
|
|
unsigned char *utf8;
|
|
|
|
const unsigned char *p;
|
|
|
|
bool cur_blink = true;
|
|
|
|
int char_screen = 0;
|
|
|
|
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
param[l].default_kbd =
|
|
|
|
"1234567890\n"
|
|
|
|
"qwertyuiop\n"
|
|
|
|
"asdfghjkl\n"
|
|
|
|
"zxcvbnm\n"
|
|
|
|
"S\n"
|
|
|
|
"E";
|
|
|
|
|
|
|
|
param[l].DEFAULT_LINES = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
char outline[256];
|
2011-05-01 13:48:28 +00:00
|
|
|
int button;
|
2006-09-15 11:11:16 +00:00
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
/* Copy default keyboard to buffer */
|
|
|
|
i = 0;
|
|
|
|
param[l].curfont = FONT_SYSFIXED;
|
|
|
|
p = param[l].default_kbd;
|
|
|
|
while (*p != 0)
|
|
|
|
p = rb->utf8decode(p, ¶m[l].kbd_buf[i++]);
|
|
|
|
param[l].nchars = i;
|
|
|
|
/* param[l].curfont = FONT_UI;*/
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
param[l].font = rb->font_get(param[l].curfont);
|
|
|
|
param[l].font_h = param[l].font->height;
|
|
|
|
|
|
|
|
/* check if FONT_UI fits the screen */
|
2020-07-15 23:40:55 +00:00
|
|
|
if (2*param[l].font_h+3 >
|
2008-06-28 20:45:21 +00:00
|
|
|
rb->screens[l]->getheight()) {
|
2006-09-15 11:11:16 +00:00
|
|
|
param[l].font = rb->font_get(FONT_SYSFIXED);
|
|
|
|
param[l].font_h = param[l].font->height;
|
|
|
|
param[l].curfont = FONT_SYSFIXED;
|
|
|
|
}
|
|
|
|
|
|
|
|
rb->screens[l]->setfont(param[l].curfont);
|
|
|
|
/* find max width of keyboard glyphs */
|
|
|
|
for (i=0; i<param[l].nchars; i++) {
|
|
|
|
w = rb->font_get_width(param[l].font, param[l].kbd_buf[i]);
|
|
|
|
if (w > param[l].font_w)
|
|
|
|
param[l].font_w = w;
|
|
|
|
}
|
|
|
|
/* Since we're going to be adding spaces, make sure that we check
|
|
|
|
* their width too */
|
|
|
|
w = rb->font_get_width( param[l].font, ' ' );
|
|
|
|
if( w > param[l].font_w )
|
|
|
|
param[l].font_w = w;
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
/* Pad lines with spaces */
|
|
|
|
while( i < param[l].nchars )
|
|
|
|
{
|
|
|
|
if( param[l].kbd_buf[i] == '\n' )
|
|
|
|
{
|
2008-06-28 20:45:21 +00:00
|
|
|
k = ( rb->screens[l]->getwidth() / param[l].font_w ) -
|
|
|
|
i % ( rb->screens[l]->getwidth() / param[l].font_w ) - 1;
|
|
|
|
if( k == ( rb->screens[l]->getwidth() / param[l].font_w ) - 1 )
|
2006-09-15 11:11:16 +00:00
|
|
|
{
|
|
|
|
param[l].nchars--;
|
|
|
|
for( j = i; j < param[l].nchars; j++ )
|
|
|
|
{
|
|
|
|
param[l].kbd_buf[j] = param[l].kbd_buf[j+1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( param[l].nchars + k - 1 >= KBD_BUF_SIZE )
|
|
|
|
{ /* We don't want to overflow the buffer */
|
|
|
|
k = KBD_BUF_SIZE - param[l].nchars;
|
|
|
|
}
|
|
|
|
for( j = param[l].nchars + k - 1; j > i+k; j-- )
|
|
|
|
{
|
|
|
|
param[l].kbd_buf[j] = param[l].kbd_buf[j-k];
|
|
|
|
}
|
|
|
|
param[l].nchars += k;
|
|
|
|
k++;
|
|
|
|
while( k-- )
|
|
|
|
{
|
|
|
|
param[l].kbd_buf[i++] = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find max width for text string */
|
|
|
|
utf8 = text;
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
text_w = param[l].font_w;
|
|
|
|
while (*utf8) {
|
|
|
|
utf8 = (unsigned char*)rb->utf8decode(utf8, &ch);
|
|
|
|
w = rb->font_get_width(param[l].font, ch);
|
|
|
|
if (w > text_w)
|
|
|
|
text_w = w;
|
|
|
|
}
|
2008-06-28 20:45:21 +00:00
|
|
|
param[l].max_chars_text = rb->screens[l]->getwidth() / text_w - 2;
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
/* calculate keyboard grid size */
|
2008-06-28 20:45:21 +00:00
|
|
|
param[l].max_chars = rb->screens[l]->getwidth() / param[l].font_w;
|
2006-09-15 11:11:16 +00:00
|
|
|
if (!kbd_loaded) {
|
|
|
|
param[l].lines = param[l].DEFAULT_LINES;
|
|
|
|
param[l].keyboard_margin = DEFAULT_MARGIN;
|
|
|
|
} else {
|
2020-07-15 23:40:55 +00:00
|
|
|
param[l].lines = (rb->screens[l]->lcdheight -
|
2008-06-28 20:45:21 +00:00
|
|
|
statusbar_size) / param[l].font_h - 1;
|
|
|
|
param[l].keyboard_margin = rb->screens[l]->lcdheight -
|
2020-07-15 23:40:55 +00:00
|
|
|
statusbar_size -
|
2008-06-28 20:45:21 +00:00
|
|
|
(param[l].lines+1)*param[l].font_h;
|
2006-09-15 11:11:16 +00:00
|
|
|
if (param[l].keyboard_margin < 3) {
|
|
|
|
param[l].lines--;
|
|
|
|
param[l].keyboard_margin += param[l].font_h;
|
|
|
|
}
|
|
|
|
if (param[l].keyboard_margin > 6)
|
|
|
|
param[l].keyboard_margin = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
param[l].pages = (param[l].nchars + (param[l].lines*param[l].max_chars-1))
|
|
|
|
/(param[l].lines*param[l].max_chars);
|
|
|
|
if (param[l].pages == 1 && kbd_loaded)
|
|
|
|
param[l].lines = (param[l].nchars + param[l].max_chars - 1) / param[l].max_chars;
|
|
|
|
|
|
|
|
param[l].main_y = param[l].font_h*param[l].lines + param[l].keyboard_margin + statusbar_size;
|
|
|
|
param[l].main_x = 0;
|
|
|
|
param[l].keyboard_margin -= param[l].keyboard_margin/2;
|
|
|
|
|
|
|
|
}
|
2011-05-01 13:48:28 +00:00
|
|
|
#ifdef ZX_WRITE_OUT_TEXT
|
2006-09-15 11:11:16 +00:00
|
|
|
editpos = rb->utf8length(text);
|
2011-05-01 13:48:28 +00:00
|
|
|
#endif
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
while(!done)
|
|
|
|
{
|
2011-05-01 13:48:28 +00:00
|
|
|
#ifdef ZX_WRITE_OUT_TEXT
|
2006-09-15 11:11:16 +00:00
|
|
|
len_utf8 = rb->utf8length(text);
|
2011-05-01 13:48:28 +00:00
|
|
|
#endif
|
2006-09-15 11:11:16 +00:00
|
|
|
FOR_NB_SCREENS(l)
|
2021-04-23 12:42:10 +00:00
|
|
|
{
|
2006-09-15 11:11:16 +00:00
|
|
|
rb->screens[l]->clear_display();
|
2021-04-23 12:42:10 +00:00
|
|
|
}
|
2006-09-15 11:11:16 +00:00
|
|
|
|
2021-04-23 12:42:10 +00:00
|
|
|
/* draw page */
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
rb->screens[l]->setfont(param[l].curfont);
|
|
|
|
k = param[l].page*param[l].max_chars*param[l].lines;
|
|
|
|
for (i=j=0; j < param[l].lines && k < param[l].nchars; k++) {
|
|
|
|
utf8 = rb->utf8encode(param[l].kbd_buf[k], outline);
|
|
|
|
*utf8 = 0;
|
|
|
|
rb->screens[l]->getstringsize(outline, &w, NULL);
|
|
|
|
rb->screens[l]->putsxy(i*param[l].font_w + (param[l].font_w-w)/2, j*param[l].font_h
|
|
|
|
+ statusbar_size, outline);
|
|
|
|
if (++i == param[l].max_chars) {
|
|
|
|
i = 0;
|
|
|
|
j++;
|
2006-09-15 11:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-23 12:42:10 +00:00
|
|
|
}
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
/* separator */
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
2008-06-28 20:45:21 +00:00
|
|
|
rb->screens[l]->hline(0, rb->screens[l]->getwidth() - 1,
|
|
|
|
param[l].main_y - param[l].keyboard_margin);
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
/* write out the text */
|
2011-05-01 13:48:28 +00:00
|
|
|
#ifdef ZX_WRITE_OUT_TEXT
|
|
|
|
rb->screens[l]->setfont(param[l].curfont);
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
i=j=0;
|
|
|
|
param[l].curpos = MIN(editpos, param[l].max_chars_text
|
|
|
|
- MIN(len_utf8 - editpos, 2));
|
|
|
|
param[l].leftpos = editpos - param[l].curpos;
|
|
|
|
utf8 = text + rb->utf8seek(text, param[l].leftpos);
|
|
|
|
|
|
|
|
text_w = param[l].font_w;
|
|
|
|
while (*utf8 && i < param[l].max_chars_text) {
|
|
|
|
outline[j++] = *utf8++;
|
|
|
|
if ((*utf8 & MASK) != COMP) {
|
|
|
|
outline[j] = 0;
|
|
|
|
j=0;
|
|
|
|
i++;
|
|
|
|
rb->screens[l]->getstringsize(outline, &w, NULL);
|
|
|
|
rb->screens[l]->putsxy(i*text_w + (text_w-w)/2, param[l].main_y, outline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param[l].leftpos) {
|
|
|
|
rb->screens[l]->getstringsize("<", &w, NULL);
|
|
|
|
rb->screens[l]->putsxy(text_w - w, param[l].main_y, "<");
|
|
|
|
}
|
|
|
|
if (len_utf8 - param[l].leftpos > param[l].max_chars_text)
|
|
|
|
rb->screens[l]->putsxy(rb->screens[l]->width - text_w, param[l].main_y, ">");
|
|
|
|
|
|
|
|
/* cursor */
|
|
|
|
i = (param[l].curpos + 1) * text_w;
|
|
|
|
if (cur_blink)
|
|
|
|
rb->screens[l]->vline(i, param[l].main_y, param[l].main_y + param[l].font_h-1);
|
|
|
|
|
|
|
|
if (hangul) /* draw underbar */
|
|
|
|
rb->screens[l]->hline(param[l].curpos*text_w, (param[l].curpos+1)*text_w,
|
|
|
|
param[l].main_y+param[l].font_h-1);
|
|
|
|
#endif
|
2011-05-01 13:48:28 +00:00
|
|
|
}
|
2006-09-15 11:11:16 +00:00
|
|
|
cur_blink = !cur_blink;
|
|
|
|
|
2021-04-23 12:42:10 +00:00
|
|
|
/* highlight the key that has focus */
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
rb->screens[l]->set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
rb->screens[l]->fillrect(param[l].font_w * param[l].x,
|
|
|
|
statusbar_size + param[l].font_h * param[l].y,
|
|
|
|
param[l].font_w, param[l].font_h);
|
|
|
|
rb->screens[l]->set_drawmode(DRMODE_SOLID);
|
|
|
|
}
|
2020-10-08 13:47:40 +00:00
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
FOR_NB_SCREENS(l)
|
2021-04-23 12:42:10 +00:00
|
|
|
{
|
|
|
|
rb->screens[l]->update();
|
|
|
|
}
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
button = rb->button_get_w_tmo(HZ/2);
|
|
|
|
|
|
|
|
switch ( button ) {
|
|
|
|
|
|
|
|
case KBD_ABORT:
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
rb->screens[l]->setfont(FONT_UI);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KBD_RIGHT:
|
|
|
|
case KBD_RIGHT | BUTTON_REPEAT:
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
if (++param[l].x == param[l].max_chars) {
|
|
|
|
param[l].x = 0;
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
|
|
|
if (++param[l].page == param[l].pages)
|
|
|
|
param[l].page = 0;
|
|
|
|
}
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*param[l].max_chars + param[l].x;
|
|
|
|
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KBD_LEFT:
|
|
|
|
case KBD_LEFT | BUTTON_REPEAT:
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
if (param[l].x)
|
|
|
|
param[l].x--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
|
|
|
if (--param[l].page < 0)
|
|
|
|
param[l].page = (param[l].pages-1);
|
|
|
|
param[l].x = param[l].max_chars - 1;
|
|
|
|
}
|
|
|
|
k = (param[l].page*param[l].lines +
|
|
|
|
param[l].y)*param[l].max_chars + param[l].x;
|
|
|
|
/* kbd_spellchar(param[l].kbd_buf[k]);*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KBD_DOWN:
|
|
|
|
case KBD_DOWN | BUTTON_REPEAT:
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
if (param[l].y < param[l].lines - 1)
|
|
|
|
param[l].y++;
|
|
|
|
else
|
|
|
|
param[l].y=0;
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*
|
|
|
|
param[l].max_chars + param[l].x;
|
|
|
|
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KBD_UP:
|
|
|
|
case KBD_UP | BUTTON_REPEAT:
|
|
|
|
{
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
if (param[l].y)
|
|
|
|
param[l].y--;
|
|
|
|
else
|
|
|
|
param[l].y = param[l].lines - 1;
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
{
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*
|
|
|
|
param[l].max_chars + param[l].x;
|
|
|
|
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KBD_SELECT:
|
|
|
|
{
|
|
|
|
if (button == KBD_SELECT)
|
|
|
|
char_screen = 0;
|
|
|
|
|
|
|
|
/* inserts the selected char */
|
2020-10-08 13:47:40 +00:00
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
/* find input char */
|
|
|
|
k = (param[char_screen].page*param[char_screen].lines +
|
|
|
|
param[char_screen].y)*param[char_screen].max_chars +
|
|
|
|
param[char_screen].x;
|
|
|
|
if (k < param[char_screen].nchars)
|
|
|
|
ch = param[char_screen].kbd_buf[k];
|
|
|
|
else
|
|
|
|
ch = ' ';
|
|
|
|
text[0]=ch;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
rb->screens[l]->setfont(FONT_SYSFIXED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (button != BUTTON_NONE)
|
|
|
|
{
|
|
|
|
cur_blink = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
rb->screens[l]->setfont(FONT_UI);
|
|
|
|
return 0;
|
|
|
|
}
|