Bug 244339

Summary: x11-servers/xorg-server: Some keys not working (1.20.7 regression)
Product: Ports & Packages Reporter: ice
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, fixer, grahamperrin, grembo, patovm04, sv, wulf
Priority: --- Flags: bugzilla: maintainer-feedback? (x11)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Xorg log
none
xev output for PgDn and Up
none
Xorg log #2 none

Description ice 2020-02-23 15:49:24 UTC
Created attachment 211860 [details]
Xorg log

With the update of xorg-server from 1.18.4_13 to 1.20.7 and all configuration updates as per UPDATING and pkg-message done, I am with non-working page down and up arrow keys. Hardware is a ThinkPad X220 running 12.1p2.

X events regarding these two keys look odd:

Page down press:
----------------

FocusOut event, serial 36, synthetic NO, window 0x2000001,
    mode NotifyGrab, detail NotifyAncestor

Page down release:
------------------

FocusIn event, serial 36, synthetic NO, window 0x2000001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 36, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

Up arrow press:
---------------

FocusOut event, serial 36, synthetic NO, window 0x2000001,
    mode NotifyGrab, detail NotifyAncestor

Up arrow release:
-----------------

FocusIn event, serial 36, synthetic NO, window 0x2000001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 36, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

They don't repeat either, as they normally would. Other keys (like Page up and down arrow) a) do repeat, b) look like as if they had actually been recognised by whatever component it is that does the recognising:

KeyPress event, serial 36, synthetic NO, window 0x2000001,
    root 0xf5, subw 0x0, time 5542498, (29,94), root:(96,183),
    state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x2000001,
    root 0xf5, subw 0x0, time 5542778, (29,94), root:(96,183),
    state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 36, synthetic NO, window 0x2000001,
    root 0xf5, subw 0x0, time 5591303, (29,94), root:(96,183),
    state 0x0, keycode 116 (keysym 0xff54, Down), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x2000001,
    root 0xf5, subw 0x0, time 5591454, (29,94), root:(96,183),
    state 0x0, keycode 116 (keysym 0xff54, Down), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
