ELI5: How do computer mice work?
Arjun Aravind • 27 June 2020 • 10 min read Mice (no, it's not 'mouses') are an ubiquitous object in households these days. Anyone who's ever used a computer has used a mouse. It's so common that we don't really ever think about it, same way that we don't think about how a car moves when we see one.When you see an Apple Watch or Amazon Alexa or some other 'cool' gadget, it's automatically the center of attention. A mouse? Mmmm, not so much.
I've never really given it any thoughts myself. But, one day, I came across the wikipedia article for 'Computer Mouse' and I was extremely fascinated by how they work. Since I was starting this blog, I thought it'd be a nice idea to tell people how creatively mice are designed.
Alright so, in this article, we're going to be discussing how a mouse actually senses movement and the distance that it's been moved rather than aspects such as data transmission to a computer and all that.
What's so special about a mouse, though?
You might know really think about it, but when modern computer mice were introduced roughly about 40 years ago, they completely revolutionised the way that users interacted with a computer.
This improvement in UX let any average individual operate a computer without having the need to have any programming skills. Think about it, the very concept of a Graphical User Interface is not tenable without a mouse!
Wow, who even thought of a 'mouse'?
A modern version of a trackball manufactured by Kensington.
So, the origins of the mouse lay in the invention of the 'trackball', pictured above. The trackball was invented by the British in 1946, right after WWII, for military air-defence systems. Unlike a mouse, a trackball is stationary. You have to rotate the ball on the pad with your palm and this will reflect the cursor on screen. Trackballs are still used today and are considered to be more ergonomic but are way more costly than standard mice.
Douglas Engelbart, widely credited to be the inventor of the modern mouse, came up with the idea for a 'mouse' when he was designing a computer system known as NLS (oN-Line System) in the 1960s.
- NLS is a widely influential invention in the field of computing and many of the modern features we see in today's computers such as video-conferencing, hypertext, and collabarative editing were first implemented in that system.
- Jeez, can you even imagine something like videocalls in the 60s? Check out Engelbart's demo for NLS here!
Engelbart wanted a input device that would be more 'easier' and 'natural' to use than a stylus or a trackball. Engelbart came up with something called a 'bug', that was basically an early predecessor of the mouse, but with wheels (which sounds hilarious, for some reason).
This is what Engelbart's early mouse looked like. Also, the world needs a resurgence in polished-wood mice, imo.
And from there on, I guess the concept of the mouse just.....'clicked'! Sorry about that. The computer mouse as we know it today is an improvement upon Engelbart's original design and has included many extra features such as the scroll wheel and click buttons. Read on to see how those work!
So how do they work?
The inner workings of mice are simple yet ingenuiously engineered! We'll be discussing two types of mice:- mechanical mice and optical mice.
Mechanical mice are the ones that used to be more popular from the 80s to the early 2000s. These type of mice feature a ball that slightly projects outward from the underside of the mouse, pictured below. The ball is allowed to rotate in any direction.
The dissection of a mouse.
The mechanism is quite simple. When the mouse is moved in any direction, the ball (1) is rotated. Two small rollers (2) are connected to the ball such that they rotate when the ball is rotated.
- So, for example, one roller will rotate if the mouse is moved in a left/right direction and another one will rotate if the direction is forward/backward.
- Just to clarify, the rollers I'm talking about are the small circular objects near the ball and not the big ones.
LDRs produce a high voltage when light is shined on them. So, when light from the LED reaches the LDR, it sends a pulse. So, if a pulse from the LDR assigned to the left/right wheel is received, that means the mouse moved left or right. If it was received from the LDR assigned to the forward/backward wheel, then it moved forward or backward.
A vertical view of the insides of a mechanical mouse. Notice the encoder wheels positioned perpendicular to each other!
Mechanical mice were the first modern mice. However, they have been replace largely by optical mice, which are much more accurate. Mechanical mice also other disadvantages such as easily becoming dirty and the ball displaying erratic behaviour.
Optical mice, on the other hand, have taken over the world in the last 20 years due to their cost-efficiency and accuracy. Many people think that optical mice probably use some sort of light sensor or some similar magical device to detect movement. The truth is actually much more surprising! Optical mice actually contain a minitaure, working camera! A chip inside the mouse compares successive pictures, calculates an offset distance and determines how much the mouse has moved. Take a look at the pic below.
Don't worry, I'll explain this. Btw, who likes Daft Punk?
The two images shown are portions of a bigger image. In IMAGE 1, the center of the image is marked with the white line. The distance from the center to the left edge of the image is 50px. In IMAGE 2, we notice that the old center has moved to the right. The distance from the old center to the left edge is now 100px.
We can see that IMAGE 2 is what we'll get if we slid IMAGE 1 to the right. How can we find this out for sure? Because the distance, let's call it offset, from the white line to the left edge has increased.
In a mouse, the exact same thing happens. The mouse-camera takes around 1000 images of the platform it is on every second! Since the mouse blocks natural light, it shines light at an angle on the platform and then takes the pictures. Each image is analysed to determine what is the offset between this and the previous image.
If the image looks like the previous image 'slid' to the right, the mouse must have moved left. If it was 'slid' left, the mouse must have moved right. Similarly for forward and backward. Amazing, right?
- Light is shown at an angle so that it creates shadows on the platform the mouse has been placed on. This is so that the mouse can identify unique points on each image using the shadows, so that it can calculate offset accurately.
- Light shadows are also the reason that the mouse only works on a diffused (or rough surface). Shadows cannot be created on smooth surfaces so the mouse cannot calculate offset.
The underside anatomy of an optical mouse.
How does the on-screen cursor move?
The mouse only calculates by how much the user has moved since the last position. It sends this information to the computer either through a wire or a wireless medium. The computer's operating system then shifts the cursor on the screen. The mouse then calculates again. It's an endless cycle, basically.
#MiceMatterToo
Mice are really underrated. Feel free to read more on the different types of mice available on the market (There are some really weird ones). Hope you guys had a 'mice' (sorry) time reading this, feel free to send in your thoughts or requests for more articles!