2

I am using a Logitech Trackman Marble Trackball on Ubuntu 22.04, Gnome Shell 42, Wayland.

I wish to simulate a middle mouse click with one of the extra side buttons, but it seems I am able to synthesize any type of button except the middle button.

  • I have created file at /etc/udev/hwdb.d/71-logitech-trackman.hwdb like so:
evdev:name:Logitech USB Trackball:*
 KEYBOARD_KEY_90004=btn_middle

I then run:

sudo systemd-hwdb update
sudo udevadm trigger

And physically reconnect the device.

  • Running sudo udevadm info /dev/input/event8 | grep btn_middle shows that the mapping has taken effect.
  • Running sudo evtest /dev/input/event8 outputs the correct mapping like so:
Event: time 1689266776.764313, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004
Event: time 1689266776.764313, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1
  • However, running sudo libinput debug-events --device /dev/input/event8 does not emit any output when I press the remapped button (though it does output correct lines for all other events).

Oddly, libinput does emit output if I choose any other target event, such as btn_left, btn_right, or even other buttons that the device does not have, such as btn_back, and these clicks are correctly reflected in the GUI. It appears to be only the middle button that cannot be emulated.

The behaviour is the same if I attempt to remap any of the four physical buttons.

What could be preventing the middle mouse button mapping from working?

  • Have you explored the second solution here? https://unix.stackexchange.com/a/662684/135544

    It does not use udev, instead a separate program to remap your side buttons to middle mouse.

    My searches show others have been able to remap these exact keys to middle mouse. Any chance you have some other operation/program blocking middle mouse you may have forgotten of?

    – AlwaysTalkingAboutMyDog Jul 20 '23 at 11:06
  • @AlwaysTalkingAboutMyDog Thanks, I had tried input-remapper, but sadly it conflicts with scroll-wheel-emulation which I am also using (https://github.com/sezanzeb/input-remapper/issues/124). Certainly, something must be blocking remapping to btn_middle, but I cannot determine what it might be. – Ian Mackinnon Jul 23 '23 at 13:52
  • Scroll-wheel-emulation seems suspicious here, there's a good chance it is interfering with the middle-mouse button if you say it conflicts with input-remapper. I think you've identified the problem yourself here - some conflict between scroll-wheel-emulation and other input changers/simulators. Likely not going to resolve this without investigating scroll-wheel-emulation in more detail on how it captures/blocks/suspends certain mouse clicks under different conditions. – AlwaysTalkingAboutMyDog Jul 26 '23 at 05:58

2 Answers2

1

I wanted to map side button to left. Here is what I did.

Created file /etc/udev/hwdb.d/99-mouse.hwdb:

evdev:input:b*v062Ap4101*
 KEYBOARD_KEY_90004=btn_left

Where v062Ap4101 is USB device ID from lsusb command. Note all hex numbers have to be uppercase.

Default mapping is:

 KEYBOARD_KEY_90001=btn_left
 KEYBOARD_KEY_90002=btn_right
 KEYBOARD_KEY_90003=btn_middle
 KEYBOARD_KEY_90004=btn_side
 KEYBOARD_KEY_90005=btn_extra

Then:

  • $ sudo systemd-hwdb update - to update the database
  • $ sudo udevadm trigger /sys/class/input/event9 - to reload database
  • $ sudo udevadm test /sys/class/input/event9 - to validate it worked

For testing and dubugging I used $ sudo libinput debug-events . You can get event device number and more. Hope it helps.

0

I have similar issue and i solve it, try change you .hwdb file:

evdev:input:*
 KEYBOARD_KEY_90004=btn_middle