From d9bf3b288ce5f6e84f7e6079948fdf0735b4711f Mon Sep 17 00:00:00 2001
From: Uros Majstorovic <majstor@majstor.org>
Date: Mon, 8 Jun 2020 15:10:47 +0200
Subject: kbd iface fixed

---
 code/fe310/eos/eve/eve_kbd.c       | 8 +++++---
 code/fe310/eos/eve/eve_kbd.h       | 7 ++++---
 code/fe310/eos/eve/eve_platform.c  | 2 +-
 code/fe310/eos/eve/eve_platform.h  | 2 +-
 code/fe310/eos/eve/eve_text.c      | 2 +-
 code/fe310/eos/eve/eve_touch.c     | 2 +-
 code/fe310/eos/eve/screen/font.c   | 2 +-
 code/fe310/eos/eve/screen/font.h   | 2 +-
 code/fe310/eos/eve/screen/form.c   | 3 +--
 code/fe310/eos/eve/screen/page.c   | 1 -
 code/fe310/eos/eve/screen/screen.c | 2 --
 code/fe310/eos/eve/screen/screen.h | 2 +-
 code/fe310/eos/eve/widget/page.h   | 2 +-
 code/fe310/eos/eve/widget/text.c   | 2 +-
 code/fe310/eos/eve/widget/widget.c | 2 +-
 15 files changed, 20 insertions(+), 21 deletions(-)

(limited to 'code/fe310')

diff --git a/code/fe310/eos/eve/eve_kbd.c b/code/fe310/eos/eve/eve_kbd.c
index 26361cf..aa8406f 100644
--- a/code/fe310/eos/eve/eve_kbd.c
+++ b/code/fe310/eos/eve/eve_kbd.c
@@ -36,6 +36,7 @@ void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next) {
     kbd->key_count = 0;
     kbd->key_down = 0;
     kbd->putc = NULL;
+    kbd->param = NULL;
 
     kbd->active = 1;
     eve_write16(REG_CMD_DL, 0);
@@ -50,11 +51,12 @@ void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next) {
     *mem_next = kbd->mem_addr + kbd->mem_size;
 }
 
-void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc) {
+void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param) {
     kbd->putc = putc;
+    kbd->param = param;
 }
 
-int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) {
+int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) {
     EVETouch *t;
     uint16_t evt;
 
@@ -86,7 +88,7 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w) {
                     int c = _tag;
 
                     if ((kbd->key_modifier & FLAG_CTRL) && (_tag >= '?') && (_tag <= '_')) c = (_tag - '@') & 0x7f;
-                    kbd->putc(w, c);
+                    kbd->putc(kbd->param, c);
                 }
             }
         }
diff --git a/code/fe310/eos/eve/eve_kbd.h b/code/fe310/eos/eve/eve_kbd.h
index 6529df1..4711421 100644
--- a/code/fe310/eos/eve/eve_kbd.h
+++ b/code/fe310/eos/eve/eve_kbd.h
@@ -16,9 +16,10 @@ typedef struct EVEKbd {
     uint8_t key_modifier_lock;
     char active;
     eve_kbd_input_handler_t putc;
+    void *param;
 } EVEKbd;
 
 void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next);
-void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc);
-int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx, void *w);
-uint8_t eve_kbd_draw(EVEKbd *kbd);
\ No newline at end of file
+void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param);
+int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx);
+uint8_t eve_kbd_draw(EVEKbd *kbd);
diff --git a/code/fe310/eos/eve/eve_platform.c b/code/fe310/eos/eve/eve_platform.c
index 598b932..e64d326 100644
--- a/code/fe310/eos/eve/eve_platform.c
+++ b/code/fe310/eos/eve/eve_platform.c
@@ -60,4 +60,4 @@ void eve_platform_init(void) {
     eos_intr_set(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_UI, handle_intr);
 
     eos_spi_dev_set_div(EOS_DEV_DISP, 4);
-}
\ No newline at end of file
+}
diff --git a/code/fe310/eos/eve/eve_platform.h b/code/fe310/eos/eve/eve_platform.h
index 0fb8081..41ec6b4 100644
--- a/code/fe310/eos/eve/eve_platform.h
+++ b/code/fe310/eos/eve/eve_platform.h
@@ -24,4 +24,4 @@ void eve_timer_set(uint32_t ms);
 void eve_timer_clear(void);
 uint64_t eve_time_get_tick(void);
 
-void eve_platform_init(void);
\ No newline at end of file
+void eve_platform_init(void);
diff --git a/code/fe310/eos/eve/eve_text.c b/code/fe310/eos/eve/eve_text.c
index 1d4174c..5510f80 100644
--- a/code/fe310/eos/eve/eve_text.c
+++ b/code/fe310/eos/eve/eve_text.c
@@ -183,4 +183,4 @@ void eve_text_backspace(EVEText *box) {
         box->ch_idx = (box->ch_idx + 2) % (box->line_size * box->w * 2);
     }
     eve_write16(box->mem_addr + box->ch_idx, TEXT_CRSR);
