A mouse is a fairly standard piece of peripheral hardware on a modern PC, and Linux can take full advantage of this device, both in standard text modes and in X windows.
In general, mice come in two flavors: serial and bus (I'm counting the PS/2 mouse as a bus mouse here). This difference just determines what type of interface to your computer they require.
As its name suggests a serial mouse will plug directly into one of the serial ports on the back of your machine. The device special files to use for a serial mouse are:
/dev/ttyS0 /dev.ttyS1 /dev/ttyS2 /dev/ttyS3
As in the case of a modem, a common practice is to create a symbolic link to the serial device from /dev/mouse with a command like:
# ln -s /dev/ttySl /dev/mouse
If you are going out to buy a mouse, then unless you have a good reason to do otherwise, buy a serial mouse. If your computer already has a PS/2 mouse interface, or if you already have a bus mouse, or if you are determined that you want to buy a bus mouse anyway, then that is okay but the installation and configuration of these devices just takes more effort.
In general, a bus mouse will require its own interface card to be fitted inside your computer and the mouse itself will plug into that card. Sometimes a bus mouse interface will be fitted to some other card such as a video adaptor, so that the mouse will not take up an extra slot on your motherboard.
Having fitted the hardware to the machine, you will need to set the interface card up so that it generates an interrupt (IRQ) which does not conflict with any other hardware in your machine and then recompile the kernel to include the appropriate bus mouse support.
By default, most bus mouse interface cards use IRQ 5 as their interrupt number, but lots of other cards also use this as their default, especially sound cards, so you will need to take some care over getting the choices right. The IRQ numbers you cannot use are:
0 1 2 6 8 13 14 and 15
as these are already in use for standard devices and cannot be changed. This leaves you with the choice of:
3 4 5 7 9 10 11 and 12
Of these, the first four are allocated for use by the standard serial and parallel ports, as follows:
IRQ | Allocation |
3 | COM2 |
4 | COM1 |
5 | LPT2 |
7 | LPTl |
Many machines have two serial ports and one parallel port fitted, which only leaves the LPT2 port's IRQ as spare. The other IRQs (9 to 12), while spare, cannot be accessed by 8-bit ISA cards, which includes most of the stand alone bus mouse interface cards. So you could have some problems.
One particularly useful application that is available under Linux is gpm. This command actually runs as a daemon, and would usually be executed at system boot time from within one of the standard rc.XXX files (usually rc.local).
What this daemon does is to allow you to use cut and paste facilities on a virtual terminal screen or between virtual terminals. With gpm running, moving the mouse will cause a mouse cursor to appear which moves in step with the mouse. Move the mouse cursor to the start of the block of text you wish to cut. Then press the left mouse button, move the mouse to the end of the text block and release the mouse button again. This should have marked the block of text on the screen. Now pressing the center button on a three-button mouse, or the right button on a two-button mouse will paste the marked text in at the current text cursor position. It is also possible to change virtual consoles after marking a block of text so that the block can be pasted into a different application.
When you run the gpm command you need to specify the type of mouse you have fitted to your machine with a command like the following:
# gpm -t msc &
where the list of mouse types supported by gpm includes:
ms | microsoft serial mouse; |
msc | mouse systems serial mouse |
bm | busmouse protocol bus mouse |
ps2 | PS/2 bus mouse. |
A word of warning deserves to go here. If you specify a mouse systems mouse you may get very odd results and loose control of the mouse! The reason is that all mouse systems mice can also function as microsoft mice and they might need to be told they should function with three buttons not two.
If you run into problems kill the gpm daemon with:
# gpm -k
then try to restart it with:
# gpm -t msc -o cts
and all should go well. This command clears the cts line in the serial cable. Sometimes the dtr line needs to be cleared in the same way, it is possible that some mice might want both lines cleared.
If your mouse hase a switch underneath it then you should have no problem, set it to either 3 or mouse systems.
If you need further help there is a Linux 3-Button Mice mini Howto available in most distributions.