Friday, December 13, 2013

Lenovo T440 touchpad button configuration

Update March 19 2014: this post is outdated, please read X.Org synaptics support for the Lenovo T440, T540, X240, Helix, Yoga, X1 Carbon instead.

The T440 has a rather unusual touchpad with the buttons painted on top of the touchpad rather than the bottom. In addition, the separate set of buttons for the trackstick have gone the way of the dodo. Moving the software-emulated buttons up on the touchpad is obviously quite important for trackstick users but it throws up a bunch of problems. There are some limitations with the current synaptics X.Org driver: we can only have one region each designated for the right and the middle button. The rest of the touchpad is a left button click. In the case of the T440, the default Windows config has a right button up the top and another one at the bottom of the touchpad. An ASCII-art of that would look like this:

+----------------------------+
| LLLLLLLLLL MMMMM RRRRRRRRR |
|                            |
|                            |
|                            |
|                            |
|                            |
|                            |
| LLLLLLLL          RRRRRRRR |
+----------------------------+
We simply can't do that at the moment, best we can is split the touchpad so that the whole right side is a right-click and a strip in the middle that is a middle click. So the best we can do is:
+----------------------------+
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
| LLLLLLLLLL MMMMM RRRRRRRRR |
+----------------------------+
I'm working on a solution for the proper config, but for now you'll have to be content with this.

The easiest approach for local configuration is a new InputClass section in the form:

Section "InputClass"
    Identifier "t440 top buttons"
    MatchDriver "synaptics"
    #                         right btn|middle btn
    Option "SoftButtonAreas" "60% 0 0 0 40% 60% 0 0"
EndSection
Drop that into /etc/X11/xorg.conf.d/99-t440-synaptics.conf and you're good to go.

The problem is finding a generic solution to this that we can ship in a distribution. That requires a two-step progress. The touchpads look the same as all others, the only differentiator we have is the DMI information on the box. We can't check that in the xorg.conf snippets yet (Daniel Martin is working on a MatchDMI tag, but it won't happen until server 1.16). For now, we need a udev rule to help the xserver.

ACTION!="add|change", GOTO="touchpad_quirks_end"
KERNEL!="event*", GOTO="touchpad_quirks_end"
ENV{ID_INPUT_TOUCHPAD}!="1", GOTO="touchpad_quirks_end"

ATTR{[dmi/id]product_version}=="*T440*", \
  ENV{ID_INPUT.tags}="touchpad_softbutton_top"

LABEL="touchpad_quirks_end"
If our product matches T440, we tag the touchpad, and that tag is something we can match against. Our revised InputClass section now looks like this:
Section "InputClass"
    Identifier "t440 top buttons"
    MatchDriver "synaptics"
    MatchTag "touchpad_softbutton_top"
    Option "SoftButtonAreas" "60% 0 0 0 40% 60% 0 0"
EndSection
I've pushed this configuration into Fedora now (rawhide, F20, F19), let's see what the feedback is. Having the whole right-side of the touchpad work as right button may cause a few issues so this is one change I may have to revert in the future.

11 comments:

strohel said...

Hey, this is great news that you're working on this, first time I've seen this otherwise adorable machine I thought "oh, will X.Org synaptics driver handle such strange clickpad?"

Assuming you have the notebook at hand, I'd like to ask a related question: is it possible to disable cursor movement from the touchpad, but still have its softbuttons working? The thing is I usually disable touchpads on ThinkPads because of spurious movements caused by my palm (when using TrackPoint), but that might be no longer possible with TrackPoint softbuttons on the touchpad.

It also seems that there are more Lenovo models that have the same new TrackPoint/touchpad combo and might need matching in udev/input rules: X240, E341, S431, T431s, T540p.

Martin McDowell said...

I just bought a T440s and also have issues with the trackpad. However my Ubuntu installation does not have the same directory structure ...
/etc/X11/xorg.conf.d/99-t440-synaptics.conf

after /etc/X11 my file directory system is different

jscurtu said...

@Martin McDowell
on *buntu's you will find what you need under:
/usr/share/X11/xorg.conf.d/

Peter Hutterer said...

