Bug 94236

Summary: Palm detection: ignore moves over a pressure threshold
Product: Wayland Reporter: Cyril B. <lagoon42>
Component: libinputAssignee: Wayland bug list <wayland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: bugzilla, nekohayo, peter.hutterer
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on: 99355    
Bug Blocks: 98802, 100571    
Attachments: Palm touches

Description Cyril B. 2016-02-21 14:28:18 UTC
libinput's palm detection is well described in the documentation and works pretty well for the listed use cases. However, I've found that palms are frequently not detected in other cases, basically when the palms are not in the palm exclusion zones.

This is slightly annoying, and neither Windows 10 (on the same hardware, a Dell XPS 9350 [1]) nor OS X (on a different hardware, a Macbook Air) suffer from that issue.

I've tested a trivial patch (added a condition in tp_touch_active) to libinput 1.1.7 which ignores moves when the pressure is over 100, and I've found that it resolves the issue. All my palms are correctly detected wherever they are, and I haven't had false positives. The detection is now as good as Windows or OS X.

The threshold value (100) is good for my fingers and my touchpad, but maybe that should be configurable. My legitimate moves are in the between 50 and 55.

The synaptics driver includes a similar feature with the PalmMinZ option.

[1] the touchpad has to be in PS/2 mode to report pressure, as it doesn't in I2C mode.
Comment 1 Peter Hutterer 2016-02-23 21:56:25 UTC
hmm, this would likely end up being very device specific. we looked at pressure-based palm detection but the data we get from palm touches was so close to finger touches that we discarded it again. plus, any light palm touch would still be detected as finger, at least on my touchpad I have to put the palm down relatively hard to make it go past a threshold.

what's your touchpad again? can you attach the evemu-describe here?
Comment 2 Cyril B. 2016-03-07 09:06:46 UTC
Sorry for the delay, for some reason I hadn't received your response notification by email.

My touchpad is a Dell XPS 13 9350 (which is identical to earlier version of the Dell XPS, according to Benjamin). Here is the evemu-describe (in I2C mode, so the mode when pressure is not reported...):

# EVEMU 1.3
# Kernel: 4.5.0-rc5-mainline
# DMI: dmi:bvnDellInc.:bvr1.2.3:bd01/08/2016:svnDellInc.:pnXPS139350:pvr:rvnDellInc.:rn07TYC2:rvrA01:cvnDellInc.:ct9:cvr:
# Input device name: "DLL0704:01 06CB:76AD Touchpad"
# Input device ID: bus 0x18 vendor 0x6cb product 0x76ad version 0x100
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#   Event type 1 (EV_KEY)
#     Event code 272 (BTN_LEFT)
#     Event code 325 (BTN_TOOL_FINGER)
#     Event code 330 (BTN_TOUCH)
#     Event code 333 (BTN_TOOL_DOUBLETAP)
#     Event code 334 (BTN_TOOL_TRIPLETAP)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value    609
#       Min        0
#       Max     1216
#       Fuzz       0
#       Flat       0
#       Resolution 12
#     Event code 1 (ABS_Y)
#       Value    300
#       Min        0
#       Max      680
#       Fuzz       0
#       Flat       0
#       Resolution 12
#     Event code 47 (ABS_MT_SLOT)
#       Value      0
#       Min        0
#       Max        2
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 53 (ABS_MT_POSITION_X)
#       Value      0
#       Min        0
#       Max     1216
#       Fuzz       0
#       Flat       0
#       Resolution 12
#     Event code 54 (ABS_MT_POSITION_Y)
#       Value      0
#       Min        0
#       Max      680
#       Fuzz       0
#       Flat       0
#       Resolution 12
#     Event code 57 (ABS_MT_TRACKING_ID)
#       Value      0
#       Min        0
#       Max    65535
#       Fuzz       0
#       Flat       0
#       Resolution 0
# Properties:
#   Property  type 0 (INPUT_PROP_POINTER)
#   Property  type 2 (INPUT_PROP_BUTTONPAD)
N: DLL0704:01 06CB:76AD Touchpad
I: 0018 06cb 76ad 0100
P: 05 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 01 00 00 00 00 00
B: 01 20 64 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 03 00 00 00 00 80 60 02
B: 04 00 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
A: 00 0 1216 0 0 12
A: 01 0 680 0 0 12
A: 2f 0 2 0 0 0
A: 35 0 1216 0 0 12
A: 36 0 680 0 0 12
A: 39 0 65535 0 0 0

If I try hard enough, I can have a light palm be detected as a finger, so the pressure detection obviously won't help. Howver in my case, in real conditions, when my palm rests on the touchpad, it's definitely not a light palm. Is there a drawback to discard touches with a very high pressure? Those are definitely not fingers.

