Configuring Linux and X for a Kensington Expert Mouse

This is a page to remind me about how to configure Linux and X for this input device, which despite the name is actually a trackball.

Firstly, you need a version of the Linux kernel which supports the input core and which puts PS/2 mice through the input core. It also needs to be new enough to have the patch for Expert Mouse support in psmouse-base.c. That probably means later 2.4.x kernels or a 2.6.x kernel. Use cat -A /dev/input/mice to check that this is all working and that all four buttons and the scroll wheel generate different byte sequences. (If your Expert Mouse is USB then /dev/input/mice should still work, I think.)

A suitable XF86Config-4 or xorg.conf rune is:

Section "InputDevice"
        Identifier      "Generic Mouse"
        Driver          "mouse"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/input/mice"
        # /dev/input/mice can emulate plain PS2, ImPS/2 and ExplorerPS/2;
        # only this one supports more than 3 buttons + scrollwheel:
        Option          "Protocol"              "ExplorerPS/2"
        # scroll wheel
        Option          "ZAxisMapping"          "4 5"
        # four real buttons and the scroll wheel:
        Option          "Buttons"               "6"
        # This bit's optional; it configures button 4 as a sort of 'lock'
        # button, so instead of holding down one of the other buttons you
        # first press button four then click the other button:
        Option          "DragLockButtons"       "6"
EndSection

NB: this assumes that you have a plain Expert Mouse with four buttons and a scroll wheel. Some models might have more buttons (or just be gratuitously different), in which case the fourth button might not be logical button 6 -- I've had a report of it appearing as 8. Some experimentation with xev may be required.

Bonus note on button mappings

The ExpertMouse has four hardware buttons and a scroll wheel. X has a concept of the physical button and the logical button. The physical buttons are numbered 1,2,3,4 in the order bottom-left, top-left, bottom-right, top-right. The logical buttons are numbered starting from 1, and they include the scroll wheel as a pair of fake buttons. The above setup makes the physical and logical buttons 1 to 3 correspond; then logical buttons 4 and 5 are the scroll wheel, and finally physical button 4 is logical button 6. Notice that DragLockButtons takes a logical button number.

If you want to have the buttons do different things, then probably the easiest thing is to add a ButtonMapping line to this Section. For example:

        Option          "ButtonMapping"             "6 3 1 2"
will make bottom-right be left-click, top-right middle-click, top-left right-click and bottom-left DragLock. ButtonMap takes a list of logical buttons; so the first number is what bottom-left ought to do (here 6, which we have set up to DragLock), the second is top-left (here logical button 3, right-click), and so on.
This page written by Peter Maydell (pmaydell@chiark.greenend.org.uk).