mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
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>
This commit is contained in:
committed by
Peter Hutterer
parent
e18abd0049
commit
c9a2b4e9ce
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
39
src/evdev.c
39
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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user