Geoff Short, geoff@kipper.york.ac.uk v1.33, 31 May 1998
How to get a 3 button serial mouse working properly under Linux.
Table of Contents
The following document is offered in good faith as comprising only safe programming and procedures. No responsibility is accepted by the author for any loss or damage caused in any way to any person or equipment, as a direct or indirect consequence of following these instructions.
The most recent version of this document can always be found at http://kipper.york.ac.uk/mouse.html
There is a Japanese translation at http://jf.gee.kyoto-u.ac.jp/JF/JF- ftp/euc/3-Button-Mouse.euc; and a French one at http://www.freenix.fr/linux/HOWTO/mini/3-Button-Mouse.html. Other translations may be available - check your local LDP mirrors.
Most X applications are written with the assumption that the user will be working with a 3 button mouse. Serial mice are commonly used on computers and are cheap to buy. Many of these mice have 3 buttons and claim to use the Microsoft protocol, which in theory means they are ideal for the X windows setup. (The record for the cheapest working 3 button mouse currently stands at $1.14!)
Most dual-protocol mice will work in two modes:
This document leads you through the different steps needed to configure your mouse in these two different modes, especially the steps needed to use the more useful 3-button mode.
As distributions become easier to set up, some of the problems ought to go away. For instance, RedHat have a mouseconfig program to set things up for you. However, some versions of RH5.0 had a bug in mouseconfig, so make sure you check for patches.
The first thing to do is to make sure the software can find the mouse. Work out which serial port your mouse is connected to - usually this will be /dev/ttyS0 (COM1 under DOS) or /dev/ttyS1 (COM2). (ttyS0 is usually the 9 pin socket, ttyS1 the 25 pin socket, but of course there is no hard and fast rule about these things.) There are also an equivalent number of /dev/cua devices, which are almost the same as the ttyS ones, but their use is now discouraged. For convenience make a new link /dev/mouse pointing at this port. For instance, for ttyS0:
ln -s /dev/ttyS0 /dev/mouse
Some mice, not usually the cheapest ones, have a switch on the bottom marked `2/3'. Sometimes this may be `PC/MS'. In this case the `2' setting is for 2 button Microsoft mode, and the `3' for 3 button MouseSystems mode. The `PC/MS' switch is a bit more complicated. You will probably find the `MS' setting is for Microsoft, and the `PC' is for MouseSystems. You may find the `PC' setting described as ps/2 mode, but it should do MouseSystems as well. If you have such a mouse, you can switch the switch to `3' or `PC', put the MouseSystems settings in your XConfigs (see below) and the mouse should work perfectly in 3-button mode.
If you don't have any switches, and no instructions, then a little bit of experimentation is needed. The first thing to try is to assume the mouse maker is telling the truth, and the mouse is full Microsoft. Set up your Xconfigs to expect a Microsoft mouse (see the Xconfig section) and give it a try.
If the mouse didn't work at all, then you don't have a Microsoft mouse, or there is some other problem. Try the other protocols in the configs, the man page for the config file is the best place to start looking. Also look in the Miscellaneous Problems section below.
What you will probably find is that when you run X, the mouse works fine but only the outer two buttons do anything. You can of course accept this, and emulate the third button (press both buttons at once to click the middle one) like you do with a two button mouse. To do this, change your Xconfig file as shown in the Xconfig example section below. This may mean you have bought a 3 button mouse for no good reason, and you are certainly no further forward. So, now you need to look at your hardware.
Even cheap mice can also work under the Mouse Systems protocol, with all three buttons working. The trick is to get the mouse to think it's a Mouse Systems one, something you rarely see in your instructions.
When the mouse first gets power, if the left button is held down it switches into Mouse Systems mode. A simple fact, but not always publicised. Note that a soft reboot of your computer may not cut the mouse power and therefore may not work. There are a number of other ways of switching the mode, which may or may not work with your particular mouse. Some of these are less drastic than rebooting your computer, two are more so!
-----------
| o | o | o | SW1
-----------
1 2 3
Try linking pins 1-2 or 2-3, and see if it changes the behaviour of the mouse. If it does, you can either fit a small switch, or solder across the contacts for a quick and permanent solution.
(Pins are numbered as follows:)
____
pin1 -| \/ |-
pin2 -| |-
pin3 -| |-
-| |-
-| |-
-| |-
-| |-
pin8 -|____|-
(This info comes courtesy of Hans-Christoph Wirth, and Juergen Exner, who posted it to de.comp.os.linux.hardware) You can solder a link between pin 3 and gnd, which will fix the mouse into MouseSystems mode.
-----
--- R ---------O------ + Supply
| ----- | | C = 100nF capacitor
| | E | R = 100kOhm
| __ / | T = BC557 transistor
| / \ O
| B | #V | T /
|-----|-# | / Left button switch of the mouse
| | #\ | O
| \__/ |
--- \ C |
--- C ------O----------> (to somewhere deep inside the mouse)
|
### Ground
The test mouse was a no-name model MUS2S - whether this works in other mice depends on the circuit of the mouse; if the switch is connected to ground and not to +Supply, an npn-transistor like the BC547 should work; R and C have to be swapped then, too.
So there you have it, the choice is yours. Stick with the default Microsoft two buttons, or work out how to switch the mode and set X up to take advantage of this.
Mice with wheels have emerged in the last few years, starting with the Microsoft Intellimouse and spreading to other manufacturers. The wheel can be clicked like a button, or rolled up and down. Far and away the best reference for information is http://www.inria.fr/koala/colas/mouse-wheel-scroll/ which describes how to get lots of X applications to recognise the scrolling action.
In general, you'll need a fairly new Xserver to use the scrolling action, but some older servers will recognise the clicking actions. For instance, the Intellimouse is supported by XFree 3.3.1 and later.
8. Using gpm to Switch Mouse Modes
gpm is the program that lets you use the mouse in console mode. It is usually included in linux distributions, and can be started from the command line or in the startup script /etc/rc.d/rc.local. Note that distributions don't always have the most recent version (1.13 at time of writing) which can be found on mirrors of sunsite.unc.edu.
The main modes for serial mice under gpm are:
gpm -t ms gpm -t msc gpm -t help
for Microsoft or MouseSystems modes, or to probe the mouse for you and tell you what it found. To run gpm in MouseSystems mode, you may need a -3 flag, and possibly a DTR option, using the -o dtr flag:
gpm -3 -o dtr -t msc
gpm is often able to recognise all three buttons of the mouse even in Microsoft mode. And newer versions (Version 1.0 and later (?)) can then make this information available to other programs. For this to work, you need to run gpm with the -R tag, like this:
gpm -R -t ms
This will make gpm re-export the mouse data to a new device, called /dev/gpmdata, which looks like a mouse to any other program. Note that this device always uses the MouseSystems protocol. You can then set your Xconfig to use this instead of /dev/mouse as shown below, but of course you must ensure gpm is always running when you use X. Some people have reported that some middle-button events are not correctly interpreted by X using this technique, this may be down to an individual mouse setup.
Changing button mapping for gpm and X (gustafso@math.utah.edu)
You may find that gpm uses different default button mappings to X, so using both systems on the same machine can be confusing. To make X use the same buttons for select and paste operations as gpm, use the X command
xmodmap -e "pointer = 1 3 2"
which causes the left button to select and the right button to paste, for either 2-button or 3-button mice. To force gpm to use the X stan dard button mapping, start it with a -B command, eg:
gpm -t msc -B 132
In some cases, for instance a laptop with a built-in pointing device, you may wish to use a serial mouse as a second device. In most cases the built-in device uses the PS/2 protocol, and can be ignored if you don't wish to use it. Simply configure gpm or X to use /dev/ttyS0 (or whatever) as usual.
To use both at once, you can use gpm -M to re-export the devices. More details in the gpm man page. Also, XFree 3.3.1 and later support muliple input devices, using the XInput mechanism. Auto-generated XF86Config files should have the necessary comments in them.
The location of your configuration file for X depends on the particular release and distribution you have. It will probably be either /etc/Xconfig, /etc/XF86Config or /usr/X11/lib/X11/XF86Config. You should see which one it is when you start X - it will be echoed to the screen before all the options are displayed. The syntax is slightly different between the XF86Config and Xconfig files, so both are given.
Microsoft Serial Mouse
Section "Pointer"
Protocol "microsoft"
Device "/dev/mouse"
EndSection
# # Mouse definition and related parameters # Microsoft "/dev/mouse"
Microsoft Serial Mouse with Three Button Emulation
Section "Pointer"
Protocol "microsoft"
Device "/dev/mouse"
Emulate3Buttons
EndSection
#
# Mouse definition and related parameters
#
Microsoft "/dev/mouse"
Emulate3Buttons
MouseSystems Three Button Serial Mouse
Section "Pointer"
Protocol "mousesystems"
Device "/dev/mouse"
ClearDTR # These two lines probably won't be needed,
ClearRTS # try without first and then just the DTR
EndSection
# # Mouse definition and related parameters # MouseSystems "/dev/mouse" ClearDTR # These two lines probably won't be needed, ClearRTS # try without first and then just the DTR
Microsoft Serial Mouse with gpm -R
Section "Pointer" Protocol "MouseSystems" Device "/dev/gpmdata" EndSection
#
# Mouse definition and related parameters
#
MouseSystems "/dev/gpmdata"
The only wires needed in a mouse cable are as follows: TxD and RxD for data transfer, RTS and/or DTR for power sources, and ground. Translated into pin numbers, they are:
9-pin port 25-pin port TxD 3 2 RxD 2 3 RTS 7 4 DTR 4 20 Gnd 5 7
The above table may be of use if you wish to make adaptors between 9- and 25-pin plugs, or extension cables.
stty -crtscts < /dev/mouse
(Tested on UART 16450/Pentium by Vladimir Geogjaev geog jaev@wave.sio.rssi.ru)
Subsection "Display"
Modes "1024x768" "800x600" "640x480" "1280x1024"
Invert_VCLK "*" 1
...
There are a lot of different mice out there, and I cannot honestly say that you should go out and buy one rather than the other. What I can do is give a list of what I think these mice do, based on experience and heresay. Even with this information you should be a little cautious - we had two identical mice in our office on two computers, some things worked on one and not t'other! Any additions to this list would be welcome.
Mouse Systems optical mouse, serial version
WiN mouse, as sold by Office World for eight quid.
Agiler Mouse 2900
Sicos mouse
Artec mouse
DynaPoint 3 button serial mouse. Usual dual-protocol mouse, needs ClearDTR' AND ClearRTS' in Xconfig. Genius Easymouse 3 button mouse Works fine with Mouseman protocol without the ChordMiddle parameter set. From Roderick Johnstone (rmj@ast.cam.ac.uk) Truemouse, made in Taiwan
Champ brand mouse
MicroSpeed mouse
Venus brand ($7)
Saturn
Manhattan mouse.
Inland mouse
qMouse (3-button), FCC ID E6qmouse X31.
Mitsumi Mouse (2-button), FCC ID EW4ECM-S3101.
PC Accessories mouse that i got from CompUSA for under $10.
First Mouse - seriously cheap at 7.79 pounds at Tempo.
Trust 3-button mouse.
Chic 410
KeyMouse 3-button mouse.
Qtronix keyboard `Scorpio 60'
Tecra 720 laptop
Anubis mouse
Yakumo No.1900 mouse
Genius `Easy Trak' Trackball
Highscreen Mouse Pro
Logitech CA series
A4-Tech mouse
Vertech mouse
Boeder M-7 Bit Star (and other M series apart from M13)
Mouse Systems ``Scroll'' Mouse (four buttons and a roller/button)
Radio Shack 3-button Serial Mouse Model 26-8432, available in Tandy for about 20 quid
Dexxa serial mouse
Belkin 3 button mouse
Much of the information for this document has been trawled from the various linux newsgroups. I am sorry I did not keep a record of everyone who has indirectly contributed by this route, thank you all very much.
So, to sum up: