In an X configuration file mouse buttons can be mapped using a ButtonMapping option:
Section "InputClass"
# ...
Option "ButtonMapping" "1 9 3 4 5 6 7 8 2"
# ...
EndSection
Changing the order of the numbers changes the behaviour of the mouse buttons. Yet I cannot find any documentation that describes how the behaviour is assigned. What little documentation there is, I helped write.
For example, if the button mapping was written thus:
Option "ButtonMapping" "a b c d e f g h i"
We would document these positions as:
- a – Left click
- b – Middle
- c – Right click
- d – Scroll forward
- e – Scroll backward
- f – Forward
- g – Backward
- h – Horizontal scroll
- i – Vertical scroll
My question then: what do the positional values of a through i actually represent and how are they mapped to mouse buttons?
Update
Running xmodmap -pp
shows:
$ xmodmap -pp
There are 10 pointer buttons defined.
Physical Button
Button Code
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
This is not useful as it contains no information a human can use about the physical attributes of the mouse (i.e., showing two columns of numbers is useless without button names, such as "left button"). So while technically this might answer the question of "how are they mapped", the question remains unanswered in any practical sense.
Best Answer
I think you should look at it this way:
The position that indicates the key id as reported by mouse (through driver). So it's up to the manufacturer how to order them, however most stick to common order.
Mouses still using the old protocols like PS2, it doesn't have a way store or tell info about available buttons and their functions. So X server can't tell you the id of each physical button, only by trying them using a tool like
xev
that shows the X events:Or
evtest
that shows the raw events:The logical key are the ones actually mapped some where else for extra functions. At this level, X looks at them as: button1, button2, button3, button4,...,button24 and it does not know their function.
Official reference examples:
Source: ftp://ftp.x.org/pub/current/doc/mouse.txt