• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

PS2 Keyboard on Mac Plus

bbraun

Well-known member
Ever since I got the pile of compacts without keyboards or mice, I've been on the lookout for keyboards. Most of the keyboards I see available are going for about as much as the whole machine, so I haven't picked any up.

Finally, I gave up and decided to make an adapter that allows using a PS2 keyboard on the older compacts.ps2tomackbd1.jpg

No fancy fine pitch soldering, just connecting up header pins and some wires. I think it's less than $20 in parts all told.

Here are a couple videos of it in action, but my phone seems to do a pretty poor job of it:

Amber screen Plus

Normal Plus

I've written it up in more detail here along with parts list, links, instructions, and code to the controller.

Right now it has all the keys of the original keyboard mapped, but none of the number pad.

 

uniserver

Well-known member
You are a machine.

I would like to look a little more closely at this.

PS/2 keyboards are everywhere that is for sure!

 

markyb86

Well-known member
Hold up, that plus has an AMBER SCREEN!?? Awesome.

I too would like to know more about this awesome hack.

 

bbraun

Well-known member
I'd be happy to help anyone that wants to build one. In the link up above I tried to list the parts and how to build one. The board I used has its own programmer built in, so there's nothing extra there. I used a template from someone else (based on someone else's template, based on ST's sample code), and the README.md in the code has all the instructions on how to setup an environment to build the code and program it. If someone is really interested in building one and programming it is the stumbling block, we can probably figure something out like a virtual machine that has everything ready to go or something.

The short version is that board I used is ~$8 from digikey, I used two premade level converters from adafruit to do the 3.3V to 5V conversion, and then the connectors which I hacked up from existing cords. I'm just using GPIO signals on the board to talk to the Plus on one side, and the PS2 keyboard on the other. It then has a table to convert the scan codes between the two. I'm currently mapping all the keys on the original (non-keypad) keyboard. I'm also using a (ttl) serial port on the board for diagnostics. The windows keys on the ps2 keyboard are the cmd key. I'm not actually implementing all (only 4) of the mac keyboard commands at the moment, the Model Number and Inquiry commands are the two that really need implementing. The other big one is the Instant command to return the keys down at that very moment, but I haven't seen that command actually issued in my testing.

As for the amber screen, it came in one of the Plus' in that big lot. I used it here to see if it got any better results in the video than the stock screen.

 

uniserver

Well-known member
I don't know why there isn't more people going silly over this...

I mean by hand you created your own working PS/2 to Plus/512k/128k KBD adaptor.

This is not something normal people do.

How long did this take to make once you had all the parts handy and the software done?

How hard would an ADB version be?

 

CC_333

Well-known member
This would be interesting.

I don't need one per se, but it could be a good learning experience.

I'll PM bbraun at some point (or he's more than welcome to PM me) and see what I can do.

c

 

Trash80toHP_Mini

NIGHT STALKER
I'm very intrigued by it and impressed with the hack, great job comrade! It'll be great to have the 128kDrexel/Plus/Micromac KVM'd with the rest of the goodies!

The programmable scan code conversion capability of the controller has me even more excited! I've always wanted to have an easily programmable hardware remapping converter:

 

Caps Lock: make it do useful as opposed to destructive things . . . or nothing at all! [}:)] ]'>

- turn it off on (PS/2->PS/2 version, please!) the scan converter by remapping the capslock state to the standard keystroke map.

- use it to map the capslock state to a custom embedded numeric/pagenav(igation) setup for any KBD!

That's all a big assumption on my part, my (Murphy's Law) guess is that CapsLock on the PS/2 interface never hits the CPU/KCHR resource level like it does on the Mac. :-/

Is the scan code for a capslocked k(K) the same for a shift-k(K) on the PS/2 interface or is it a state level difference? :?:

 

bbraun

Well-known member
I originally worked entirely with jumper wires like this:

ps2tomackbd.jpg

