Thursday, April 19, 2012

ClickPad support in the synaptics driver

[update 20 Apr: clarify middle finger emulation]
One of the features added to the upcoming xf86-input-synaptics version 1.6 is support for clickpad-style devices. This post outlines what clickpads are, how they are supported and how you go about enabling the new features.

What are clickpads

The name ClickPad comes from the Synaptics product of the same name. It describes a touchpad that does not have physical buttons. Instead, the whole touchpad works as a button. Devices like this have been around for a while, most notably the touchpads found in Apple laptops and the Dell Mini 10 series. The challenges for us were to handle the data streams correctly. Most of this work was done by Chase Douglas.

Clickpads give us the position for each finger, and a button 1 event when the pad is pressed. The design of the hardware however means that whenever you click the pad, you always add one more finger to the mix. Decoupling that finger from the ones that actually matter is the challenge. And integrating it with all the other whacky features that the synaptics driver currently has.

Clickpad Support

Clickpad support requires server 1.12 [0]. It heavily relies on multitouch support.
Central to the new feature is the "ClickPad" option and property. It is enabled if the kernel sets the INPUT_PROP_BUTTONPAD property on the device, otherwise you can enable it in an xorg.conf.d snippet or at runtime with either xinput or synclient:
xinput set-prop "device name" "Synaptics ClickPad" 1
synclient ClickPad=1
This toggles a few driver behaviours to make the clickpad much more usable. Most notably, you can use one finger to press the button and another finger to move the cursor around.

Word of warning here: if you enable clickpad support manually at runtime, you will also have to manually disable traditional middle mouse button emulation (synclient EmulateMidButtonTime=0). For autoconfigured devices or xorg.conf.d configured devices this is done automatically.

The second big feature for clickpads is support for software buttons. Since the device only gives us left button clicks, we expose an option to allow for right and middle button clicks. By default, we ship this xorg.conf.d snippet:
Section "InputClass"
        Identifier "Default clickpad buttons"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
The order of soft button edges is left, right, top, bottom for the right button, then left, right, top, bottom for the middle button. So the above snippet sets the right half of the bottom 18% to be a right button, with no middle button present. A coordinate of 0 means "stretch to edge of touchpad". [1]

Traditional middle mouse button emulation is disabled by default and we don't handle it for clickpads. Traditional middle mouse button emulation refers to the method of generating a button 2 press when both button 1 and button 3 are pressed simultaneously. Mostly because, well, I'm not sure how you would even trigger middle mouse button emulation for clickpads given that all buttons except the first are already emulated anyway. You can still emulate middle mouse button emulations through clickfingers (see below), tapping, or the soft button areas as described above.

Tapping works as on any other touchpad.

ClickFinger functionality works, albeit slightly different. In the default ClickFinger setting, if you have 2 fingers on the touchpad and you press the left button, you will see a ClickFinger2 action performed (right button by default). On clickpads we guess the number of fingers by proximity (since you need one finger to actually press the button). Fingers closer together than 30% of the touchpad's size [2] will count towards ClickFinger actions, others will be skipped. So in the default use-case, where you have two fingers down on the touchpad in the middle and you use a third to click the button, you will still get a ClickFinger2 action. Likewise, if you press with two fingers down, you will also get a ClickFinger2 action.

All other functions are not affected by clickpad support and behave as before.

  • [0] Ubuntu 12.04 will ship a 1.11/1.12 mix, that will work as well
  • [1] "edge of touchpads" should be 100% but it isn't due to a years-old mishandling of the coordinate ranges. So 0 is better to use here.
  • [2] All touchpads lie about their size, so we just hardcode 30% since anything we infer is going to be wrong anyways


Scott Tsai said...

So for a clickpad user that loves middle button paste, what's the recommended way to trigger a middle button click?

Is there any hope of having some finger / gesture combination trigger middle button click on clickpads out of the box? I'm very willing to learn new ways of operating the touchpad in return of not having to modify a config file on every Fedora reinstall.

FelipeC said...

I just bought an Asus Zenbook, and have been struggling to get the mousepad (clickpad) working properly.

I do have Xorg 1.12.1, Linux 3.3.2, and synaptics driver

But it just doesn't work. I had configured everything similarly to what you said.

Still, when I press the right button and then move my finger on the pad, press and release events are sent in the middle of it, so I always end up selecting what I don't want. It's impossible. I have truly given up on selecting items on a menu and using key-bindings now.

Also, sometimes I have my left finger on top of what would be a button, and moving my right finger on the pad doesn't do anything. I have to remember "right, clickpad", and lift my left finger.

I need an external mouse if I truly want something done on this laptop.

Right after installing Arch Linux it was much worst, at least now I can do a few things, but it took me a long time to find this configuration, but it seems that's as good as it gets:

Here's my config:

Gianluigi said...

Tnx for the guide: but with xorg 1.12.1 and xf86-input-synaptics- (latest) what you just said doesn't work.
Enabling clickpad options, turns the "virtual" right button on, but there's no way to use drag and drop as you stated.
Can you be more precise please?



Peter Hutterer said...

@Gianluigi. FelipeC:

Possibly this kernel bug: Clickpad kernel bugs in 3.3.x and 3.4. If not, then please file a bug.

FelipeC said...

I just tried that patch, I still see the same issues.

Leho Kraav said...

I'm also not experiencing any possibility to click and drag at the same time.

Magnus Dagbro said...

Where can i set the proximity value to 100%?

This 30% thing does not make sense to me, because if I want to initiate a click-and-drag action, I'll click and hold the "correct" number of fingers and then add another one for dragging. So synclient should never have to guess if, for example, it's a two-finger click or a one-finger click plus dragging finger.

Magnus Dagbro said...

Nevermind, i found the patch and changed it in source.

In effect, synclient is now checking if my fingers are closer together than the entire size of the touchpad. :)