3 answers
No wonder it's hard to find good programs - it's no longer necessary! At some point this became a built in part of Xorg via xinput.
The process is something like this:
-
xinput list
and find the ID of your mouse -
xinput get-button-map $MOUSE_ID
and see the current map -
xev -event button | grep button
to check which button is which -
xinput set-button-map $MOUSE_ID $NEW_BUTTON_MAP
to remap
This will only work until the next reboot.
To make it permanent you can create Xorg config files (described in the link).
0 comment threads
Wayland, ideally
If you are on Wayland, the blessed way is to use the configuration for your desktop environment (DE) to map mouse keys and other input devices, except for a couple well-known options (eg left-handed mode and middle mouse emulation).
Wayland, via hwdb
If your DE doesn't have configuration for mouse key bindings, you may be able to mess with the hwdb
like this person on Reddit. Wayland's current version of libinput
says not to do this anymore, but if you're stuck you're stuck.
Get the device ID
$ lsusb | grep Kens Bus 001 Device 008: ID 047d:8018 Kensington
Get the input events with evtest
Event: time 1584228876.372060, -------------- SYN_REPORT ------------ Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003 Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1 Event: time 1584228877.572302, -------------- SYN_REPORT ------------
I was lucky because I really just wanted to swap two buttons, and
evtest
dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up onevtest
reportingBTN_SIDE
, but having to use lower-casebtn_side
in thehwdb
entry.
Add changes to the hwdb
I'm on Fedora 31, and have been using [a]
hwdb
entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)[The] rule in my
hwdb
entry (evdev:input:b*v047Dp8018*
) is just the USB Vendor + Product$ cat 90-trackball-buttons.hwdb # Kensington Expert Mouse Trackball: # * Rebind top-left from BTN_MIDDLE to BTN_SIDE # * Rebind top-right from BTN_SIDE to BTN_MIDDLE evdev:input:b*v047Dp8018* KEYBOARD_KEY_90003=btn_side KEYBOARD_KEY_90004=btn_middle
Reload your hwdb
$ sudo systemd-hwdb update
$ sudo udevadm trigger /sys/class/input/eventX
0 comment threads
Piper can be used for this. All mice supported by Piper (actually libratbag) are a result of the community reverse engineering the mouse protocol. It will not support all mice, but only selected ones.
Corsair mice are not supported by Piper, but they are supported by ckb-next which is analogous to Piper, but for Corsair only.
0 comment threads