diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2010-09-20 15:03:09 +1000 |
---|---|---|
committer | Chase Douglas <chase.douglas@canonical.com> | 2010-11-22 14:01:44 -0500 |
commit | 717dacfb43a593cb2f2d45d96054e227c44f2843 (patch) | |
tree | b40c26b4e71fc5fd2bb8127589c166d37cf13ded | |
parent | 72c6ec92dcb647dbd7930f4fc3e60b1868f1a225 (diff) |
Add experimental multitouch support from XI 2.1xi2.1-new
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.
Based on an initial patch by Daniel Stone.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/list.c | 28 | ||||
-rw-r--r-- | src/test_xi2.c | 14 |
3 files changed, 48 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 1dc2ce2..d657a59 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,12 @@ PKG_CHECK_MODULES(XI2, [xi >= 1.2.99.2] [inputproto >= 1.9.99.15], HAVE_XI2="no"); AM_CONDITIONAL(HAVE_XI2, [ test "$HAVE_XI2" = "yes" ]) +# XI2.1 support +PKG_CHECK_MODULES(XI2_1, [xi >= 1.4.99.1] [inputproto >= 2.0.99.1], + HAVE_XI2_1="yes"; AC_DEFINE(HAVE_XI2_1, 1, [XI2_1 available]), + HAVE_XI2_1="no"); +AM_CONDITIONAL(HAVE_XI2_1, [ test "$HAVE_XI2_1" = "yes" ]) + AC_SUBST(XINPUT_CFLAGS) AC_SUBST(XINPUT_LIBS) AC_SUBST(HAVE_XI2) @@ -24,6 +24,9 @@ #include "xinput.h" #include <string.h> #include <X11/extensions/XIproto.h> /* for XI_Device***ChangedNotify */ +#ifdef HAVE_XI2_1 +#include <X11/extensions/XI2proto.h> /* for XITouch* */ +#endif static void print_info(Display* dpy, XDeviceInfo *info, Bool shortformat) @@ -178,6 +181,31 @@ print_classes_xi2(Display* display, XIAnyClassInfo **classes, XFree(name); } break; +#ifdef HAVE_XI2_1 + 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; +#endif /* HAVE_XI2_1 */ } } diff --git a/src/test_xi2.c b/src/test_xi2.c index 5b56397..fda695d 100644 --- a/src/test_xi2.c +++ b/src/test_xi2.c @@ -279,6 +279,11 @@ 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; +#ifdef HAVE_XI2_1 + case XI_TouchBegin: name = "TouchBegin"; break; + case XI_TouchEnd: name = "TouchEnd"; break; + case XI_TouchMotion: name = "TouchMotion"; break; +#endif default: name = "unknown event type"; break; } @@ -301,7 +306,11 @@ test_xi2(Display *display, /* Select for motion events */ mask.deviceid = XIAllDevices; +#ifdef HAVE_XI2_1 + mask.mask_len = XIMaskLen(XI_TouchMotion); +#else mask.mask_len = XIMaskLen(XI_RawMotion); +#endif mask.mask = calloc(mask.mask_len, sizeof(char)); XISetMask(mask.mask, XI_ButtonPress); XISetMask(mask.mask, XI_ButtonRelease); @@ -315,6 +324,11 @@ test_xi2(Display *display, XISetMask(mask.mask, XI_FocusOut); XISetMask(mask.mask, XI_HierarchyChanged); XISetMask(mask.mask, XI_PropertyEvent); +#ifdef HAVE_XI2_1 + XISetMask(mask.mask, XI_TouchBegin); + XISetMask(mask.mask, XI_TouchMotion); + XISetMask(mask.mask, XI_TouchEnd); +#endif XISelectEvents(display, win, &mask, 1); XMapWindow(display, win); XSync(display, False); |