This project was inspired by a kickstarter scam that in hindsight a bit too good to be true. The product that was being advertised was a mouse that was covered with a flexible touchscreen OLED that could be programed with shortcuts to any number of applications. It seemed like a novel and interesting idea (even if not fully practical) where they seemingly showed functioning prototypes as shown below.
When the project did eventually fall through; I decided why not try to make the best of the situation and build my own. The goal of this project was to make a functioning mouse that implemented a touchscreen display that could be programed with custom shortcuts for various applications.
This is also a story, in a continually growing large part, about scope creep. When I started this project, the plan was to Frankenstein together an existing mouse with a touchscreen for shortcuts. Maybe a simple USB data splitter to handle both the mouse signal and shortcuts from the controller…
Learning How a Mouse Works
The Basics
First and foremost, this needs to be a functional computer mouse so we need to figure out how they work. Essentially all mice that we use today have optical sensors that are used to detect the movement of the mouse. They work by taking consecutive images of the surface under the sensor and comparing each image to the previous image then calculating the relative motion of the mouse based on the offset. That x and y offset is then sent to the computer which then turns that data into the motion of your cursor.
Some of these chips also take input from the buttons and scroll wheel and send those inputs as well. So, theoretically, it should be pretty simple to create a functional mouse from a torn down mouse or two… right? Well it turns out that something as simple, common, and cheap as a computer mouse can make you feel like an idiot.
A Teardown or Three
The most fun part of reverse engineering something is always the teardown; so I bought and tore apart a few inexpensive options. Two were standard wired USB mice and the third was bluetooth.
Each of the mice had a different optical sensor; all doing essentially the same thing but in different form factors and resolutions. Unfortunately, not all of the data sheets were available for the sensors which meant trying to repurpose these into my own circuit wouldn’t have worked. Even worse is that one of the sensors (mouse on the right) used PS/2 communication protocol with is mostly obsolete and would have really limited its functionality.
The first one (on the left) initially seemed like it was going to helpful in testing because I was able to find its data sheet online. This chip takes its data and uses the Human Interface Device (HID) standard to talk directly to the computer via USB without the need for an additional microcontroller.
While that sounds helpful, it’s actually an issue once you try to integrate it to work with a microcontroller like I am. The reason is that the controller would require extra software packages that can first translate this to data that is usable by the microcontroller. I’ll go more in depth on this in the next section.
The last was a bluetooth mouse. Overall this wasn’t much different from the first except some battery charging circuitry and another IC for processing and sending the data over BT. Unfortunately the sensor on this one was proprietary with no data sheet to be found. So without being able to see inside the chip, this ended up being useless.
Talking to the Mouse
All I wanted was data, but all I got was pain. I thought this was going to be the easy part of the project but quickly found myself going off the deep end trying to get this to work.
As I quickly learned, there are two primary ways that the mouse and computer communicate; PS/2 and HID. PS/2 is an old standard that isn’t used anymore while the HID standard is used by essentially all mice and other devices like keyboards. I won’t get into these much more...
Read more »