A USB to Gameport joystick adapter implemented on an Arduino Nano (and any Arduino-compatible hardware).
Originally from "Built to Spec" [link] and modified to allow for different types of Gameport joysticks.
The test Gameport joystick (a CH Products joystick shipped with the iRobot Magellans) has two buttons and two axes. The two axes are wired through ADC0 and ADC1 on the Arduino in parallel with two 100kOhm pull-down resistors. The two buttons are wired through D2 and D3 on the Arduino in parallel with two 10kOhm pull-up resistors.
The following table shows the Gameport wiring:
PIN1 | +5VDC |
PIN2 | BTN0 |
PIN3 | AXS0 |
PIN4 | GND |
PIN5 | GND |
PIN6 | AXS1 |
PIN7 | BTN1 |
PIN8 | N/A |
PIN9 | +5VDC |
PIN10 | BTN3 |
PIN11 | AXS2 |
PIN12 | GND |
PIN13 | AXS3 |
PIN14 | BTN2 |
PIN15 | N/A |
The Arduino writes to the serial port (e.g., /dev/ttyUSB0) at 9600 baud using the following protocol (format):
$ARDJOY,TIME,BTNC,AXSC,BTN0,BTN1,...,AXS0,AXS1,...
BTNC and AXSC define the number of buttons and axes (up to 4 each).
In the future, the Arduino should advertise itself as a USB HID device, so that it becomes accessible through a joystick driver (as /dev/input/jsX).