From: Daniel Stone <[email protected]> This patch adds experimental support for listening to touch streams (TouchBegin, TouchMotion and TouchEnd) with test-xi2, as well as showing TouchClass information with list.
Signed-off-by: Daniel Stone <[email protected]> Signed-off-by: Chase Douglas <[email protected]> --- src/list.c | 26 ++++++++++++++++++++++++++ src/test_xi2.c | 8 +++++++- 2 files changed, 33 insertions(+), 1 deletions(-) diff --git a/src/list.c b/src/list.c index 8633c62..fa3ffcc 100644 --- a/src/list.c +++ b/src/list.c @@ -24,6 +24,9 @@ #include "xinput.h" #include <string.h> #include <X11/extensions/XIproto.h> /* for XI_Device***ChangedNotify */ +#ifdef HAVE_XI2 +#include <X11/extensions/XI2proto.h> /* for XITouch* */ +#endif static void print_info(Display* dpy, XDeviceInfo *info, Bool shortformat) @@ -178,6 +181,29 @@ print_classes_xi2(Display* display, XIAnyClassInfo **classes, XFree(name); } break; + case XITouchClass: + { + XITouchClassInfo *t = (XITouchClassInfo *)classes[i]; + + printf("\t\tMultitouch capable (max %d touches):\n", + t->num_touches); + printf("\t\t Mode: %s\n", + t->mode == XIDirectTouch ? "direct" : "dependent"); + } + break; + case XITouchValuatorClass: + { + XITouchValuatorClassInfo *tv = + (XITouchValuatorClassInfo *)classes[i]; + char *name = tv->label ? + XGetAtomName(display, tv->label) : NULL; + + printf("\t\tDetail for Touch Valuator %d:\n", tv->number); + printf("\t\t Label: %s\n", (name) ? name : "None"); + printf("\t\t Range: %f - %f\n", tv->min, tv->max); + printf("\t\t Resolution: %d units/m\n", tv->resolution); + } + break; } } diff --git a/src/test_xi2.c b/src/test_xi2.c index 30bb0fa..ba92d27 100644 --- a/src/test_xi2.c +++ b/src/test_xi2.c @@ -279,6 +279,9 @@ static const char* type_to_name(int evtype) case XI_RawButtonPress: name = "RawButtonPress"; break; case XI_RawButtonRelease: name = "RawButtonRelease"; break; case XI_RawMotion: name = "RawMotion"; break; + case XI_TouchBegin: name = "TouchBegin"; break; + case XI_TouchEnd: name = "TouchEnd"; break; + case XI_TouchMotion: name = "TouchMotion"; break; default: name = "unknown event type"; break; } @@ -301,7 +304,7 @@ test_xi2(Display *display, /* Select for motion events */ mask.deviceid = XIAllDevices; - mask.mask_len = XIMaskLen(XI_RawMotion); + mask.mask_len = XIMaskLen(XI_TouchMotion); mask.mask = calloc(mask.mask_len, sizeof(char)); XISetMask(mask.mask, XI_ButtonPress); XISetMask(mask.mask, XI_ButtonRelease); @@ -315,6 +318,9 @@ test_xi2(Display *display, XISetMask(mask.mask, XI_FocusOut); XISetMask(mask.mask, XI_HierarchyChanged); XISetMask(mask.mask, XI_PropertyEvent); + XISetMask(mask.mask, XI_TouchBegin); + XISetMask(mask.mask, XI_TouchMotion); + XISetMask(mask.mask, XI_TouchEnd); XISelectEvents(display, win, &mask, 1); XMapWindow(display, win); XSync(display, False); -- 1.7.1 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