-}
\ No newline at end of file
+}
diff --git a/code/fe310/eos/eve/eve_touch.c b/code/fe310/eos/eve/eve_touch.c
index cbeae87..34cb79a 100644
--- a/code/fe310/eos/eve/eve_touch.c
+++ b/code/fe310/eos/eve/eve_touch.c
@@ -389,4 +389,4 @@ void eve_etrack_stop(void) {
         _ext_tracker.stop(&_touch_timer, touch);
     }
     _touch_timer_clear();
-}
\ No newline at end of file
+}
diff --git a/code/fe310/eos/eve/screen/font.c b/code/fe310/eos/eve/screen/font.c
index 6721f00..b5b7b74 100644
--- a/code/fe310/eos/eve/screen/font.c
+++ b/code/fe310/eos/eve/screen/font.c
@@ -5,4 +5,4 @@
 
 void eve_font_init(EVEFont *font, uint8_t font_id) {
     font->id = font_id;
-}
\ No newline at end of file
+}
diff --git a/code/fe310/eos/eve/screen/font.h b/code/fe310/eos/eve/screen/font.h
index 409b109..0572015 100644
--- a/code/fe310/eos/eve/screen/font.h
+++ b/code/fe310/eos/eve/screen/font.h
@@ -6,4 +6,4 @@ typedef struct EVEFont {
     uint8_t h;
 } EVEFont;
 
-void eve_font_init(EVEFont *font, uint8_t font_id);
\ No newline at end of file
+void eve_font_init(EVEFont *font, uint8_t font_id);
diff --git a/code/fe310/eos/eve/screen/form.c b/code/fe310/eos/eve/screen/form.c
index 41105f6..bdf910a 100644
--- a/code/fe310/eos/eve/screen/form.c
+++ b/code/fe310/eos/eve/screen/form.c
@@ -37,7 +37,7 @@ int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
                     eve_screen_hide_kbd(form->p.window->screen);
                     form->widget_f->putc(form->widget_f, CH_EOF);
                 }
-                eve_kbd_set_handler(kbd, widget->putc);
+                eve_kbd_set_handler(kbd, widget->putc, widget);
                 if (widget && widget->putc) {
                     eve_screen_show_kbd(form->p.window->screen);
                 }
@@ -75,4 +75,3 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
 
     return _tagN;
 }
-
diff --git a/code/fe310/eos/eve/screen/page.c b/code/fe310/eos/eve/screen/page.c
index b2ef091..66c7c13 100644
--- a/code/fe310/eos/eve/screen/page.c
+++ b/code/fe310/eos/eve/screen/page.c
@@ -58,4 +58,3 @@ void eve_page_handle_evt(EVEPage *page, EVEWidget *widget, EVETouch *touch, uint
     }
     */
 }
-
diff --git a/code/fe310/eos/eve/screen/screen.c b/code/fe310/eos/eve/screen/screen.c
index 52015be..9827323 100644
--- a/code/fe310/eos/eve/screen/screen.c
+++ b/code/fe310/eos/eve/screen/screen.c
@@ -71,5 +71,3 @@ void eve_screen_win_append(EVEScreen *screen, EVEWindow *window) {
 void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) {
     eve_touch_clear_opt();
 }
-
-
diff --git a/code/fe310/eos/eve/screen/screen.h b/code/fe310/eos/eve/screen/screen.h
index ff634b4..9fa155a 100644
--- a/code/fe310/eos/eve/screen/screen.h
+++ b/code/fe310/eos/eve/screen/screen.h
@@ -12,9 +12,9 @@ typedef struct EVERect {
 typedef struct EVEScreen {
     uint16_t w;
     uint16_t h;
-    EVEKbd *kbd;
     struct EVEWindow *win_head;
     struct EVEWindow *win_tail;
+    EVEKbd *kbd;
     char kbd_active;
 } EVEScreen;
 
diff --git a/code/fe310/eos/eve/widget/page.h b/code/fe310/eos/eve/widget/page.h
index a0b3e02..d7f87f0 100644
--- a/code/fe310/eos/eve/widget/page.h
+++ b/code/fe310/eos/eve/widget/page.h
@@ -10,4 +10,4 @@ typedef struct EVEPageWidget {
 
 void eve_pagew_init(EVEPageWidget *widget, EVERect *g, uint8_t font_id, char *title, EVEPage *page);
 int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus);
-uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
\ No newline at end of file
+uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c
index 2d80bbc..8b3fcdb 100644
--- a/code/fe310/eos/eve/widget/text.c
+++ b/code/fe310/eos/eve/widget/text.c
@@ -439,4 +439,4 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t
 
 void eve_textw_cursor_clear(EVETextCursor *cursor) {
     cursor->on = 0;
-}
\ No newline at end of file
+}
diff --git a/code/fe310/eos/eve/widget/widget.c b/code/fe310/eos/eve/widget/widget.c
index 79a1b25..2e253b3 100644
--- a/code/fe310/eos/eve/widget/widget.c
+++ b/code/fe310/eos/eve/widget/widget.c
@@ -30,4 +30,4 @@ void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_tou
 EVEWidget *eve_widget_next(EVEWidget *widget) {
     char *_w = (char *)widget;
     return (EVEWidget *)(_w + _eve_wsize[widget->type]);
-}
\ No newline at end of file
+}
-- 
cgit v1.2.3