@jscurtu: /usr/share/X11/xorg.conf.d are the system-provided configuration snippets. They may get overwritten when you update a package. /etc/X11/xorg.conf.d is the one for user-specific configuration, if it doesn't exist you can just create it.


@Matěj: there's a bug filed for softbuttons-only, but it's not yet ready for merging. Thanks for the list, I'll have to merge those one-by-one as people file bugs for them, I don't have any of those.

jscurtu said...

thanks for clearing that up..
I just bought me a T540p and I cant get the touchpad to work in a way that I can actually use it.

if I do a : grep "TouchPad: buttons:" /var/log/Xorg.0.log

it spits out:
[ 4.096] (--) synaptics: SynPS/2 Synaptics TouchPad: buttons: left double triple

I find that weird that I don't have a right and middle button. When I try your solution, I get :
synaptics: SynPS/2 Synaptics TouchPad: invalid SoftButtonAreas value '60% 0 0 0 40% 60% 0 0', keeping defaults

You got a idea?
Thanks..

-Jason

Unknown said...

Thanks for this help. This really improved the situation a lot.

Another problem with the touchpad is that it always moves the cursor a little. This is especially annoying when you are using the trackpad.
Is there a way to fix this under X11?

Anonymous said...

Thanks a lot! This really helped me setting up the touchpad of my T440s. However, I found it quite irritating to have the touchpad produce a right or middle click over the whole area. If understood correctly, we can currently only choose between having three buttons all over the touchpad, or using either buttons on top or at the bottom.
For anybody preferring buttons only on top, maybe the following is helpful:

xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Soft Button Areas" 3656 5112 0 2200 2928 3656 0 2200

(or as Option "SoftButtonAreas" "3656 5112 0 2200 2928 3656 0 2200" in xorg.conf file, for whatever reason I did not get this to work correctly with percentages)

The following, in addition, turns off any movement, scrolling and tapping recognition in the area of the top buttons (more as less at the red line):

xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Area" 0 0 2200 0

Chas Emerick said...

I understand that some like to have the soft-button area on the right side for right-clicking, but I've never found it useful since a simple click-with-two-fingers registers as a right-click anyway (and means you can easily right-click anywhere on the trackpad, not just in the lower-right corner). This also simplifies the configuration of the top-edge buttons:

# via https://github.com/ScottGarman/thinkpad_t440s/blob/master/99-synaptics-t440s.conf
# This sets the top area of the touchpad to not track
# movement but can be used for left/middle/right clicks
Option "SoftButtonAreas" "60% 0 0 2400 40% 60% 0 2400"
Option "AreaTopEdge" "2400"

# Helps to reduce mouse cursor "jumpiness"
Option "HorizHysteresis" "30"
Option "VertHysteresis" "30"

Now just looking forward to middle-button scroll support...

sol said...

Is it just me, or is PalmDetect = 1 not working in T440S?

I've tried it with everything from PalmMinZ = 2 and PalmMinWidth = 2 to PalmMinZ = 30 and PalmMinWidth = 80 (which should be reasonable numbers).

This is odd, since
$ xinput list-props "SynPS/2 Synaptics TouchPad"

reveals that:

Synaptics Capabilities (291): 1, 0, 0, 1, 1, 1, 1

And my understanding is that the seventh bit (in this case "1") reveals whether PalmDetect is supported or not.

Does anyone have a fix for this? Relying on syndaemon (to prevent cursor movement / clicks / scroll while typing) isn't viable, since I don't want the cursor to move even when I'm *going to type* (have my palms on the keyboard) and not just when I'm typing. Furthermore, syndaemon works unevenly for me, with clicks sometimes being registered while I'm typing.

Does anyone have a fix for this?

Unknown said...

No, @sol, it's not just you. I have the same problem on both my X1 Carbon and my brand new X240. The palmdetection is not working at all, and I can't find any information about this issue anywhere. Now that I have two separate machines with this issue (eliminating the possibility that it's a hardware fault), I will start the painstaking process of reporting it somewhere.

C Claiborne said...

I found a simple way to work with the Touchpad and the Trackpoint on the 440.
If you go to Control Panel, click on Hardware and Sound you will find a Mouse button in the upper part of the screen. This will enable you to make a large variety of changes to your touchpad and trackpoint, including changing the touchpad into a click panel and a scroll panel