Wednesday, March 19, 2014

X.Org synaptics support for the Lenovo T440, T540, X240, Helix, Yoga, X1 Carbon

Updates: 30 April 2014, for the new INPUT_PROP_TOP_BUTTONPAD

This is a follow-up to my post from December Lenovo T440 touchpad button configuration. Except this time the support is real, or at least close to being finished. Since I am now seeing more and more hacks to get around all this I figured it's time for some info from the horse's mouth.

[update] I forgot to mention: synaptics 1.8 will have all these, the first snapshot is available here

Lenovo's newest series of laptops have a rather unusual touchpad. The trackstick does not have a set of physical buttons anymore. Instead, the top part of the touchpad serves as software-emulated buttons. In addition, the usual ClickPad-style software buttons are to be emulated on the bottom edge of the touchpad. An ASCII-art of that would look like this:

+----------------------------+
| LLLLLLLLLL MMMMM RRRRRRRRR |
|                            |
|                            |
|                            |
|                            |
|                            |
|                            |
| LLLLLLLL          RRRRRRRR |
+----------------------------+
Getting this to work required a fair bit of effort, patches to synaptics, the X server and the kernel and a fair bit of trial-and-error. Kudos for getting all this sorted goes to Hans the Goede, Benjamin Tissoires, Chandler Paul and Matthew Garrett. And in the process of fixing this we also fixed a bunch of other issues that have been plaguing clickpads for a while.

The first piece in the puzzle was to add a second software button area to the synaptics driver. Option "SecondarySoftButtonAreas" now allows a configuration in the same manner as the existing one (i.e. right and middle button). Any click in that software button area won't move the cursor, so the buttons will behave just like physical buttons. Option "HasSecondarySoftButtons" defines if that button area is to be used. Of course, we expect that button area to work out of the box, so we now ship configuration files that detect the touchpad and apply that automatically. Update 30 Apr: Originally we tried to get this done based on the PNPID or DMI matching but a better solution is the new INPUT_PROP_TOPBUTTONPAD evdev property bit. This is now applied to all these touchpads, and the synaptics driver uses this to enable the secondary software button area. This bit will be aviailable in kernel 3.15, with stable backports happening after that.

The second piece in the puzzle was to work around the touchpad firmware. The touchpads speak two protocols, RMI4 over SMBus and PS/2. Windows uses RMI4, Linux still uses PS/2. Apparently the firmware never got tested for PS/2 so the touchpad gives us bogus data for its axis ranges. A kernel fix for this is in the pipe. Update 30 Apr: every single touchpad of this generation needs a fix. They have been or are being merged.

Finally, the touchpad needed to be actually usable. So a bunch of patches that tweak the clickpad behaviours were merged in. If a finger is set down inside a software button area, finger movement does no longer affect the cursor. This stops the ever-so-slight but annoying movements when you execute a physical click on the touchpad. Also, there is a short timeout after a click to avoid cursor movement when the user just presses and releases the button. The timeout is short enough that if you do a click-and-hold for drag-and-drop, the cursor will move as expected. If a touch started outside a software button area, we can now use the whole touchpad for movement. And finally, a few fixes to avoid erroneous click events - we'd sometimes get the software button wrong if the event sequence is off.

Another change changed the behaviour of the touchpad when it is disabled through the "Synaptics Off" property. If you use syndaemon to disable the touchpad while typing, the buttons now work even when the touchpad is disabled. If you don't like touchpads at all and prefer to use the trackstick only, use Option "TouchpadOff" "1". This will disable everything but physical clicks on the touchpad.

On that note I'd also like to mention another touchpad bug that was fixed in the recent weeks: plenty of users reported synaptics having a finger stuck after suspend/resume or sometimes even after logging in. This was an elusive bug and finally tracked down to a mishandling of SYN_DROPPED events in synaptics 1.7 and libevdev. I won't provide a fix for synaptics 1.7 but we've fixed libevdev - please use synaptics 1.8 RC1 or later and libevdev 1.1 RC1 or later.

Update 30 Apr: If the INPUT_PROP_TOPBUTTONPAD is not available on your kernel, you can use DMI matching through udev rules. PNPID matching requires a new kernel patch as well, at which point you might as well rely on the INPUT_PROP_TOPBUTTONPAD property. An example for udev rules that we used in Fedora is below:

