Configuring my 5-button mouse in X Windows
Contents
Problem
I want to make use of the two additional buttons on my 5 button mouse (Trust 450L, MI-2500X, MI-2540D, http://www.trust.com/15373, http://www.trust.com/16535).
Solution
Caveat
After changing the button mapping with the solutions below, I haven't been able to emulate a middle mouse button using the "Emulate3Buttons" xorg functionality.
Ubuntu 8.10/9.04/10.04
To:
- switch `forward' and `back' buttons (8, 9);
- switch `forward' and `middle' buttons (9, 2);
add this command to {System | Preferences | Startup Applications | Add } or { System | Preferences | Sessions | Startup Programs | Add }:
Name: xmodmap Command: xmodmap -e "pointer = 1 9 3 4 5 6 7 2 8" Comment: Switch buttons 2, 8, 9.
NOTE: If you just want to switch `forward' and `middle' buttons (9, 2), use the command:
xmodmap -e "pointer = 1 9 3 4 5 6 7 8 2"
Ubuntu 8.04
Firefox 3
Firefox 3 designates buttons 6 and 7 to horizontal scrolling, whereas Firefox 2 does not.
Make sure the active Mouse section in /etc/X11/xorg.conf contains something like this:
Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ExplorerPS/2" Option "Buttons" "7" # Use `forward' button (id 9, nr 5) as an additional `middle' button (id 2, +nr 2) Option "ButtonMapping" "1 2 3 8 2" # Simulate `middle' button by clicking simultaneous `left' and `right' buttons Option "Emulate3Buttons" "true" EndSection
Firefox 2
Make sure the active Mouse section in /etc/X11/xorg.conf contains something like this:
Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ExplorerPS/2" Option "Buttons" "7" # Use `forward' button (id 7, nr 4) as an additional `middle' button (id 2, nr 2) Option "ButtonMapping" "1 2 3 2 6" #Option "ButtonMapping" "1 2 3 7 6" # Simulate `middle' button by clicking simultaneous `left' and `right' buttons Option "Emulate3Buttons" "true" EndSection
SuSE 10.0
Specify the following lines to xorg.conf:
# Issue 'xmodmap -e "pointer = 1 2 3 6 7 4 5" in your startup script to map #+ scroll buttons 6 & 7 to locations 4 & 5 where applications expect them. Section "InputDevice" Driver "mouse" Identifier "Mouse[1]" # Do not connect to /dev/mouse0, otherwise it will conflict with Wacom Option "Device" "/dev/psaux" # This protocol supports a scroll wheel Option "Protocol" "ExplorerPS/2" # Adding this maps wheel scrolling events to mouse buttons 6 & 7 Option "ZAxisMapping" "6 7" # Adding this enables the extra buttons on the Trust 450L Option "Buttons" "7" EndSection
Put this into the global xinitrc (usually in /usr/X11/lib/X11/xinit/):
# Switch mouse wheel button positions 6 & 7 with extra buttons 4 & 5 xmodmap -e "pointer = 1 2 3 6 7 4 5"
See also
- https://help.ubuntu.com/community/ManyButtonsMouseHowto
- Useful Ubuntu wiki page how to configure a mouse with many buttons
- http://gentoo-wiki.com/HOWTO_Advanced_Mouse
- Detailed howto for setting up a mouse under different versions of X with all buttons functional
- Colas Nahaboo X mouse wheel scroll page (dated ~2002)
- Collection of configuration tips to use the scroll wheel in different X applications (dated 2002)
Journal
20051215
Had to change the diff underneath in xorg.conf after upgrading to SuSE 10.0, because my mouse didn't work anymore:
Section "InputDevice" # Do not connect to /dev/input, # otherwise it will conflict with Wacom - Option "Device" "/dev/input/mouse1" + Option "Device" "/dev/input/mouse0"
20060721
- Fixed ZAxisMapping which shouldn't read '4 5' but:
Option "ZAxisMapping" "6 7"
- Moved xmodmap to xinitrc
20060729
- With 'Buttons 7' and 'ZAxisMapping 4 5' I can use the scroll wheel, but not the additional buttons
- With 'Buttons 7' and 'ZAxisMapping 6 7' the additional buttons function as a scroll wheel, and the scroll wheel functions as back/forward.
- With 'Buttons 7' and 'ZAxisMapping 6 7' and 'pointer 1 2 3 7 6 4 5' in /etc/X11/Xmodmap the additional buttons function as additional buttons and the scroll wheel functions as a scroll wheel. '7 6' reverses the additional buttons.
20081106
After upgrading to Ubuntu-8.10, my extra mouse buttons stopped working.
The `InputDevice' mouse section in xorg.conf appears to be commented out after the upgrade:
# commented out by update-manager, HAL is now used #Section "InputDevice" # Identifier "Configured Mouse" # Driver "mouse" # Option "CorePointer" # Option "Device" "/dev/input/mice" # Option "Protocol" "ExplorerPS/2" # Option "Buttons" "7" # # Use `forward' button (id 9, nr 5) as an additional `middle' button (id 2, +nr 2) # Option "ButtonMapping" "1 2 3 2 8" # # Simulate `middle' button by clicking simultaneous `left' and `right' buttons # Option "Emulate3Buttons" "true" #EndSection
This page https://help.ubuntu.com/community/ManyButtonsMouseHowto suggests to use xinput
. Setting normal buttons goes ok:
$ xinput set-button-map "A4Tech USB Optical Mouse" 1 2 3 4 5 6 7 8 9
But I had the `back'-mousebutton set up as an additional `middle'-mousebutton, so I could click the scrollwheel or the `back'-mousebutton to achieve the effect of clicking the middle mousebutton. This is refused by xinput:
$ xinput set-button-map "A4Tech USB Optical Mouse" 1 8 3 4 5 6 7 8 9 X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 145 (XInputExtension) Minor opcode of failed request: 29 (X_SetDeviceButtonMapping) Value in failed request: 0x8 Serial number of failed request: 13 Current serial number in output stream: 13
Replacing the scrollwheel click with the `back' mousebutton seems to work, but then clicking the scrollwheel has lost its meaning:
$ xinput set-button-map "A4Tech USB Optical Mouse" 1 9 3 4 5 6 7 2 8
Using xmodmap has the same effect:
xmodmap -e "pointer = 1 9 3 4 5 6 7 2 8"