Constructing a USB to Mac ADB keyboard adapter
Jan 13, 2024
QMK
ADB
Mac
Keyboard
Atmega32u4
Pro Micro
Electronics
A few 12 months in the past I began a brand new job as a Employees Engineer with a bigger FinTech. Loads of
upside, and I’m having fun with myself rather a lot, however the draw back is that I’m obliged to work on
a Mac. I sort of hate Macs. Not fairly as unhealthy as Home windows, however rattling I’m lacking Linux in
the office.
Notice: In the event you plan on following in my footsteps, do be aware that I did all of the work described right here
on my private Linux machine over a weekend – it’s solely the tip outcome that I used on the
precise work Mac
Nonetheless, this did give me an excuse to indulge my style for retro-computing by selecting up
an unique Macintosh Prolonged Keyboard II – this magnificence:
Partly I selected it as a result of it’s of the classic that I sometimes used throughout my last
12 months at college within the Mac lab – largely whereas coding up a reasonably hapless AI mission
in Macintosh Frequent Lisp (MCL).
Apple all the time did issues a bit in a different way, so whereas the IBM PC derived machines had
more-or-less standardised on the PS/2 based mostly connectors, Macs had their very own serial
bus system for keyboards and mice. The PC stuff and the Mac stuff each used a 4
pin DIN connector simply to make sure most confusion, and naturally they had been utterly
incompatible.
The good factor concerning the Apple system was that you can daisy chain it – and the keyboards
typically had a connector on each side, making a uncommon concession to lefties who may thus
join the keyboard on the precise and chain the mouse off of it on the left aspect of the
keyboard in the event that they selected.
By the way, when you had been in a whimsical pupil temper, you can additionally chain the entire
keyboards on a row of machines finish to finish leading to 5 – 6 machines utterly
unconnected from their keyboard and the one on the finish taking any and all enter from
the neighbours. Okay, it was sort of a dick transfer, however in a lab filled with IT college students it
wasn’t too imply a trick and no one was stymied for lengthy.
The previous connection system was referred to as “Apple Desktop Bus”
(ADB). Lately Macs are firmly USB oriented for his or her minor peripherals, so getting an old-skool
keyboard to speak to a spiffy trendy M1 Mac requires an appropriate adapter. There are a handful of
commercially accessible adapters, nevertheless it’s extra enjoyable to construct one thing and it’s the sort of
mission that’s truly inside attain of even my meagre electronics expertise.
The QMK Project is the idea for the gadget that I subsequently constructed – it’s
higher often known as a foundation for constructing customized keyboards, nevertheless it additionally incorporates some code for
constructing adapters. The wiring required is nicely documented within the README for the supply
folder for the adapter logic: https://github.com/qmk/qmk_firmware/tree/master/keyboards/converter/adb_usb
The ASCII artwork wiring diagram stolen from that’s:
ADB Socket from entrance:
,--_--.
/ o4 3o 1: DATA
| o2 1o | 2: Energy SW
- === - 3: VCC
`-___-' 4: GND
Keyboard Converter
,------.
5V------+------|VCC |
| | |
[R] | |
| | |
Sign--+------|PD0 |
| |
GND------------|GND |
`------'
R: 1K Ohm resistor
I feel I ended up utilizing a 4.7KΩ resistor – however I can’t keep in mind why. In all probability I noticed it in some on-line
directions someplace, however I’ve misplaced it now – my apologies to whichever reference I’m thus failing to
cite right here.
I picked up an inexpensive clone of a Pro Micro
board on Amazon. The unique and the clone are each based mostly round
the atmega32u4 and the pinouts are
an identical. The circuit consists of the board, a single resistor, and the DIN connector,
so there’s actually little or no to do.
The one “gotcha” value mentioning is that the PD0
pin talked about within the QMK documentation
corresponds to the D3
pin on the processor board, not the D0
pin as you may (I did)
assume initially.
Burning the firmware was truly (marginally) more durable than soldering all of it collectively! Nonetheless
you need to ignore the directions on the README for the adapter logic – that’s a bit outdated
and appears to be left over from the unique TMK origin
of the code. As an alternative, comply with the directions
outlined in the main QMK documentation:
After cloning the QMK repository domestically, the primary
steps had been truly to put in a qmk
python command independently of that:
python3 -m pip set up --user qmk
export PATH=$PATH:$HOME/.native/bin
qmk setup
Notice within the above that the .native/bin
listing isn’t, on Ubuntu, in your path by default as a consequence of
a long-standing Ubuntu bug. Operating the qmk setup
command will immediate you to put in all
the pre-requisites crucial for constructing the precise adapter logic.
With that full you’re good to go to construct the adapter-specific code from the foundation of the
checked out QMK repository:
qmk compile -kb converter/adb_usb -km default
The default
right here is the keyboard map – you possibly can alternatively construct and compile
in any bizarre mapping you select.
The results of the construct ought to be a file converter_adb_usb_rev1_default.hex
and
the following job is to get that loaded into the microcontroller.
Fortunately this requires no particular steps and all the things is auto-detected with the next
command:
qmk flash converter_adb_usb_rev1_default.hex
With the adapter logic flashed onto the microcontroller and all the things wired up, you need to
see the adapter present up within the USB gadget listing as QMK ADB to USB Keyboard Converter
:
dcminter@kanelbulle:~$ lsusb
Bus 002 System 010: ID 413c:81b6 Dell Laptop Corp. DW5811e Snapdragon™ X7 LTE
Bus 002 System 001: ID 1d6b:0003 Linux Basis 3.0 root hub
Bus 001 System 005: ID feed:0adb QMK ADB to USB Keyboard Converter
Bus 001 System 003: ID 8087:0a2b Intel Corp. Bluetooth wi-fi interface
Bus 001 System 002: ID 0bda:568c Realtek Semiconductor Corp. Built-in Webcam HD
Bus 001 System 004: ID 0a5c:5834 Broadcom Corp. 5880
Bus 001 System 001: ID 1d6b:0002 Linux Basis 2.0 root hub
A minor gotcha to say – I had quite a lot of preliminary hassle flashing the picture, however I finally
realised that this was as a result of the cable I used to be utilizing was rubbish. It got here with some low-cost crap
audio gadget and was apparently barely ok to make use of for charging and nothing else. All
my points went away after I swapped it for a great one!
I constructed my adapter on a little bit of veroboard and I needed to cover that away. A little bit of measuring
with calipers, some tinkering in Tinkercad, and sliiiightly extra do-overs as a consequence of my horrible
3D design expertise than I may need favored, and I had a design for a case to place all of it in:
I do know Tinkercad is the unsuitable device for the job, nevertheless it’s so fast to get
began even when it finally ends up taking longer. I swear I’ll study SolveSpace correctly
actual quickly now ™. I did have a go at studying FreeCad some time again, however that factor
is so buggy and inconsistent that TinkerCad looks as if the higher wager of the 2!
Anyway, with the design in hand and exported as an STL file I fired up Cura, pushed it
over to my 3D printer, and ran off the case
The tip outcome was a great match for the electronics – although I’m kicking myself for soldering
the DIN adapter on first and never after I’d selected the size of the case as a result of the
wires are all of the unsuitable size. I may unsolder and re-solder it, nevertheless it’s not fairly value
the hassle as it’s going to all be hidden from the attention. Listed below are the innards resting within the base
of the case:
You’ll be able to see there’s virtually nothing besides the microcontroller right here – a resistor and some wires with
all of the smarts being the pre-existing controller board. I used to be happy with the match of the
DIN connector although – it has a 1mm ridge that holds it securely in place and I received a
good match for this regardless of the required variability within the bodily output versus digital
enter.
The outcome, inline to the keyboard and bolted collectively, is respectably beige. If I
retro-bright the keyboard it might be a greater match for the shade, however I fairly take pleasure in
the legacy-discoloration of the keyboard.
Anyway, it labored out okay as I’m typing these phrases on the Apple
Prolonged Keyboard now!
Subsequent steps are to determine how (if) one can get an appropriate key mapped because the
operate key – although since I largely use it to modify between multimedia mode
and “pure” F1 to F12 keys, I can do with out it if crucial. In that case I’d
arrange for F-keys to be default and hit the laptop computer keyboard’s Fn key immediately after I
want the multimedia ones.
To date the one drawback I’ve is that … I don’t truly prefer it as a lot because the
trendy exterior keyboard that work equipped. We’ll see if it grows on me, however
constructing it was enjoyable so I contemplate myself amply rewarded regardless.