PC Gameport (Joystick) pinout

15 pin D-SUB female connector layout
15 pin D-SUB female connector at the computer

15 pin D-SUB male connector layout
15 pin D-SUB male connector

Nowadays the most common analogue joystick type is PC analogue
joystick. This joystick model was presented by IBM together with their
first IBM PC computer. The joystick is just a basic analogue joystick
with two buttons. The original joystick interface had circuit for
connecting two joysticks, but had only one joystick connector. A special
Y-cable was needed if there was need for two joysticks at the same
time. Later time some manufacturers put two connectors to their
interface card and some card manufacturers implemented only one joystick
input. Fortunately most of the card nowadays have option for two
joysticks like the original IBM joystick card.

The joystick interface card was designed to be as simple and cheap as
possible. The card consisted only of bus interface electronics and four
monostable multivibrators (all in on 558 chip). Those monostable
multivibrators were simple timer circuits which put out a pulse with
width directly proportional to the joystick resistance value. The pulse
width was then measured using software loop. This has caused anormous
amounts of problems to game programmers when computers have become
faster and faster all the time. On faster machines, the joystick routine
in the software does not read the joystick signal properly resulting in
a timing problems. Some dedicated joystick cards are designed to vary
the joystick signal so the software can properly detect the joystick and
process the data.

Pin Name Dir Description
1 +5V --> +5 VDC
2 /B1 <-- Button 1
3 X1 <-- Joystick 1 – X
4 GND --- Ground (for switch 1)
5 GND --- Ground (for switch 2)
6 Y1 <-- Joystick 1 – Y
7 /B2 <-- Button 2
8 +5V --> +5 VDC
9 +5V --> +5 VDC
10 /B4 <-- Button 4
11 X2 <-- Joystick 2 – X
12 GND --- Ground (for switch 3,4)
13 Y2 <-- Joystick 2 – Y
14 /B3 <-- Button 3
15 +5V --> +5 VDC or N/C

The joystick consists of two potentiometers with variable resistance
value between 0 Ohm and 100 kohm (in some joysticks up to 150 kohm). The
potentiometer resistances have the minimum values when the joystick is
at the top left position. One end of the potentiometer is connected to
+5V pin and the center pin is connected top the analogue input of the
joystick. The other end of the potentiometer is left not connected to

There are two commonly used ways how PC analogue joystick stick
mechanism is constructed. Some joystick convert the stick position to
linear motion, whcih then changes the position of the slider in about
100 kohm linear potentiometer. More popular construction is to use
normal axial potentiometers and the joystick movement directly turns
those potentiometers. Some joystick used special 100 kohm potentiometer
which can only turn that 60..90 degrees which joytick can turn. The more
common construction is to use the standard 470 kohm (lin) 270 degree
potentiomer and use about one fourth of the scale from the beginning (in
this way getting 0..120 kohm value range). Usually those potentiometers
are normal carbon slider potentimeters which do not last long in
intense gaming.

How PC joystick port hardware works

The joystick port is a very simple 8 bit I/0 card which resides in
ISA bus I/O address 201h. The CPU can read and write to the joystick
port I/O address 201h. Writing to that address starts joystick postition
measurement. Joystick interface only uses the signal that somebody is
writing to the I/O address to reset the multivibrators in the card. The
data value is not stored anywhere, so it is really same what value is
written to this address.

When you read one byte from I/O addess 201h, you get the status
information of the joystick interface. The following table will show how
the bits are mapped in the value you get.

 Game port 201h byte:
        |   7  |   6  |   5  |   4  |   3  |   2  |   1  |   0  |
        | but4 | but3 | but2 | but1 | stk4 | stk3 | stk2 | stk1 |

The four most significant bits tell you the state of the joystick
buttons. Four least significant bits tell the state of the
multivibrators which are used for measuring the resistance value of the
joytick position potentiometers. More accurate description of the bit
meanings can be found at the table below:

