Bug 1227992

Summary: ALPS touchpads claim BTN_MIDDLE when they don't have one
Product: [Fedora] Fedora Reporter: Yaroslav <yaroslav.sapozhnik>
Component: libinputAssignee: Peter Hutterer <peter.hutterer>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: bcostescu, clive.m.messer, gansalmon, hdegoede, itamar, jonathan, kernel-maint, madhu.chinakonda, marco.guazzone, mchehab, peter.hutterer, yaroslav.sapozhnik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libinput-0.18.0-3.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-28 23:30:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
evemu-describe
none
dmesg
none
Ouput from udevadm info --export-db on Dell e5530 with ALPS TP
none
Hack force middle emulation fot TouchPad
none
Ouput from "udevadm info --export-db" on Dell e6320 with combo ALPS TP and ALPS Stick
none
udevadm Dell M2800
none
evemu recording for the Dell E5430 touchpad none

Description Yaroslav 2015-06-04 03:00:55 UTC
Description of problem:
With synaptics it was possible to simulate middle button click when pressing both left and right touchpad buttons simultaneously. With libinput it doesn't work anymore

Version-Release number of selected component (if applicable):
xorg-x11-drv-libinput - 0.10.0
libinput - 0.15.0

How reproducible: always


Steps to Reproduce:
1. Press touchpad left and right buttons on a firefox tab simultaneously

Actual results:
Either context menu is opened or the tab is being activated depending on the first button clicked. 

Expected results:
The tab is closed

Comment 1 Peter Hutterer 2015-06-04 04:44:26 UTC
huh, weird, that should work just fine. Are those physical buttons or software buttons? What's the output of libinput-list-devices and libinput-debug-events when you press both buttons?

and the output of 
   gsettings get org.gnome.desktop.peripherals.touchpad click-method
provided you're using gnome, the configuration of your DE regarding click methods otherwise. Thanks.

Comment 2 Yaroslav 2015-06-04 14:11:24 UTC
The strange thing is that this functionality works on the other laptop. The buttons are both physical.

Here is the output of the list-devices:

Device:         AlpsPS/2 ALPS DualPoint TouchPad
Kernel:         /dev/input/event8
Group:          8
Seat:           seat0, default
Size:           76.92x41.18mm
Capabilities:   pointer 
Tap-to-click:   disabled
Left-handed:    disabled
Nat.scrolling:  disabled
Calibration:    n/a
Scroll methods: *two-finger edge 
Click methods:  none

debug-events (while pressing both buttons):
event8  POINTER_BUTTON  +16.47s 272 pressed, seat count: 1
event8  POINTER_BUTTON  +16.47s 273 pressed, seat count: 1
event8  POINTER_BUTTON  +16.57s 272 released, seat count: 0
event8  POINTER_BUTTON  +16.59s 273 released, seat count: 0

I didn't find the configuration for click methods in KDE.

Comment 3 Peter Hutterer 2015-06-04 22:08:58 UTC
doesn't matter in this case anyway, if the buttons are physical there's no specific click method - your buttons are the click method :)

also, can you update to 0.16 please, it's in updates-testing. The exact bit I need to look at was missing in 0.15 (should be between Nat.scrolling and Calibration). then run again. What I suspect is that middle button emulation is disabled by default, it should tell you when you re-run libinput-list-devices.

If it is disabled can you please attach an evemu-describe of that device so we can look at why it is disabled. Does your touchpad have a physical middle button?

Comment 4 Yaroslav 2015-06-05 01:51:26 UTC
The thing is that I don't see the 0.16 in the update testing for some reason (and Ii know there is a 0.17 pending for testing, but it's not committed yet). I have no idea why I don't see it with updates-testing enabled.

There is also AlpsPS/2 ALPS DualPoint Stick  device (trackpad with 3 buttons except the touchpad with 2 buttons)