To actually assemble all the pieces onto the perfboard and have it working took maybe 20-30mins? I made a mistake on the first try and had the clock and data lines mixed up on the mac keyboard side, and once that got sorted out, it worked. There's really not that much to it. One thing that might be interesting would be turning the perfboard into a pcb. I might be able to handle that.

It's still powered by 5V (USB or whatever), since the mac keyboard interface can't supply enough power for most ps2 keyboards + this converter.

I've ordered some of the female connectors to not have the floppy wires soldered to the board. Hopefully that'll make it easier on the desk.

As for ADB, that's completely different, and a much more complicated protocol. I'll poke at it eventually, but it's not a simple thing.

Inside Macintosh Volume III was my reference for the scan codes, they're all there. The keyboard is reporting the ky pressed, so there is a scan code for capslock and shift and for 'k'. The keyboard is not aware of capital vs. lower case.

I've internally implemented logic to keep track of the state of the capslock key in order to make the capslock LED work properly on the PS2 keyboard. The keyboard tells me the capslock key was pressed, and I'm sending back a command to the keyboard to turn the LED on or off.

There are a bazillion extra keys on the PS2 keyboard, and I've thought about setting them up to do interesting things on the mac side, but haven't thought of much yet.

 

Trash80toHP_Mini

NIGHT STALKER
The keyboard tells me the capslock key was pressed, and I'm sending back a command to the keyboard to turn the LED on or off.
Does that translate into having have capslock bi or tri-state the mapping depending on how many times the capslock key is pressed in succession?

 

James1095

Well-known member
That's awesome.

If the uC has 5V tolerant IO pins, you may be able to get away without using the level shifters. 3.3V is well above the "high" threshold for 5V TTL so most of the time a 3.3V LVTTL line will drive a 5V TTL input without any issues.

 

bbraun

Well-known member
For the capslock key, the led is off when the keyboard is powered up. If you press the capslock key, the led comes on. If you press it again, the capslock key turns off. And so forth.

The controller does have 5V tolerant IO, but I was not having reliable operation when the uC needed to bring a 5V line low. But, you can try it without the level conversion and see how it goes.

 

James1095

Well-known member
http://www.timeline-inc.com/blowout.html#monitorlooks like they still sell amber screens.
I was looking at that place a while back for something else. I noticed though that the site hasn't been updated since 2001 and the email inquiry I sent them never got a response. Has anyone tried giving them a call? I would be shocked if they still have any of that stuff, but I wouldn't mind getting a couple of the 5" Samtron CGA monitors if they do.

 

Trash80toHP_Mini

NIGHT STALKER
I was wondering if the processor(?) had intelligence and memory enough interpret more than one consecutive keycaps toggle to swap keystrokes to an alternate mapping and back to standard again with the same multiple toggle signal.

 

uniserver

Well-known member
(310) 784-5488

it's a good number they have a recording saying leave a message for sales orders and someone will call you back

so at least someone is paying the phone bill :)

 

James1095

Well-known member
it's a good number they have a recording saying leave a message for sales orders and someone will call you backso at least someone is paying the phone bill :)
Well if you ever reach someone there, let me know. I wouldn't mind getting a couple of those 5" Samtron CGA monitors but I suspect I'm about a decade late to the party. I kept meaning to try calling but I'm usually at work during business hours.

 

bbraun

Well-known member
I've got my Fisher-Price My First PCB in. It works, but there's some rough edges to it.

The PCB is made to use those level converter breakout boards from adafruit. They're about $4 each + shipping, and there's 2 on here. I've tried one without the level conversion, since the GPIOs are 5V tolerant, and it seems to work fine. It just requires wires jumping the connections where the level converter is supposed to go.

So, if anyone is interested in one, let me know. It would be good if the first round of people trying it were comfortable reprogramming the thing. No special hardware required, and the information on setting it up can be found here. I use a linux virtual machine for programming mine.

The firmware as it stands now seems to work ok for me, but it would be good to have some feedback before sending it out to people that can't update.

