diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2011-01-08 12:55:57 +0100 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2011-01-08 12:55:57 +0100 |
commit | b69a64a6ab0afc429a12dd15fdec2ccae8ab771c (patch) | |
tree | a2c66d211ad7356cf1f5557078386d385800d523 | |
parent | 46f4b2b686959eda144748d5a7416716256a7d50 (diff) |
this works - ie touch data comes through
now just need to map it correctly
-rw-r--r-- | src/frame-xi2.c | 5 | ||||
-rw-r--r-- | tools/utouch-frame-test-xi2.c | 62 |
2 files changed, 32 insertions, 35 deletions
diff --git a/src/frame-xi2.c b/src/frame-xi2.c index 5edf9ce..d1adc19 100644 --- a/src/frame-xi2.c +++ b/src/frame-xi2.c @@ -264,17 +264,20 @@ utouch_frame_pump_xi2(utouch_frame_handle fh, const XIDeviceEvent *ev) switch (ev->evtype) { case XI_TouchBegin: + fprintf(stderr, "touch begin\n"); break; case XI_TouchMotion: + fprintf(stderr, "touch motion\n"); break; case XI_TouchEnd: + fprintf(stderr, "touch end\n"); break; } for (i = 0; i < nbit; i++) { if (!XIMaskIsSet(mask, i)) continue; - fprintf(stderr, "%d\n", value[i]); + fprintf(stderr, " data: %d %d\n", i, value[i]); } //return utouch_frame_sync(fh, ev->time); diff --git a/tools/utouch-frame-test-xi2.c b/tools/utouch-frame-test-xi2.c index b896b26..65adce3 100644 --- a/tools/utouch-frame-test-xi2.c +++ b/tools/utouch-frame-test-xi2.c @@ -32,25 +32,38 @@ struct frame_test { Display *display; + Window root, win; XIDeviceInfo *info, *dev; utouch_frame_handle fh; }; static int init_xi2(struct frame_test *test, int id) { + Display *dpy; int ndevices, i; - test->display = XOpenDisplay(NULL); - if (!test->display) + dpy = XOpenDisplay(NULL); + if (!dpy) return -1; - test->info = XIQueryDevice(test->display, XIAllDevices, &ndevices); + test->display = dpy; + test->info = XIQueryDevice(dpy, XIAllDevices, &ndevices); test->dev = 0; for (i = 0; i < ndevices; i++) if (test->info[i].deviceid == id) test->dev = &test->info[i]; if (!test->dev) return -1; + + test->root = DefaultRootWindow(dpy); + test->win = XCreateSimpleWindow(dpy, test->root, + 0, 0, 200, 200, 0, + BlackPixel(dpy, 0), + WhitePixel(dpy, 0)); + + XMapWindow(test->display, test->win); + XFlush(test->display); + return 0; } @@ -66,6 +79,7 @@ static void destroy_all(struct frame_test *test) { utouch_frame_delete_engine(test->fh); XIFreeDeviceInfo(test->info); + XDestroyWindow(test->display, test->win); XCloseDisplay(test->display); memset(test, 0, sizeof(*test)); } @@ -133,54 +147,34 @@ static void loop_device(struct frame_test *test) { const struct utouch_frame *frame; XIEventMask mask; - XEvent ev; - Window win = DefaultRootWindow(test->display); - - XSelectInput(test->display, win, ExposureMask); - XMaskEvent(test->display, ExposureMask, &ev); - XSelectInput(test->display, win, 0); + mask.deviceid = XIAllDevices; + mask.mask_len = XIMaskLen(XI_TouchMotion); + mask.mask = calloc(mask.mask_len, sizeof(char)); memset(mask.mask, 0, mask.mask_len); + XISetMask(mask.mask, XI_TouchBegin); XISetMask(mask.mask, XI_TouchMotion); XISetMask(mask.mask, XI_TouchEnd); - XISelectEvents(test->display, win, &mask, 1); + XISelectEvents(test->display, test->win, &mask, 1); - XMapWindow(test->display, win); - XSync(test->display, False); + XSelectInput(test->display, test->win, ExposureMask); while (1) { + XEvent ev; + XIDeviceEvent *event = (void*)&ev; XGenericEventCookie *cookie = &ev.xcookie; XNextEvent(test->display, &ev); - fprintf(stderr, "ev %d %d\n", - cookie->extension, cookie->evtype); - if (XGetEventData(test->display, cookie) && cookie->type == GenericEvent) { - fprintf(stderr, "type %d %d\n", - cookie->extension, cookie->evtype); - switch (cookie->evtype) { - case XI_TouchBegin: - break; - case XI_TouchMotion: - break; - case XI_TouchEnd: - break; - } - } - XFreeEventData(test->display, cookie); - } - -#if 0 - while (!mtdev_idle(test->mtdev, fd, 5000)) { - while (mtdev_get(test->mtdev, fd, &ev, 1) > 0) { - frame = utouch_frame_pump_mtdev(test->fh, &ev); + // should have that opcode as well + frame = utouch_frame_pump_xi2(test->fh, cookie->data); if (frame) report_frame(frame); } + XFreeEventData(test->display, cookie); } -#endif } int main(int argc, char *argv[]) |