I spent a few weeks making an old Serial Mouse work. I’ve been tweeting a log of what I’ve done so far and I already wrote a piece on the serial mouse protocols.

Sprinkle in a little robotjs and I’ve got a fully functioning mouse! 🙌🙌🙌🙌

You can use an old microsoft mouse by running npx serial-mouse-parser and find the source on github.

Blog Posts


This thread can be found at toot.cafe includes 3 statuses.

I spent my evening accidentally(?) studying serial mouse protocols. I found a great secondary source but only a fraction of the primary sources exist any longer (even with wayback).

It's weird and I have so many questions. It also reminds me of MIDI


I can't believe serial mice are $25 on ebay. Probably way cheaper then when they were new.🤔

In case you find this in the future, I got one for $1 at re:pc in seattle =)

This thread can be found at toot.cafe includes 84 statuses.

Starting my hunt for serial equipment in Seattle. I only have two places on my list so far. Goodwill and RePC

Goodwill is a bust but they did have some neat stuff

I called RePC Seattle and they said “our other location has the old stuff” promising 🤞

“We have a bin of them, 99c and up” RePC Tukwila


REPC was amazing! Let’s start with my childhood computer. It’s an IBM 8086. My mother swapped the floppy drive for a 4mb hd and upgraded it to an 8088.

RE PC is a computer recycling store that uses their incredible wealth of parts and space to do the appropriate things. Also they print signs.

At the entrance they had a few teletypes which were fantastic to look at. (Not pictured here a 40mb drive larger than most desktops I’ve ever owned)

This horrible photo of a nonplussed child has 1/3rd of the inventory pictured.

He was more excited by the gamepads

And the electric typewriters

So I went searching for serial mice. DAT drives anyone?

If only I had a warehouse of my own... Fun story, a fancy Manhattan loft has a permanent oscilloscope I salvaged with help from @TVCOG@twitter.com from GE(?) that nobody could move when we left

Hahaha if only you knew kid

So I had a few options. My goal is to make a serial mouse driver. From my blog post researching the protocols I know there were at least two versions of the mouse protocol. Microsoft’s 2 button and Logitech’s 3 button.

Honorable mention was the trackball my mother got to fight Carpal tunnel. Also because it looked cool. This was a two button mouse with one button. I *almost* bought it but it’s too big for my suitcase.

It was a tough call though. “What are you going to do with it?” My wife asked.

I ended up with the knockoff Logitech and the ms mouse.

I also snagged a serial barcode scanner because, why not? I really hope it goes *beep*

I don’t actually have a 9 pin serialport to USB adapter with me on this trip. I do have a bunch of serial UART to USB adapters for 5v serial. Most of them only have RX and TX (which is fine for the mouse) but all this equipment runs on 12 volts! These days 3.3v is standard.

(It's really cool how 3.3v and 5v devices usually work together allaboutcircuits.com/textbook/ except for some things like the raspberry pi where it dies at 5v, that's not fun)

The blog post I wrote analyzing a 22 year old page someone made about the then aging serial mouse protocols can be found here roborooter.com/post/serial-mic

I get my DE-9 to usb-c converter Thursday just in time for the plane. 🤞🤞🤞

I really like this ascii diagram. The useless second byte is all about synchronizing packets. The useless first byte is anybodies guess.

Other things I couldn't buy because of travel.

1) A "till display" from a cash register that shows you in 7-Segment glory how much money you owe
2) A Flux capacitor (they had huge capacitors)
3) A 102 key break spring keyboard
4) A huge joystick with lots of buttons
5) An Atari

*Bits* not *Bytes* in that ascii art thing

And lest you think I drag my son to things he hates, we bought him that mini keyboard too.

RT @opheliasdaisies@twitter.com
Getting him started young.

That "lets ignore the first bit" of the mouse update packet bothers me a lot. The best I can fathom is that some other widely used device (keyboard, printer, monitor?) used the first bit and this was a easy way to identify devices or ignore bad input.

And of course the prolific driver download is down. And the contact form is down.

"String or binary data will be truncated. The statement has ended."

Glad I'm trying to install kernel drivers from this operation.

Alright, if you log in with GUEST/GUEST you can get the driver and it works! Now let’s get this working.

It wouldn’t power on... says it takes 5v (instead of powered via serial?)

Ahh! A hidden power port. Will have to try it again later.

After finding a bug in node-serialport's master branch. I'm printing every 3 bytes as binary. These don't really make sense, I'm supposed to be seeing 01xxxxxx, 00xxxxxx, 00xxxxxx but that is not the case.

Btw @Foone@twitter.com just did a quick tear down of an old usb mouse which is pretty rad
RT @Foone@twitter.com
So w@Foone@twitter.com'm stuck in jury duty purgatory, let's look at some hardware teardowns I already did and haven't posted yet. This one is a junk HP mouse, and it's interesting because of how boring it is. No, really.

So I have a hunch as to why I can’t eyeball the data coming in, but I’ll come back to that. For now let’s look at the 3 button and see if we can’t learn from the differences.

I'm supposed to be getting 4-5 byte packets if it's a Logitech or "Mouse systems" but it still looks like mostly 0s. I do see data flowing when I mouse around and click. But nothing with the middle mouse button.

Opening it up doesn’t reveal much, everything looks in good condition. The sunlight throws the rotors from the wheel sensor into a frenzy. The mouse constantly streams data while it’s open. =p

I found my mistake! Both MS and Logitech protocols are 1200 baud and 7 databits with 1 stop bit! It was in the article but I missed it with my initial read through. It also matches the 7 bit bytes of the protocol.

