From: Chase Douglas <[email protected]> MTDev translates all multitouch devices to the slotted evdev protocol. This provides a clean and uniform interface and reduces message handling inside the input module and X.
Signed-off-by: Chase Douglas <[email protected]> --- v5: No changes other than fixing conflicts. configure.ac | 3 +++ src/Makefile.am | 1 + src/evdev.c | 41 ++++++++++++++++++++++++++++++++++++++--- src/evdev.h | 5 +++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 02ab67a..d968b22 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,9 @@ AC_ARG_ENABLE(multitouch, if test "x$MULTITOUCH" = xyes; then AC_DEFINE(MULTITOUCH, 1, [Enable experimental multitouch code]) + + # Obtain compiler/linker options for mtdev + PKG_CHECK_MODULES(MTDEV, mtdev) fi # Define a configure option for an alternate input module directory diff --git a/src/Makefile.am b/src/Makefile.am index a5c89ac..b8d0dd9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ AM_CPPFLAGS =-I$(top_srcdir)/include @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version +@DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS) @DRIVER_NAME@_drv_ladir = @inputdir@ @DRIVER_NAME@_drv_la_SOURCES = @[email protected] \ diff --git a/src/evdev.c b/src/evdev.c index 32d9109..fd810c8 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -934,7 +934,17 @@ EvdevReadInput(InputInfoPtr pInfo) while (len == sizeof(ev)) { - len = read(pInfo->fd, &ev, sizeof(ev)); +#ifdef MULTITOUCH + EvdevPtr pEvdev = pInfo->private; + + if (pEvdev->mtdev) + len = mtdev_get(pEvdev->mtdev, pInfo->fd, ev, NUM_EVENTS) * + sizeof(struct input_event); + else + len = read(pInfo->fd, &ev, sizeof(ev)); +#else + len = read(pInfo->fd, &ev, sizeof(ev)); +#endif if (len <= 0) { if (errno == ENODEV) /* May happen after resume */ @@ -1457,8 +1467,8 @@ EvdevAddAbsClass(DeviceIntPtr device) int mode = pEvdev->flags & EVDEV_TOUCHPAD ? XIDependentTouch : XIDirectTouch; - if (pEvdev->absinfo[ABS_MT_SLOT].maximum > 0) - num_touches = pEvdev->absinfo[ABS_MT_SLOT].maximum; + if (pEvdev->mtdev->caps.slot.maximum > 0) + num_touches = pEvdev->mtdev->caps.slot.maximum; if (!InitTouchClassDeviceStruct(device, num_touches, mode, num_mt_axes)) { @@ -1566,8 +1576,10 @@ out: free(pEvdev->mtMask); pEvdev->mtMask = NULL; for (i = 0; i < EVDEV_MAXQUEUE; i++) + { free(pEvdev->queue[i].touchMask); pEvdev->queue[i].touchMask = NULL; + } #endif free(pEvdev->mask); pEvdev->mask = NULL; @@ -1961,6 +1973,8 @@ EvdevProc(DeviceIntPtr device, int what) free(pEvdev->mtMask); for (i = 0; i < EVDEV_MAXQUEUE; i++) free(pEvdev->queue[i].touchMask); + if (pEvdev->mtdev) + mtdev_close(pEvdev->mtdev); #endif EvdevRemoveDevice(pInfo); pEvdev->min_maj = 0; @@ -2337,6 +2351,16 @@ EvdevOpenDevice(InputInfoPtr pInfo) pEvdev->device = device; xf86Msg(X_CONFIG, "%s: Device: \"%s\"\n", pInfo->name, device); + +#ifdef MULTITOUCH + pEvdev->mtdev = malloc(sizeof(struct mtdev)); + if (!pEvdev->mtdev) + { + xf86Msg(X_ERROR, "%s: Couldn't allocate mtdev structure\n", + pInfo->name); + return BadAlloc; + } +#endif } if (pInfo->fd < 0) @@ -2351,6 +2375,17 @@ EvdevOpenDevice(InputInfoPtr pInfo) } } +#ifdef MULTITOUCH + if (mtdev_open(pEvdev->mtdev, pInfo->fd) == 0) + pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value; + else { + free(pEvdev->mtdev); + pEvdev->mtdev = NULL; + xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name); + return FALSE; + } +#endif + /* Check major/minor of device node to avoid adding duplicate devices. */ pEvdev->min_maj = EvdevGetMajorMinor(pInfo); if (EvdevIsDuplicate(pInfo)) diff --git a/src/evdev.h b/src/evdev.h index 62619dd..3fbf407 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -39,6 +39,10 @@ #include <xf86_OSproc.h> #include <xkbstr.h> +#ifdef MULTITOUCH +#include <mtdev.h> +#endif + #ifndef EV_CNT /* linux 2.6.23 kernels and earlier lack _CNT defines */ #define EV_CNT (EV_MAX+1) #endif @@ -140,6 +144,7 @@ typedef struct { int cur_slot; BOOL close_slot; BOOL open_slot; + struct mtdev *mtdev; #endif int flags; -- 1.7.2.3 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
