diff options
author | Benjamin Tissoires <tissoire@cena.fr> | 2009-12-19 10:27:27 +0100 |
---|---|---|
committer | Benjamin Tissoires <tissoire@cena.fr> | 2010-03-15 19:05:22 +0100 |
commit | a6b2ba626570e27bc1706d260ec3491792cd1b05 (patch) | |
tree | f5aa84d5c41c5063b35720758a04e6d88108832d | |
parent | 801778c3106fc7e409369b4500253a38be6a5795 (diff) |
Detection of multitouch devices
This patch makes nothing except detecting multitouch devices and putting
this detection in the log.
Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
-rw-r--r-- | src/evdev.c | 36 | ||||
-rw-r--r-- | src/evdev.h | 6 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/evdev.c b/src/evdev.c index 3051462..0e1577f 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -118,6 +118,7 @@ static Atom prop_calibration = 0; static Atom prop_swap = 0; static Atom prop_axis_label = 0; static Atom prop_btn_label = 0; +static Atom prop_multitouch = 0; #endif /* All devices the evdev driver has allocated and knows about. @@ -349,6 +350,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 +557,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 +722,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 +1511,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); @@ -1881,6 +1890,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 tablet.\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); @@ -1929,6 +1947,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 screen\n", pInfo->name); + pInfo->type_name = "MULTITOUCHSCREEN"; } else { xf86Msg(X_INFO, "%s: Configuring as mouse\n", pInfo->name); pInfo->type_name = XI_MOUSE; @@ -2493,6 +2514,19 @@ EvdevInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_swap, FALSE); + if (pEvdev->flags & EVDEV_MULTITOUCH) { + /* The number of multitouch subdevices. + * If 0, we emulate a touchscreen. */ + prop_multitouch = MakeAtom(EVDEV_PROP_MULTITOUCH_SUBDEVICES, + strlen(EVDEV_PROP_MULTITOUCH_SUBDEVICES), TRUE); + rc = XIChangeDeviceProperty(dev, prop_multitouch, XA_INTEGER, 8, + PropModeReplace, 1, &pEvdev->num_multitouch, FALSE); + if (rc != Success) + return; + + XISetDevicePropertyDeletable(dev, prop_multitouch, FALSE); + } + #ifdef HAVE_LABELS /* Axis labelling */ if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP))) diff --git a/src/evdev.h b/src/evdev.h index 1133985..f78420b 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 @@ -79,6 +80,8 @@ #define MAX_VALUATORS 36 #endif +/* MT related */ +#define EVDEV_PROP_MULTITOUCH_SUBDEVICES "Evdev MultiTouch" #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 typedef struct { @@ -192,6 +195,9 @@ typedef struct { /* Event queue used to defer keyboard/button events until EV_SYN time. */ int num_queue; EventQueueRec queue[EVDEV_MAXQUEUE]; + + /* mt-related */ + unsigned int num_multitouch; } EvdevRec, *EvdevPtr; /* Event posting functions */ |