Comment 5 Peter Hutterer 2015-06-05 02:01:46 UTC
not sure about the repo issue, I think it just needs someone to hit a button somewhere. but you can grab it straight from koji: http://koji.fedoraproject.org/koji/buildinfo?buildID=641682

Comment 6 Yaroslav 2015-06-05 14:05:29 UTC
So, here goes list-devices (for some reason middle emulation is n/a):

Device:           AlpsPS/2 ALPS DualPoint TouchPad
Kernel:           /dev/input/event8
Group:            8
Seat:             seat0, default
Size:             76.92x41.18mm
Capabilities:     pointer 
Tap-to-click:     disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    none

evemu-describe is in the attachment

Comment 7 Yaroslav 2015-06-05 14:06:02 UTC
Created attachment 1035298 [details]
evemu-describe

Comment 8 Peter Hutterer 2015-06-09 00:05:41 UTC
problem is simple: the device claims to have a middle mouse button:
#     Event code 274 (BTN_MIDDLE)

and that's why we don't enable middle button emulation here.
what laptop is this? can you attach your dmesg output here please?

Comment 9 Yaroslav 2015-06-09 02:31:20 UTC
That's a Dell Precision M2800. dmesg output is attached.

Comment 10 Yaroslav 2015-06-09 02:32:28 UTC
Created attachment 1036538 [details]
dmesg

Comment 11 Peter Hutterer 2015-06-09 03:57:05 UTC
Hans, can you have a look at this please? Thanks.

Comment 12 Hans de Goede 2015-06-12 08:05:37 UTC
Hi Yaroslav, Peter,

I've just checked the kernel code and the problem is that the alps driver does not know if there are 2 are 3 buttons on the touchpad, so it always reports that there are 3 buttons.

I seems the alps driver is unique in this, the elantech and synaptics drivers both only claim to have a middle button if there really is one (or atleast try to do so).

