diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2010-11-08 14:35:02 -0500 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-11-11 15:50:36 +1000 |
commit | c9a2b4e9ce9b15e57241184df78c72ec8f6a4705 (patch) | |
tree | c635d1f2989721a022eb1fa9e7677078c5b3cb29 | |
parent | Add experimental XI 2.1 multitouch support (diff) | |
download | xf86-input-evdev-c9a2b4e9ce9b15e57241184df78c72ec8f6a4705.tar.gz xf86-input-evdev-c9a2b4e9ce9b15e57241184df78c72ec8f6a4705.tar.bz2 xf86-input-evdev-c9a2b4e9ce9b15e57241184df78c72ec8f6a4705.zip |
Use MTDev for multitouch devices
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 <chase.douglas@canonical.com>
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/evdev.c | 39 | ||||
-rw-r--r-- | src/evdev.h | 5 |
4 files changed, 45 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 8acc862..cfff2d4 100644 --- a/configure.ac +++ b/configure.ac @@ -57,6 +57,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 b3a5671..cca1b0c 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 = @DRIVER_NAME@.c \ diff --git a/src/evdev.c b/src/evdev.c index 16f7339..48bfaea 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -998,7 +998,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 */ @@ -1199,8 +1209,8 @@ EvdevAddAbsValuatorClass(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)) { @@ -1685,6 +1695,8 @@ EvdevProc(DeviceIntPtr device, int what) valuator_mask_free(&pEvdev->mt_mask); for (i = 0; i < EVDEV_MAXQUEUE; i++) valuator_mask_free(&pEvdev->queue[i].touchMask); + if (pEvdev->mtdev) + mtdev_close(pEvdev->mtdev); #endif EvdevRemoveDevice(pInfo); pEvdev->min_maj = 0; @@ -2084,6 +2096,16 @@ EvdevOpenDevice(InputInfoPtr pInfo) pEvdev->device = device; xf86IDrvMsg(pInfo, X_CONFIG, "Device: \"%s\"\n", 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) @@ -2098,6 +2120,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 6e3b850..c588b5d 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 @@ -142,6 +146,7 @@ typedef struct { int cur_slot; BOOL close_slot; BOOL open_slot; + struct mtdev *mtdev; #endif int flags; |