Back to Technical Index
PC joystick port
Most PCs have a Gameport. Sometimes it is located on-board, some have extra controller cards, mot often it is part of the Sound card.
It might be interesting to know how this port functions, so you can build your own adapters etc.
Technical basics
The connector on the PC is a 15-pin-D-Sub-female, the Connector at the Joystick is a 15-pin-D-Sub-male.
Pin | Function |
1 | P5V |
2 | Button 1 |
3 | Axis 1 (Joystick 1-X) |
4 | GND |
5 | GND |
6 | Axis 2 (Joystick 1-Y) |
7 | Button 2 |
8 | P5V |
9 | P5V |
10 | Button 3 |
11 | Axis 3 (Joystick 2-X) |
12 | GND |
13 | Axis 4 (Joystick 2-Y) |
14 | Button 4 |
15 | P5V |
The Hardwarebook states that pin 10 is for button 4 and pin 14 for button 3 - this is a mistake.
So basically the port has 4 axis and 4 buttons.
You can connect two joysticks to the port (with an adapter). Then each Joystick gets two axis and two buttons (axis 3 and 4 plus button 3 and 4 are mapped to
second player axis 1 and 2 plus button 3 and 4). So when you play with 2 players, no player has more than 2 buttons.
If only one joystick is connected it can use all 4 axis and buttons. Normally the first axis is used for x-movement and the second for y-movement. The third
axis can be used for throttle, steering wheel or something.
The electrics
When a button is pressed, the corresponding wire gets connected to GND.
The axis are analog values. They are represented by the resistor value between P5V and the corresponding pin (e.g. 3 for x-axis). If the resistor value
is unlimited (no connection at all) the joystick is regarded as not connected. A resistor value of 0 (full contact) is considered to be completely left (or up),
a resistor value of about 100 kOhm is considered to be completely right (or down). Any value in between is considered to be a partial push into the direction.
If the joystick is centered, the resistor value should be about 50 kOhm.
Digital gamepads don't produce the values in between, they only deliver 0, 50 or 100 kOhm.
Basically you can build your own Joystick with two resistors (better variable resitors) and some switches. I linked a page with some more information about this.
Non-Standard
Of course, whenever there is a standard, there are people modifying it for their purposes. I won't talk about the joysticks that have an additional USB or
Serial connection. I only want to look at joysticks using the standard 15 pins, here.
- Coolie-Hat (A digital mini-stick for changing perspektive or so).
There are several ways of implementing this.
In case the rest of the joystick only uses 2 axis you can use the remaining two axis for the hat (as digital joystick)
If you have one axis left, you can divide it into several areas, each representing a certain Coolie-Hat-direction.
One site in the internet states, that he axis is divided into 4 parts. I rather believe it is 5 parts (one for no direction pressed). Even better would be 9 parts
so that the diagonals can be used, too.
Sometimes the directions of the coolie hat are signalled as several buttons pushed at once. Unfortunately that means that you can't push more than one
button in normal gameplay.
- Additional Buttons
If there are additional buttons, they can be implemented with dividing spare axis into parts and each part (resistor value) represents
a certain button pressed (like with the coolie-hat).
Like with the coolie hat, those additional buttons can also be mapped to certain button combinations that are ignored when pressed normally
Of course, these non-standard Connections require special drivers.