Fixing this inside the alps driver is going to be quite hard as alps touchpad / trackstick combos will report the trackstick buttons through a touchpad packet (and thus through the touchpad's input-dev) as long as the trackpoint itself is not being used and the trackpoint usually has 3 buttons, so we need to claim button-middle even if we know there is none so as for the reporting of the trackpoint middle button to work through the touchpad input-dev.

So it looks like we will need to treat alps touchpads the same way in libinput as mice which claim to have 3 buttons, allow middle button emulation but default it to off.

Note that given the nastiness of reporting pointingstick buttons through the touchpad device, we will also
need a flag for the middlebutton emulation code to NOT turn itself off if it sees a real middle click.

Peter I'm currently quite busy with the backlight interface selection logic rewrite for the kernel which I've wanted to do for a long time already, if you have time can you write a libinput patch for this?

Regards,

Hans

Comment 13 Peter Hutterer 2015-06-15 04:04:22 UTC
yep, will do, renaming to make it easier to find.

Yaroslav, pls attach the output of udevadm info --export-db here. Thanks

Comment 14 Peter Hutterer 2015-06-15 08:00:46 UTC
test build here:
http://koji.fedoraproject.org/koji/taskinfo?taskID=10055530

Note that to enable middle button emulation you'll need an xorg.conf snippet, gnome does not have a toggle to expose this.

Section "InputClass"
   Identifier "middle button on ALPS"
   MatchProduct "Alps"
   MatchDriver "libinput:
   Option "MiddleEmulation" "on"
EndSection


but now that I'm writing this I'm beginning to think we should just enable this by default rather than having it disabled by default.

Comment 15 Hans de Goede 2015-06-15 08:04:38 UTC
Hi,

(In reply to Peter Hutterer from comment #14)
> but now that I'm writing this I'm beginning to think we should just enable
> this by default rather than having it disabled by default.

For (alps) touchpads only I presume, not for mice? If you only intend to do this for (alps) touchpads then ack.

Regards,

Hans

Comment 16 Clive Messer 2015-06-15 11:52:47 UTC
IMHO, middle button emulation should be enabled by default for ALPS touchpad, so behaviour is unchanged from how it used to be, prior to the introduction of libinput.

And as Hans suggested above, it should remain enabled even after a "real" middle button event, so the guys who have combined touchpad and stick, wont have it switched off again the first top they use the stick "real" middle mouse button, but still want to have it emulated for the touchpad left/right button press.

Comment 17 Clive Messer 2015-06-15 12:02:39 UTC
Created attachment 1038952 [details]
Ouput from udevadm info --export-db on Dell e5530 with ALPS TP

Peter,

I know you asked for this from Yaroslav, but as he has not replied yet and it may help, I attach my output from "udevadm info --export-db". It may help.

Comment 18 Clive Messer 2015-06-15 12:06:22 UTC
Created attachment 1038976 [details]
Hack force middle emulation fot TouchPad

Peter,

I don't suspect this makes any difference for the info you are seeking, but the export-db output was generated with this patch applied to libinput, which was my quick hack yesterday to get middle mouse button emulation restored. ;)

Comment 19 Clive Messer 2015-06-15 14:24:41 UTC
Created attachment 1039072 [details]
Ouput from "udevadm info --export-db" on Dell e6320 with combo ALPS TP and ALPS Stick

Peter,

Output from "udevadm info --export-db" from a Dell e6320 which has combo ALPS stick with physical LEFT/MIDDLE/RIGHT buttons, as well as ALPS TP with physical LEFT/RIGHT buttons.

Comment 20 Yaroslav 2015-06-15 14:58:06 UTC
Created attachment 1039093 [details]
udevadm Dell M2800

Providing udevadm info --export-db for Dell Precision M2800

Comment 21 Bogdan Costescu 2015-06-15 17:56:40 UTC
The solution proposed in comment #14 (the RPM built by koji plus the xorg snippet) works on a Latitude E7240. This model has a touchpad with 2 physical buttons, but has no stick.

Comment 22 Peter Hutterer 2015-06-16 03:24:37 UTC
Thanks for the tests, fwiw, the upstream version will have this enabled by default (for alps touchpads), so the config snippet won't be needed.

(In reply to Hans de Goede from comment #12)
> Note that given the nastiness of reporting pointingstick buttons through the
> touchpad device, we will also
> need a flag for the middlebutton emulation code to NOT turn itself off if it
> sees a real middle click.

forgot to reply to this earlier: we don't have that behaviour in libinput anyway. the middle button counts as another button, so all it does is reset the emulation state (release buttons accordingly) but it won't turn the emulation off for the next click.

Comment 23 Marco Guazzone 2015-06-26 07:45:42 UTC
Hi,
After the last libinput update (v. 0.17.0-5.fc22) the middle click emulation is broken again on my Dell Latitude E5430.
I was initially broken and then fixed at the beginning of June (see bug https://bugzilla.redhat.com/show_bug.cgi?id=1205771)

I attach the evemu-record output

Comment 24 Marco Guazzone 2015-06-26 07:46:28 UTC
Created attachment 1043427 [details]
evemu recording for the Dell E5430 touchpad

Comment 25 Bogdan Costescu 2015-06-26 09:02:59 UTC
libinput 0.17.0-5.fc22 also breaks middle button emulation on Latitude E7240. The presence or absence of the xorg config snippet makes no difference.

Downgrading back to 0.17.0-3.bz1227992.fc22 together with the xorg config snippet (i.e. the solution proposed in comment #14) restores functionality.

Comment 26 Clive Messer 2015-06-26 09:15:19 UTC
Test the 0.18 libinput version in updates-testing. You should find that this resolves, by always enabling middle button emulation for ALPS TP, without needing the xorg config. Works for me.

Comment 27 Bogdan Costescu 2015-06-26 09:21:22 UTC
Indeed libinput 0.18.0-2.fc22 works without the xorg config snippet on Latitude E7240. Thanks!

Comment 28 Marco Guazzone 2015-06-26 10:25:20 UTC
Works for me too (Dell E5430). Thank you so much