Kevin Vance - Getting X to work with all the buttons on a contemporary mouse is…

Entries | Archive | Friends | Friends' Friends | User Info

09:45 pm

Friday, August 22nd, 2008
Previous Entry Share Next Entry
Getting X to work with all the buttons on a contemporary mouse is really hard. Here is a dump of information on the Logitech MX Revolution that you may find useful:

xorg.conf

You have to get this right first, or nothing will work. Relevant parts of relevant sections:
Section "ServerLayout"
	...
	InputDevice    "CoreMouse" "CorePointer"
	InputDevice    "Revolution" "SendCoreEvents"
	...
EndSection

Section "InputDevice"
	Identifier      "CoreMouse"
	Driver          "mouse"
	Option      "Protocol" "auto"
	Option      "Device" "/dev/input/mice"
	Option      "ZAxisMapping" "4 5 6 7"
	Option          "Buttons" "20"
EndSection

Section "InputDevice"
	Identifier  "Revolution"
	Driver  "evdev"
	Option  "Protocol" "auto"
	Option  "Name"     "Logitech USB Receiver"
	Option  "Phys"     "usb-*/input0"
EndSection
We define two mice, CoreMouse and InputDevice. The "Revolution" evdev device does all the work, but setting that as the core pointer causes X to segfault! The "mouse" driver won't detect all the buttons, so we really need that "evdev" driver somehow. If we didn't specify our own core pointer, the evdev pointer could still send some buttons, but the default core pointer wouldn't have enough buttons, so some would still be lost.

Horizontal scrolling

Programs expect horizontal scrolling to be on buttons 6 and 7, but they are really on buttons 11 and 12. Make sure xinput is installed, and add the following line to your .xinitrc (or to whatever session manager you use):

xinput set-button-map `xinput list | grep -o '"Revolution.*"' | sed -e 's/"//g'` 1 2 3 4 5 11 12 8 9 10 6 7

Back and forward buttons

Firefox will do the right thing with the forward and back buttons, but other programs may still be confused. I prefer to map them to alt+left and alt+right, since those key combinations are universally understood. Make sure xbindkeys and xvkbd are installed, add kbindkeys to your .xinitrc (or session manager), and add these lines to your .xbindkeysrc:
"xvkbd -text "\[Alt_L]\[Left]""
 m:0x10 + b:8
"xvkbd -text "\[Alt_L]\[Right]""
 m:0x10 + b:9
That maps buttons 8 and 9 to the appropriate key combinations. You can do a similar mapping for the secondary wheel with buttons 13 and 15 for scrolling; and 17 for pressed. I couldn't find a use for the scrolling, but I liked to bind button 17 to moving a window when I used enlightenment. I can't find a way to do that in metacity though.

The extraneous button 20

When free-scrolling, the mouse emits button 20 clicks, which some programs decide to interpret as left button clicks! Add this to your .xbindkeysrc to filter it out:
"NoCommand"
m:0x10 + b:20


A lot of work just to make all the buttons do what you want...
Link )Reply )