summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/eve_kbd.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-03-07 05:15:17 +0100
committerUros Majstorovic <majstor@majstor.org>2020-03-07 05:15:17 +0100
commit8592a98072740de43a5b469f60854d805641c999 (patch)
tree6a98fc6e90089a2c7257374832299f875bfbefd2 /code/fe310/eos/eve/eve_kbd.c
parenta0688d29102539f8bc0f5b412683bf3d899d85c0 (diff)
eve screen/tile/canvas/page/form fw added; page widget added
Diffstat (limited to 'code/fe310/eos/eve/eve_kbd.c')
-rw-r--r--code/fe310/eos/eve/eve_kbd.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/code/fe310/eos/eve/eve_kbd.c b/code/fe310/eos/eve/eve_kbd.c
index 73bd9c9..282cb37 100644
--- a/code/fe310/eos/eve/eve_kbd.c
+++ b/code/fe310/eos/eve/eve_kbd.c
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
#include "eve.h"
#include "eve_kbd.h"
@@ -17,29 +19,39 @@
#define KEY_BS 0x08
#define KEY_RET 0x0a
-void eve_kbd_init(EVEKbd *kbd, eve_kbd_input_handler_t putc, uint32_t mem_addr, uint32_t *mem_next) {
+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->mem_addr = mem_addr;
+ kbd->mem_size = mem_size;
+ kbd->key_modifier = 0;
+ kbd->key_count = 0;
+ kbd->key_down = 0;
+ kbd->putc = NULL;
+
+ kbd->active = 1;
eve_write16(REG_CMD_DL, 0);
- eve_kbd_draw(kbd, 1);
+ eve_kbd_draw(kbd);
eve_cmd_exec(1);
mem_size = eve_read16(REG_CMD_DL);
eve_cmd(CMD_MEMCPY, "www", mem_addr, EVE_RAM_DL, mem_size);
eve_cmd_exec(1);
+ kbd->active = 0;
- kbd->mem_addr = mem_addr;
- kbd->mem_size = mem_size;
- kbd->key_modifier = 0;
- kbd->key_count = 0;
- kbd->key_down = 0;
- kbd->putc = putc;
*mem_next = kbd->mem_addr + kbd->mem_size;
}
+void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc) {
+ kbd->putc = putc;
+}
+
int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) {
+ EVETouch *t;
uint16_t evt;
- EVETouch *t = eve_touch_evt(tag0, touch_idx, 1, 0x7e, &evt);
+ t = eve_touch_evt(tag0, touch_idx, 1, 0x7e, &evt);
if (t && evt) {
if (evt & EVE_TOUCH_ETYPE_TAG) {
uint8_t _tag = t->tag;
@@ -91,14 +103,15 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) {
}
}
}
- return 1;
+ kbd->active = 1;
} else {
- return 0;
+ kbd->active = 0;
}
+ return kbd->active;
}
-uint8_t eve_kbd_draw(EVEKbd *kbd, char active) {
- if (active) {
+uint8_t eve_kbd_draw(EVEKbd *kbd) {
+ if (kbd->active) {
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");