ATTR{[dmi/id]product_version}=="*T540*", ENV{ID_INPUT.tags}="top_softwarebutton_area"
and with the matching xorg.conf snippet:
Section "InputClass"
        Identifier "Lenovo T540 trackstick software button buttons"
        MatchTag "top_softwarebutton_area"
        Option "HasSecondarySoftButtons" "on"
        # If you dont have the kernel patches for your touchpad 
        # to fix the min/max ranges, you need to use absolute coordinates
        # Option "SecondarySoftButtonAreas" "3363 0 0 2280 2717 3362 0 2280"
        Option "SecondarySoftButtonAreas" "58% 0 0 8% 42% 58% 0 8%"
EndSection
Update 30 Apr: For those touchpads that already have the kernel fix to adjust the min/max range, simply specifying the buttons in % of the touchpad dimensions is sufficient. For all other touchpads, you'll need to use absolute coordinates.

Fedora users: everything is being built in rawhide Update 30 Apr:, F20 and F19. The COPR listed in an earlier version of this post is not available anymore.

22 comments:

K900 said...

I've got a similar clickpad on my Acer V5-573G. How do you set it up to only use the bottom part of the thing as buttons?

Harold said...

Ubuntu 14.04 has xserver-xorg-input-synaptics 1.7.3.

is it possible to disable the trackpad, but keep the buttons working with that version?

Xfce config also disables the buttons when you disable the trackpad, and the Option "TouchpadOff" "1" does too.

Looking forward to "If a finger is set down inside a software button area, finger movement does no longer affect the cursor." but I guess that will take a while before it's avalable for all?

Cheers!

Harold

Eitan Adler said...

If this required udev changes doesn't it also require devd changes?
Also, does this work on FreeBSD or are kernel changes required too?

Peter Hutterer said...

K900: bottom buttons are part of the driver for quite a while now, please file a bug if it's not working

Harold: no, I haven't backported those changes to 1.7 yet.

Eitan: yeah, I guess. Note that we only use the udev rules for tagging a device. And I suspect the BSD kernels will run into the same issues as the linux kernel, please look at the patch I linked to

Ray said...

Thanks for synaptics 1.8 (1.7.99.1). I'm actually using it on my thinkpad yoga with kubuntu trusty.
Unfortunately I can't get middle-button scrolling to work with the trackpoint, as it uses the touchpad areas as buttons. I could manage to define all 3 upper button areas, but cannot scroll with my trackpoint. Is there any sollution? (on older thinkpads: http://www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint#Scrolling)

This is really driving me crazy!
Any help would be much appreciated!
Ray

Ray said...

There's a sollution for this issue. But I'm afraid to use this...
https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/1246683/comments/40

Ray said...
This comment has been removed by the author.
Bruce said...

My attempts to install the snapshot on my new t440s w/xubuntu 14.04 beta 2 have been unsuccessful (I get errors about missing xutils-macros, despite having installed them). Any idea when we might see 1.8 done and land in standard packages?

Harold said...

I managed to install the 1.7.90.1 snapshot, but it's in /usr/local/lib/xorg/modules/input/synaptics_drv.[la|so] and isn't picked up by Xorg.

How can I point Xorg to that folder?

Harold said...

http://lists.freedesktop.org/pipermail/xorg/2011-February/052308.html

Adding folders isn't possible, you have to override all with your extra folder included. :(

I'll look into submitting a bug agains Ubuntu/Xorg for default inclusion of /usr/local paths.

Xaver Gerster said...

On my T440s I'm experiencing strange things setting RBL, RBR, RBT, RBB, MBL, MBR, MBT, and MBB values for SecondarySoftButtonAreas and SoftButtonAreas in 50-synaptics.conf

- first I used percent type-of values, which did not work

- then I found your post, saying one should put absolute numbers.
First that did not work either, until I 'discovered' that the x/y-axis range reported in Xorg.0.log for my clickpad, which I relied on to do the settings, namely 1472-5112/1408-3834 where different from those determined by evtest namely 1025-5110/2024-4830.
Why is X reporting such wrong numbers? Can I fix this? Or are the x/y-ranges for the clickpad in Xorg.0.log just irrelevant?

Regards, Xaver

