NeXT Computers Forum Index NeXT Computers
www.NeXTComputers.org
 
Log in to check your private messagesLog in to check your private messages

Log inLog in  RegisterRegister


Profile  Search  Memberlist  FAQ  Usergroups
Emulating the NeXT Non-ADB protocol

 
Post new topic   Reply to topic    NeXT Computers Forum Index -> NeXT Work Logs
View previous topic :: View next topic  
Author Message
drakar



Joined: 23 Sep 2016
Posts: 5

PostPosted: Fri Jan 06, 2017 8:28 pm    Post subject: Emulating the NeXT Non-ADB protocol Reply with quote

Hello NeXT fans,

A while ago I picked up a nextstation color without a keyboard and mouse. How hard could it be to emulate them? (Very.) Thanks to info from this forum I got a soundboard converted and working and have gradually figured out the full protocol. With a USB microcontroller and an Arduino I can successfully emulate the keyboard and mouse with their USB equivalents.

Details and some code are on my page: https://drak.org/next-keyboard-protocol
I'll put the important parts below.

Most of the info out there about the keyboard is right, but it usually treats the responses as 22 bits. It makes more sense if you treat it as 2 bytes with some start/stop bits. The mouse was a lot harder to figure out although it seems really simple now. The movement isn't quite the same as the real deal but it works pretty well.

Code:

- = high
_ = low
50us each character
LSB first

From the computer:
KB Query
-----_____-____----- 0x10
Mouse Query
-----_-___-____----- 0x11
KB Reset
-----_----_------__________-----

LEDs Off
-----__________--__________----- 0x0, 0x0
Left LED On
-----__________--_-________----- 0x0, 0x1
Right LED On
-----__________--__-_______----- 0x0, 0x2
Both LEDs On
-----__________--_--_______----- 0x0, 0x3


From the keyboard:
KB Idle
-----__________--__________----- 0x0, 0x0

KB Packet
-----_BCCCCCCC_--_MMMMMMMM_-----
B: Make/Break (0/1)
C: 7-bit keycode
M: Modifiers

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


KB and mouse queries:


It works!


Right now I just have a breadboard set up with some wires and dev boards. Someday I'll put together a PCB design, right after I learn how to do that Smile

Edit - Here's a video demo: https://www.youtube.com/watch?v=tVobmMhLYDg


Last edited by drakar on Sat Jan 07, 2017 8:14 am; edited 1 time in total
Back to top
View user's profile Send private message
barcher174



Joined: 07 Dec 2012
Posts: 560

PostPosted: Fri Jan 06, 2017 9:44 pm    Post subject: Reply with quote

Excellent work! The USB host functionality has been the biggest hurdle to doing this. Hopefully one day soon there will be a good uC with built in support. I think a lot of people would be OK with giving up sound if this was cheap/easy enough.
Back to top
View user's profile Send private message
Daxziz



Joined: 29 Dec 2005
Posts: 33

PostPosted: Sat Jan 07, 2017 1:33 am    Post subject: Reply with quote

Brilliant :)

Personally I don't understand the code. But I would love to; would you consider writing a detailed post about the reverse engineering, debugging, tools and programming language that led you to this success :)
Back to top
View user's profile Send private message
drakar



Joined: 23 Sep 2016
Posts: 5

PostPosted: Sat Jan 07, 2017 8:55 am    Post subject: Reply with quote

The VNC2 controller that I'm using is pretty good for the USB part but I ran into some issues with getting the timing right. It would miss a query and get reset or it would see a KB query, get delayed, then send the response, so I'd press a key and the mouse would move. Combining it with an Arduino turned out to work pretty well.
I've been looking at PIC stuff too, they have a few that can do USB. If I could do everything on one controller that'd be nice.


Most of the reverse engineering was already done, there was an adafruit project that converted a NeXT keyboard to USB. I basically just had to flip that around and figure out the mouse part.
Debugging was some work with a cheap oscilloscope and lots of trial and error. Start up the nextstation, try some keys, adjust the timing, try a slightly different format, repeat. A logic analyzer would have made it a lot easier.
Back to top
View user's profile Send private message
Rob Blessin Black Hole
Site Admin


Joined: 05 Sep 2006
Posts: 599
Location: Ft. Collins, Colorado

PostPosted: Sat Jan 07, 2017 7:54 pm    Post subject: Reply with quote

Awesome stuff , great work.
_________________
Rob Blessin President computerpowwow ebay sales@blackholeinc.com http://www.blackholeinc.com
303-741-9998 Serving the NeXT Community since 2/9/93
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    NeXT Computers Forum Index -> NeXT Work Logs All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2017 phpBB Group