Main Menu

Projects

Linux Games
Linux Games
[HOWTO Home :: HOWTO INDEX Hardware :: This page]  

Get all mouse buttons working

Authors: Andreas 'GlaDiaC' Schneider
Keywords: Mouse evdev, Event Device, Linux evdev, Logitech evdev, all buttons

Creative Commons License
This work is licensed under a Creative Commons License.

Warning: This HOWTO comes with no explicit or implicit warranty whatsoever. Use at your own risk!

Table of Content

  1. Preface
  2. The Kernel Event Interface
  3. The X.Org evdev module
  4. Edit your Xorg config
  5. Xmodmap
  6. Map mouse buttons with your favorite functions
  7. Restart X
  8. Check buttons
  9. Credits

1. Preface

evdev xorg

Many new mouse models provide more and more buttons, but the current protocols support up to 7 buttons. This document will discribe how to get all buttons work with the new evdev module of the Kernel and X.Org.

2. The Kernel Event Interface

evdev is the generic input event interface. It passes the events generated in the kernel (since verson 2.6.8) straight to the program, with timestamps. This is the way for X to get keyboard and mouse events. It allows for multihead in X without any specific multihead kernel support.

To see on which device you mouse is mapped, use the following command:

cat /proc/bus/input/devices

This should give you the needed informations. It looks like this:

I: Bus=0003 Vendor=046d Product=c01d Version=2100
N: Name="Logitech USB-PS/2 Optical Mouse"
P: Phys=usb-0000:00:10.0-2/input0
H: Handlers=mouse1 event3
B: EV=7
B: KEY=ff0000 0 0 0 0 0 0 0 0
B: REL=103

You can see the event device at the Handler and test it with a little tool you can get here.

Copmile it with gcc -o evdev-key-btn-test evdev-key-btn-test.c an run it with the following command

$ evdev-key-btn-test /dev/input/eventX where X = input device number

3. The X.Org evdev module

xorg mouse driver

The X.Org evdev driver is a standalone, generic evdev driver. Standalone in the sense that it isn't another protocol for the "mouse" and "keyboard" drivers, it's a new driver, "evdev". Generic in the sense that it works for both keyboard and mice and the evdev ioctl probing is shared between the two parts.

3.1 Install the evdev module

You should first check if your distro has a package for the new evdev driver. Your can find an rpm for SuSE 9.3 here.

3.2 Compile the evdev module

To compile the evdev driver you need the X.Org SDK package and the evdev-driver archive. The SDK package should ship with your distro. If you have compiled Xorg by yourself, you simply need a make install.sdk.

You can get the evdev driver here:

https://bugs.freedesktop.org/attachment.cgi?id=1745

Unzip the package and run the configure script like the following lines:

./configure --prefix=/usr/X11R6 --with-xorg-sdk=/usr/X11R6/lib/Server
make
make install

4. Edit your Xorg config

Open up your Xorg configuration file /etc/X11/xorg.conf and look forward to the "Input Section". In this Section you can set up your Mouse like this:

Section "InputDevice"
        Identifier  "Mouse[0]"
        Driver      "evdev"
        Option      "Device" "/dev/input/event0" # (cat /proc/bus/input/devices)
        Option      "Name" "Logitech MX510"
EndSection

Type into a shell: cat /proc/bus/input/devices. You get an output like this:

I: Bus=0003 Vendor=046d Product=c50e Version=2500
N: Name="Logitech USB Receiver"
P: Phys=usb-0000:00:1d.0-2/input0
H: Handlers=mouse0 event0 kbd
B: EV=120007
B: KEY=ffff0000 10000 0 0 0 0 0 0 0
B: REL=103
B: LED=fc00

Overwrite the correctly "Device" with your own. Now you can restart your Xserver and enjoy a nice 12-button mouse.

5. Xmodmap

This is a utility for modifying keymaps and pointer button mappings in X. It is usually run from the user's session startup script to configure the pointer buttom map.

The following should work for almost all cases (do as user):

12 button mouse (e.g. MX1000):

echo -e "pointer = 1 2 3 6 7 8 9 10 11 12 4 5\n" > ~/.Xmodmap (please try it and submit reports via contact form in the menu)

10 button mouse (e.g. MX 510/700):

echo -e "pointer = 1 3 2 4 5 8 9 6 7 10\n" > ~/.Xmodmap

This sets the index numbers for the buttons of your mouse. Some distributions don't load the .Xmodmap file. So you have to use .xinit and add for example the command:

xmodmap -e "pointer = 1 3 2 4 5 8 9 6 7 10"

6. Map mouse buttons with your favorite functions

To use all the mouse buttons for a specific function, you can use xvkbd or xbindkeys. With these programs you can set up your buttons for every function you want. Go into your home-directory and create a file called .xbindkeysrc.

An Example:

"xvkbd -xsendevent -text "\[Alt_L]\[Left]""
  m:0x10 + b:9
"xvkbd -xsendevent -text "\[Alt_L]\[Right]""
  m:0x10 + b:10[/code]

To use all possibilities, please read the manual or look here:

http://hocwp.free.fr/xbindkeys/
http://homepage3.nifty.com/tsato/xvkbd/

7. Restart X

The above changes do not take effect until you have restarted X.

8. Check buttons

To check if the buttons are working use xev. xev creates a window and then asks the X server to send it events whenever anything happens to the window (such as it being moved, resized, typed in, clicked in, etc.).

Run xev from within a console, and move your mouse to within the new window. Being careful not to move the mouse, press one of your side buttons.
There should be some output in the terminal both when you press the button and when you release it. If there is no output, there is something wrong with either your X config file /etc/X11/xorg.conf or with your pointer in the ~./Xmodmap.

Wheel UP and DOWN should be mapped to 4 and 5, the two thumb mouse buttons to 6 and 7. The two thumb mouse buttons are "one page forward" and "one page back".

9. Credits

Special thanks to Kristian Høgsberg for writing the new driver :)

https://bugs.freedesktop.org/show_bug.cgi?id=968

Last modified: 04.01.10 by GlaDiaC  

Comments
The comments are owned by the poster. We aren't responsible for their content.
Linux Games
Linux Games
Terms of Use · Privacy Policy · Creative Commons License · Credits · Linux Games · Linux Games · World Time · Vereins Intern