You are not logged in.

#1 2020-11-10 05:52:28

MountainX
Member
Registered: 2016-02-08
Posts: 371

Two mice connected. How to swap mouse buttons for one device?

I have multiple mice connected. I want to use one for right hand and one for left hand (not at the same time of course). I need to reverse the left and right mouse buttons on one of them while not affecting the other. I also want to invert the scroll direction on that one (as well as increase scrolling speed in all applications).

I'm running KDE. System Settings > Input Devices > Mouse has these options, but they apply to all mice. So I am thinking that either Xorg or udev might allow me to accomplish this. The mouse I want to reverse & invert is the PixArt USB Optical Mouse. What's the recommended way to do this?

# egrep "Name|Handlers" /proc/bus/input/devices | egrep -B1 'Handlers.*mouse'
N: Name="Logitech USB Laser Mouse"
H: Handlers=event4 mouse1

N: Name="PixArt USB Optical Mouse"
H: Handlers=event9 mouse2

# ls /dev/input/by-id/

lrwxrwxrwx 1 root root   9 Nov 10 00:25 usb-Logitech_USB_Laser_Mouse-event-mouse -> ../event4
lrwxrwxrwx 1 root root   9 Nov 10 00:25 usb-Logitech_USB_Laser_Mouse-mouse -> ../mouse1

lrwxrwxrwx 1 root root   9 Nov 10 00:25 usb-PixArt_USB_Optical_Mouse-event-mouse -> ../event9
lrwxrwxrwx 1 root root   9 Nov 10 00:25 usb-PixArt_USB_Optical_Mouse-mouse -> ../mouse2

# xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Laser Mouse                  id=10   [slave  pointer  (2)]
⎜   ↳ PixArt USB Optical Mouse                  id=11   [slave  pointer  (2)]
# xinput list-props 11
Device 'PixArt USB Optical Mouse':
        Device Enabled (153):   1
        Coordinate Transformation Matrix (155): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Natural Scrolling Enabled (287):       0
        libinput Natural Scrolling Enabled Default (288):       0
        libinput Scroll Methods Available (289):        0, 0, 1
        libinput Scroll Method Enabled (290):   0, 0, 0
        libinput Scroll Method Enabled Default (291):   0, 0, 0
        libinput Button Scrolling Button (292): 2
        libinput Button Scrolling Button Default (293): 2
        libinput Button Scrolling Button Lock Enabled (294):    0
        libinput Button Scrolling Button Lock Enabled Default (295):    0
        libinput Middle Emulation Enabled (296):        0
        libinput Middle Emulation Enabled Default (297):        0
        libinput Accel Speed (298):     0.000000
        libinput Accel Speed Default (299):     0.000000
        libinput Accel Profiles Available (300):        1, 1
        libinput Accel Profile Enabled (301):   1, 0
        libinput Accel Profile Enabled Default (302):   1, 0
        libinput Left Handed Enabled (303):     0
        libinput Left Handed Enabled Default (304):     0
        libinput Send Events Modes Available (272):     1, 0
        libinput Send Events Mode Enabled (273):        0, 0
        libinput Send Events Mode Enabled Default (274):        0, 0
        Device Node (275):      "/dev/input/event9"
        Device Product ID (276):        2362, 9488
        libinput Drag Lock Buttons (305):       <no items>
        libinput Horizontal Scroll Enabled (306):       1

I am not currently using an xorg.conf, and I don't have any input devices defined in /etc/X11/xorg.conf.d/. I have a generic /usr/share/X11/xorg.conf.d/40-libinput.conf:

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

System info:

xf86-input-libinput 0.30.0-1
xorg-server 1.20.9-2

EDIT: For temporary testing, the first line will reverse the left and right mouse buttons on one mouse, the second line inverts scrolling direction. (I have not found anything that affects scrolling speed of just one mouse yet.)

xinput set-button-map 11 3 2 1
xinput set-prop 11 287 1

Unfortunately, that method doesn't invert scrolling direction in Firefox (although other apps like Kate, Dolphin, Atom work as expected).

Last edited by MountainX (2020-11-10 06:34:02)

Offline

#2 2020-11-10 07:26:32

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: Two mice connected. How to swap mouse buttons for one device?

https://wiki.archlinux.org/index.php/Li … ation_file and more specifically the follow up link  https://wiki.archlinux.org/index.php/Lo … e#libinput shows how to do this via xorg configuration, read man 4 libinput for the applicable options in particular NaturalScrolling and ButtonMapping options.

Last edited by V1del (2020-11-10 07:29:42)

Offline

Board footer

Powered by FluxBB