ch0wned – Getting a Logitech G500 Mouse and all its Buttons Working in Redhat EL5
Written by max on 2011-02-04
ch0wned. adj. This is the state when you are a Linux user and don't have root access. Ok, so technically for this edition of ch0wned you need to have root :-P Hint – Sys admins usually like beer.
Intro
You have a Logitech G500 or other multi-button mouse and want to get all the buttons working. These mice use the evdev driver in xserver. Unfortunately, Redhat EL5 ships with a very buggy version 1.0.0.5-5 !!! We will replace that with a slightly-less buggy version 1.1.2.
Prerequisites
- yum install xorg-x11-server-sdk
- Evdev 1.1.2 Locally or from http://xserver-xorg-input-evdev.sourcearchive.com/
Building
- evdev
tar xvfz xserver-xorg-input-evdev_1.1.2.orig.tar.gz cd xf86-input-evdev-1.1.2 ./configure make
If you have any problems in that stage, make sure you’ve installed the xserver devel package.
Installing
cp /usr/lib64/xorg/modules/input/evdev_drv.so /root/evdev_drv.so.SAVEME cd xf86-input-evdev-1.1.2 cp src/.libs/evdev_drv.so /usr/lib64/xorg/modules/input/evdev_drv.so |
If you have stability problems later, copy the original driver back over your new one.
Configuring
- /etc/X11/xorg.conf
Section "ServerLayout" ... InputDevice "FakeMouse" InputDevice "LogitechG500" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" ... EndSection # xorg 7.1 can't handle evdev as the main device. this is a hack to have it not create a fake device # http://www.chromakode.com/blog/2007/09/19/logitech-lx7-in-ubuntu-edgy-ihatekludgers/ Section "InputDevice" Identifier "FakeMouse" Driver "void" EndSection Section "InputDevice" Identifier "LogitechG500" Driver "evdev" Option "Protocol" "auto" Option "Device" "/dev/input/event0" # If X keeps crashing then you need to change /dev/input/eventX to the right slot. # Check /proc/bus/input/devices to find the right one # Apparently you can't assign two buttons to the same function anymore. Suckage. #Option "ButtonMapping" "1 2 3 4 5 9 8 7 6 2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32" # https://bugs.freedesktop.org/show_bug.cgi?id=16723 # Option "ButtonMapping" "1 2 3 4 5 6 7 4 5 2" # Swapping Middle button w/ left thumb... and l/r scroll wheel w/ l/r left thumb # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #Option "ButtonMapping" "1 10 3 4 5 9 8 7 6 2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32" # oh except for the following.. # Apparently the evdev driver that comes w/ EL5 (version 1.x) sucks. # NONE of these options are recognized #Option "Emulate3Buttons" "no" #Option "Buttons" "10" #Option "ZAxisMapping" "4 5" #Option "EmulateWheel" "TRUE" #Option "EmulateWheelButton" "10" #Option "ZAxisMapping" "4 5" # Solution : Run xmodmap from the commandline : #xmodmap -e "pointer = 1 3 10 4 5 8 9 7 6 2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32" # Or add to Xmodmap EndSection
Notice the line that says
Option "Device" "/dev/input/event0"
This is where you are telling X where your mouse is plugged into. Unfortunately it may move around between reboots if you are not lucky.
To find out where it is cat /proc/bus/input/devices and look for the mouse entries…I: Bus=0003 Vendor=046d Product=c068 Version=5802 N: Name="Logitech G500" P: Phys=usb-0000:00:1d.1-1/input0 S: Sysfs=/class/input/input0 H: Handlers=mouse0 event0 B: EV=7 B: KEY=ffff0000 0 0 0 0 B: REL=143 I: Bus=0003 Vendor=046d Product=c068 Version=5802 N: Name="Logitech G500" P: Phys=usb-0000:00:1d.1-1/input1 S: Sysfs=/class/input/input1 H: Handlers=kbd event1 B: EV=10000f B: KEY=c0002 40000000000 1 10f8000078007 ffe639fad84157ff febeffdfffefffff fffffffffffffffe B: REL=40 B: ABS=100000000
Look for the entry that DOES NOT have Handlers=kbd.
- /etc/X11/Xmodmap
! See notes in xorg.conf - max's fancy logitech mouse ! Swap L/R scroll w/ L/R thumb; swap middle->thumb ! old exdev - 2/3 swapped, 8/9 swapped !pointer = 1 3 10 4 5 8 9 7 6 2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 !pointer = 1 10 3 4 5 8 9 7 6 2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ! Swap L/R scroll w/ L/R thumb; swap middle->thumb, switch thumb buttons pointer = 1 10 3 4 5 9 8 2 6 7 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
This is where you can remap buttons on your mouse! Unfortunately the button mapping between version 1.0.0 and 1.1.2 of evdev have
some buttons crossed up. Trial and error are the name of the game. For me using 1.1.2 the final listing above does the following- Swap the middle-click and biggest thumb button. You use this a lot in CAD work for electrical engineering. It’s a lot easier on your hands to not have to try to click the moving scroll wheel, especially when it’s in “free-ball” mode.
- Swap the right/left scroll-wheel with the up-down on the thumb. Now the thumb can be used to scroll left and right and the mouse wheel can be used to do history back/forward in Firefox. This just works out of the box in FF3 for me on RHEL EL5.
- Mouse acceleration just seems to work too, no settings needed. There is some program out there that lets you reclaim the little acceleration +/- buttons, but i’ve never tried it.
The way you test it is to run the program xev. Then click in the little white box that appears and see a bunch of gibberish on the console
ButtonPress event, serial 32, synthetic NO, window 0x2000002, root 0x28c, subw 0x2000003, time 4086723575, (47,40), root:(1159,65), state 0x0, button 1, same_screen YES EnterNotify event, serial 32, synthetic NO, window 0x2000002, root 0x28c, subw 0x0, time 4086723575, (47,40), root:(1159,65), mode NotifyGrab, detail NotifyInferior, same_screen YES, focus YES, state 256 KeymapNotify event, serial 32, synthetic NO, window 0x0, keys: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ButtonRelease event, serial 32, synthetic NO, window 0x2000002, root 0x28c, subw 0x2000003, time 4086723710, (47,40), root:(1159,65), state 0x100, button 1, same_screen YES
This was me pushing the left button (1) and releasing it. Do this with all the buttons and you can see how your remap is working.