Trackballs work by using optical sensors to read the movements of dots on the surface of the ball. By tracking the direction in which the dots move, the optics translate the movement of the ball into moving the cursor.
Older trackball units use rollers or wheels to record the movement of the ball within an enclosed housing. Friction of the ball against these surfaces turns small drive wheels, which the device records as movement on an X and Y axis. The wheels have small wire contact discs on them that would pulse an on and off signal as the wheel rotated and created a circuit. Computers then translated the amount of pulses in the signal to cursor movements.
Later variations replaced the contacting disks with a similarly shaped wheel marked with holes. LED light is then displayed through the holes, and read by an optical sensor. As light passes through the holes to the sensor or is interrupted by the spinning wheel, it creates a pulse similar to earlier models.
While an early prototype was developed and patented in 1947, the first trackball was built in 1952, for the Royal Canadian Navy's DATAR system. It used four movement tracking disks, and a five-pin bowling ball.