Skip to content
hasu@tmk edited this page Oct 14, 2024 · 71 revisions

NeXT Keyboard Converter

With this converter you can use NeXT Keyboard non-ADB on modern computer.

For NeXT Keyboard ADB see TMK ADB Converter, instead.

TMK Prebuilt Converter

You can support this project by buying prebuilt TMK NeXT Keyboard Converter.

https://geekhack.org/index.php?topic=72052.0

TMK NeXT Keyboard Converter supports NeXT mouse preliminarily. It should work somewhat. But I don't have NeXT mouse to test and mouse movement direction is still unclear to me especially. Let me know your result if you have one.(2024-10)

Souce Code

https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb_ng

Keymap Editor

You can remap keys with Keymap Editor for prebuilt TMK NeXT Keyboard Converter.

http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?next_usb_ng

See this page for other variants and information.

https://www.tmk-kbd.com/tmk_keyboard/editor/

NeXT Keyboard Protocol

Signal

It is UART with 18958.3333baud(= 455kHz / 24) and its pulse width is 52.7472us.

Frame

UART 11-bit frame: 1-start bit(0), 9-data bit(lsb-first), 1-stop bit(1)

____   ______________________
    \_/_________________/
     S 0 1 2 3 4 5 6 7 X T
S: start bit
T: stop bit
X: 9th data bit

'X'-bit or 9th data bit is typically used as address/control flag to differentiate between data and address/control byte in 'multidrop' bus application(master and multiple slaves). NeXT keyboard protocol is also defined in accordance with this convention apparently.

Some UART engines and libraries have 9-bit data and/or address bit support. You will be able to use them to implement the protocol, in that case address should be 0 in converter.

Confirmed that on 'SET_LED' command interval between first and second byte can be prolonged. This also indicates the command is consisted of two 9-bit data, not one long bit sequence.

Responses

Keyboard to Host

No event

0x100, 0x100

Keyboard replies with this to keyboard/mouse queries when it has no data to be sent.

____                   ___                   ______       
    \_________________/   \_________________/        
     S 0 1 2 3 4 5 6 7 X T S 0 1 2 3 4 5 6 7 X T

This can be interpreted as two 'address 0' from the viewpoint of UART multidrop convention.

KEYBOARD events

Response to QUERY_KEYBOARD command

 ____   _______________   _   _______________   ____
     \_/_______________\_/ \_/_______________\_/
      S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

0-6: keycode   / F: 0 when key is pressed, 1 when released
a-g: modifiers / h: 0 when modifier state is changed, 1 when not changed

Modifier state: 0(off), 1(on)
    a: Control
    b: L-Shift
    c: R-Shift
    d: L-Command
    e: R-Command
    f: L-Alt
    g: R-Alt

Key only event

0x0KK, 0x080

Key with no modifiers

 ____   _______________   _                 _   ____
     \_/_______________\_/ \_______________/ \_/
      S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

Key event with modifiers

0x0KK, 0x0MM

Note that modifiers state is not changed(h=1)

 ____   _______________   _   _______________   ____
     \_/_______________\_/ \_/_______________\_/
      S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

Modifiers only event

0x080, 0x0MM

No other key is pressed

____                 _   _   _____________     ____
    \_______________/ \_/ \_/_____________\___/
     S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

Modifiers with key pressed

0x0KK, 0x0MM

when modifiers is changed with a key already pressed

 ____   _____________     _   _____________     ____
     \_/_____________\___/ \_/_____________\___/
      S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

Modifiers with keycode released

0x0KK, 0x0MM

when modifiers is changed with a key released. This cannot seem to be happened.

 ____   _______________   _    ____________     ____
     \_/_______________\_/ \__/____________\___/
      S 0 1 2 3 4 5 6 F x T S a b c d e f g h x T

MOUSE events

Response to QUERY_MOUSE command

____   _______________   _   _______________   ____
    \_/_______________\_/ \_/_______________\_/
     S L 0 1 2 3 4 5 6 x T S R 0 1 2 3 4 5 6 x T

      L: Left Button        R: Right Button
      0-6: X-movement       0-6: Y-movement

This code indicates that NeXT mouse movement direction is inverted in both X and Y axis comparing to HID mouse.

MOUSE button event

0x10l, 0x00r

without no movement

____   _                 _   _                 ____
    \_/_\_______________/ \_/_\_______________/      
     S L 0 1 2 3 4 5 6 x T S R 0 1 2 3 4 5 6 x T

MOUSE move event

0x1xx, 0x0yy

with button state being retained

____   _______________   _   _______________   ____
    \_/_______________\_/ \_/_______________\_/
     S L 0 1 2 3 4 5 6 x T S R 0 1 2 3 4 5 6 x T

MOUSE two buttons depressed with no movement

0x000, 0x000

Note that this is just difrent from no event at 'x' bit.

