Accessing the Joysticks

Please see disclaimer on main page

The standard PC joystick has a stick which can be moved on two axes, with the position on one axis being independent of the position on the other. When released the stick generally springs back to the 'center' position. The standard joystick also has two buttons with two states (pressed or released). A PC allows the connection of up to two joysticks through the use of two 'game ports'. Note that some PCs are not fitted with any game ports, and many have only one. Information on non-standard joysticks follows.

To read the joystick(s):

Output a dummy value to port 201h. Then continuosly poll port 201h, and the bits corresponding to each axis will eventually drop to 0; the time taken for each is relative to the position of the joystick (low time = up/left). The value returned will not be linear. Center is not necessarily dead halfway between top/bottom or left/right.

The buttons status can be found by examining the appropriate bits; a 0 value indicates a depressed button. No dummy byte need be sent in this case.

76543210
BB2BB1AB2AB1BAYBAXAAYAAX

The first letter (either A or B) indicates the joystick; The second letter (A or B) stands for 'Axis' or 'Button'. The third letter is either the axis (X or Y) or button number.

Note that the exact values for center & corners varies from joystick to joystick, computer to computer and port to port.

Information about non-standard joysticks follows:


Standard Four-Button Joystick

The third and fourth buttons can be read as joystick B buttons one and two. (This apparently only works on computers with two gameports anyway. On computers with only one game port, there is no way to access the value of the third and fourth button states).

Wingman Extreme

'Wingman Extreme' is a trademark of Logitech.

The WE has four buttons & a 'cooly' atop the stick. The cooly can be moved up, down, left or right, or may be centered. It is read as the 2nd joystick Y-Axis; approximate values (as returned by BIOS):

6up
33right
54down
91left
 
Values do vary on different reads (eg may return 7, 8, 5 for up) also different WE's / different ports will return different values (so the top switch ultimately requires calibration). Third and fourth buttons are read as 2nd stick button 1 & 2.

Gravis Gamepad

The Gravis Gamepad is a 8 direction pad with four buttons (layout below):

        |                  [2]
        |
   -----+-----         [1]     [3]
        |
        |                  [4]

The Gravis Gamepad is not really a joystick; the values returned for X/Y axis are not relative to the amount the pad is depressed, just whether a direction is depressed at all. To the programmer the Gamepad appears as a standard four button joystick.


Gravis Analog Pro

The Analog Pro is a Joystick with five buttons & a dial atop the stick. It is read as standard 4 button joystick; button 5 cannot be directly accessed (it is set by the user to have the same effect as one of the other four buttons). Throttle is read as Joystick B X-Axis.

               --1-2-
                \   |
                 3 -|
                 | |
                 | |
                 | |
            --4--+-+--5--
            +-----------+