Bug 101861 - ABS_MT_DISTANCE is not handled by libinput
Summary: ABS_MT_DISTANCE is not handled by libinput
Status: RESOLVED NOTOURBUG
Alias: None
Product: Wayland
Classification: Unclassified
Component: libinput (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Wayland bug list
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-20 21:38 UTC by Zoltán Böszörményi
Modified: 2017-08-16 06:56 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
hid-recorder output from starting EETI's eGTouchD daemon (20.00 KB, text/plain)
2017-07-25 04:57 UTC, Zoltán Böszörményi
Details
strace output from eGTouchD (724.90 KB, text/plain)
2017-07-25 05:18 UTC, Zoltán Böszörményi
Details

Description Zoltán Böszörményi 2017-07-20 21:38:47 UTC
I have to work with a new POS device with an USB eGalax touchscreen device,
VID:PID = 0x0eef:0x0001.

xf86-input-libinput provides a half working touchscreen experience, the X cursor
follows my finger but taps are not registered as clicks.

I found with evtest that this device reports ABS_MT_DISTANCE = 0 when pressed
and ABS_MT_DISTANCE = 1 when not pressed, like this below:

# evtest 
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	Lid Switch
/dev/input/event1:	Power Button
/dev/input/event2:	Sleep Button
/dev/input/event3:	Power Button
/dev/input/event4:	AT Translated Set 2 keyboard
/dev/input/event5:	ID TECH TM3 Magstripe USB-HID Keyboard Reader
/dev/input/event6:	Video Bus
/dev/input/event7:	HID 04f3:0103
/dev/input/event8:	HID 04f3:0103
/dev/input/event9:	PC Speaker
/dev/input/event10:	eGalax Inc. USB TouchController Pen
/dev/input/event11:	eGalax Inc. USB TouchController
/dev/input/event12:	HDA Digital PCBeep
/dev/input/event13:	HDA Intel PCH HDMI/DP,pcm=3
/dev/input/event14:	HDA Intel PCH HDMI/DP,pcm=7
Select the device event number [0-14]: 11
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xeef product 0x1 version 0x100
Input device name: "eGalax Inc. USB TouchController"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    818
      Min        0
      Max     4095
    Event code 1 (ABS_Y)
      Value   3232
      Min        0
      Max     4095
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        0
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     4095
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max     4095
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 59 (ABS_MT_DISTANCE)
      Value      0
      Min        0
      Max        1
Properties:
  Property type 1 (INPUT_PROP_DIRECT)
Testing ... (interrupt to exit)
Event: time 1500585531.437703, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 826
Event: time 1500585531.437703, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2376
Event: time 1500585531.437703, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 0
Event: time 1500585531.437703, type 3 (EV_ABS), code 0 (ABS_X), value 826
Event: time 1500585531.437703, type 3 (EV_ABS), code 1 (ABS_Y), value 2376
Event: time 1500585531.437703, -------------- SYN_REPORT ------------
Event: time 1500585531.445689, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 824
Event: time 1500585531.445689, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2370
Event: time 1500585531.445689, type 3 (EV_ABS), code 0 (ABS_X), value 824
Event: time 1500585531.445689, type 3 (EV_ABS), code 1 (ABS_Y), value 2370
Event: time 1500585531.445689, -------------- SYN_REPORT ------------
Event: time 1500585531.451689, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 820
Event: time 1500585531.451689, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2356
Event: time 1500585531.451689, type 3 (EV_ABS), code 0 (ABS_X), value 820
Event: time 1500585531.451689, type 3 (EV_ABS), code 1 (ABS_Y), value 2356
Event: time 1500585531.451689, -------------- SYN_REPORT ------------
Event: time 1500585531.459688, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 814
Event: time 1500585531.459688, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2340
Event: time 1500585531.459688, type 3 (EV_ABS), code 0 (ABS_X), value 814
Event: time 1500585531.459688, type 3 (EV_ABS), code 1 (ABS_Y), value 2340
Event: time 1500585531.459688, -------------- SYN_REPORT ------------
Event: time 1500585531.465694, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 808
Event: time 1500585531.465694, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2326
Event: time 1500585531.465694, type 3 (EV_ABS), code 0 (ABS_X), value 808
Event: time 1500585531.465694, type 3 (EV_ABS), code 1 (ABS_Y), value 2326
Event: time 1500585531.465694, -------------- SYN_REPORT ------------
Event: time 1500585531.471692, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 804
Event: time 1500585531.471692, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2314
Event: time 1500585531.471692, type 3 (EV_ABS), code 0 (ABS_X), value 804
Event: time 1500585531.471692, type 3 (EV_ABS), code 1 (ABS_Y), value 2314
Event: time 1500585531.471692, -------------- SYN_REPORT ------------
Event: time 1500585531.479689, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 800
Event: time 1500585531.479689, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2304
Event: time 1500585531.479689, type 3 (EV_ABS), code 0 (ABS_X), value 800
Event: time 1500585531.479689, type 3 (EV_ABS), code 1 (ABS_Y), value 2304
Event: time 1500585531.479689, -------------- SYN_REPORT ------------
Event: time 1500585531.485694, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 798
Event: time 1500585531.485694, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 2296
Event: time 1500585531.485694, type 3 (EV_ABS), code 0 (ABS_X), value 798
Event: time 1500585531.485694, type 3 (EV_ABS), code 1 (ABS_Y), value 2296
Event: time 1500585531.485694, -------------- SYN_REPORT ------------
Event: time 1500585531.489682, type 3 (EV_ABS), code 59 (ABS_MT_DISTANCE), value 1
Event: time 1500585531.489682, -------------- SYN_REPORT ------------

ABS_MT_DISTANCE is not handled with libinput's evdev methods.
Comment 1 Zoltán Böszörményi 2017-07-20 21:44:04 UTC
I forgot to mention versions:

libinput 1.8.1
xf86-input-libinput 0.25.1
kernel 4.12.2
Comment 2 Peter Hutterer 2017-07-24 23:22:28 UTC
does this thing use a special kernel driver? The device is supposed to send BTN_TOUCH when the touch is logically down and if it did, libinput should work just fine.

Please attach the hid-record output for the device from one of these touches so we can see if there's a kernel quirk that needs to be set.
https://bentiss.github.io/hid-replay-docs/
Comment 3 Zoltán Böszörményi 2017-07-25 03:43:55 UTC
(In reply to Peter Hutterer from comment #2)
> does this thing use a special kernel driver? The device is supposed to send
> BTN_TOUCH when the touch is logically down and if it did, libinput should
> work just fine.
> 
> Please attach the hid-record output for the device from one of these touches
> so we can see if there's a kernel quirk that needs to be set.
> https://bentiss.github.io/hid-replay-docs/

This device is simply detected by hidraw.

Apparently, EETI makes a lot of touchscreeen variants and many different
ones uses the same 0eef:0001 VID/PID value.

Instead of proper documentation (which was not updated since 2000 and only
covers serial attached single-touch touchscreens in the protocol docs)
EETI provides an eGTouchD daemon that provides a bridge in userspace between
HIDRAW and UINPUT, i.e. it creates a new /dev/input/xxx device from userspace
which then provides the necessary properly working details and which can then
be picked up by Xorg properly.

I have straced this daemon already and it seems to be doing an extensive
device discovery and initialization over hidraw.

The new input device created from userspace does indeed provide BTN_TOUCH
events.

I have already asked for a more recent documentation from EETI.

I will try hid-record.
Comment 4 Zoltán Böszörményi 2017-07-25 04:07:37 UTC
These are the lines about the detection of this device in dmesg:

[    3.884340] input: eGalax Inc. USB TouchController Pen as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1.4/1-1.1.4:1.0/0003:0EEF:0001.0004/input/input10
[    3.884726] input: eGalax Inc. USB TouchController as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1.4/1-1.1.4:1.0/0003:0EEF:0001.0004/input/input12
[    3.885219] hid-multitouch 0003:0EEF:0001.0004: input,hiddev96,hidraw3: USB HID v1.00 Pointer [eGalax Inc. USB TouchController] on usb-0000:00:1d.0-1.1.4/input0
Comment 5 Zoltán Böszörményi 2017-07-25 04:47:02 UTC
Here's the output of hid-recorder. There was one short touch at the beginning,
some motion and then a few short touches again.

# hid-recorder 
Available devices:
/dev/hidraw0:	ID TECH TM3 Magstripe USB-HID Keyboard Reader
/dev/hidraw1:	HID 04f3:0103
/dev/hidraw2:	HID 04f3:0103
/dev/hidraw3:	eGalax Inc. USB TouchController
Select the device event number [0-3]: 3
D: 0
R: 341 05 01 09 01 a1 01 85 01 09 01 a1 00 05 09 19 01 29 02 15 00 25 01 95 02 75 01 81 02 95 01 75 06 81 01 05 01 09 30 09 31 16 00 00 26 ff 0f 36 00 00 46 ff 0f 66 00 00 75 10 95 02 81 02 c0 c0 05 0d 09 04 a1 01 85 02 09 20 a1 00 09 42 09 32 15 00 25 01 95 02 75 01 81 02 95 06 75 01 81 03 05 01 09 30 75 10 95 01 a4 55 0d 65 33 36 00 00 46 99 28 16 00 00 26 ff 0f 81 02 09 31 16 00 00 26 ff 0f 36 00 00 46 af 19 81 02 b4 c0 c0 06 00 ff 09 01 a1 01 09 01 15 00 26 ff 00 85 03 75 08 95 3f 81 02 06 00 ff 09 01 15 00 26 ff 00 75 08 95 07 91 02 c0 05 0d 09 04 a1 01 85 04 09 22 a1 00 09 42 15 00 25 01 75 01 95 01 81 02 09 32 15 00 25 01 81 02 09 51 75 05 95 01 16 00 00 26 10 00 81 02 09 47 75 01 95 01 15 00 25 01 81 02 05 01 09 30 75 10 95 01 55 0d 65 33 35 00 46 60 17 26 ff 0f 81 02 09 31 75 10 95 01 55 0d 65 33 35 00 46 26 0e 26 ff 0f 81 02 05 0d 09 55 25 08 75 08 95 01 b1 02 c0 06 00 ff 09 c5 85 07 15 00 26 ff 00 75 08 96 00 01 b1 02 c0 05 0d 09 0e a1 01 85 05 09 22 a1 00 09 52 09 53 15 00 25 0a 75 08 95 02 b1 02 c0 c0
N: eGalax Inc. USB TouchController
P: usb-0000:00:1d.0-1.1.4/input0
I: 3 0eef 0001
D: 0
E: 0.000000 6 04 83 26 03 1e 05
E: 0.007944 6 04 83 26 03 1e 05
E: 0.009934 6 04 83 26 03 1e 05
E: 0.011924 6 04 82 26 03 1e 05
E: 13.425913 6 04 83 58 02 c2 09
E: 13.431941 6 04 83 58 02 c4 09
E: 13.439909 6 04 83 58 02 c8 09
E: 13.446007 6 04 83 5a 02 cc 09
E: 13.451903 6 04 83 5a 02 d0 09
E: 13.459881 6 04 83 5a 02 d4 09
E: 13.465910 6 04 83 5a 02 d6 09
E: 13.473905 6 04 83 5a 02 d8 09
E: 13.479981 6 04 83 5c 02 da 09
E: 13.485902 6 04 83 5c 02 dc 09
E: 13.493891 6 04 83 5c 02 dc 09
E: 13.499847 6 04 83 5c 02 dc 09
E: 13.507864 6 04 83 5c 02 dc 09
E: 13.513888 6 04 83 5e 02 dc 09
E: 13.519904 6 04 83 5e 02 dc 09
E: 13.527880 6 04 83 60 02 da 09
E: 13.533914 6 04 83 64 02 d8 09
E: 13.541905 6 04 83 68 02 d4 09
E: 13.547912 6 04 83 6e 02 ce 09
E: 13.555905 6 04 83 74 02 c6 09
E: 13.561909 6 04 83 7a 02 be 09
E: 13.569906 6 04 83 80 02 b0 09
E: 13.575907 6 04 83 86 02 9e 09
E: 13.581912 6 04 83 8c 02 8a 09
E: 13.589905 6 04 83 90 02 72 09
E: 13.595936 6 04 83 94 02 58 09
E: 13.603905 6 04 83 98 02 3c 09
E: 13.609910 6 04 83 9a 02 1e 09
E: 13.615909 6 04 83 9c 02 fe 08
E: 13.623901 6 04 83 9c 02 de 08
E: 13.629914 6 04 83 9c 02 be 08
E: 13.635901 6 04 83 9c 02 a0 08
E: 13.643904 6 04 83 9c 02 84 08
E: 13.649912 6 04 83 9a 02 6c 08
E: 13.657904 6 04 83 98 02 56 08
E: 13.663965 6 04 83 94 02 40 08
E: 13.671905 6 04 83 90 02 2c 08
E: 13.677905 6 04 83 8a 02 1a 08
E: 13.685908 6 04 83 84 02 0a 08
E: 13.691908 6 04 83 80 02 fe 07
E: 13.699907 6 04 83 7a 02 f6 07
E: 13.705905 6 04 83 72 02 f0 07
E: 13.711941 6 04 83 6a 02 ec 07
E: 13.719848 6 04 83 62 02 e8 07
E: 13.725950 6 04 83 5a 02 e6 07
E: 13.731852 6 04 83 4e 02 e4 07
E: 13.739905 6 04 83 40 02 e4 07
E: 13.746005 6 04 83 34 02 e4 07
E: 13.753900 6 04 83 2a 02 e4 07
E: 13.755850 6 04 83 2a 02 e4 07
E: 13.757890 6 04 82 2a 02 e4 07
E: 13.777907 6 04 83 f8 01 3e 08
E: 13.783910 6 04 83 f6 01 44 08
E: 13.791902 6 04 83 f0 01 52 08
E: 13.797911 6 04 83 ea 01 64 08
E: 13.805904 6 04 83 e4 01 7a 08
E: 13.811904 6 04 83 e0 01 94 08
E: 13.817909 6 04 83 de 01 b0 08
E: 13.825904 6 04 83 dc 01 cc 08
E: 13.831852 6 04 83 da 01 ea 08
E: 13.837964 6 04 83 d8 01 0c 09
E: 13.845952 6 04 83 d8 01 2e 09
E: 13.851916 6 04 83 d8 01 52 09
E: 13.859900 6 04 83 d8 01 72 09
E: 13.865909 6 04 83 d8 01 92 09
E: 13.871919 6 04 83 d8 01 b2 09
E: 13.879882 6 04 83 da 01 ce 09
E: 13.885962 6 04 83 de 01 e4 09
E: 13.893904 6 04 83 e2 01 f6 09
E: 13.899913 6 04 83 e6 01 06 0a
E: 13.907989 6 04 83 ea 01 12 0a
E: 13.913850 6 04 83 ee 01 1c 0a
E: 13.921917 6 04 83 f2 01 24 0a
E: 13.927905 6 04 83 f6 01 2a 0a
E: 13.933909 6 04 83 fa 01 2e 0a
E: 13.941903 6 04 83 fc 01 30 0a
E: 13.947909 6 04 83 fc 01 32 0a
E: 13.955892 6 04 83 fc 01 32 0a
E: 13.961861 6 04 83 fc 01 32 0a
E: 13.967894 6 04 83 fc 01 32 0a
E: 13.975862 6 04 83 fc 01 32 0a
E: 13.981807 6 04 83 fc 01 32 0a
E: 13.989922 6 04 83 fc 01 2e 0a
E: 13.995904 6 04 83 fc 01 28 0a
E: 14.049911 6 04 83 fc 01 28 0a
E: 14.051871 6 04 82 fc 01 28 0a
E: 14.467903 6 04 83 8a 01 9e 0c
E: 14.469898 6 04 83 8a 01 9e 0c
E: 14.471904 6 04 82 8a 01 9e 0c
E: 15.245894 6 04 83 da 00 d2 0d
E: 15.247884 6 04 83 da 00 d2 0d
E: 15.249898 6 04 82 da 00 d2 0d
E: 15.729941 6 04 83 c0 00 be 0e
E: 15.731828 6 04 83 c0 00 be 0e
E: 15.733897 6 04 82 c0 00 be 0e
E: 16.147893 6 04 83 d4 00 2a 0f
E: 16.153900 6 04 83 d2 00 26 0f
E: 16.161879 6 04 83 cc 00 26 0f
E: 16.167899 6 04 83 c6 00 2a 0f
E: 16.175895 6 04 83 c0 00 32 0f
E: 16.229887 6 04 83 c0 00 32 0f
E: 16.231862 6 04 82 c0 00 32 0f
^C
Comment 6 Zoltán Böszörményi 2017-07-25 04:55:55 UTC
Here's the whole section from dmesg about this device:

[    3.871689] usb 1-1.1.4: New USB device found, idVendor=0eef, idProduct=0001
[    3.871692] usb 1-1.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.871694] usb 1-1.1.4: Product: USB TouchController
[    3.871696] usb 1-1.1.4: Manufacturer: eGalax Inc.
[    3.884187] hid-multitouch 0003:0EEF:0001.0004: failed to fetch feature 7
[    3.884340] input: eGalax Inc. USB TouchController Pen as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1.4/1-1.1.4:1.0/0003:0EEF:0001.0004/input/input10
[    3.884726] input: eGalax Inc. USB TouchController as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1.4/1-1.1.4:1.0/0003:0EEF:0001.0004/input/input12
[    3.885219] hid-multitouch 0003:0EEF:0001.0004: input,hiddev96,hidraw3: USB HID v1.00 Pointer [eGalax Inc. USB TouchController] on usb-0000:00:1d.0-1.1.4/input0

Why are there two separate input devices for this touchscreen in the first place?
Also, the message about "failed to fetch feature 7" may be an indication that
there is some vendor-specific magic to this device.
Comment 7 Zoltán Böszörményi 2017-07-25 04:57:49 UTC
Created attachment 132944 [details]
hid-recorder output from starting EETI's eGTouchD daemon

I have run a hid-recorder session about starting EETI's eGTouchD and
made some touches and movements in the touchscreen.
Comment 8 Zoltán Böszörményi 2017-07-25 05:18:40 UTC
Created attachment 132945 [details]
strace output from eGTouchD

It seems the messages sent to the device are not logged by hid-recorder,
only the incoming ones. The strace output also reveals messages that are sent.
Comment 9 Kirill Esipov 2017-08-04 09:47:41 UTC
I've the same issue. Any news about fixing?

P.S. ts_lib fix it here: https://github.com/kergoth/tslib/commit/fa10e4c6c2b379a79897bb16b2f3b07740d199fb
Comment 10 Zoltán Böszörményi 2017-08-04 11:56:19 UTC
I have a kernel patch based on parts of the GPL EETI kernel driver
I got sent to by way of a PC maker. The patch is at:

http://marc.info/?l=linux-input&m=150167441312020&w=2

With this patch, xf86-input-libinput works out of the box.

The way EETI treats their devices is somewhat funny.

Their kernel driver leaves a backdoor (a pipe) so the older generation of their
closed source daemon can switch it into some specific mode. Then the daemon
opens a new uinput device and feeds it with data.

Same with their latest generation of said daemon which talks to the device
over a hidraw device node. The in-kernel hid-multitouch driver then completely
loses events and only the events fed by the daemon to uinput is accepted.
Comment 11 Zoltán Böszörményi 2017-08-07 08:25:41 UTC
(In reply to Kirill Esipov from comment #9)
> I've the same issue. Any news about fixing?
> 
> P.S. ts_lib fix it here:
> https://github.com/kergoth/tslib/commit/
> fa10e4c6c2b379a79897bb16b2f3b07740d199fb

Unfortunately I can't use tslib for some reason as xf86-input-tslib crashes Xorg.
https://github.com/merge/xf86-input-tslib
Comment 12 Kirill Esipov 2017-08-08 12:05:01 UTC
(In reply to Zoltán Böszörményi from comment #11)
> (In reply to Kirill Esipov from comment #9)
> > I've the same issue. Any news about fixing?
> > 
> > P.S. ts_lib fix it here:
> > https://github.com/kergoth/tslib/commit/
> > fa10e4c6c2b379a79897bb16b2f3b07740d199fb
> 
> Unfortunately I can't use tslib for some reason as xf86-input-tslib crashes
> Xorg.
> https://github.com/merge/xf86-input-tslib
(In reply to Zoltán Böszörményi from comment #10)
> I have a kernel patch based on parts of the GPL EETI kernel driver
> I got sent to by way of a PC maker. The patch is at:
> 
> http://marc.info/?l=linux-input&m=150167441312020&w=2
> 
> With this patch, xf86-input-libinput works out of the box.
> 
> The way EETI treats their devices is somewhat funny.
> 
> Their kernel driver leaves a backdoor (a pipe) so the older generation of
> their
> closed source daemon can switch it into some specific mode. Then the daemon
> opens a new uinput device and feeds it with data.
> 
> Same with their latest generation of said daemon which talks to the device
> over a hidraw device node. The in-kernel hid-multitouch driver then
> completely
> loses events and only the events fed by the daemon to uinput is accepted.

Thank you for reply! I've tested this patch on wayland/weston armv7-a machine -it work fine!
Comment 13 Zoltán Böszörményi 2017-08-08 12:14:56 UTC
Glad to have helped.

BTW, I also got word from the PC maker and EETI is preparing a patch against
hid-multitouch to make the 0x0eef:0x0001 HID class device work with that driver.
I don't know when this patch gets done but they intend to upstream it themselves.
Comment 14 Peter Hutterer 2017-08-16 06:56:27 UTC
sorry, was at a conference and on holidays.

fwiw, it's fairly common for devices to create multiple event nodes, especially for devices that support pen and touch (which we expect on different nodes). This looks like a kernel bug and since you already fixed it there isn't anything left in libinput, afaict. Thanks for the fix, much appreciated.

libinput still doesn't handle distance for touch devices, but that's a separate issue from this specific bug and not one we've had much or any demand for. Meanwhile, I'm closing this one and punting it to the kernel.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.