____                     _                     ____
    \___________________/ \___________________/
     S L 0 1 2 3 4 5 6 x T S R 0 1 2 3 4 5 6 x T

Commands

Host to Keyboard

QUERY_KEYBOARD

0x110

____           _       ____
    \_________/ \_____/
     S 0 1 2 3 4 5 6 7 X T

SET_LED

0x100, 0x00?

____                   _____   ___               __
    \_________________/     \_/___\_____________/
     S 0 1 2 3 4 5 6 7 X T   S L R 2 3 4 5 6 7 x T

L: Left LED
R: Right LED
LED state: 0(off), 1(on)

RESET

0x1EF, 0x000

____   _______   ___________                     __
    \_/       \_/           \___________________/
     S 0 1 2 3 4 5 6 7 X T   S 0 1 2 3 4 5 6 7 x T

QUERY_MOUSE

0x111

____   _       _       ____
    \_/ \_____/ \_____/
     S 0 1 2 3 4 5 6 7 X T

References

Keyboard Scan code

Scan codes below are used in keyboard event response.

,---------------------------------------------------------. ,-----------. ,---------------.
|Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS | |VUp|Pwr|BrU| |`  |  =|  /|  *|
|---------------------------------------------------------| |-----------| |---------------|
| Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \| |VDn|   |BrD| |  7|  8|  9|  -|
|---------------------------------------------------------| `---'   `---' |---------------|
| Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return|               |  4|  5|  6|  +|
|---------------------------------------------------------|     ,---.     |---------------|
| Shift  |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|  Shift |     |Up |     |  1|  2|  3|   |
|---------------------------------------------------------| ,-----------. |-----------|Ent|
|Alt  |Cmd  |              Space              | Cmd | Alt | |Lef|Dow|Rig| |      0|  .|   |
`---------------------------------------------------------' `-----------' `---------------'

,---------------------------------------------------------. ,-----------. ,---------------.
| 49| 4A| 4B| 4C| 4D| 50| 4F| 4E| 1E| 1F| 20| 1D| 1C|  1B | | 1A|*58| 19| | 26| 27| 28| 25|
|---------------------------------------------------------| |-----------| |---------------|
| 41  | 42| 43| 44| 45| 48| 47| 46| 06| 07| 08| 05| 04| 03| | 02|   | 01| | 21| 22| 23| 24|
|---------------------------------------------------------| `---'   `---' |---------------|
|  *57 | 39| 3A| 3B| 3C| 3D| 40| 3F| 3E| 2D| 2C| 2B|  2A  |               | 12| 18| 13| 15|
|---------------------------------------------------------|     ,---.     |---------------|
|   *56  | 31| 32| 33| 34| 35| 37| 36| 2E| 2F| 30|   *55  |     | 16|     | 11| 17| 14|   |
|---------------------------------------------------------| ,-----------. |-----------| 0D|
| *52 | *54 |              38                 | *53 | *51 | | 09| 0F| 10| |    0B | 0C|   |
`---------------------------------------------------------' `-----------' `---------------'
*: pseudo scan code

There are two variants for keyboard layout. Note that Return and \ key are different.

NeXT Keyboard non-ADB

Keyboard Pinouts

Socket on host

        _____
 GND  / 5   4 \  PSW 
FROM | 3     2 | TO
      |     1 |  VCC 
       `-----'
FROM: keyboard to computer
TO:   computer to keyboard
PSW:  Power key

Power key line is normally high and is pulled to ground when pressed. PSW pin is needed to detect Power key unlike ADB.

Wiring

Connections to ATmega32U2 for TMK NeXT Converter.

FROM(Pin3): PD0
TO(Pin2):   PD1
PSW(Pin4):  PD4
GND(Pin5):  GND
VCC(Pin1):  VCC

Mouse Pinouts

NeXT keyboard has socket for mouse on its back. NeXT mouse is a kind of bus mouse.

Mouse is plugged into keyboard and host queries to keyboard for mouse data.

Cable inside keyboard

+-----+
|Black|\
|Green|-\
|Yello|--\--------  to computer via Mini-Din 5 plug
|Orang|--/--------
|Red  |-/
|Brown|/
+-----+
Black:  FG
Green:  GND
Yellow: PSW(Power key)
Orange: FROM Keyboard
Red:    TO Keyboard
Brown:  VCC

Resources

Projects

NeXT Computer Keyboard to USB HID with CircuitPython: https://learn.adafruit.com/next-computer-keyboard-to-usb-hid-with-circuitpython

Keyboard Interface

  • NeXT Computer(N1000) have non-ADB interface on Display(N4000).

  • NeXTcube(N1000A) seems to have non-ADB interface on Display(N4000A).

  • NeXTstation seems to have ADB interface on SoundBox and Display.

  • NeXTstation Turbo(N1100)

  • NeXTstation Turbo Color(N1200)

  • SoundBox(N4004)

  • https://www.okqubit.net/machines/next.html

MegaPixel Display

Clone this wiki locally