# Middle click stopped working on Thinkpad X1 trackpad since xorg-server 1.20.7



## ultrageranium (Aug 9, 2020)

Hello,

Since the 1.20.7 (20200220) changes in x11-servers/xorg-server, my Thinkpad X1 (Gen 6) trackpad middle click button stopped working. I tried to follow the hints in /usr/ports/UPDATING regarding x11/libinput and x11-drivers/xf86-input-libinput, and everything worked out of the box, except the middle click of the trackpad that I use very frequently (the emulation works, but it's very unpractical and flimsy).

This is my current configuration, on FreeBSD 12.1-STABLE (r363948)

/etc/sysctl.conf


```
# Enable evdev hardware mouse + hardware keyboa
kern.evdev.rcpt_mask=12
```

/boot/loader.conf


```
# Disable Trackpoint and Trackpad support in psm
hw.psm.trackpoint_support="0"
hw.psm.synaptics_support="0"
```

/boot/device.hints


```
hint.atkbdc.0.at="isa"
hint.atkbdc.0.port="0x060"
hint.atkbd.0.at="atkbdc"
hint.atkbd.0.irq="1"
hint.psm.0.at="atkbdc"
hint.psm.0.irq="12"
```

Xorg: no config at all (except some font related stuff, that's all)

Trackpad sits at /dev/input/event5, if I cat it, I get responses for everything but the middle click button.

output of `libinput list-devices`:


```
Device:           Generic PS/2 mouse
Kernel:           /dev/input/event5
Group:            6
Seat:             seat0, default
Capabilities:     pointer
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   button
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   flat *adaptive
Rotation:         n/a
```

Output of `dmesg | grep psm`


```
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Generic PS/2 mouse, device ID 0
```

Mouse related info from /var/log/Xorg.0.log


```
[   558.480] (**) Option "Device" "/dev/input/event1"
  [   558.480] (**) Option "_source" "server/udev"
  [   558.480] (II) event1  - System mouse: is tagged by udev as: Mouse
  [   558.480] (II) event1  - System mouse: device is a pointer
  [   558.480] (II) event1  - System mouse: device removed
  [   558.480] (**) Option "config_info" "udev:/dev/input/event1"
  [   558.480] (II) XINPUT: Adding extended input device "System mouse" (type: MOUSE, id 7)
  [   558.480] (**) Option "AccelerationScheme" "none"
  [   558.480] (**) System mouse: (accel) selected scheme none/0
  [   558.480] (**) System mouse: (accel) acceleration factor: 2.000
  [   558.480] (**) System mouse: (accel) acceleration threshold: 4
  [   558.481] (II) event1  - System mouse: is tagged by udev as: Mouse
  [   558.481] (II) event1  - System mouse: device is a pointer
[...]
  [   558.484] (II) config/udev: Adding input device Generic PS/2 mouse (/dev/input/event5)
  [   558.484] (**) Generic PS/2 mouse: Applying InputClass "evdev pointer catchall"
  [   558.484] (**) Generic PS/2 mouse: Applying InputClass "libinput pointer catchall"
  [   558.484] (II) Using input driver 'libinput' for 'Generic PS/2 mouse'
  [   558.484] (**) Generic PS/2 mouse: always reports core events
  [   558.484] (**) Option "Device" "/dev/input/event5"
  [   558.484] (**) Option "_source" "server/udev"
  [   558.502] (II) event5  - Generic PS/2 mouse: is tagged by udev as: Mouse
  [   558.502] (II) event5  - Generic PS/2 mouse: device is a pointer
  [   558.502] (II) event5  - Generic PS/2 mouse: device removed
  [   558.538] (**) Option "config_info" "udev:/dev/input/event5"
  [   558.538] (II) XINPUT: Adding extended input device "Generic PS/2 mouse" (type: MOUSE, id 10)
  [   558.538] (**) Option "AccelerationScheme" "none"
  [   558.538] (**) Generic PS/2 mouse: (accel) selected scheme none/0
  [   558.538] (**) Generic PS/2 mouse: (accel) acceleration factor: 2.000
  [   558.538] (**) Generic PS/2 mouse: (accel) acceleration threshold: 4
  [   558.561] (II) event5  - Generic PS/2 mouse: is tagged by udev as: Mouse
  [   558.561] (II) event5  - Generic PS/2 mouse: device is a pointer
```

Output of `xinput`

```
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                    id=4    [slave  pointer  (2)]
⎜   ↳ System mouse                                  id=7    [slave  pointer  (2)]
⎜   ↳ Generic PS/2 mouse                            id=10   [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                     id=5    [slave  keyboard (3)]
    ↳ System keyboard multiplexer                     id=6    [slave  keyboard (3)]
    ↳ Sleep Button                                    id=8    [slave  keyboard (3)]
    ↳ AT keyboard                                     id=9    [slave  keyboard (3)]
```

Output of `xinput --list-props 10` 


```
Device 'Generic PS/2 mouse':
        Device Enabled (139):   1
        Coordinate Transformation Matrix (140): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Natural Scrolling Enabled (276):       0
        libinput Natural Scrolling Enabled Default (277):       0
        libinput Scroll Methods Available (278):        0, 0, 1
        libinput Scroll Method Enabled (279):   0, 0, 0
        libinput Scroll Method Enabled Default (280):   0, 0, 0
        libinput Button Scrolling Button (281): 3
        libinput Button Scrolling Button Default (282): 3
        libinput Button Scrolling Button Lock Enabled (283):    0
        libinput Button Scrolling Button Lock Enabled Default (284):    0
        libinput Accel Speed (287):     0.000000
        libinput Accel Speed Default (288):     0.000000
        libinput Accel Profiles Available (289):        1, 1
        libinput Accel Profile Enabled (290):   1, 0
        libinput Accel Profile Enabled Default (291):   1, 0
        libinput Left Handed Enabled (292):     0
        libinput Left Handed Enabled Default (293):     0
        libinput Send Events Modes Available (261):     1, 0
        libinput Send Events Mode Enabled (262):        0, 0
        libinput Send Events Mode Enabled Default (263):        0, 0
        Device Node (264):      "/dev/input/event5"
        Device Product ID (265):        2, 1
        libinput Drag Lock Buttons (294):       <no items>
        libinput Horizontal Scroll Enabled (295):       1
```

I'm completely clueless about what to try to have this working again... Reading through psm(4), I understand that it should support 2 or 3 buttons, so what am I doing wrong?


----------



## Mjölnir (Aug 10, 2020)

Looks like the trackpad's PS/2 implementation somewhere along the line a peace does not support 3 buttons, but only two.  In contrast, if you enable `hw.psm.synaptics_support="1"` and use x11-drivers/xf86-input-synaptics, it should work fine.  Usually no other special settings are needed, Xorg's automagic should detect and use the synaptics driver.  If you run moused(8), you have to set `sysrc moused_flags='-l 2'` to enable the native protocol (else the trackpad talks PS/2).
EDIT Do you run moused(8)?  Then RTFM psm(4): you must set at least `sysrc moused_flags='-l 1'`


----------



## ultrageranium (Aug 11, 2020)

Ah! The plot thickens...

First of all, no I don't use `moused` anymore. I was using it before the change in Xorg, but then I only needed a mouse to work under Xorg, and it was my understanding that `EVDEV` support in the kernel, psm() and libinput() were the only things needed.

So I enabled `hw.psm.synaptics_support="1"` and after a reboot I got a sixth input device, which was indeed recognised as a synaptics device (more specifically it became /dev/input/event5 and the trackpoint was pushed to /dev/input/event6).

Both `xinput` and `libinput list-devices` confirmed all this. Now if I `cat` this new device, I also got something with the middle-click button. But it was still not working. By that I mean that when I would middle-click, I did not get a middle-click, instead the trackpoint seemed to freeze until I release the button. Reading a bit more into libinput(), I learned that there is this feature where it is possible to give a button a scroll feature ("If the ScrollMethod is button and the button is logically down, x/y axis movement is converted into scroll events). I checked with `xinput` and `libinput list-devices` and the middle-click was configured by default to have such a feature. I disabled it in ~/.xinitrc with `xinput --set-prop 10 139 0`. And the middle-click finally worked again!

However... I have a new problem now (regardless of my ~/.xinitrc change).

With `hw.psm.synaptics_support="1"`, the mouse behaves very strangely at the beginning of an X session:

the trackpoint never works at first
the trackpad needs to be first touched to have the trackpoint works (!) ...but it does not always make it work
while interacting with the trackpad, the cursor movement slows down completely, then freezes, it can stay like this for 5, 10, 30secs, before it can move again
sometimes I am unable to get out of this ritual, the mouse stops working completely (keyboard, everything else is perfectly fine), only a reboot will give me another chance to make it all work, restarting Xorg is not enough (psm out for lunch?)
if I succeed the ritual, then it's rock solid, both trackpoint, trackpad, buttons, all happy. It only happens at the very beginning of the X session.
there has not been one session in all my tests where things just worked right away
When this happens there is no load at all, my setup is very simple (basically just x11-wm/evilwm) Xorg log file does not mention anything weird, `dmesg` is also quiet. If I go back to `hw.psm.synaptics_support="0"`, then this weird behaviour disappears, but then I'm back with only 2 buttons...


----------



## Mjölnir (Aug 11, 2020)

`hw.psm.synaptics_support="0"`: TrackPad (mousepad) talks PS/2
`hw.psm.trackpoint_support="0"`: TrackPoint (stick) talks PS/2
`sysrc moused_flags="contains -l 1"`: up to 11 buttons & wheel
`sysrc moused_flags="contains -l 2"`: native protocol, must use x11-drivers/xf86-input-synaptics
and psm(4) is in operation level zero (up to 3-button mouse, but the hardware default is the middle button acts as wheel?) by default.  It can not be set to higher levels by driver flags or sysctl(8) knobs.  Please RTFM psm(4) sections attentively:

Operation Levels
Data Packet Format: _Data packets read from the psm driver are formatted differently at each operation level._
Driver Flags
LOADER TUNABLES
I'd strongly guess your problems can be solved by enabling moused(8) and `sysrc moused_flags="[I]your preferences[/I] -l 1"` (or `-l 2`), because then the hardware & psm(4) get initialized by ioctl(2)'s issued by moused(8).
Consider to file in a bug report (@top of this web page) on base/psm(4), kindly asking for the addition of a sysctl(8) knob to set the operation level.
You may want to search a GUI tool to configure the TrackPad if you use the native protocol; else you have to fiddle around with the `sysctl hw.psm`.  I use KDE, it comes with a very good touchpad GUI.  But I guess you don't want that.  `pkg search synaptics`


----------



## Mjölnir (Aug 11, 2020)

Sorry I forgot: Please add to sysctl.conf(5): `kern.evdev.rcpt_mask=6` (or 12).

Standard disclaimer: install the docs: `pkg install {de,en}-freebsd-doc`, replace _de_ with your native tongue, and point your favorite browser to /usr/local/share/doc/freebsd.

You can add to the ALIAS section of /usr/local/etc/pkg.conf `message: "query '[%C/%n] %M'",` and read through all `pkg message|less`.


----------

