2

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.

Buttons A and B work out of the box as primary (button 1) and right click (button 3). Pressing A + B together generates a middle click (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 button map, I get this mapping:

physical buttons:   A C B         D
xinput button-map:  1 2 3 4 5 6 7 8 9 10 11 12 

If I try to map button C to 8 and D to 9, with xinput set-button-map, then pressing A+B is mapped to button 8 too!

physical buttons:   A C B         D
xinput button-map:  1 8 3 0 0 0 0 9
                      ^
                      A+B emulation becomes 8 too!

How can I map button C to an arbitrary button number, while keeping the A+B emulation as button 2?

Should I work on a lower level than Xinput? How? Should I use a different Xinput setting?

Edit: 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
2

I ended up patching the Xorg evdev driver to add an Emulate3Button option, that configures the button number emitted by the middle button emulation. (I submitted the patch to the mailing list, it should be merged sooner or later.)

Then I added this piece of config:

Section "InputClass"
    Identifier  "SlimBlade Trackball"
    Driver      "evdev"

    Option      "ButtonMapping" "1 8 3 4 5 6 7 9 0 2"
    Option      "Emulate3Button" "10"
EndSection

This makes the middle button emulation emit button number 10, then it maps button C to 8, D to 9, and 10 to 2. Voila.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.