Thursday, October 02, 2014

xorg.conf and the ButtonMapping Option

This is partly a reference for anyone who's looking for information on the positioning of xorg.conf's mouse remap ButtonMapping option, and for myself in the future.

After doing some trial-and-error using xmodmap -e "pointer = 1 2 3 4 5 ..." and xev -event mouse I've been able to map numbers to actions:
  1. Left click
  2. Middle click
  3. Right click
  4. Scroll Up
  5. Scroll Down
  6. Scroll Left
  7. Scroll Right
  8. Back (eg: browser back)
  9. Forward (eg: browser forward)
  10. ?
  11. ?
  12. ? (the red target button on my mouse)
  13. ?
  14. ?
  15. ?
In xorg.conf the position refers to which physical mouse button (eg: third number means button #3), and the number in the position defines the action for that button. In xmodmap everything is backwards: the position is the action, and the number is the physical mouse button.

Note: If you modify the button's action in xorg.conf then it will become that button for as long as X is running for all other tools.

I was doing this to help get my Cyborg R.A.T.5 Mouse working. I followed some instructions to get started, then modified it a bit to get the mapping working as I wanted:

Section "InputClass"
        Identifier "Mouse Remap"
        MatchProduct "Saitek Cyborg R.A.T.5 Mouse"
        MatchDevicePath "/dev/input/event*"
        # Button number         1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
        Option "ButtonMapping" "1 2 3 4 5 0 0 8 9 7  6  12 0  0  0"
EndSection

This mapping means, for example, that the button X sees as #10 will perform action #7, which is "scroll right". This mapping is specific to my mouse; you'd have to use xev to determine what the buttons are for your mouse, but the actions will be the same.

The same mapping in xmodmap would be:

# Action number       1 2 3 4 5 6  7  8 9 10 11 12 13 14 15
xmodmap -e "pointer = 1 2 3 4 5 11 10 8 9 0  0  12 0  0  0"

If you know what the remaining actions are, or have any corrections, please let me know!