bitbox: implement and enable mouse support.
diff --git a/contiki-bitbox/conf/ctk-conf.h b/contiki-bitbox/conf/ctk-conf.h
index 3f0fa39..bf09701 100644
--- a/contiki-bitbox/conf/ctk-conf.h
+++ b/contiki-bitbox/conf/ctk-conf.h
@@ -54,8 +54,10 @@
#define CTK_CONF_WIDGETDOWN_KEY '\t'
#define CTK_CONF_WIDGETUP_KEY (signed char)KEY_PAGEUP
+#define CTK_CONF_MOUSE_SUPPORT 1
+
/* Toggles support for icons. */
-#define CTK_CONF_ICONS 1 /* 107 bytes */
+#define CTK_CONF_ICONS 1
/* Toggles support for icon bitmaps. */
#define CTK_CONF_ICON_BITMAPS 1
@@ -64,13 +66,13 @@
#define CTK_CONF_ICON_TEXTMAPS 1
/* Toggles support for movable windows. */
-#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
+#define CTK_CONF_WINDOWMOVE 1
/* Toggles support for closable windows. */
-#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
+#define CTK_CONF_WINDOWCLOSE 1
/* Toggles support for menus. */
-#define CTK_CONF_MENUS 1 /* 1384 bytes */
+#define CTK_CONF_MENUS 1
/* Defines the default width of a menu. */
#define CTK_CONF_MENUWIDTH 16
diff --git a/contiki-bitbox/ctk/ctk-arch.c b/contiki-bitbox/ctk/ctk-arch.c
index dae9818..4a2f0b3 100644
--- a/contiki-bitbox/ctk/ctk-arch.c
+++ b/contiki-bitbox/ctk/ctk-arch.c
@@ -10,6 +10,9 @@
struct event e = {0};
+short mx, my;
+
+/* Keyboard management */
ctk_arch_key_t
ctk_arch_getkey(void)
{
@@ -29,6 +32,64 @@
return e.type == evt_keyboard_press && e.kbd.sym >= 8;
}
+
+/* Mouse management */
+void ctk_mouse_init(void)
+{
+ mx = 50;
+ my = 20;
+}
+
+unsigned char ctk_mouse_xtoc(unsigned short x)
+{
+ return x;
+}
+
+unsigned char ctk_mouse_ytoc(unsigned short y)
+{
+ return y;
+}
+
+void ctk_mouse_hide(void)
+{
+ vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] &= ~32;
+}
+
+void ctk_mouse_show(void)
+{
+ vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] |= 32;
+}
+
+unsigned short ctk_mouse_x(void)
+{
+ if (mouse_x != 0)
+ {
+ ctk_mouse_hide();
+ mx += mouse_x; mouse_x = 0;
+ if (mx < 0) mx = 0;
+ if (mx >= LIBCONIO_SCREEN_WIDTH) mx = LIBCONIO_SCREEN_WIDTH - 1;
+ }
+ return mx;
+}
+
+unsigned short ctk_mouse_y(void)
+{
+ if (mouse_y != 0) {
+ ctk_mouse_hide();
+ my += mouse_y; mouse_y = 0;
+ if (my < 0) my = 0;
+ if (my >= LIBCONIO_SCREEN_HEIGHT) my = LIBCONIO_SCREEN_HEIGHT - 1;
+ }
+ return my;
+}
+
+unsigned char ctk_mouse_button(void)
+{
+ return mouse_buttons;
+}
+
+
+/* Character display */
void
ctk_arch_draw_char(char c,
unsigned char x, unsigned char y,