THE 3 BUTTON SERIAL MOUSE MINI-HOWTO Geoff Short grs100@york.ac.uk v1.02 9th May 1996 _________________________________________________________________ 0. Disclaimer 1. Introduction 2. Serial ports 3. Switched Mice 4. Normal Mice 5. Switching a Mouse to 3-Button Mode 6. XF86Config and Xconfig file examples 7. Miscellaneous Problems and Setup 8. Models tested 9. Mouse Tail _________________________________________________________________ 0. Disclaimer 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. 1. Introduction 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. Most dual-protocol mice will work in two modes: * 2-button Microsoft mode. * 3-button MouseSystems mode. 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. 2. Serial ports 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) 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.) For convience make a new link /dev/mouse pointing at this port. For instance, for COM1: * ln -s /dev/ttyS0 /dev/mouse 3. Switched Mice 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' or `PC' setting is usually for 2 button Microsoft mode, and the `3' or `MS' for 3 button MouseSystems mode. If you have such a mouse, you can switch the switch to `3' or `MS', put the MouseSystems settings in your XConfigs (see below) and the mouse should work perfectly in 3-button mode. 4. Normal Mice 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 below) and give it 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 relevent 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. 5. Switching a Mouse to 3-Button Mode 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. * Before you power up your computer, hold down the left mouse button (and keep it held down until it has booted to be on the safe side.) 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, one is more so! * If your computer is get-at-able you can unplug the mouse and plug it back in with the button held down, although I of course cannot recommend this as you are not supposed to plug things in when the power is on. * You may be able to reset the mouse by typing echo "*n" > /dev/mouse, which should have the same effect as unplugging it. Hold the left button down for Mouse Systems mode, not for Microsoft. You could put this in whatever script you use to start X up. * Someone has reported that the 'ClearDTR' line in the Xconfig is enough to switch their mouse into Mouse Systems mode. * If you know your way around a soldering iron, you might want to look at the circuit board inside the mouse. You may find that the board is designed for a switch between 2 &3 buttons, but it hasn't been fitted. It will look something like: ----------- | 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 &permenant solution. It has been reported that some mice have a switch inside already, for some strange reason known only to the manufacturer. It is also possible that you need to hold down the left button when booting X windows. Some systems may send some sort of signal or spike to the mouse when X starts, so bear this in mind as well. So now it's decision time - if you don't want the hassle of switching your mouse's mode, you are stuck with two buttons. More likely, you'll want to change your X configs to use the three button mode, which are described in the section below. 6. XF86Config and Xconfig file examples 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 should be echoed to the screen before all the options are displayed. Microsoft Serial Mouse * XF86config: Section "Pointer" Protocol "microsoft" Device "/dev/mouse" EndSection * Xconfig: # # Mouse definition and related parameters # Microsoft "/dev/mouse" Microsoft Serial Mouse with Three Button Emulation * XF86config: Section "Pointer" Protocol "microsoft" Device "/dev/mouse" Emulate3Buttons EndSection * Xconfig: # # Mouse definition and related parameters # Microsoft "/dev/mouse" Emulate3Buttons MouseSystems Three Button Serial Mouse * XF86config: 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 * Xconfig: # # 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 7. Miscellaneous Problems and Setups * If you have trouble with your mouse in X or console mode, check you are not running a getty on the serial line, or anything else such as a modem for that matter. * If you have trouble with your mouse in X, don't run the text-screen mouse driver (gpm) at the same time as X - the two often do not work together. * If you do want to run gpm in MouseSystems mode, the command is gpm -t msc &/tt>. gpm is also handy for probing your mouse settings - type gpm -t help to print out your mouse type. To try to get gpm and X to coexist, try running gpm with the -R option so that it pipes the mouse data to /dev/gpmdata in MouseSystem format. Then all you have to do is configure X to use /dev/gpmdata as the device. (Thanks to mikedlt@u.washington.edu for this one.) Logitech mice may require the line ChordMiddle to enable the middle of the three buttons to work. This line replaces Emulate3Buttons or goes after the /dev/mouse line in the config file. Swapping buttons: use the xmodmap command to change which physical button registers as each mouse click. eg: xmodmap -e "pointer = 3 2 1" will turn round the buttons for use in the left hand. If you only have a two-button mouse then it's just numbers 1 &2. Acceleration: use the xset m command to change the mouse settings. eg xset m 2 will set the acceleration to 2. Look at the manpage for full details. 8. Models tested 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 have two identical mice in our office on two computers, some things work on one and not t'other! Any additions to this list would be welcome. WiN mouse, as sold by Office World for eight quid. Standard dual-mode Microsoft/MouseSystems. Agiler, Standard dual-mode Microsoft/MouseSystems. Not solderable. Sicos, Works ok, needs ClearDTR &Clear RTS in config. Index sell a mouse for 10 quid, Doesn't work in 3 button mode, but does have nice instructions :-) Artec, Usual dual-protocol mouse, needs 'ClearDTR' set in config, NOT 'ClearRTS' DynaPoint 3 button serial mouse. Usual dual-protocol mouse, needs 'ClearDTR' AND 'ClearRTS' in Xconfig. Genius 3 button mouse Steven Aizic is working on this one for me. 9. Mouse Tail Fuller details of the Xconfig &XF86Config files are found on the relevant man pages, and in the documentation about installing X windows such as the Xfree86 HOWTO. 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: * Even cheap 3 button Microsoft mice can be made to work. * Configure your copy of X to expect a Mouse Systems mouse. * Hold down the left button at power-on to switch the mouse to MouseSystems mode. * You might need to hold the left button down when starting X. * Mice are more intelligent than you think. _________________________________________________________________ Page written by Geoff Short, started March 1996 Go to homepage, send us mail or leave a comment