Oldskool mice often use an LED shining through a slotted disc.
I pulled apart an old Amiga mouse once and used the LED/sensor pairs as a lap counter for my Scalextric set - When the beam is broken, it's like the mouse is moving.
(of course, the lap-counting app was programmed in Blitz Basic II :-)