A very plausible explanation for 7 bits by @JediJeremy@twitter.com
RT @JediJeremy@twitter.com
@reconbot I'm wondering if the wire protoco@JediJeremy@twitter.com + 1 stop bit (as was common back then 'cause you could use a simple shift register instead of an expensive UART) so the 8th bit was literally never sent? (and thus irrelevant)

There is an 8 bit protocol later mentioned in the article by "Mouse systems" en.wikipedia.org/wiki/Mouse_Sy formerly "Rodent Associates" 😂

Started by the inventor of the optical mouse Steve Kirsch. I hope I don't have to hop through settings seeing if I can get good data. 🤔

With the proper settings I get a much better view on the data. I should have realized got this wrong last night. But still no obvious reaction to the middle button. 🤔 No obvious follow up packets either, the second bit should be 1 for packet start and 0 for follow up.

(that's me mousing and clicking around)

So splitting up the binary 1s and 0s and looking for the packet starts, I get nothing that makes sense. I tried both big endian and little endian. I'm pretty sure the first bit is the stop bit and the remaining 7 are the data. Button data doesn't change.

This mouse might be mouse systems and not logitech 🤔

But my Microsoft 2btn mouse works!

I'll come back to the mouse systems mouse. Lets make a parser for Microsoft compatible mice =)

- While the mousesystems mouse constantly spat data, the microsoft one only sends data on change
- It always sends 3 bytes no variable byte length
- I don't need to use a timeout looking for more bytes
- I can toss the current packet if one starts in the middle (lost data)

So after a little plane hacking during naps I have a stream based MS mouse protocol parser.


It works! But I'm pretty sure I'm not parsing the movement bytes incorrectly as they're always positive. (I'm mousing around and clicking the buttons.)

I found the bug! Off by 1 in my bit shifting because my comments were 0 indexed and my thinking was not. Looks like if we were navigating a grid 0x0 would be top left.

IIRC this matches X Windows's coordinates? How does windows do it? 🤔

After researching DOM mouse events, they are not the model I want to copy. I guess they make sense for the web but not for an OS.


Sprinkle in a little robotjs and I’ve got a fully functioning mouse! 🙌🙌🙌🙌

I got to thinking this is a lot of code for a pretty simple thing
get 3 bytes => set some state => send an event

Lets try a different approach.

Instead of a single transform stream to packetize and parse the data, lets split it up into two async iterators that are easy to compose. One for making packets, and another for parsing them.

You can follow along here github.com/reconbot/serial-mou

This bit of code looks a lot like the stream, we read 3 bytes and yield them. There's no object state, no callbacks, no classes however. This is all it does.

This next bit (read the rest here github.com/reconbot/serial-mou) does the same thing as the emit function from the stream, however it gets formed packets and "state" is now a "let state" instead of a "this._state"

And my favorite part, lets put them together.

I have to say this feels a lot like converting a react class to hooks. It's all the same logic but less complected code that's easier to reason about.

And of course it still all works the same as before. Side note: I love the look of "debug"s output. ❤️

I don't feel like digging for an external 5v power supply to make the barcode scanner work but something else did arrive today! A brand new barcode scanner!

This one is USB HID (keyboard) or Bluetooth HID or Bluetooth Serial! You just scan these control codes to make it work.

It's pretty cool how little these things have changed over the years (compared to the serial one I bought from RE:PC) except the new one has a battery and bluetooth and visibly fewer components on the inside.

Since there's no make or model on the device I can only imagine it's some sort of single chip device that gets repackaged a lot. The ebay seller is in Hong Kong. I ordered as a guest so I can't actually interact with the order or contact the seller for more info.

Which is a shame because while I can pair with this device and get a serialport, I get no data from it, nor keypresses from the HID inputs.

UNLESS I scan the code asking how many scans is in it's memory and it says "TOTAL COUNTERS = 0" but only over bluetooth HID

I just sent a message asking about the item and ebay says it's both sent and doesn't exist. 🤷‍♂️

This is about the ebay experience I expect.

Because it's a pretty common gun (the specs match about 90% of what I saw on amazon) I hope I can find some more control codes or something.

I had some time to try to get my older 9 pin serial barcode gun to work.

After some bin diving I found a multi voltage multi plug ac to dc adapter. It fits but I accidentally hit it with 9v instead of 5v for a moment. No response at either voltage but I’m pretty sure it’s broken.

I had a hunch that maybe it's waiting for a CTS/DTR response (usually from a port open) before turning on. An interesting approach if true but who knows 🤷‍♂️

Well after coming back to my workbench with my usb-c to serial cable in hand the barcode scanner was hot to the touch and I smelled magic blue smoke. Not wanting to risk my computer or serial cable to that. I decided to take it apart instead. I think this does power regulation.

That piece had a Phillips head screw but these others are a torx security bit.

A long time ago I came across torx bits trying to replace the case on my Nokia 3510(?)


It was light up and everything and it was amazing. I need a torx T10 and a T11 if I recall correctly. RadioShack only sometimes carried them.

Eventually I bought this.

Didn’t hurt my PowerBook G4 needed torx bits too. You used to be able to open these things up.

The head has two parts in this assembly. I was betting on more moving parts but there's nothing external to the PCBs. Surrounding it is a lens and shock absorbers.

PART 1 of 2 and PT2OF2. Best I can tell part 2 has a status LED and an LED like component (same shape, size, and wiring)

A better look at the base attached to the cable.

Since the base is the part that got wayy to hot, I cut it off. Going to save this cable for something in the future.

Well too bad it didn't work but at least it was $3 instead of the $45 you see on amazon. Now how do I get my Bluetooth one working?

Worth noting it was like 90 pounds
RT @reconbot@twitter.com
If only I had a warehouse of my own... Fun story, a fancy Manhattan loft has a permanent oscilloscope I salvaged with help from @TVCOG from GE(?) that nobody could move when we left