diff options
Diffstat (limited to 'code/fe310/eos/eve/eve_kbd.c')
-rw-r--r-- | code/fe310/eos/eve/eve_kbd.c | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/code/fe310/eos/eve/eve_kbd.c b/code/fe310/eos/eve/eve_kbd.c index 282cb37..26361cf 100644 --- a/code/fe310/eos/eve/eve_kbd.c +++ b/code/fe310/eos/eve/eve_kbd.c @@ -3,29 +3,35 @@ #include "eve.h" #include "eve_kbd.h" -#define FLAG_SHIFT 0x01 -#define FLAG_CTRL 0x02 -#define FLAG_FN 0x04 - -#define KEY_SHIFT 0x11 -#define KEY_CTRL 0x12 -#define KEY_FN 0x13 +#define KBD_X 0 +#define KBD_Y 575 +#define KBD_W 480 +#define KBD_H 225 -#define KEYS_Y 575 -#define KEYS_FSIZE 29 -#define KEYS_HEIGHT 40 -#define KEYS_RSIZE 45 +#define KEY_SPACERX 3 +#define KEY_SPACERY 5 +#define KEY_FONT 29 +#define MOD_FONT 21 #define KEY_BS 0x08 #define KEY_RET 0x0a +#define FLAG_SHIFT 0x01 +#define FLAG_CTRL 0x02 +#define FLAG_FN 0x04 + +#define TAG_SHIFT 0x11 +#define TAG_CTRL 0x12 +#define TAG_FN 0x13 + void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next) { uint16_t mem_size; - kbd->w = 480; - kbd->h = 225; + kbd->x = KBD_X; + kbd->y = KBD_Y; + kbd->w = KBD_W; + kbd->h = KBD_H; kbd->mem_addr = mem_addr; - kbd->mem_size = mem_size; kbd->key_modifier = 0; kbd->key_count = 0; kbd->key_down = 0; @@ -39,6 +45,7 @@ void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next) { eve_cmd(CMD_MEMCPY, "www", mem_addr, EVE_RAM_DL, mem_size); eve_cmd_exec(1); kbd->active = 0; + kbd->mem_size = mem_size; *mem_next = kbd->mem_addr + kbd->mem_size; } @@ -56,9 +63,9 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) { if (evt & EVE_TOUCH_ETYPE_TAG) { uint8_t _tag = t->tag; - if (_tag >= KEY_SHIFT && _tag <= KEY_FN) { + if (_tag >= TAG_SHIFT && _tag <= TAG_FN) { if (touch_idx == 0) { - uint8_t f = (1 << (_tag - KEY_SHIFT)); + uint8_t f = (1 << (_tag - TAG_SHIFT)); kbd->key_modifier = f; kbd->key_modifier_sticky &= f; @@ -86,9 +93,9 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) { if (evt & EVE_TOUCH_ETYPE_TAG_UP) { uint8_t _tag = t->tag_up; - if (_tag >= KEY_SHIFT && _tag <= KEY_FN) { + if (_tag >= TAG_SHIFT && _tag <= TAG_FN) { if (touch_idx == 0) { - uint8_t f = (1 << (_tag - KEY_SHIFT)); + uint8_t f = (1 << (_tag - TAG_SHIFT)); if (!((kbd->key_modifier_lock | kbd->key_modifier_sticky) & f)) { kbd->key_modifier &= ~f; @@ -112,23 +119,32 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) { uint8_t eve_kbd_draw(EVEKbd *kbd) { if (kbd->active) { + int x = kbd->x; + int y = kbd->y; + int w = kbd->w; + int row_h = kbd->h / 5; + int key_w = (w - 9 * KEY_SPACERX) / 10 + 1; + int mod_w = key_w + key_w / 2; + int key_h = row_h - KEY_SPACERY; + + eve_cmd_dl(SAVE_CONTEXT()); - eve_cmd(CMD_KEYS, "hhhhhhs", 0, KEYS_Y + KEYS_RSIZE * 0, 480, KEYS_HEIGHT, KEYS_FSIZE, kbd->key_down, kbd->key_modifier & (FLAG_FN | FLAG_SHIFT) ? "!@#$%^&*()" : (kbd->key_modifier & FLAG_CTRL ? " @[\\]^_? " : "1234567890")); - eve_cmd(CMD_KEYS, "hhhhhhs", 0, KEYS_Y + KEYS_RSIZE * 1, 480, KEYS_HEIGHT, KEYS_FSIZE, kbd->key_down, kbd->key_modifier & FLAG_FN ? "-_=+[]{}\\|" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "QWERTYUIOP" : "qwertyuiop"); - eve_cmd(CMD_KEYS, "hhhhhhs", 24, KEYS_Y + KEYS_RSIZE * 2, 432, KEYS_HEIGHT, KEYS_FSIZE, kbd->key_down, kbd->key_modifier & FLAG_FN ? "`~ ;:'\"" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "ASDFGHJKL" : "asdfghjkl"); - eve_cmd(CMD_KEYS, "hhhhhhs", 72, KEYS_Y + KEYS_RSIZE * 3, 335, KEYS_HEIGHT, KEYS_FSIZE, kbd->key_down, kbd->key_modifier & FLAG_FN ? " ,.<>/?" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "ZXCVBNM" : "zxcvbnm"); - eve_cmd_dl(TAG(KEY_SHIFT)); - eve_cmd(CMD_BUTTON, "hhhhhhs", 0, KEYS_Y + KEYS_RSIZE * 3, 69, KEYS_HEIGHT, 21, kbd->key_modifier & FLAG_SHIFT ? EVE_OPT_FLAT : 0, "shift"); + eve_cmd(CMD_KEYS, "hhhhhhs", x, y + row_h * 0, w, key_h, KEY_FONT, kbd->key_down, kbd->key_modifier & (FLAG_FN | FLAG_SHIFT) ? "!@#$%^&*()" : (kbd->key_modifier & FLAG_CTRL ? " @[\\]^_? " : "1234567890")); + eve_cmd(CMD_KEYS, "hhhhhhs", x, y + row_h * 1, w, key_h, KEY_FONT, kbd->key_down, kbd->key_modifier & FLAG_FN ? "-_=+[]{}\\|" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "QWERTYUIOP" : "qwertyuiop"); + eve_cmd(CMD_KEYS, "hhhhhhs", x + key_w / 2, y + row_h * 2, w - key_w, key_h, KEY_FONT, kbd->key_down, kbd->key_modifier & FLAG_FN ? "`~ ;:'\"" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "ASDFGHJKL" : "asdfghjkl"); + eve_cmd(CMD_KEYS, "hhhhhhs", x + mod_w + KEY_SPACERX, y + row_h * 3, w - 2 * (mod_w + KEY_SPACERX), key_h, KEY_FONT, kbd->key_down, kbd->key_modifier & FLAG_FN ? " ,.<>/?" : kbd->key_modifier & (FLAG_SHIFT | FLAG_CTRL) ? "ZXCVBNM" : "zxcvbnm"); + eve_cmd_dl(TAG(TAG_SHIFT)); + eve_cmd(CMD_BUTTON, "hhhhhhs", x, y + row_h * 3, mod_w, key_h, MOD_FONT, kbd->key_modifier & FLAG_SHIFT ? EVE_OPT_FLAT : 0, "shift"); eve_cmd_dl(TAG(KEY_BS)); - eve_cmd(CMD_BUTTON, "hhhhhhs", 410, KEYS_Y + KEYS_RSIZE * 3, 70, KEYS_HEIGHT, 21, kbd->key_down == KEY_BS ? EVE_OPT_FLAT : 0, "del"); - eve_cmd_dl(TAG(KEY_FN)); - eve_cmd(CMD_BUTTON, "hhhhhhs", 0, KEYS_Y + KEYS_RSIZE * 4, 69, KEYS_HEIGHT, 21, kbd->key_modifier & FLAG_FN ? EVE_OPT_FLAT : 0, "fn"); - eve_cmd_dl(TAG(KEY_CTRL)); - eve_cmd(CMD_BUTTON, "hhhhhhs", 72, KEYS_Y + KEYS_RSIZE * 4, 69, KEYS_HEIGHT, 21, kbd->key_modifier & FLAG_CTRL ? EVE_OPT_FLAT : 0, "ctrl"); + eve_cmd(CMD_BUTTON, "hhhhhhs", x + w - mod_w, y + row_h * 3, mod_w, key_h, MOD_FONT, kbd->key_down == KEY_BS ? EVE_OPT_FLAT : 0, "del"); + eve_cmd_dl(TAG(TAG_FN)); + eve_cmd(CMD_BUTTON, "hhhhhhs", x, y + row_h * 4, mod_w, key_h, MOD_FONT, kbd->key_modifier & FLAG_FN ? EVE_OPT_FLAT : 0, "fn"); + eve_cmd_dl(TAG(TAG_CTRL)); + eve_cmd(CMD_BUTTON, "hhhhhhs", x + mod_w + KEY_SPACERX, y + row_h * 4, mod_w, key_h, MOD_FONT, kbd->key_modifier & FLAG_CTRL ? EVE_OPT_FLAT : 0, "ctrl"); eve_cmd_dl(TAG(' ')); - eve_cmd(CMD_BUTTON, "hhhhhhs", 144, KEYS_Y + KEYS_RSIZE * 4, 263, KEYS_HEIGHT, 21, kbd->key_down == ' ' ? EVE_OPT_FLAT : 0, ""); + eve_cmd(CMD_BUTTON, "hhhhhhs", x + 2 * (mod_w + KEY_SPACERX), y + row_h * 4, w - 3 * (mod_w + KEY_SPACERX), key_h, MOD_FONT, kbd->key_down == ' ' ? EVE_OPT_FLAT : 0, ""); eve_cmd_dl(TAG(KEY_RET)); - eve_cmd(CMD_BUTTON, "hhhhhhs", 410, KEYS_Y + KEYS_RSIZE * 4, 69, KEYS_HEIGHT, 21, kbd->key_down == KEY_RET ? EVE_OPT_FLAT : 0, "ret"); + eve_cmd(CMD_BUTTON, "hhhhhhs", x + w - mod_w, y + row_h * 4, mod_w, key_h, MOD_FONT, kbd->key_down == KEY_RET ? EVE_OPT_FLAT : 0, "ret"); eve_cmd_dl(RESTORE_CONTEXT()); } else { eve_cmd(CMD_APPEND, "ww", kbd->mem_addr, kbd->mem_size); |