Swapping mouse button in wayland + KDE

I’m testing wayland and I have a problem swapping the button 2 and 3 of my mouse.

I have a Evoluent VerticalMouse. In X11 I swap button 2 and 3 because I find that it is more usable working with index and middlefinger rather than the index and ring fingers. I did it via start script

philippe@hpprol2:~/Script> cat evmouse.sh
#!/usr/bin/bash
xinput --set-button-map 8 1 3 2

In wayland this is not working

philippe@hpprol2:~/Script> ./evmouse.sh
WARNING: running xinput against an Xwayland server. See the xinput man page for details.
device has no buttons

The man page says:

Use the Wayland Compositor’s native device configuration methods instead

I searched via google but I idn’t found a answer.
Is it possible t switch mouse button 2 and 3 in wayland?

Many thanks in advance
Philippe

You can’t use X-server utilities as you’ve found out. However, for Plasma Wayland did you try re-mapping the buttons via System settings > Hardware > Mouse > ‘Rebind Additional Mouse Buttons…’ ?

Yes I tried it but it seems that this is not working (or that I didn’t understand how it works)
there is also this message

Press the mouse button for which you want to add a key binding

if I understand it correctly it should be a binding with keyboard keys? something like CTRL-V or CTR-C?

Regards
Philippe

You can remap it at the kernel level:

It appears everything, even mouse buttons are entered as “keyboard keys”. Perhaps you can do this with the native KDE tool as well.

2 Likes

Many thanks for the link.

The evtest shows

hpprol2:~ # evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Power Button
/dev/input/event1:      CHICONY HP Basic USB Keyboard
/dev/input/event2:      Kingsis Peripherals Evoluent VerticalMouse 4
/dev/input/event3:      PC Speaker
Select the device event number [0-3]: 2
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x1a7c product 0x191 version 0x111
Input device name: "Kingsis Peripherals Evoluent VerticalMouse 4"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 272 (BTN_LEFT)
    Event code 273 (BTN_RIGHT)
    Event code 274 (BTN_MIDDLE)
    Event code 275 (BTN_SIDE)
    Event code 276 (BTN_EXTRA)
    Event code 277 (BTN_FORWARD)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
    Event code 1 (REL_Y)
    Event code 6 (REL_HWHEEL)
    Event code 8 (REL_WHEEL)
    Event code 11 (REL_WHEEL_HI_RES)
    Event code 12 (REL_HWHEEL_HI_RES)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1709215636.116517, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1709215636.116517, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1
Event: time 1709215636.116517, -------------- SYN_REPORT ------------
Event: time 1709215636.293512, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1709215636.293512, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 0
Event: time 1709215636.293512, -------------- SYN_REPORT ------------
Event: time 1709215637.468573, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1709215637.468573, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1
Event: time 1709215637.468573, -------------- SYN_REPORT ------------
Event: time 1709215637.601500, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1709215637.601500, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 0

I created the directory /etc/udev/hwdb.d and therein the file 99-test.hwdb with this content

evdev:input:b0003v1A7Cp0191*
 KEYBOARD_KEY_90002=btn_middle
 KEYBOARD_KEY_90003=btn_right

therafter

# systemd-hwdb update 
# udevadm trigger

and the button are swapped :smiley:

I removed the evmouse.sh script

Mant thanks for your help
Philippe

1 Like

Thank you for coming back and updating us with the steps/results. It is very helpful for future readers :slightly_smiling_face:

I might have a use for it myself soon as I’m moving from my basic vertical mouse to a trackball one.

1 Like

How do you derive 90002 from 274?

Hello ,

I derived it from these lines in the evtest

nt: time 1709215636.116517, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1709215636.116517, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1
Event: time 1709215636.116517, -------------- SYN_REPORT ------------
nt: time 1709215637.468573, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1709215637.468573, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1
Event: time 1709215637.468573, -------------- SYN_REPORT ------------
Eve

Orignal value for button right was 90002 swap to 90003 = button middle

Regards
Philippe

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.