Edit: (April 2006)Currently not working properly in xorg-x11-7.0, will work on it and modify this post.

The following example uses a Logitech Marble Mouse, it consists of 4 buttons and a trackball. The mouse is ambidextrous, with a large and small button on either side of the trackball. The explanation should give good ideas on how to configure other mice types.

Quote:

Important tools for configuring other mice are xev, to determine what physical buttons activate which events, and xmodmap to change that.

Here is the relevant portion of xorg.conf. Don't just paste it into your xorg.conf without reading the rest.

Test your device (If you already have your mouse working in X, this is unnecessary)
From tests almost any reasonable protocol will work, ie "auto" or "ImPS/2" or "ExplorerPS/2". "Device" must be pointed correctly. To test what is correct on your system:

Code:

cat /dev/input/mice

and move the mouse around.

If you see odd characters on your screen it is correct.

If you see nothing then either

Needed options in the kernel are not there.

Check some other device, ie /dev/mouse, /dev/input/mouse.

You have hardware issues.

Configuration
The first item on the agenda once our device is working is increasing the amount of buttons that Xorg knows about.
Now the explanation. Although my mouse has only 4 physical buttons, you see

Without this, my 4 physical buttons map to two (button 1 and 3) and emulated middle (button 2).
The 7 available buttons are now these:

Large left button

Emulated middle click

Large right button

small left button

small right button

scroll up

scroll down

You may notice that instead of the normal

Quote:

"ZAxisMapping" "6 7"

there is

Quote:

"YAxisMapping" "6 7"

.
With ZAxisMapping the scroll buttons map to button 4 & 5. You would now have scrolling in X, but the physical 5th button is duplicated and will only scroll up.
With YAxisMapping you have all 7 buttons, with buttons 6 & 7 accessed by holding 4 and using the trackball.
The problem here is that scroll up & down are still mapped to buttons 4 & 5, so that you don't actually have any scroll yet.

We need to remap buttons 4 & 5 to buttons 6 & 7

Code:

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

We have now mapped physical buttons '4 5 6 7' to '6 7 4 5'. That gives us the ability to scroll by holding the small left button

Quote:

Option "EmulateWheelButton" "4"

and moving the trackball. If you wish you could make any button the one to hold, ie

Quote:

Option "EmulateWheelButton" "5"

would make the small right button the scroll button in this configuration.

At this point everything works

Left Click

Emulated Middle

Right Click

EmulateWheel

Nothing

Using (4&Trackball) UP

Using (4&Trackball)DOWN

Still I would like that small right button to do something useful.

Code:

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

Button 2 (Emulated Middle Click) is mapped to 7 (Nothing)

Button 5 (Nothing) is now Middle Click

Testing
There is an interesting effect that gives both horizontal and vertical scroll in some programs. Clicking button 5, the middle click button allows multi-scroll. Not sure why.