The board is simple (especially without the level converters), and attaches to the $8 STM32F0DISCOVERY board.

The parts list is that discovery board, the pcb and:

4P4C RJ11 connectors

PS2 connectors

Header connectors for attaching the PCB to the STM32F0DISCOVERY in an easily removable way. I cut these down to 33pins from the stock 40.

2x level converters, apparently optional

If anyone is interested, I can send the blank PCB, an assembled "shield" with or without level conversion, or the assembled shield + stm32f0discovery.

The PCB costs me about $3, and you can see the costs of all the components I've used above.

So a shield without level conversion costs somewhere around $5

With level conversion costs somewhere around $15

Plus the $8 board its self + shipping from digikey.

Currently, I'm testing with a DEC PS2 keyboard on a Plus. It seems to work ok for me, and the control & escape keys even work (they never existed on any Apple keyboards of this type).

I don't currently have any spare STM32F0DISCOVERY boards, so if there's an interest in me purchasing & programming them, I can put together an order. I've 9 available PCBs (10 in the order, 1 for me).

 

bbraun

Well-known member
I've been hacking around with the pre-adb, adb, ps2, and usb keyboards and mice for a bit and was wondering how much interest there actually is for various adapter bits.

PS2 to pre-ADB

The PS2 mouse and keyboard to pre-adb seems to be working OK for me. I've got the pcbs and components to make the 'cape' for the stm32f0discovery board I've linked above. The boards are powered by USB, since pre-adb systems can't provide enough power for both a PS2 mouse and keyboard, plus the adapter its self. Pre-adb macs are rated at a combined total of 200mA for all peripherals. My PS2 keyboard alone draws 200mA, plus mouse and adapter.

One hiccup with my current pcb is I got the DB9 connections backwards, so a straight through DB9 cable won't work. I'm using a cable I made out of db9 to rj45 adapters and an ethernet cable.

If anyone is interested, I can provide all of the above (I have more than enough of all the components, plus db9 cable), at cost.

PS2 to ADB

Using a hacked up version of the board above, I've got a PS2 mouse working with ADB on a Mac SE and 660av. I've kinda/sorta got some keyboard support working too, the main impediment is just physical connections at the moment. The ADB support works in the simple cases, but it lacks collision detection, so for example doesn't work very well if you plug in 2 keyboards or 2 mice.

If there's interest in this, I can make up some PCBs for PS2 mouse and keyboard to ADB. It'd essentially be the same as the PS2 to pre-ADB. In fact, I'm contemplating making it the same board: PS2 mouse & keyboard on one side, DB9 in the middle, and rj11 and adb ports on the other side. Then a jumper to choose whether it does ADB or pre-ADB. Getting this working would mean getting the adb connector, making up the PCB, and some more software work to glue it all together.

USB to ADB