Let me add that a change introduced in Linux 4.5 enables the touchpad own palm detection (which has its own problems, unfortunately) when it's in I2C mode.
Comment 3 Peter Hutterer 2016-03-07 23:16:45 UTC
there's no drawback to discarding touches with very high pressure, it's primarily the overlap area where it gets tricky. so yes, we could add something that discards the palms over some device-specific threshold.

one of the problems we found in the past though was that the palms start with normal pressure and don't reach maximum pressure until several events in. By then we may have started gestures/scrolling/movement and it is very hard to revert back and undo the state. this may be easier combined with the other palm detection features where we just change from palm-maybe to palm-yes when the pressure is detected.
Comment 4 Peter Hutterer 2016-03-09 02:57:03 UTC
can you attach a recording with a couple of palm touches please so we have the data to analyze, at least for your touchpad? this should also show the usual pattern of palm touches (e.g. do they start with a high pressure value)
Comment 5 Cyril B. 2016-03-13 12:00:36 UTC
Created attachment 122263 [details]
Palm touches

I've attached 3 recordings of palm touches. All of them are pretty similar: my right palm is touching the touchpad when I either use the keyboard (but I'm not typing constantly) or is resting.

By the way, here is the evemu-describe for the touchpad in PS/2 mode (which was used for these recordings):

# EVEMU 1.3
# Kernel: 4.5.0-rc5-mainline
# DMI: dmi:bvnDellInc.:bvr1.2.3:bd01/08/2016:svnDellInc.:pnXPS139350:pvr:rvnDellInc.:rn07TYC2:rvrA01:cvnDellInc.:ct9:cvr:
# Input device name: "SynPS/2 Synaptics TouchPad"
# Input device ID: bus 0x11 vendor 0x02 product 0x07 version 0x1b1
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#   Event type 1 (EV_KEY)
#     Event code 272 (BTN_LEFT)
#     Event code 325 (BTN_TOOL_FINGER)
#     Event code 328 (BTN_TOOL_QUINTTAP)
#     Event code 330 (BTN_TOUCH)
#     Event code 333 (BTN_TOOL_DOUBLETAP)
#     Event code 334 (BTN_TOOL_TRIPLETAP)
#     Event code 335 (BTN_TOOL_QUADTAP)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value   4009
#       Min     1276
#       Max     5666
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 1 (ABS_Y)
#       Value   1859
#       Min     1118
#       Max     4734
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 24 (ABS_PRESSURE)
#       Value      0
#       Min        0
#       Max      255
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 28 (ABS_TOOL_WIDTH)
#       Value      0
#       Min        0
#       Max       15
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 47 (ABS_MT_SLOT)
#       Value      0
#       Min        0
#       Max        1
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 53 (ABS_MT_POSITION_X)
#       Value      0
#       Min     1276
#       Max     5666
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 54 (ABS_MT_POSITION_Y)
#       Value      0
#       Min     1118
#       Max     4734
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 57 (ABS_MT_TRACKING_ID)
#       Value      0
#       Min        0
#       Max    65535
#       Fuzz       0
#       Flat       0
#       Resolution 0
#     Event code 58 (ABS_MT_PRESSURE)
#       Value      0
#       Min        0
#       Max      255
#       Fuzz       0
#       Flat       0
#       Resolution 0
# Properties:
#   Property  type 0 (INPUT_PROP_POINTER)
#   Property  type 2 (INPUT_PROP_BUTTONPAD)
N: SynPS/2 Synaptics TouchPad
I: 0011 0002 0007 01b1
P: 05 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 01 00 00 00 00 00
B: 01 20 e5 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 03 00 00 11 00 80 60 06
B: 04 00 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
A: 00 1276 5666 0 0 0
A: 01 1118 4734 0 0 0
A: 18 0 255 0 0 0
A: 1c 0 15 0 0 0
A: 2f 0 1 0 0 0
A: 35 1276 5666 0 0 0
A: 36 1118 4734 0 0 0
A: 39 0 65535 0 0 0
A: 3a 0 255 0 0 0
Comment 6 Peter Hutterer 2017-06-28 04:48:57 UTC
Ok, branch available for testing now (after a year... sorry). Defaults to 130 so you'll need a udev hwdb entry if you need something different. Run the "libinput measure touchpad-pressure" tool to check for a good value.

https://github.com/whot/libinput/tree/wip/touchpad-palm-pressure
Comment 8 Peter Hutterer 2017-07-04 04:46:19 UTC
commit 25d54b90db6ac056157a7ad5c807c70b43b23c9b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Jun 28 13:09:22 2017 +1000

    touchpad: add pressure-base palm detection

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.