The NeXT keyboard also has the capability to connect the NeXT mouse. The keyboard's microcontroller reads the mouse movements and can send the mouse data to the computer on request.

The mouse uses a different connector, an 8-pin mini-DIN. Deskthority's wiki has the details of the connections.

In this case, though, it is enough to rely on the keyboard's ability to daisy chain, so we need to know how the keyboard sends back the data.

Hoping for the best, I plugged in my NeXT mouse and moved it around, hoping for some reports to come back. However, none did. Luckily, a little web searching showed me that it was necessary to send a second query command to get back mouse data; drak.org thoroughly documented the details. In a happy bit of synergy, they credit Adafruit for some of the original protocol information!

According to that website, the keyboard and mouse queries differ in one bit:

KB Query
-----_____-____----- (0x10 = 00010000)
Mouse Query
-----_-___-____----- (0x11 = 00010001)

Perhaps NeXT imagined that it might place even more "devices" on the keyboard bus in the future, as it looks like there are a lot of bits available to specify a device to query.

The response to the mouse query has information about the button states as well as the amount of mouse motion since the last query. Again, according to drak.org, the response looks like this:

Mouse Packet
-----_1XXXXXXX_-_2YYYYYYY_-----
1: Button 1, 0 = down
2: Button 2
XXXXXXX: X movement, 7 bit two's complement
YYYYYYY: Same thing for Y axis

That seems easy enough to code up. The plan is to alternately send a keyboard query and a mouse query, translating the response to USB HID. If the mouse is not plugged into the keyboard, everything still works fine: no mouse events are reported, but no errors occur either. So, the same CircuitPython code can work without caring whether there's a mouse attached.

This guide was first published on Dec 07, 2022. It was last updated on Jun 18, 2024.

This page (Research II: Mouse) was last updated on Mar 08, 2024.

Text editor powered by tinymce.