Using a different chip in the same family, the stm32f4discovery has a USB OTG micro A B connector. It's about $15 from digikey, almost twice the $8 of the stm32f0discovery. It is a different form factor than the stm32f0discovery, so the boards I've made don't fit on it. It also requires a USB OTG micro USB host cable to be able to plug devices into it. This is the same cable as is typically used to plug a USB flash drive into cell phones that support it. I've gotten one of these and have a USB mouse to ADB working with it. I'm messing around with USB keyboard to ADB, and I expect to get it working in the next couple days or so. It's a little more involved than the mouse support due to differences in key press reporting. Another hiccup with keyboard support is many keyboards (all Apple ones, and at least the Dell USB keyboards I've got) are USB hubs with the keyboard device hanging off that. If your keyboard has another USB port on it for a mouse, you've got a USB hub keyboard. These aren't supported, and I probably won't be adding support for them anytime soon. So, any USB keyboard support will be for pure keyboards. This also means the board will only support one device: either a keyboard or a mouse. You could have two of these adapters, but each will only be able to do a keyboard or a mouse, unlike the PS2 version, which does both in one device.

To do this, I'd need to make up some boards, and at least for keyboard support, there's some more work to do at the moment.

USB to pre-ADB

I haven't attempted this at all, but it is a logical extension of the work I've already done. This would have all the same limitations as the USB to ADB version above. The stm32f4discovery is larger than the stm32f0discovery, so any PCB I made would probably be larger and therefore more expensive as well.

One other caveat here is before making these generally available, I would appreciate it if any 'early adopters' would be willing/able to program these with new firmware versions, in the event there's a problem. I am the only one that has used any of this, and I don't claim to write bug-free code. :) I've also only tested with the keyboards and mice I have on hand, and with the machines I've got. There may be timing differences between manufacturers/models, as well as timing differences with macs in different configurations (OC'd machines, accellerators?). I don't know if there is or not, just calling out the risks. There is no extra hardware required to program these boards, but it does require openocd. I currently use a Linux development environment with openocd, and there are instructions (linked earlier) on how to get it. Once installed, I can provide scripts to program new software into it, but I recognize this is a barrier for some. Perhaps an enterprising Linux hacker could package up a virtual machine with everything ready to go?

If anyone really really wants one of these but can't get the programming environment setup, I'm still more than happy to provide what I've got. I just want to make sure everyone knows what the situation is.

The process I've been using for all this stuff is something along the lines of: get some software working using hacked up cables and stuff just to understand what is possible, and what I need from a PCB. Then order the components I'll be putting on the PCB, so I have some idea of the connector layout, spacing, sizing, etc. Then make up a PCB. I'm using OsmondPCB that trag recommended some time ago. Then send the PCB off to be manufactured. This takes about 3 weeks before I get the boards. Then, I've probably made a mistake, fix it, and send off to have another batch of PCBs made, and wait another 3 weeks. Then once I get a PCB and all the connectors actually fit on it (connector sizing & spacing has been a problem for me), I work through the remaining software issues.

This isn't exactly a fast process, nor is it a cheap one. It's taken me pretty much all summer to get the PCB for the PS2 to pre-ADB working ok, and I still have the DB9 pins backwards. Plus, there's a difference between designing something for myself and for what other people want. This is why I'm asking if there's any real interest, and which of these is more interesting to people. I've tried to lay out the costs, tradeoffs, effort, and timeframe involved in some of this, to let people provide informed input.

I'm willing to donate my time and code to the project, but the cost of materials and shipping I can't do much about. I've already made the Osmond PCB file available for the PS2 to pre-ADB board available, as well as the code. If someone wants to assemble the boards themselves, or produce the boards on their own, by all means go for it. I'll do what I can to help. This is a hobby, I'm not in it for the money. That also means all of this is done in whatever free time I have. Please keep in mind that means all of it is a free time activity: PCB design, coding, troubleshooting, locating parts, shipping, ordering, helping folks, etc.

Also, when thinking about which of the above, if any, is interesting, keep in mind the following:

1) Many USB keyboards and mice support PS2 with a passive adapter. I currently prefer an MS Intellimouse, which is optical, and is usb with PS2 support through a passive adapter.

2) The Gee Three PS2 mouse to ADB adapter is still for sale. I have 2 of these and they're great. My PS2 to ADB adapter could support both mouse and keyboard and be maybe $5 less in parts, but the Gee Three has a much cooler form factor, a nice case, etc. Mine's bare PCB all the way around. If all you're interested in is a PS2 mouse to ADB, this would be the way to go, I think.

3) The old NTI KVMs I mentioned in this thread do PS2 to ADB (as well as Sun) conversion for both keyboard and mouse. If you're looking for a KVM solution, you might be better off with one of these.

Anyway, sorry for the long post. I'm just having fun hacking away on this, which is neat for me, but doesn't really help anyone else. It'd be great if some of my hacking helped someone else, I'm just curious which if any, other people think is most important or interesting. I've gotten zero inquiries on the PS2 to pre-ADB boards. I'm not sure if that's because it's not interesting, or if programming updates is too hard, or if I'm just not presenting it right.

 
Top