(I'm using xf86-input-synaptics-1.7.99.1-44.4.x86_64 and OpenSuse 13.1)

Peter Hutterer said...

Xaver: the firmware on those devices is broken and reports wrong values. We've fixed up some models in the kernel, others to come but until that's fully sorted and in your distributions, the ranges will be off.

Alexander Prokhorov said...

Sorry for bothering, but is there any hope to get this working in 14.04?

Xaver Gerster said...

For me, it has all been working with xf86-input-synaptics-xf86-input-synaptics-1.7.99.1 on a Lenovo T440s with Opensuse 13.1.

Now with xf86-input-synaptics-1.8.0-47.2.x86_64 it has stopped working for me: all settings for the top-row soft buttons, are without any function - irrespective of setting them percentage-wise or as numbers.

Any help?

Peter Hutterer said...

Xaver: you're probably missing the HasSecondarySoftButtons option which may not be set automatically on your kernel

Alexander: please ask your distribution's maintainers

Xaver Gerster said...

@Peter: 1) Thanks: 'Option HasSecondarySoftButtons true' into 50-synaptics.conf does the job.

2) Should I understand INPUT_PROP_TOPBUTTONPAD as a kernel config option?
Because if I do 'cat /proc/config.gz | gunzip | grep TOPBUTTON', I'm getting nothing.
(For me 'uname -r' is 3.11.10-7-desktop)

3) While I'm at it, there is one thing which still drives me nuts with the clickpad: very frequently, when I try to do a left-click in the lower soft button area, the cursor jumps to the lower left of the screen - leading to erratic clicks on the application launcher and other stuff which is in the left edge of the task bar on my desktop.
Is this a known feature which I can influence somehow?

Peter Hutterer said...

INPUT_PROP_TOPBUTTONPAD is an evdev property, check linux/input.h, but you'll need 3.15 or latest stable kernels.

3) is a bug, one that I think I fixed a number of times already :) file a bug and attach the evemu-record output, either in the driver or in the server.

cloudid.de said...

Hello everyone,

I'd like to know if there is a possibility to use "touch buttons" with the trackpoint on a Lenovo T440s?

What I want is to avoid clicking down the whole clickpad and instead define 3 small areas in the very top part of the clickpad to be sensitive for touching. With this configuration one doesn't have to keep the clickpad pushed down for scrolling (which annoys me lot when reading longer texts) but just lay the finger on the right spot. A double click would be a double tapping on the right spot.

Do you see any chance to modify the configuration file in a way that the clickpad has the behaviour I described?

cjh818 said...

I love cloudid.de's idea, make the buttons for the trackpoint touch instead of click. I find the clicking to be clunky, noisy and awkward. BUT I still love using the trackpoint. I know you can use both trackpoint and touchpad, but I find if I have moved the cursor with the trackpoint, all I can do is physically click the buttons. I need to move the cursor a bit with the touch pad to do touch clicks.

Tomasz Butkiewicz said...

Hi,

I have T440 and I read your post but I must say I'm really lost what I need to do to make this work on my laptop. I added this line
ATTR{[dmi/id]product_version}=="*T440*", ENV{ID_INPUT.tags}="top_softwarebutton_area"

to /lib/udev/66-xorg-synaptics-quirks.rules
so now I have
...
ATTR{[dmi/id]product_name}=="HP MiniNote 1000", ENV{ID_INPUT.tags}="mininote_1000"
ATTR{[dmi/id]product_version}=="*T440*", ENV{ID_INPUT.tags}="top_softwarebutton_area"

LABEL="xorg_synaptics_quirks_end"

and my conf file from xorg.conf.d looks like this:
$ cat /usr/share/X11/xorg.conf.d/99-t440-synaptics.conf
Section "InputClass"
Identifier "Lenovo T440 trackstick software button buttons"
MatchTag "top_softwarebutton_area"
# Option "TouchpadOff" "1"
#Option "HasSecondarySoftButtons" "on"
# If you dont have the kernel patches for your touchpad
# to fix the min/max ranges, you need to use absolute coordinates
Option "SecondarySoftButtonAreas" "3363 0 0 2280 2717 3362 0 2280"
Option "SecondarySoftButtonAreas" "58% 0 0 8% 42% 58% 0 8%"
EndSection

My goal is to disable Touchpad and keep buttons active. I tried this with TouchpadOff 1 but no success nothing was working with this option touchpad as well as buttons. Please advice. Thanks

T.

Mordecai said...

To repeat what others have said,

Option "TouchpadOff" "1"

does not work, because it also turns off the button clicks. There really needs to be a way to turn off the touchpad without disabling the button clicks.

Deithelm said...

This is a follow-up to my post from December Lenovo T440 touchpad button configuration. ... lenovoyoga2.blogspot.com