在 X 配置文件中,可以使用 ButtonMapping 选项来映射鼠标按钮:
Section "InputClass"
# ...
Option "ButtonMapping" "1 9 3 4 5 6 7 8 2"
# ...
EndSection
更改数字的顺序会改变鼠标按钮的行为。但我找不到任何文档描述如何分配行为。文档很少有,我帮忙写的。
例如,如果按钮映射如下写:
Option "ButtonMapping" "a b c d e f g h i"
我们将这些立场记录为:
- A- 左键单击
- b- 中间
- C- 右键点击
- d- 向前滚动
- 埃- 向后滚动
- F- 向前
- G- 向后
- H- 水平滚动
- 我- 垂直滚动
那么我的问题是:A通过我 实际上代表他们怎么样了映射鼠标按钮?
更新
正在播放的xmodmap -pp
节目:
$ 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
这没用,因为它不包含任何信息人类可以使用鼠标的物理属性(即,如果没有按钮名称(例如“左按钮”),则显示两列数字是无用的)。因此,虽然从技术上讲,这可能回答了“它们如何映射”的问题,但从任何实际意义上讲,这个问题仍未得到解答。
答案1
我认为你应该这样看待这个问题:
1 2 3 4 5 6 7 8 9 <--position-- physical keys
Option "ButtonMapping" "1 9 3 4 5 6 7 8 2" <--function-- logical keys
指示鼠标报告的按键 ID 的位置(通过驱动程序)。因此,如何排序由制造商决定,但大多数都遵循通用顺序。
鼠标仍然使用 PS2 等旧协议,无法存储或告知有关可用按钮及其功能的信息。因此 X 服务器无法告诉您每个物理按钮的 ID,只能通过使用类似
xev
显示 X 事件的工具来尝试它们:xev -event mouse
或者
evtest
显示原始事件:sudo evtest
逻辑键实际上是映射到其他地方以提供额外功能的键。在这个级别,X 将它们视为:按钮 1、按钮 2、按钮 3、按钮 4、...、按钮 24,并且它不知道它们的功能。
官方参考例子:
7. Configuration Examples
This section shows some example InputDevice section for popular mice.
All the examples assume that the mouse is connected to the PS/2 mouse
port, and the OS supports the PS/2 mouse initialization. It is also
assumed that /dev/mouse is a link to the PS/2 mouse port.
Logitech MouseMan+ has 4 buttons and a wheel. The following example
makes the wheel movement available as the button 5 and 6.
Section "InputDevice"
Identifier "MouseMan+"
Driver "mouse"
Option "Device" "/dev/mouse"
Option "Protocol" "MouseManPlusPS/2"
Option "Buttons" "6"
Option "ZAxisMapping" "5 6"
EndSection
You can change button number assignment using the xmodmap command
AFTER you start the X server with the above configuration. You may
not like to use the wheel as the button 2 and rather want the side
button (button 4) act like the button 2. You may also want to map the
wheel movement to the button 4 and 5. This can be done by the
following command:
xmodmap -e "pointer = 1 6 3 2 4 5"
After this command is run, the correspondence between the buttons and
button numbers will be as shown in the following table.
Physical Buttons Reported as:
------------------------------------
1 Left Button Button 1
2 Wheel Button Button 6
3 Right Button Button 3
4 Side Button Button 2
5 Wheel Negative Move Button 4
6 Wheel Positive Move Button 5
Starting in the Xorg 6.9 release, you can also achieve this in your
configuration file by adding this to the "InputDevice" section in
xorg.conf:
Option "ButtonMapping" "1 6 3 2 4 5"
For the MS IntelliMouse Explorer which as a wheel and 5 buttons, you
may have the following InputDevice section.
Section "InputDevice"
Identifier "IntelliMouse Explorer"
Driver "mouse"
Option "Device" "/dev/mouse"
Option "Protocol" "ExplorerPS/2"
Option "Buttons" "7"
Option "ZAxisMapping" "6 7"
EndSection
The IntelliMouse Explorer has 5 buttons, thus, you should give "7" to
the Buttons option if you want to map the wheel movement to buttons (6
and 7). With this configuration, the correspondence between the
buttons and button numbers will be as follows:
Physical Buttons Reported as:
------------------------------------
1 Left Button Button 1
2 Wheel Button Button 2
3 Right Button Button 3
4 Side Button 1 Button 4
5 Side Button 2 Button 5
6 Wheel Negative Move Button 6
7 Wheel Positive Move Button 7
You can change button number assignment using xmodmap AFTER you
started the X server with the above configuration.
xmodmap -e "pointer = 1 2 3 4 7 5 6"
The above command will moves the side button 2 to the button 7 and
make the wheel movement reported as the button 5 and 6. See the table
below.
Physical Buttons Reported as:
------------------------------------
1 Left Button Button 1
2 Wheel Button Button 2
3 Right Button Button 3
4 Side Button 1 Button 4
5 Side Button 2 Button 7
6 Wheel Negative Move Button 5
7 Wheel Positive Move Button 6
For the A4 Tech WinEasy mouse which has two wheels and 3 buttons, you
may have the following InputDevice section.
Section "InputDevice"
Identifier "WinEasy"
Driver "mouse"
Option "Device" "/dev/mouse"
Option "Protocol" "IMPS/2"
Option "Buttons" "7"
Option "ZAxisMapping" "4 5 6 7"
EndSection
The movement of the first wheel is mapped to the button 4 and 5. The
second wheel's movement will be reported as the buttons 6 and 7.
The Kensington Expert mouse is really a trackball. It has 4 buttons
arranged in a rectangle around the ball.