7 6 5 4 3 2 1 0
* . . . . . . .  Button B2 (pin 14), 0=closed, 1=open (default)
. * . . . . . .  Button B1 (pin 10), 0=closed, 1=open (default)
. . * . . . . .  Button A2 (pin 7), 0=closed, 1=open (default)
. . . * . . . .  Button A1 (pin 2), 0=closed, 1=open (default)
. . . . * . . .  Monostable BY (from pin 13), 1=timing, 0=timed-out
. . . . . * . .  Monostable BX (from pin 11), 1=timing, 0=timed-out
. . . . . . * .  Monostable AY (from pin 6), 1=timing, 0=timed-out
. . . . . . . *  Monostable AX (from pin 3), 1=timing, 0=timed-out

Resistive analogue inputs (joystick position)

Joystick position inputs are simply inputs where a variable 0-100
kohm joystick potentiometer is connected to. The potentiometers are
wired between the +5V power pin and one potentiometer input pin. The
following picture tries show how the wiring is done:

                +5      ________________
                stick1  ________        |
                                | 100K  |
                stick2  ________        |
                                | 100K  |
                stick3  ________        |
                                | 100K  |
                stick4  ________        |
                                | 100K  |


The resistance value of the joystick potentiometers are measured
using very simple monostable multivibrator circuit, where a small
capacitor is loaded through the joystick potentiometer to a certain
voltage level. The joystick interface has four of this type of
monostable multivibrators. Typically joystick interface multivibrators
are all in one 558 IC (that IC is like four simplified 555 type timers
in one IC) for two joystick ports and 556 (dual 555 timer) for one
joystick only port.

   Pot in  >---+
  (stick n)    |
       R1      /        ____________
       2.2K            |            |
               /       |            |>----------> data bit to ISA bus
               |       | Monostable |out
               +-------|   Multi-   |
               |       |  vibrator  |
       C1     ---      |            |<---------->write

NOTE: Reference design in Crystal Semiconductor CD4376B calls
recommends C1 to be 5.6 nF and R1 to be 2.2 kohm for their soundcard
reference design.

The multivibrator work on the following way:

  • 1. Normally on idle state the capacitor C1 is fully charged (5V) and multivibator output gives out logic 1.
  • 2. Computer writes to I/O address 201h to reset the
    multivibrators. The multivibrator get a triggger pulse from I/O write
    signal and it discharged capacitor C1. The multivibrator output goes to
    logic 0 because the capacitor is discharged (0V).
  • 2. The capacitor starts to charge form the current which goes through R1 and the joystick potentiometer.
  • 3. When the capacitor voltage reaches certain oltage threshold level, the multivibrator output goes back to logic 1.

The bigger the potentiometer resistance value is, the longer it takes
for the capacitor to reach the threshold voltage. The time how long it
takes for each multivibator to reach the logic 1 after the triggering is
measued using software and that value tells the resistance of the
potentiometer (and the stick position as well because the potentiometer
is connected to the stick). This simple method for measuring the
resistance value is quite cheap, but not very accurate.

This simple joystick port hardware implementation (originally
designed for 4.7 MHz IBM PC) causes many headaches to game programmers
(problems of different computer speeds, joycitck port differences,
problems in multitasking operating systems etc.). Big tolerances in
joysticks and joystick ports mean that the every game must have an
option to cablibrate the joystick (which actually means that the program
adapts to accept the values in th range which the joystick reading
routine does and then converts the values to its internal format using
the values measured in joystick calibration process).


Switch inputs (joytick buttons)

The joystick buttons are simple on/off inputs. Joystick button either leaves the pin floating or connect it to the ground.

                button1 ______o o_______
                              ___       |
                button2 ______o o_______|
                              ___       |
                button3 ______o o_______|
                              ___       |
                button4 ______o o_______|
                GND     ________________|





The state of the buttons is directly fed to the joystick interface
and through it to ISA bus data lines when somebody reads the joystick
interface I/O address. The buttons are very easily wired. Every input
has 1 kohm pull-up resistor R1 which ensires that the joystick button
pins stay in +5V potential (logic 1) when no button is pressed down.

                       / R1
   Joystick            |
   button in  >--------+-------------------------> data bit to ISA bus
  (button n)


NOTE: Reference design in Crystal Semiconductor CD4376B calls for 4.7
kohm pullup resistor and 1000 pF capacitor from input to ground.


None found.