geekhack Projects > Making Stuff Together!

ADB to USB keyboard converter

(1/216) > >>

hasu:
I needed a ADB to USB keyboard converter to test a feel of ADB keyboards on actual usage. After 2days coding and several hours debug, I made this converter based on my keyboard firmware. If you are interested in ADB keyboard converter, try this.



You can buy preassembled TMK ADB-USB converter here


Keymap Editor
You can edit keymap and download firmware with web browser.

TMK ADB-USB converter rev2(ATMega32u2)
TMK ADB-USB converter rev1 and converter with Teensy2.0 or ProMicro(ATMega32u4)

In the Keymap Editor physical key layout is based on Apple Extended Keyboard(AEK) but you can edit keymap of any other ADB keyboards.  For example when you want to edit arrow keys on M0116 you can just change them on the Keymap Editor. The key layout of M0116 is physically different but logically identical to AEK.


README FIRST
https://github.com/tmk/tmk_keyboard
https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb

and optionally,
https://github.com/tmk/tmk_keyboard/wiki
https://github.com/tmk/tmk_keyboard/labels/NOTE


NEED HELP: Your self-made converter doesn't work?

Don't ask help before trying pull-up resistor(1K Ohm) and trying solder on J1!

You are cheap and got Pro Micro from unreliable source, instead of Sparkfun? OK, but confirm it has 16MHz crystal. And probably you need to fill solder on jumper J1 to feed keyboard good power supply 5V if you are in trouble and J1 is not soldered yet. See this post and schematic.

In most cases your wiring is wrong. Check your wiring yourself again and again, one hundred times! And try swapping wires at your own risk, note that your wiring are already wrong at this point probably :D It won't break your keyboard unless you are extremely unlucky.

Now you need help? OK. If you are not sure about your wiring, post pics of your hardware and wriring this really save our time. Don't save your time by omitting this. Shots of controller side and ADB connector/keyboard side would be helpful. If you edit code post your code. Don't hesitate to show your dirty code! Also output from hid_listen command would be useful to debug hardware and firmware.

