kentie.net

Sun keyboard to USB converter

Note that a newer version has been released. This page still contains all relevant background info though.

See page 2 for a more in-depth description of how the converter works and its source code. The converter's USB communication is (heavily) based on Brad Minch's project 2 firmware, so my thanks go out to him.

converter prototype
The converter built as a PIC18F4550 based prototype setup.

After hearing positive things about Sun's old keyboards, and the Type 5 in particular, I decided to try and hook it up to a PC. Linux supports them via the serial port and there's a hard to build PS/2 and a half finished USB converter out there; for all compatibility, features and fun I decided to build my own USB converter. The converter should work with Type 4 keyboards too.

The converter offers the following features:

Unfortunately the converter has one big disadvantage: the volume and power keys aren't directly recognized as such (this would require implementing a composite USB device). Unix should be able to map commands to their keycodes though, and when put into their secondary mode they do send codes that Windows recognizes. An application such as Hoekey can then be used to assign functions to them. See special keys below for more information.

Hardware

converter schematic
The converter schematic - click for larger.

The ISCP connector is used to program the chip, see software below. If you have an socket-based PIC programmer you can leave it out. Some other comments on the schematic:

final converter
The finished converter, based on the smaller (but compatible) PIC18F2550... a PCB would have been nicer though. It has a number of extra components over the schematic: a reset and bootloader button (+ pull-up resistors) for easier further development, a LED to show that it's on, a jumper to choose between external and USB power and a small RC network for more stable programming (see the schematic notes). The pin header in the top left is the ICSP (programming) header, the bottom left header is USB, the bottom right one connects to the Sun mini-DIN connector.

Software

The software can be downloaded here. As far as programmers and software goes, I recommend the ICD2 in combination with MPLAB, or WinPic and a supported programmer. Also included is a version of the software for use with Microchip's USB bootloader. Setting up the bootloader is outside the scope of this document, but offers tons of advantages. The source code for the software can be found on the second page of this document.

Special Keys

The Sun keyboards have a number of keys that aren't present on a standard PC keyboard. These include the the volume, power, and 'Sun' keys (help, stop, again, etc). The converter emulates a Type 6 USB keyboard; it should work with Solaris without problems. Other Unix-like operating systems can be made te recognize the codes these special keys report too. Unfortunately, Windows doesn't report any virtual (=internal) key codes when these keys (except for power, but no function is mapped to its code) are pressed, making them unable to do anything. I haven't been succesful in getting the Sun, volume and power keys to be recognized as standard PC-style media/volume/power keys as found on many keyboards. To do this the convertor would need to be implement a composite USB device, which is something I have haven't gotten to work. Still, the keys can be made to work with Windows, see below.

There's also different styles of Sun keyboards: Unix style keyboard have the escape/tilde and control/caps lock pairs switched compared to PC keyboards. To further complicate matters a Sun keyboard has the modifier keys (alt,meta,etc) in other positions than a PC keyboard. Note that by default the meta and compose keys do work fine though, they report the same scancodes as the Windows and Application keys respectively.

To solve these two problems the adapter has the ability to switch some keys between two options. This allows the special keys to report scan codes that work with Windows (and can then be mapped to a function) and the modifier and style dependent keys to be changed to your preferred layout. To change a key's setting, just hold scroll lock and press the key. This will toggle between its two configurations. To reset all keys to their default values (Sun Type 6 style), hold scroll lock and press pause. For a list of keys, their alternatives, and the Windows scan codes the alternatives to special keys report, see this file.

Once a special key has been made to be recognized by Windows it still won't do anything useful, as Windows doesn't know what to do with the reported virtual key code. Software such as Hoekey can be used to map the keys' scan codes to useful functions. Here's the settings needed to let the keys work with Hoekey; I've set up some basic functions for most keys.

In conclusion, getting the special keys to work in Windows entails changing their mode (hold scroll lock and press the key to change) and using software to map the now recognized key to a function. With the provided Hoekey configuration this is a piece of cake. Some other keys can be changed to alternatives depending on your prefered layout.

Files

Special Sun keys, their various scan codes, and their alternative configurations
Sample HoeKey configuration
Sun keyboard converter compiled code

Page: 1 2 next ›

Created: Jun 22 2007
Modified: Dec 01 2010