Xinput button mapping and middle button emulation

Tobia Conforto tobia.conforto at gruppo4.eu
Mon Oct 10 10:35:42 UTC 2016


I have a mouse with 4 physical buttons (Kensington Slimblade
Trackball), let's call them A B C D, plus 3 axes: mouse X, Y, and
scroll wheel. I'm using Xorg 1:7.7+13ubuntu3 on Linux Mint 18, kernel
4.4.0-38-generic.

Buttons A and B work out of the box as primary (button 1) and right
click (button 3). Pressing A + B together triggers the middle button
emulation (button 2) which is also great.

Now I'd like to map buttons C and D for my own purposes, but I cannot
find how to map button C separately from the A+B emulation.

With the default xinput button-map, I get this mapping:

1 A
2 C
3 B
4
5
6
7 D
...

If I try to map button C to 8 and D to 9, with `xinput set-button-map
"..." 1 8 3 0 0 0 9`, then button C is mapped to 8, but the middle
button emulation (A+B) gets mapped to button 8 too!

1 A
8 C, but also A+B!
3 B
0
0
0
9 D

How can I map button C to an arbitrary button number (such as 8) while
keeping the A+B emulation as button 2? Can it be done at the Xinput
level at all?

Here are the evtest codes for the 4 buttons:

A:
type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
type 1 (EV_KEY), code 272 (BTN_LEFT), value 1

B:
type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1

C:
type 4 (EV_MSC), code 4 (MSC_SCAN), value ff000001
type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1

D:
type 4 (EV_MSC), code 4 (MSC_SCAN), value ff000002
type 1 (EV_KEY), code 275 (BTN_SIDE), value 1

If Xinput cannot do it, does anybody know if I can change the mapping
between MSC_SCAN and BTN_* without writing a kernel driver?


-Tobia


More information about the xorg mailing list