[PATCH evdev 2/5] Detection of multitouch devices
Peter Hutterer
peter.hutterer at who-t.net
Thu Apr 8 22:43:23 PDT 2010
On Sun, Mar 28, 2010 at 01:58:10PM +0200, Benjamin Tissoires wrote:
> This patch does nothing except detecting multitouch devices and putting
> this detection in the log.
>
> Signed-off-by: Benjamin Tissoires <tissoire at cena.fr>
ACK, but I'd like this one to be squashed in with the next one, it feels a
bit lost on its own.
Cheers,
Peter
> ---
> src/evdev.c | 22 +++++++++++++++++++++-
> src/evdev.h | 1 +
> 2 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 1491120..b84af7f 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -349,6 +349,8 @@ EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count)
> #define ABS_X_VALUE 0x1
> #define ABS_Y_VALUE 0x2
> #define ABS_VALUE 0x4
> +#define ABS_MT_X_VALUE 0x8
> +#define ABS_MT_Y_VALUE 0x16
> /**
> * Take the valuators and process them accordingly.
> */
> @@ -554,6 +556,10 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
> pEvdev->abs |= ABS_X_VALUE;
> else if (ev->code == ABS_Y)
> pEvdev->abs |= ABS_Y_VALUE;
> + else if (ev->code == ABS_MT_POSITION_X)
> + pEvdev->abs |= ABS_MT_X_VALUE;
> + else if (ev->code == ABS_MT_POSITION_Y)
> + pEvdev->abs |= ABS_MT_Y_VALUE;
> else
> pEvdev->abs |= ABS_VALUE;
> }
> @@ -715,6 +721,8 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
> #undef ABS_X_VALUE
> #undef ABS_Y_VALUE
> #undef ABS_VALUE
> +#undef ABS_MT_X_VALUE
> +#undef ABS_MT_Y_VALUE
>
> /* just a magic number to reduce the number of reads */
> #define NUM_EVENTS 16
> @@ -1502,7 +1510,7 @@ EvdevInit(DeviceIntPtr device)
>
> if (pEvdev->flags & (EVDEV_UNIGNORE_RELATIVE | EVDEV_UNIGNORE_ABSOLUTE))
> EvdevInitAnyClass(device, pEvdev);
> - else if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN | EVDEV_TABLET))
> + else if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN | EVDEV_TABLET | EVDEV_MULTITOUCH))
> EvdevInitTouchDevice(device, pEvdev);
> else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
> EvdevInitRelClass(device, pEvdev);
> @@ -1887,6 +1895,15 @@ EvdevProbe(InputInfoPtr pInfo)
> xf86Msg(X_INFO, "%s: Found absolute axes\n", pInfo->name);
> pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
>
> + if ((TestBit(ABS_MT_POSITION_X, pEvdev->abs_bitmask) &&
> + TestBit(ABS_MT_POSITION_Y, pEvdev->abs_bitmask))) {
> + xf86Msg(X_INFO, "%s: Found absolute multitouch device.\n", pInfo->name);
> + pEvdev->flags |= EVDEV_MULTITOUCH;
> + if (!pEvdev->num_buttons) {
> + pEvdev->num_buttons = 7; /* LMR + scroll wheels */
> + pEvdev->flags |= EVDEV_BUTTON_EVENTS;
> + }
> + }
> if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
> TestBit(ABS_Y, pEvdev->abs_bitmask))) {
> xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
> @@ -1935,6 +1952,9 @@ EvdevProbe(InputInfoPtr pInfo)
> } else if (pEvdev->flags & EVDEV_TOUCHSCREEN) {
> xf86Msg(X_INFO, "%s: Configuring as touchscreen\n", pInfo->name);
> pInfo->type_name = XI_TOUCHSCREEN;
> + } else if (pEvdev->flags & EVDEV_MULTITOUCH) {
> + xf86Msg(X_INFO, "%s: Configuring as multitouch device\n", pInfo->name);
> + pInfo->type_name = "MULTITOUCHDEVICE";
> } else {
> xf86Msg(X_INFO, "%s: Configuring as mouse\n", pInfo->name);
> pInfo->type_name = XI_MOUSE;
> diff --git a/src/evdev.h b/src/evdev.h
> index 1133985..0e115f3 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -70,6 +70,7 @@
> #define EVDEV_UNIGNORE_ABSOLUTE (1 << 9) /* explicitly unignore abs axes */
> #define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
> #define EVDEV_RELATIVE_MODE (1 << 11) /* Force relative events for devices with absolute axes */
> +#define EVDEV_MULTITOUCH (1 << 12) /* device looks like a multi-touch screen? */
>
> #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
> #define HAVE_PROPERTIES 1
> --
> 1.6.6.1
>
More information about the xorg-devel
mailing list