Comment 1 ice 2020-02-23 15:51:14 UTC
Created attachment 211861 [details]
xev output for PgDn and Up
Comment 2 Michael Gmelin freebsd_committer 2020-02-23 16:12:03 UTC
(In reply to ice from comment #1)

This sounds like a problem with your keyboard layout. I ran into this
yesterday with someone using xfce4.

Can you post the content of your ~/.xinitrc here?
Also, which window manager and which keyboard layout?

Assuming it's Hungarian, try:

  pkg install setxkbmap

Then put

  setxkbmap -model pc105 -layout hu

at the beginning of your ~/.xinitrc and restart X. If you're using xfce,
you also need to run that command a second time after xfce started
(at least I had to while testing). It always must be .xinitrc though.
Comment 3 ice 2020-02-23 17:01:12 UTC
Curious. Not sure what I might have done, the keys are working now, but now the middle mouse button is gone.

I am using Window Maker, here are my various config files and things:

$ cat .xinitrc
#!/bin/sh

xrdb -merge ~/.Xresources
xmodmap ~/.Xmodmap
autocutsel -selection PRIMARY -fork
autocutsel -fork
xhost +
setxkbmap -rules "evdev" -model "pc104" -layout "us,hu" -variant ",qwerty" -option "grp:alt_shift_toggle" -keycodes evdev
sxhkd -c ~/.sxhkdrc >/dev/null 2>/dev/null < /dev/null &
exec /usr/local/bin/wmaker

$ cat .Xmodmap 

clear Lock

! CapsLock -> Enter
keycode 66 = Return

! Audio controls
keycode 140 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 162 = XF86AudioPlay
keycode 164 = XF86AudioStop
keycode 144 = XF86AudioPrev
keycode 153 = XF86AudioNext

! AltGr-e -> Euro sign
keycode 26 = e E e E EuroSign cent

The middle button is now not recognised by either xev or libinput debug-events. Moused is running as '/usr/sbin/moused -p /dev/psm0 -t auto'.
Comment 4 Darren Mulligan 2020-02-23 17:06:17 UTC
i lost all function from multimedia keys which was working with sysutils/uhidd. no output in xev. reverting the update worked and redoing the update broke again.
Comment 5 Jan Beich freebsd_committer 2020-02-23 18:37:36 UTC
(In reply to Darren Mulligan from comment #4)
> i lost all function from multimedia keys which was working with sysutils/uhidd.

sysutils/uhidd doesn't support /dev/input/event* yet. Upstream added the support[1] but it conflicts with evdev(4) from base system. However, after base r357861 you may be able usbhidaction(1) with multimedia keys. usbhidaction compared to uhidd will work everywhere: console, X11 server, Wayland compositor.

[1] https://github.com/kaiwang27/uhidd/commit/db331702e515

$ cat /usr/local/etc/uhidd.conf
default={
    cc_attach="evdev+"
    forced_attach="YES"
}
...
Comment 6 Michael Gmelin freebsd_committer 2020-02-23 22:00:23 UTC
(In reply to Jan Beich from comment #5)

Here is a good howto describing how to use usbhidaction(1),
which is part of base.

https://forums.freebsd.org/threads/howto-using-multimedia-keys-from-uhid-4-devices.24069/

I followed it to construct a little test case on a little Cherry keyboard (vendor 0x046a product 0x0023) that provides media keys over uhid,
unfortunately this didn't just work out of the box with this keyboard:


  # usbhidctl -f /dev/uhid1 -r
  Report descriptor:
  Collection type=Application page=Consumer usage=Consumer_Control
  Input   rid=1 pos=0 size=16 count=1 page=Consumer usage=Unassigned Array, logical range 0..1023
  End collection
  Collection type=Application page=Generic_Desktop usage=System_Control
  Input   rid=2 pos=0 size=1 count=1 page=Generic_Desktop usage=System_Power_Down, logical range 0..1
  Input   rid=2 pos=1 size=1 count=1 page=Generic_Desktop usage=System_Sleep, logical range 0..1
  Input   rid=2 pos=2 size=1 count=1 page=Generic_Desktop usage=System_Wake_Up, logical range 0..1
  End collection
  Total   input size 3 bytes
  Total  output size 0 bytes
  Total feature size 0 bytes

Reading keys is possible, but it's all part of that Unassigned Array above:

  # usbhidctl -f /dev/uhid1 -r -a -l
  Report descriptor:
  Collection type=Application page=Consumer usage=Consumer_Control
  Input   rid=1 pos=0 size=16 count=1 page=Consumer usage=Unassigned Array, 
  logical range 0..1023
  End collection
  Collection type=Application page=Generic_Desktop usage=System_Control
  Input   rid=2 pos=0 size=1 count=1 page=Generic_Desktop usage=System_Power_Down, logical range 0..1
  Input   rid=2 pos=1 size=1 count=1 page=Generic_Desktop usage=System_Sleep, logical range 0..1
  Input   rid=2 pos=2 size=1 count=1 page=Generic_Desktop usage=System_Wake_Up, logical range 0..1
  End collection
  Total   input size 3 bytes
  Total  output size 0 bytes
  Total feature size 0 bytes
  usbhidctl: hid_get_report(rid 1): Device not configured
  Consumer:Consumer_Control.Consumer:Unassigned=

  Generic_Desktop:System_Control.Generic_Desktop:System_Power_Down=
  Generic_Desktop:System_Control.Generic_Desktop:System_Sleep=
  Generic_Desktop:System_Control.Generic_Desktop:System_Wake_Up=

  Consumer:Consumer_Control.Consumer:Unassigned=0

  Consumer:Consumer_Control.Consumer:Unassigned=234

  Consumer:Consumer_Control.Consumer:Unassigned=0

  Consumer:Consumer_Control.Consumer:Unassigned=233

  Consumer:Consumer_Control.Consumer:Unassigned=0


As you can see, there's a problem getting the hid_report for rid 1. 

Good news is, that it still reports key events (234 and 233 are
"vol down/vol up").

In theory, writing rules should be possible, e.g.

  # cat myconfig
  Consumer:Consumer_Control.Consumer:Unassigned 234 0 mixer vol -10
  Consumer:Consumer_Control.Consumer:Unassigned 233 0 mixer vol +10

In practice this doesn't work, as the range is limited by usbhidaction:

  # usbhidaction -f /dev/uhid1 -c myconfig -v
  PARSE:1 Consumer:Consumer_Control.Consumer:Unassigned, -1, 'mixer vol -10'
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, -1, 'mixer vol +10'
  report size 3
  system 'mixer vol +10'
  Setting the mixer vol from 75:75 to 85:85.
  system 'mixer vol -10'
  Setting the mixer vol from 85:85 to 75:75.

The values are cut to -1. So pressing media keys always executes
both actions, not useful (in the example pressing any of the
media keys will issues both commands).

Looking at the code, I hacked in a workaround:

  # cat /usr/src/usr.bin/usbhidaction/usbhidaction.c | \
    sed "s/range = 1/range = 0/g" >myhidaction.c
  # cc -o myhidaction myhidaction.c -lusbhid

With this patch we can now configure actions. In this example, very basic
volume control and controlling audio/cmus (this all runs as root,
not ideal, but left out for simplicity):

  # cat myconfig

  # voldown
  Consumer:Consumer_Control.Consumer:Unassigned 234 0 mixer vol -10
  # poor man's mute
  Consumer:Consumer_Control.Consumer:Unassigned 226 0 mixer vol 0
  # volup
  Consumer:Consumer_Control.Consumer:Unassigned 233 0 mixer vol +10
  # prev
  Consumer:Consumer_Control.Consumer:Unassigned 182 0 cmus-remote --prev
  # play/pause
  Consumer:Consumer_Control.Consumer:Unassigned 205 0 cmus-remote --pause
  # next
  Consumer:Consumer_Control.Consumer:Unassigned 181 0 cmus-remote --next

  # ./myhidaction  -c myconfig -f /dev/uhid1 -v
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, 234, 'mixer vol -10'
  PARSE:4 Consumer:Consumer_Control.Consumer:Unassigned, 226, 'mixer vol 0'
  PARSE:6 Consumer:Consumer_Control.Consumer:Unassigned, 233, 'mixer vol +10'
  PARSE:8 Consumer:Consumer_Control.Consumer:Unassigned, 182, 'cmus-remote --prev'
  PARSE:10 Consumer:Consumer_Control.Consumer:Unassigned, 205, 'cmus-remote --pause'
  PARSE:12 Consumer:Consumer_Control.Consumer:Unassigned, 181, 'cmus-remote --next'
  report size 3
  system 'cmus-remote --pause'
  PARSE:2 Consumer:Consumer_Control.Consumer:Unassigned, 234, 'mixer vol -10'
  PARSE:4 Consumer:Consumer_Control.Consumer:Unassigned, 226, 'mixer vol 0'
  PARSE:6 Consumer:Consumer_Control.Consumer:Unassigned, 233, 'mixer vol +10'
  PARSE:8 Consumer:Consumer_Control.Consumer:Unassigned, 182, 'cmus-remote --prev'
  PARSE:10 Consumer:Consumer_Control.Consumer:Unassigned, 205, 'cmus-remote --pause'
  PARSE:12 Consumer:Consumer_Control.Consumer:Unassigned, 181, 'cmus-remote --next'
  system 'mixer vol +10'
  Setting the mixer vol from 20:20 to 30:30.
  system 'mixer vol +10'
  Setting the mixer vol from 30:30 to 40:40.
  system 'mixer vol +10'
  Setting the mixer vol from 40:40 to 50:50.
  system 'mixer vol +10'
  Setting the mixer vol from 50:50 to 60:60.
  system 'mixer vol +10'
  Setting the mixer vol from 60:60 to 70:70.
  system 'mixer vol +10'
  Setting the mixer vol from 70:70 to 80:80.
  system 'mixer vol +10'
  Setting the mixer vol from 80:80 to 90:90.
  system 'cmus-remote --pause'
  system 'cmus-remote --pause'

So that's good enough for me for demonstration purposes. I hardly
ever use that keyboard, but I thought leaving this here still might
be useful.
Comment 7 Serge Volkov 2020-02-23 22:35:52 UTC
Hi, All!

I've just upgraded xorg-server to 1.20.7,1 via pkg (latest). And now, if I press the Down Arrow key on the keyboard, the plasma5 Main Menu pops up. It’s impossible to work normally. As I know, the plasma5 Main Menu should appear when you press Alt+F1. And Alt+F1 works now. I had no such problem with Down Arrow key before upgrade.

I use KDE Plasma5 with Generic 105 keyboard and us,ru layout.

Can anyone help?
Comment 8 Patricio Villar 2020-02-24 00:11:13 UTC
(In reply to Serge Volkov from comment #7)
I have the same problem, and it exhibits the same behavior with the 'End' key.
The only workaround I've found at the moment is disabling the keyboard shortcut for the Application Menu...
Perhaps we should open a bug report for Plasma specifically
Comment 9 ice 2020-02-24 11:22:15 UTC
It somehow doesn't seem to be specidic to a DE/WM. I have tried with a fresh, no-customisations whatsoever user (except for .xinitrc starting the WM) with no custom X config (nothing in etc/X11/xorg.conf.d/, no xkb config, no custom Xresources, no nothing) with both Window Maker and mwm, with exactly the same results.
Comment 10 Michael Gmelin freebsd_committer 2020-02-24 12:19:44 UTC
(In reply to ice from comment #9)

What exactly are the symptoms you're experiencing now?

I installed windowmaker + your .xinitrc (without having .Xmodmap .Xresources and  .sxhkdrc files) and everything works:

- Keyboard (internal and usb), pgup/pgdown/cursor keys
- Mouse: all buttons (incl. middle button for paste)
(note: I'm *not* running moused)

Could you run this script:
https://github.com/grembo/xorg-udev-setup-check

(direct link https://raw.githubusercontent.com/grembo/xorg-udev-setup-check/master/xorg-udev-setup-check.sh)

Run './xorg-udev-setup-check.sh -d' (drm shouldn't matter here), can be
run as an unprivileged user.

Could you share more details about your installation?
(xorg configuration files, Xorg*.log etc., which kind of hardware
mouse, keyboard etc., ~/.sxhkdrc)
Comment 11 ice 2020-02-24 12:53:42 UTC
Completely new user with the only specific config being .xinitrc:

--
#!/bin/sh
exec /usr/local/bin/wmaker
--

moused not running (if running, same symptom), nothing in /usr/local/etc/X11/xorg.conf.d/, wmaker config is as copied from system defaults on first startup, as barebones and unmodified as I can get it.

The middle mouse button is not working at all, but left+right together act as if the middle mouse button was pressed (i.e. it seems to have forgotten the middle one exists and switched to some sort of emulation mode. I don't quite remember what these things are properly called as I haven't had a two-button mouse in about 20 years :).

This is tested with Firefox (middle mouse does not open a link in a new tab) and xterm (middle mouse does not paste as it should do).

If I switch to mwm, exact same thing.

'xev' and 'libinput debug-events' are both completely mum about the middle mouse button (they do recognise left and right as well as any other key).

Hardware is a Lenovo ThinkPad X220 (touchpad turned off in BIOS, only TrackPoint is active, the buttons belong to TrackPoint), Xorg log attached. 

'kern.evdev.rcpt_mask' is set to '6':
$ sysctl kern.evdev.rcpt_mask
kern.evdev.rcpt_mask: 6


xorg-server is compiled with 'UDEV':
$ make showconfig
===> The following configuration options are available for xorg-server-1.20.7,1:
     SUID=on: Install setuid wrapper to allow startx as non-root
====> Backend to use for input device configuration: you can only select none or one of them
     DEVD=off: Use devd for autoconfiguration of input devices
     UDEV=on: Use udev via libudev-devd for autoconfiguration of input devices
===> Use 'make config' to modify these settings
Comment 12 ice 2020-02-24 13:04:46 UTC
Created attachment 211893 [details]
Xorg log #2
Comment 13 Vladimir Kondratyev freebsd_committer 2020-02-24 13:09:57 UTC
Just to be on the safe side, check some basic parameters:

1. Your keyboard is working properly on low level. Use evemu-record from devel/evemu port for it. Depending on kern.evdev.rcpt_mask sysctl value, evemu-record should be attached to actual hardware device when value is 12 or to "System keyboard multiplexor" when value is 6 or 3. Keys pressed by you should match keycodes reported by utility.

2. Check that your keyboard keymap has not been clobbered by WM or some long ago forgotten configs. Type 'setxkbmap -print -verbose 10'. It should return e.g:

For US:

% setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/local/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+inet(evdev)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

For US+RU with capslock as group toggle key:

% setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/local/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us,ru
variant:    ,
options:    grp:caps_toggle
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+ru:2+inet(evdev)+capslock(grouplock)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+ru:2+inet(evdev)+capslock(grouplock)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
Comment 14 Michael Gmelin freebsd_committer 2020-02-24 13:14:20 UTC
(In reply to ice from comment #11)

A few more questions:

- So the "only" problem you have at the moment is that the middle
  mouse button of your Lenovo trackpoint isn't working, correct?

- Did you run/pass the script?

- Could you share the output of

  xinput list --long

- And the output of:

  libinput list-devices

- Share /var/log/Xorg*.log

- Does "click scrolling" work? (holding the middle mouse button
  and moving the trackpoint up/down and/or left/right)
Comment 15 ice 2020-02-24 13:29:14 UTC
- As far as I can currently tell, yes, the only problem is the middle mouse button not working

- Almost passed, the bit it flags is not true:

$ /tmp/xorg-udev-setup-check.sh 
Info: kern.evdev.rcpt_mask is set to 6.

You might consider setting it to 12 in case of problems
(which will change keyboard events to go to hardware)
-- run /tmp/xorg-udev-setup-check.sh -i to suppress info messages
Info: Synaptics support isn't enabled.
This is only relevant if you use a synapctics touchpad.
You can enable synaptics support using these commands:

echo hw.psm.synaptics_support >>/boot/loader.conf
reboot

-- run /tmp/xorg-udev-setup-check.sh -i to suppress info messages
Error: Neither i915kms nor radeonkms is loaded.

Please load using

kldload i915kms
or
kldload radeonkms

You can load one of these drivers automatically on
boot by adding it to kld_list in rc.conf:

sysrc kld_list+=/boot/modules/i915kms.ko
or
sysrc kld_list+=/boot/modules/radeonkms.ko

Please fix and re-run /tmp/xorg-udev-setup-check.sh

as
$ kldstat | fgrep i915
29    1 0xffffffff82e33000    7aa40 i915kms.ko

With -d, it passes though:

$ /tmp/xorg-udev-setup-check.sh -d
Info: kern.evdev.rcpt_mask is set to 6.

You might consider setting it to 12 in case of problems
(which will change keyboard events to go to hardware)
-- run /tmp/xorg-udev-setup-check.sh -i to suppress info messages
Info: Synaptics support isn't enabled.
This is only relevant if you use a synapctics touchpad.
You can enable synaptics support using these commands:

echo hw.psm.synaptics_support >>/boot/loader.conf
reboot

-- run /tmp/xorg-udev-setup-check.sh -i to suppress info messages
Done - All checks passed

- xinput list --long:

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
        Reporting 7 classes:
                Class originated from: 9. Type: XIButtonClass
                Buttons supported: 12
                Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" None None None None None
                Button state:
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 0:
                  Label: Rel X
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 1:
                  Label: Rel Y
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 2:
                  Label: Rel Horiz Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 3:
                  Label: Rel Vert Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIScrollClass
                Scroll info for Valuator 2
                  type: 2 (horizontal)
                  increment: 15.000000
                  flags: 0x0
                Class originated from: 9. Type: XIScrollClass
                Scroll info for Valuator 3
                  type: 1 (vertical)
                  increment: 15.000000
                  flags: 0x0

⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
        Reporting 3 classes:
                Class originated from: 4. Type: XIButtonClass
                Buttons supported: 10
                Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" None None None
                Button state:
                Class originated from: 4. Type: XIValuatorClass
                Detail for Valuator 0:
                  Label: Rel X
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 4. Type: XIValuatorClass
                Detail for Valuator 1:
                  Label: Rel Y
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative

⎜   ↳ System mouse                              id=6    [slave  pointer  (2)]
        Reporting 7 classes:
                Class originated from: 6. Type: XIButtonClass
                Buttons supported: 12
                Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" "Button Side" "Button Extra" "Button Forward" "Button Back" None
                Button state:
                Class originated from: 6. Type: XIValuatorClass
                Detail for Valuator 0:
                  Label: Rel X
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 6. Type: XIValuatorClass
                Detail for Valuator 1:
                  Label: Rel Y
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 6. Type: XIValuatorClass
                Detail for Valuator 2:
                  Label: Rel Horiz Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 6. Type: XIValuatorClass
                Detail for Valuator 3:
                  Label: Rel Vert Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 6. Type: XIScrollClass
                Scroll info for Valuator 2
                  type: 2 (horizontal)
                  increment: 15.000000
                  flags: 0x0
                Class originated from: 6. Type: XIScrollClass
                Scroll info for Valuator 3
                  type: 1 (vertical)
                  increment: 15.000000
                  flags: 0x0

⎜   ↳ Generic PS/2 mouse                        id=9    [slave  pointer  (2)]
        Reporting 7 classes:
                Class originated from: 9. Type: XIButtonClass
                Buttons supported: 7
                Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right"
                Button state:
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 0:
                  Label: Rel X
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 1:
                  Label: Rel Y
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 2:
                  Label: Rel Horiz Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIValuatorClass
                Detail for Valuator 3:
                  Label: Rel Vert Scroll
                  Range: -1.000000 - -1.000000
                  Resolution: 0 units/m
                  Mode: relative
                Class originated from: 9. Type: XIScrollClass
                Scroll info for Valuator 2
                  type: 2 (horizontal)
                  increment: 15.000000
                  flags: 0x0
                Class originated from: 9. Type: XIScrollClass
                Scroll info for Valuator 3
                  type: 1 (vertical)
                  increment: 15.000000
                  flags: 0x0

⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
        Reporting 1 classes:
                Class originated from: 7. Type: XIKeyClass
                Keycodes supported: 248

    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
        Reporting 1 classes:
                Class originated from: 5. Type: XIKeyClass
                Keycodes supported: 248

    ↳ System keyboard multiplexer               id=7    [slave  keyboard (3)]
        Reporting 1 classes:
                Class originated from: 7. Type: XIKeyClass
                Keycodes supported: 248

    ↳ AT keyboard                               id=8    [slave  keyboard (3)]
        Reporting 1 classes:
                Class originated from: 8. Type: XIKeyClass
                Keycodes supported: 248

- libinput list-devices:

Device:           System mouse
Kernel:           /dev/input/event0
Group:            1
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: disabled
Calibration:      n/a
Scroll methods:   button
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   flat *adaptive
Rotation:         n/a

Device:           System keyboard multiplexer
Kernel:           /dev/input/event1
Group:            2
Seat:             seat0, default
Capabilities:     keyboard 
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   n/a
Rotation:         n/a

Device:           AT keyboard
Kernel:           /dev/input/event2
Group:            3
Seat:             seat0, default
Capabilities:     keyboard 
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   n/a
Rotation:         n/a

Device:           Generic PS/2 mouse
Kernel:           /dev/input/event3
Group:            4
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

- Xorg.log is uploaded

- Click scrolling does not work

Again, both 'libinput debug-events' and 'xev' are *completely mum* about the middle mouse button.
Comment 16 Michael Gmelin freebsd_committer 2020-02-24 14:03:38 UTC
(In reply to ice from comment #15)

Is trackpoint support enabled in loader.conf? Check

sysctl hw.psm.trackpoint_support
Comment 17 Michael Gmelin freebsd_committer 2020-02-24 14:43:13 UTC
(In reply to Michael Gmelin from comment #16)

@ice
I tested on an newer Lenovo model (touchpad disabled, trackpoint enabled).

If hw.psm.trackpoint_support==0, the trackpoint shows up as a generic mouse
in the output of `libinput list-devices':

  Device:           Generic PS/2 mouse
  Kernel:           /dev/input/event3
  Group:            4

just like it did in your output. Also, the middle mouse button is ignored
in this case, no click to paste etc.

When setting hw.psm.trackpoint_support=1 on boot, `libinput list-devices'
shows the device as a trackpoint:

  Device:           TPPS/2 IBM TrackPoint
  Kernel:           /dev/input/event3
  Group:            4

In this case, the middle mouse button works for pasting selection
(tested in xterm) as well as for scrolling (hold middle mouse
button and move trackpoint).

So if the X220 is anything like the T470s, doing

  echo "hw.psm.trackpoint_support=1" >>/boot/loader.conf
  reboot

should fix your problem.
Comment 18 ice 2020-02-24 17:53:16 UTC
(In reply to Michael Gmelin from comment #17)

It did, thank you very much!

To summarise:

- as per your advice, hw.psm.trackpoint_support=1 is needed so the trackpoint is properly recognised

- sxhkd doesn't really work anymore, but is apparently not even needed anymore, as the multimedia (volume up/down/mute) keys work by default as intended

- the multimedia keys work without custom Xmodmap entries (this may have been the case for a while, though)

- setting the xkb map from xorg.conf.d works as it worked before:

Section "InputClass"
        Identifier      "KeyboardDefaults"
        MatchDevicePath "/dev/input/event*"
        MatchIsKeyboard "on"
        Driver          "libinput"
        Option          "XkbRules"      "evdev"
        Option          "XkbModel"      "pc104"
        Option          "XkbLayout"     "us,hu"
        Option          "XkbVariant"    ",qwerty"
        Option          "XkbOptions"    "grp:alt_shift_toggle"
EndSection

(I did change rules from xorg to evdev, not sure if it is necessary or not)

- autocutsel works as it worked before (not sure if (still) necessary)

My only remaining problem was that Alt+middle button used to drag the window (much like Alt+left button does). Middle button+trackpoint now does this "click scroll" thing (which it may or may not have done before, half a day ago I did not know it was a thing).

Per https://askubuntu.com/a/959924, 'xinput set-prop "TPPS/2 IBM TrackPoint" "libinput Scroll Method Enabled" 0 0 0' turns something I've never heard about off, so now Alt+middle button is back to dragging windows.

Thank you, Michael and everyone for your help, I seem to be set for the moment.
Comment 19 Michael Gmelin freebsd_committer 2020-02-24 20:04:36 UTC
(In reply to ice from comment #18)

> I seem to be set for the moment.

Good to hear and thank you for summarizing.

As a learning, I added a note about hw.psm.trackpoint_support to
xorg-udev-setup-check.