[rant]
Many people said they are sure their wiring was fine first but it became clear they failed to do that in the end many times in this thread :( Don't omit pull-up resistor with your laziness, you better have it absolutely.
Don't take advantage of generosity of kind and helpful members(yes, including me, of course  ;))! Their time is more precious than your time, use your time to learn and look into your problem first.
[/rant]



DEBUG
You can use hid_listen to see debug prints.

Debut Outputs
RRR
The "R" on debug output means that the conveter didn't get any respnse to a command within specific term(500ms).
https://github.com/tmk/tmk_keyboard/blob/66e97371bacb1ad55096f0407b47f0a73fadc6c7/tmk_core/protocol/adb.c#L160-L164

This happens when connecting keyboard with converter already powered(hotplug/hotswap) because keyobard can't response to the converter during its startup. It is not error in this case. But in many other cases the "R" means that there is something wrong on your converter, keyboard or wiring setup.



UPDATE
2012/12/12 Extended keyboard support by blargg
2013/04/08 Fix issue: ADB-USB converter misses keystrokes (NOT FIXED COMPLETELY)
2013/07/22 Changed Pin usage: PD0, NOT PF0 now
2013/10/11 WIP: Fix ADB-USB converter misses keystrokes
2013/11/28 Fix key drop problem finally Thank you, blargg!
2015/04/28 Mouse is supported by mek-apelsin
2015/12/18 Request for help: extended mouse support
2016/06/04 Added LIMITATION section
2016/06/04 Apple Adjustable Keyboard media keys are supported now
2016/09/03 Keymap editor(unimap) is available now
2018/01/19 Fix lag problem on ADB-USB converter
2019/06/23 Added Apple Extended Mouse Protocol and Kensignton Turbo Mouse support
2020-02-13 Updated firmware to fix AEK support
2021-01-24 Change default mapping for 'keypad ='

LIMITATION
- Hotplug/Hotswap of keyboard is not fully supported, you will have to connect keyboard with the converter first, then plug-in USB port. You can hotplug/hotswap mouse, though.




SOURCE CODE
https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb


BUILD FIRMWARE
https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md

Use 'make' to build firmware for TMK ADB-USB converter rev.2.
Use 'make -f Makefile.rev1' to build firmware for TMK ADB-USB converter rev.1, Teensy2.0 or Pro Micro.

You are recommended to use Keymap Editor above, instead build yourself.


BUILD CONVERTER YOURSELF
You can use PJRC Teensy or other dev board with ATMega32U4/2.


--- Code: ---ADB female socket from the front:
  ,--_--.                 
 / o4 3o \      1: DATA
| o2   1o |     2: Power SW
 -  ===  -      3: VCC
  `-___-'       4: GND

--- End code ---

Connect keyboard DATA line to PD0(Pin3 on Pro Micro),  VCC to 5V(VCC on Pro Micro, not RAW) and GND as well. Power SW is not used.


pull-up resistor
You must have an external pull-up resistor(1K Ohm) between VCC(5V) and DATA(PD0) line.

1K ohm is strongly recommended.
You may use 4.7K, 10K or any of 1K-10K Ohm resister, if you don't have 1K in hand. It won't work with longer curled cable or daisy-chained multiple devices.  See this issue. https://github.com/tmk/tmk_keyboard/issues/683


--- Code: ---Keyboard       Conveter
               ,------.
VCC---------+--|VCC   |
            |  |      |
            R  |      |
            |  |      |
DATA--------+--|PD0   |
               |      |
GND------------|GND   |
               `------'

R: 1K Ohm resistor

--- End code ---
https://github.com/tmk/tmk_keyboard/wiki/FAQ#pull-up-resistor





AEK left/right modifiers discrimination, ISO layout and Adjustable keyboard media keys
To use these features you have to connect keyboard to the converter first before plug-in USB port.
Keyboard initilization needed for the features occurs only when the converter powers up with current firmware.

On ADB Standard keyboards left and right corresponding modifiers are logically indentical and can not be discriminated one another by the converter. This is ADB keyboard limitation, not converter's.
Apple Extended keyboard can discriminate them except for 'Command' key.



ISO keys
The ISO keys are supported. To let the converter recognize ISO layout correctly see above.

iMate and uKey have problem on some keys reportedly.
https://geekhack.org/index.php?topic=4185.msg61270#msg61270
https://github.com/randyrants/sharpkeys/issues/225#issue-537872871


Power key
In default configuration Power key works as 'Magic command' trigger key when it is held, or as Power when tapping.
https://github.com/tmk/tmk_keyboard#magic-commands

You may need to change thse line in config.h if 'Magic command' interferes with your keymap.
https://github.com/tmk/tmk_keyboard/blob/7b31d1b9d9f0d9c7d1e4b553e583381552cd8778/converter/adb_usb/config.h#L54-L57


Keypad =
The key is assigned to keycode 'EQL'(usual equal) on default keymap.

Note that keycode 'PEQL'(keypad equal) works on Linux and MacOS but doesn't on Windows. If you are on Windows you will need to use 'EQL'.



Locking CapsLock
Many of old ADB keyboards have mechanically locking switch for Caps lock and TMK supports them.
https://github.com/tmk/tmk_keyboard#mechanical-locking-support

Or you may want to remove locking pin from the push-lock switch to use it as a normal momentary switch.
http://www.youtube.com/watch?v=9wqnt2mGJ2Y

Caps lock key of Apple adjustable keyboard is not mechanical locking switch but it emulates locking switch behaviour. You will have problem when using the key as control, for example.


ADB protocol Resource
This is code for ADB protocol:
https://github.com/tmk/tmk_core/blob/master/protocol/adb.c#L301-L478



Extended mouse protocol support
- Kensington Turbo Mouse 5(by hasu)

Do you have other multiple button mouse to support? Check this issue on github and ask help in this thread.
https://github.com/tmk/tmk_keyboard/issues/274



TESTED DEVICES
- Apple Extended Keyboard M0115
- Apple Extended Keyboard II M3501
- Apple Standard Keyboard M0116, M0118
- Apple Adjustable Keyboard M1242
- Apple Desktop Bus Keyboard(Apple II GS Keyboard) 658-4081

- Apple Desktop Bus Mouse G5431(Taiwan)
- Apple Desktop Bus Mouse II M2706(Taiwan)
- Kensington Turbo Mouse 5 #64210


ISSUES
- Apple Desktop Bus Mouse II(M2706) assembled in Ireland doesn't work due to initialization failure. Meanwhile, M2706 assembled in Taiwan works.
https://geekhack.org/index.php?topic=14290.msg2873443#msg2873443
https://geekhack.org/index.php?topic=14290.msg2875515#msg2875515


OLD STUFF: MoreAnyway pull-up resistor is a must-have.
https://github.com/tmk/tmk_keyboard/issues/249


Key drop problem[SOLVED]
https://geekhack.org/index.php?topic=14290.msg1064567#msg1064567

Finally this was fixed due to blargg's contribution. 2013/11/28
https://geekhack.org/index.php?topic=14290.msg1134847#msg1134847
https://github.com/tmk/tmk_keyboard/pull/80
https://github.com/tmk/tmk_keyboard/issues/14


LIMITATION
- Apple adjustable keyboard keypad is not confirmed yet. Not sure if it works or not at this time. Confirmed finally!(2018 Dec)





lowpoly:
Hah, great.

Strange nobody replied. I thought the Griffin iMate was hard to get these days. The mod forum should have a better place in the forum overview, IMO.

Also, the iMate had issues with intl. 'boards.

So, Colemak converter for ps/2 'boards next? :-)

Soarer:
Neat. :)

I would like to add ADB support to my adapter in the future, but I have lots of other tasks to complete first! One of them is implementing a key remapping UI ;)

And I recently bought a couple of the Belkin ADB adapters, which work ok, at least on US layout. But it seems they are not generally available either :/

Findecanor:
Superb! How does it handle latching Caps Lock, though?

iMav:
Great job!  Love seeing this type of stuff.  How many days have you lost with your head down programming that teensy?  ;)

I may just have to pick up one of these and start playing as well.

Navigation

[0] Message Index

[#] Next page

Go to full version