xatkey
XT and AT keys on USB: open-source firmware and tools that connect vintage IBM-style keyboards (PC/XT, AT, PS/2 and 122-key terminal keyboards with 5-pin DIN, mini-DIN or terminal connectors) to USB, with a text config language for remapping, layers, macros and switchable config sets.
- Firmware for ATmega32u4 boards (Teensy 2.0, Pro Micro), written in C with LUFA. Data on PD0, clock on PD1, keyboard reset on PB7 (Teensy) or PB6 (Pro Micro). See docs/wiring.md.
- Protocols: XT (IBM two-start-bit and clone one-start-bit framing, soft and hard reset), AT/PS2 scan code set 2 with host-to-keyboard commands (reset, ID, LEDs, code set selection), terminal scan code set 3. The protocol is detected automatically, and keyboards can be hot-plugged.
- USB: a real boot-protocol keyboard (BIOS, KVMs), an NKRO keyboard, media and system keys, a debug console and a config interface.
- Host tool
xatkey(Python 3, no dependencies on Linux): compile, check, decompile, write, read back, diff, status, bootloader.
Quick start
tools/build.sh # firmware for both boards (podman)
# -> firmware/build/teensy2/xatkey_teensy2.hex
# -> firmware/build/promicro/xatkey_promicro.hex
tests/run.sh # unit tests + engine simulator (podman)
podman run --rm --network=none -v "$PWD:/src:Z" -w /src \
localhost/xatkey-toolchain tests/simavr/run.sh # firmware in simavr
cd host
python3 -m xatkey check my.conf # compile and show problems
python3 -m xatkey write my.conf # compile and write to the converter
python3 -m xatkey diff my.conf # compare with the converter's config
python3 -m xatkey status # protocol, keyboard ID, error counts
python3 -m xatkey listen # debug console
Flash the .hex with the Teensy Loader (Teensy 2.0) or avrdude
(avrdude -p m32u4 -c avr109 -P /dev/ttyACM0 -U flash:w:xatkey_promicro.hex
after a double reset of a Pro Micro). Once xatkey runs, xatkey boot
returns to the bootloader without pressing reset.
Documentation
- docs/design.md - architecture, detection, timing, USB
- docs/config-language.md - config reference
- docs/protocol.md - USB interfaces, config protocol, binary format, EEPROM layout
- docs/wiring.md - connectors and pins
- docs/comparison.md - comparison with the converter that inspired this one, the improvements and the research sources
Status
Built and tested without hardware: host unit tests, an engine simulator and the complete firmware running in simavr against simulated XT, XT-clone, AT and PS/2 keyboards. USB enumeration and real keyboards are not yet verified; see "Hardware verification" in docs/design.md.
Credits and licence
Prior art: the configuration language and wiring follow Soarer's Converter
(Soarer, geekhack/deskthority, 2010-2013), so its configs keep working
(details in docs/comparison.md). Protocol knowledge
comes from TMK's IBM PC keyboard converter and its wiki by Jun Wako, whose
frame-discrimination idea frame.c re-implements. USB uses the LUFA library
by Dean Camera (firmware/lib/LUFA, its own permissive licence).
xatkey is licensed under the GNU GPL, version 2 or (at your option) any later version; see COPYING.