summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Gupta <ashmew2@gmail.com>2017-09-24 22:07:06 (GMT)
committer Ashish Gupta <ashmew2@gmail.com>2017-09-24 22:07:06 (GMT)
commit5d78cf0b61564552789af82529220167d561e5d7 (patch)
tree3e52271622e54f2bfcf2bd0cdd054fd4c09025f2
parent1a6a2518ee6485f37f3ac6479ca6e6098d964d80 (diff)
downloadlibnsfb-5d78cf0b61564552789af82529220167d561e5d7.tar.gz
libnsfb-5d78cf0b61564552789af82529220167d561e5d7.tar.bz2
Improve mouse/keypress handling
-rw-r--r--src/surface/kolibri.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/surface/kolibri.c b/src/surface/kolibri.c
index f39fc44..6a7b2dc 100644
--- a/src/surface/kolibri.c
+++ b/src/surface/kolibri.c
@@ -124,7 +124,7 @@ unsigned kolibri_mouse_get_relative(void)
unsigned kolibri_mouse_get_buttonpress(void)
{
unsigned error;
- __asm__ __volatile__ ("int $0x40":"=a"(error):"a"(37), "b"(2));
+ __asm__ __volatile__ ("int $0x40":"=a"(error):"a"(37), "b"(3));
return error;
}
@@ -237,6 +237,7 @@ static int kolibri_surface_initialise(nsfb_t *nsfb)
kolibri_redraw(nsfb);
/* This is for setting flags for MCALL 40 for events read by a window */
+
kolibri_set_wanted_events(EVENT_REDRAW |
EVENT_KEY |
EVENT_BUTTON |
@@ -309,7 +310,6 @@ int scan2key(int scan)
if (keycode == 0x31) return NSFB_KEY_n;
if (keycode == 0x32) return NSFB_KEY_m;
- /* TODO: Add a TAB Key here to cycle through fields */
if (keycode == 0x27) return NSFB_KEY_SEMICOLON;
if (keycode == 0x28) return NSFB_KEY_QUOTEDBL;
if (keycode == 0x2B) return NSFB_KEY_BACKSLASH;
@@ -326,10 +326,13 @@ int scan2key(int scan)
if (keycode == 0x1C) return NSFB_KEY_RETURN;
+ if (keycode == 0xE047) return NSFB_KEY_HOME;
if (keycode == 0xE04B) return NSFB_KEY_LEFT;
if (keycode == 0xE04D) return NSFB_KEY_RIGHT;
+ if (keycode == 0xE04F) return NSFB_KEY_END;
if (keycode == 0xE048) return NSFB_KEY_UP;
if (keycode == 0xE050) return NSFB_KEY_DOWN;
+ if (keycode == 0xE053) return NSFB_KEY_DELETE;
if (keycode == 0x3F) return NSFB_KEY_F5;
@@ -347,6 +350,9 @@ int scan2key(int scan)
if (keycode == 0xE049) return NSFB_KEY_PAGEUP;
if (keycode == 0xE051) return NSFB_KEY_PAGEDOWN;
+ if (keycode == 0xF) return NSFB_KEY_TAB;
+
+ debug_board_printf("[libnsfb] UNKNOWN keycode = 0x%x\n", keycode);
return NSFB_KEY_UNKNOWN;
}
@@ -431,47 +437,32 @@ static bool kolibri_surface_input(nsfb_t *nsfb, nsfb_event_t *event,
}
else if (previous_mouse_buttons != b) {
unsigned diff = previous_mouse_buttons^b;
- /* All high bits in the XOR represent bits that
- changed */
+ /* All high bits in the XOR represent bits that changed */
- if (diff & EVENT_REDRAW) {
+ if (diff & 0x1) {
/* Left mouse button */
event->value.keycode = NSFB_KEY_MOUSE_1;
- if (b & EVENT_REDRAW) {
+ /* debug_board_printf("-- Mouse LEFT button : 0x%x\n", b); */
+
+ if (b & 0x0100) {
event->type = NSFB_EVENT_KEY_DOWN;
- } else {
+ } else if (b & 0x10000) {
event->type = NSFB_EVENT_KEY_UP;
}
- } else if (diff & EVENT_KEY) {
+ } else if (diff & 0x2) {
/* Right mouse button */
event->value.keycode = NSFB_KEY_MOUSE_3;
- if (b & EVENT_KEY) {
+ if (b & 0x0200) {
event->type = NSFB_EVENT_KEY_DOWN;
- } else {
+ } else if (b & 0x20000) {
event->type = NSFB_EVENT_KEY_UP;
}
- } else if (diff & EVENT_BUTTON) {
+ } else if (diff & 0x4) {
/* Middle mouse button */
event->value.keycode = NSFB_KEY_MOUSE_2;
- if (b & EVENT_BUTTON) {
- event->type = NSFB_EVENT_KEY_DOWN;
- } else {
- event->type = NSFB_EVENT_KEY_UP;
- }
- } else if (diff & EVENT_END_REQUEST) {
- /* 4th mouse button (forward) */
- event->value.keycode = NSFB_KEY_MOUSE_4;
- if (b & EVENT_END_REQUEST) {
- event->type = NSFB_EVENT_KEY_DOWN;
- } else {
- event->type = NSFB_EVENT_KEY_UP;
- }
- } else if (diff & EVENT_DESKTOP_BACK_DRAW) {
- /* 5th mouse button (back) */
- event->value.keycode = NSFB_KEY_MOUSE_5;
- if (b & EVENT_DESKTOP_BACK_DRAW) {
+ if (b & 0x0400) {
event->type = NSFB_EVENT_KEY_DOWN;
- } else {
+ } else if (b & 0x40000) {
event->type = NSFB_EVENT_KEY_UP;
}
} else {
@@ -479,15 +470,15 @@ static bool kolibri_surface_input(nsfb_t *nsfb, nsfb_event_t *event,
char diffstr[40];
sprintf(diffstr, "Unhandled case."
"Previous_mouse_buttons^b is :"
- "%u", diff);
+ "0x%x\n", diff);
debug_board_write_str(diffstr);
}
previous_mouse_buttons = b;
}
else if (s != 0) {
- short int vert = s & 0xffff;
- short int hori = s >> 16;
+ int16_t vert = s & 0xffff;
+ int16_t hori = s >> 16;
event->type = NSFB_EVENT_KEY_DOWN;