There are some nice emulators for vintage video games and computers out there, for example VICE for commodore hardware like the C64, but how do you connect old joysticks to your PC, like the Competition Pro (the original one, with 9-pin D-sub for an original C64, not the USB version) ? Most emulators provides joystick emulation with the cursor keys or other configurable keys. So this project is one solution for this problem: a Freescale microcontroller implements an USB keyboard and translates the up/down etc. buttons to keyboard events, like if you have pressed the cursor keys.
Programming the microcontroller and testing the joystick with WinVice and International Karate:
Some useful tools for this project:
Consumption items for soldering: soldering flux, solder, and desoldering wire. A cotton bud is useful for applying the soldering flux.
I recommend a good regulated soldering iron with a 1 mm tip for the SMD parts, like my i-CON 1. The easiest way to solder it is a stereo microscope, but magnifying glasses works, too. But with some practice, the SOP-20 IC needed for this project can be soldered without any magnifying.
The parts list:
C1, C2: 1 uF
C3, C4, C6: 100 nF
C5: 10 uF
IC1: MCP1703CB, Digikey MCP1703T-3302E/MBCT-ND, 0.52 €
IC2: MC9S08JS16L, Digikey MC9S08JS16LCWJ-ND, 0.92 €
IC3: 8 MHz crystal oscillator, Digikey CW515CT-ND, 2.20 €
R1, R2: 33 ohm
R3, R4: 1 k
R5: 1 k
RED-LED: 5 mm LED, 0.20 €
BLUE-LED: 5 mm LED, 0.20 €
S1: programming momentary button, Farnell 1550254, 0.88 €
S2: on/off switch
X1: USB connector, e.g. Farnell 1654060, 1.22 €
X2: sub-D, 9 pin, e.g. Farnell 1653939, 0.33 €
Some of the parts:
For the momentary button I like this type, stable and nice to press:
The mini USB connector:
For the PCB I have used the type with soldering points on one side, you can get it cheap at eBay:
For connecting the USB connector, I have soldered thin wire, 0.4 mm silver-plated copper wire, and for mounting the USB stick I have soldered thick wire, 1 mm silver-plated copper wire, which I soldered at the four outer contacts of the USB connector, which is pretty stable.
For the SMD IC you can get cheap adapters from eBay:
So without the wire coils, in sum you can build it for less than 20 €.
The finished board:
Full setup with Joystick and USB cable connected:
Eagle: joystickadapter.sch
Freescale provides a free IDE, CodeWarrior Development Suite - Special, which is limited to 32 kB, but the chip has only 16 kB anyway, so this is no problem. The microcontroller has an integrated bootloader, so no programmer is required, just the "BOOTLOADER_GUI" from here.
firmware.zip containts the project file for Code Warrior and all sources. It is based on the keyboard example from the Freescale USB Stack. You can change the switch detection for other types of joysticks in main.c and the key event generation in keyboard.c. The HID protocol is not based on key-press and key-release events, but you have to fill the HID buffer each time it is called with the scancode of all keys currently pressed.