This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, generate has been updated via fb50f1facaec877cd3b8a71f6d621648ebc0f451 (commit) via d8cb24d4ac08ad588cda79f2a5c1e96e48587484 (commit) from 1a1eb5042ec3cb87352d5d8d3f051ba7f600a7ed (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/fb50f1facaec877cd3b8a71f6d621648ebc0f...
commit fb50f1facaec877cd3b8a71f6d621648ebc0f451 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 24 15:30:25 2011 +0000
Fixes for abs linux event driver.
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c index e5beb2e..129f1ee 100644 --- a/libs/input/GP_Event.c +++ b/libs/input/GP_Event.c @@ -119,6 +119,8 @@ const char *GP_EventKeyName(enum GP_EventKeyValue key) return "RightButton"; case GP_BTN_MIDDLE: return "MiddleButton"; + case GP_BTN_PEN: + return "Pen"; default: return "Unknown"; }; @@ -151,6 +153,16 @@ static void dump_key(struct GP_Event *ev)
}
+static void dump_abs(struct GP_Event *ev) +{ + switch (ev->code) { + case GP_EV_ABS_POS: + printf("POSSITION %u %u %un", + ev->cursor_x, ev->cursor_y, ev->val.abs.pressure); + break; + } +} + void GP_EventDump(struct GP_Event *ev) { printf("EVENT (%u) ", (unsigned int)ev->time.tv_sec % 10000); @@ -163,8 +175,10 @@ void GP_EventDump(struct GP_Event *ev) dump_rel(ev); break; case GP_EV_ABS: - printf("EVENT ABSn"); + dump_abs(ev); break; + default: + printf("Unknown %un", ev->type); } }
@@ -229,7 +243,7 @@ void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure, { /* event header */ cur_state.type = GP_EV_ABS; - cur_state.code = GP_EV_REL_POS; + cur_state.code = GP_EV_ABS_POS; cur_state.val.abs.x = x; cur_state.val.abs.y = y; cur_state.val.abs.pressure = pressure; @@ -239,9 +253,11 @@ void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure, set_time(time);
- /* set global cursor */ - cur_state.cursor_x = x * screen_w / x_max; - cur_state.cursor_y = y * screen_h / y_max; + /* set global cursor, pressure == 0 is penup */ + if (pressure != 0) { + cur_state.cursor_x = x * screen_w / x_max; + cur_state.cursor_y = y * screen_h / y_max; + }
/* put it into queue */ event_put(&cur_state); diff --git a/libs/input/GP_InputDriverLinux.c b/libs/input/GP_InputDriverLinux.c index 22138cd..a0f4ddf 100644 --- a/libs/input/GP_InputDriverLinux.c +++ b/libs/input/GP_InputDriverLinux.c @@ -144,7 +144,7 @@ struct GP_InputDriverLinux *GP_InputDriverLinuxOpen(const char *path)
static void input_rel(struct GP_InputDriverLinux *self, struct input_event *ev) { - GP_DEBUG(3, "Relative event"); + GP_DEBUG(4, "Relative event");
switch (ev->code) { case REL_X: @@ -162,7 +162,7 @@ static void input_rel(struct GP_InputDriverLinux *self, struct input_event *ev)
static void input_abs(struct GP_InputDriverLinux *self, struct input_event *ev) { - GP_DEBUG(3, "Absolute event"); + GP_DEBUG(4, "Absolute event"); switch (ev->code) { case ABS_X: @@ -184,7 +184,7 @@ static void input_abs(struct GP_InputDriverLinux *self, struct input_event *ev)
static void input_key(struct GP_InputDriverLinux *self, struct input_event *ev) { - GP_DEBUG(3, "Key event"); + GP_DEBUG(4, "Key event"); (void) self;
@@ -213,7 +213,7 @@ static void do_sync(struct GP_InputDriverLinux *self)
static void input_syn(struct GP_InputDriverLinux *self, struct input_event *ev) { - GP_DEBUG(3, "Sync event"); + GP_DEBUG(4, "Sync event"); switch (ev->code) { case 0: @@ -229,27 +229,30 @@ int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self) struct input_event ev; int ret;
- while ((ret = read(self->fd, &ev, sizeof(ev))) != -1) { - switch (ev.type) { - case EV_REL: - input_rel(self, &ev); - break; - case EV_ABS: - input_abs(self, &ev); - break; - case EV_KEY: - input_key(self, &ev); - break; - case EV_SYN: - input_syn(self, &ev); - break; - default: - GP_DEBUG(3, "Unhandled type %i", ev.type); - } - } + ret = read(self->fd, &ev, sizeof(ev));
if (ret == -1 && errno == EAGAIN) return 0;
+ if (ret < 1) + return -1; + + switch (ev.type) { + case EV_REL: + input_rel(self, &ev); + break; + case EV_ABS: + input_abs(self, &ev); + break; + case EV_KEY: + input_key(self, &ev); + break; + case EV_SYN: + input_syn(self, &ev); + break; + default: + GP_DEBUG(3, "Unhandled type %i", ev.type); + } + return 1; } diff --git a/tests/drivers/linux_input.c b/tests/drivers/linux_input.c index 04a0480..86b75a6 100644 --- a/tests/drivers/linux_input.c +++ b/tests/drivers/linux_input.c @@ -24,8 +24,6 @@
*/
-#include <math.h> - #include <GP.h> #include <input/GP_InputDriverLinux.h>
@@ -33,7 +31,7 @@ int main(int argc, char *argv[]) { struct GP_InputDriverLinux *drv;
- GP_SetDebugLevel(10); + GP_SetDebugLevel(2);
if (argc != 2) { printf("Usage: %s /dev/input/eventXn", argv[0]); @@ -50,14 +48,12 @@ int main(int argc, char *argv[]) GP_EventSetScreenSize(640, 480);
for (;;) { - GP_InputDriverLinuxRead(drv); + while (GP_InputDriverLinuxRead(drv) >= 1); - while (GP_EventQueued()) { - GP_Event ev; + GP_Event ev;
- GP_EventGet(&ev); + while (GP_EventGet(&ev)) GP_EventDump(&ev); - }
usleep(1000); }
http://repo.or.cz/w/gfxprim.git/commit/d8cb24d4ac08ad588cda79f2a5c1e96e48587...
commit d8cb24d4ac08ad588cda79f2a5c1e96e48587484 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 24 15:27:42 2011 +0000
Fix the Set/Get/Reset Key not to touch out of the array.
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h index 126c0c2..cb412f1 100644 --- a/include/input/GP_Event.h +++ b/include/input/GP_Event.h @@ -39,6 +39,8 @@
#define GP_EVENT_QUEUE_SIZE 32
+#define GP_EVENT_KEYMAP_BYTES 36 + enum GP_EventType { GP_EV_KEY = 1, /* key/button press event */ GP_EV_REL = 2, /* relative event */ @@ -204,6 +206,9 @@ enum GP_EventKeyValue { GP_BTN_FORWARD = 0x115, GP_BTN_BACK = 0x116, GP_BTN_TASK = 0x117, + + /* Touchscreen pen */ + GP_BTN_PEN = 0x14a, };
enum GP_EventRelCode { @@ -264,7 +269,7 @@ typedef struct GP_Event { * Bitmap of pressed keys including mouse buttons * accumulated for all input devices. */ - uint8_t keys_pressed[36]; + uint8_t keys_pressed[GP_EVENT_KEYMAP_BYTES]; } GP_Event;
/* @@ -328,18 +333,27 @@ void GP_EventPush(uint16_t type, uint32_t code, int32_t value, static inline void GP_EventSetKey(struct GP_Event *ev, uint32_t key) { + if (key >= GP_EVENT_KEYMAP_BYTES * 8) + return; + ev->keys_pressed[(key)/8] |= 1<<((key)%8); }
static inline int GP_EventGetKey(struct GP_Event *ev, uint32_t key) { + if (key >= GP_EVENT_KEYMAP_BYTES * 8) + return 0; + return !!(ev->keys_pressed[(key)/8] & (1<<((key)%8))); }
static inline void GP_EventResetKey(struct GP_Event *ev, uint32_t key) { + if (key >= GP_EVENT_KEYMAP_BYTES * 8) + return; + ev->keys_pressed[(key)/8] &= ~(1<<((key)%8)); }
-----------------------------------------------------------------------
Summary of changes: include/input/GP_Event.h | 16 ++++++++++++- libs/input/GP_Event.c | 26 +++++++++++++++++---- libs/input/GP_InputDriverLinux.c | 47 ++++++++++++++++++++----------------- tests/drivers/linux_input.c | 12 +++------ 4 files changed, 65 insertions(+), 36 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.