The PC Mouse is a pointing device
shipped with almost every computer nowadays as
because is an important element of the graphical user interfaces available.
It was invented by Doug Engelbart
and presented at the Fall Joint Computer
held in San Francisco
The idea behind the mouse is that you move the device on a mouse pad and
the computer responds by moving a cursor accordingly around the screen.
Using buttons placed on the top of the mouse enables you to select things
or move things around.
Complex mouse gestures have been developped by software designers and the
mouse has been enhanced with additionnal buttons and wheels to suit user's needs.
Other pointing devices that mimic what you can do with a mouse have been
developped : the Touch Pad, IBM ThinkPad's TrackPoint etc.
A mouse consists of five functional units : sensors
, a mouse controller
a communication link
, a data interface
and a driver
Sensors detect movement and trigger the mouse controller which sends
data through the communication link to the data interface. Then the
driver reads the data and updates the mouse information (position, buttons
pressed, etc.) available to the kernel and the applications.
Sensors and Movement
Traditional mice use a rubber ball that rolls on the mouse pad when you move the
mouse. The ball is placed between three wheels : two of them form an angle of 90°
and are used to detect the movement, the third one is connected to a spring that
holds the rubber ball in place.
The movement wheels are connected to a disk pierced of little equaly spaced holes
placed between two infrared light emitting diodes and the corresponding
diodes => | >= photo transistors
--+------- shaft connected to the movement wheel
When the mouse moves, so does the wheel, cycling through blocking and allowing the
light to reach the detector. There is a 90° phase difference between the signals
collected by the two detectors.
Let 0 code for no light being detected by the sensor and 1 for light being detected.
Upon mouse movement, the signal typically looks like :
sensor #0 - 1111000011110000111100001111
sensor #1 - 0011110000111100001111000011
The controller's job is to determine in which direction the mouse is moving. This
can easily be done by constructing an integer from the two signals and seeing if it
is incremented (the mouse moves one way) or decremented (the mouse moves the other
sensor #0 | 0 | 0 | 1 | 1
sensor #1 | 0 | 1 | 1 | 0
integer | 0 | 1 | 2 | 3
Say if the integer increases the moving direction is left to right, when the sequence
12 is encountered, the controller should send a 'mouse moved right' packet to the
computer. If the sequence 03 is encountered, then it means that the mouse is moved to
When the mouse's status changes (button press, mouse movement, etc.), the controller
is expected to send a packet containing the new information to the computer.
But due protocol limitations, there is a limit on the transmission rate.
For example, the Microsoft serial mouse
uses a 1200 baud
protocol and each packet
consists of 3 bytes. Therefore the mouse can't send more than 50 packets per second.
This isn't really a problem since screen refrash rates
range from 60 to 120 Hz
The baud rate is related to the maximum display rate.
It can be changed by sending the appropriate signals to the hardware (see mouse protocol
). For example PS/2 mice can have refresh rates as high as 200 Hz
If mice were updated only 50 times per second, you couldn't move them fast
without the controller losing track of the movement.
Say you have a classic mouse with a 1 cm diameter ball and 40 slots
and 40 spokes on the optomechanical sensors. Then a complete revolution
of the ball involves 40 * 2 * 2 = 160 counts of movement, which can't be
done in less than 160 / 50 = 3.2 s and represents a travel distance of
2 * π * 1 = 6.28 cm.
The maximum mouse speed would be about 2 cm/s which is very low.
In fact, the controller has a higher refresh rate. Typical cheap mice are
able to achieve more than 5000 counts per second. The tracking speed is
the maximum mouse speed without the controller losing track of movement
(ie. not skipping sensor changes).
If samples are lost, the controller can think that the mouse is going
in the opposite direction and cause the mouse to jitter on the screen.
To visualize this, think of a spinning
disk with a black spot and lit by a stroboscope. If the disk is spinning
too fast, you might think that it is turning in the opposite direction.
Tracking speed defines how fast the mouse can move without jittering.
(Of course if the baud rate is too low, the buffers might overflow)
A complete revolution of the previous mouse involves 160 counts and
represents a distance of 6.28 cm which means that it measures movement
with a granularity of 0.098mm. This reprenents about 259 dpi.
The resolution is expressed in Counts Per Inch (CPI) and defines how
precise the mouse can measure movement.
The mouse is a basic device, it is rather easy to build on your own and even easier to program. See Mouse Protocol
for further information on the data sent to the computer.
PC MOUSE Implementation Using COP800 AN-681, National Semiconductor, Application Note 681