← All spotlightsHardware / Input

Spotlight › Hardware

The joystick driver

The PC’s game port now has one driver that every program shares. You calibrate the stick once in the Control Panel, and each game that reads it gets the same corrected position.

The Joystick page, live
Recorded on MartyPC, an emulator of the IBM XT at 4.77 MHz, with a game port and a stick moved by a script. Shown in the machine’s own time. VGA at 640 by 480.
One reading on the XT
About 2 ms
Memory while loaded
About 11KB
Programs that read it
6

01 / What it is

What it is

IBM’s Game Control Adapter of 1981 put a 15-pin socket on the back of the PC for joysticks and paddles. Later sound cards and multi-I/O cards copied it, so most PCs of the period have one. A stick on that port is analog: each axis is a variable resistor, and the card reports a position as a length of time. A program starts a timer on the card, then counts how long each axis takes to settle. A stick pushed one way settles quickly, and pushed the other way it takes longer, up to about a thousandth of a second.

Until this release no os8088 program read the port. Each game would have had to time the axes itself, guess where the centre is, and ask the player to calibrate in its own way. JOYSTICK.DRV does that once for everyone. It times the axes, turns the counts into a position from -127 to +127 on each axis, and applies the calibration and dead zone you set on its Control Panel page. A program asks the driver for the position and the buttons, and never touches the port.

One port carries two sticks, through a Y-cable or a card with two sockets. The driver reads a 2-button or 4-button stick, two sticks, a flight stick with a throttle and rudder, and the hat switch of a CH FlightStick Pro or ThrustMaster FCS.

A stick for the game port
An illustration of a 1980s analog joystick: a wedge-shaped base with a tall stick and a round knob, a fire button on top of the stick and a second on the base, two small trim sliders, and a cable ending in a 15-pin plug.
An illustration, made with an image generator, not a photograph. The trim sliders set the centre by hand; the driver’s calibration does the same job in software.
Two sticks on one port
An illustration of two of the same joysticks whose cables meet in a Y-splitter ending in one 15-pin plug.
The port has four axes and four buttons, enough for two 2-button sticks. An illustration, not a photograph.

02 / On the screen

On the screen

Arkanoid, VGA
Arkanoid in a window on VGA, played with the stick. The score is 10, one brick is gone from the bottom row, the ball is in flight and the paddle sits where the stick put it. The Drive B games folder is behind it.
The paddle follows the stick’s left-right position, and button 1 serves the ball. MartyPC, VGA.
The compact page, CGA
The compact Control Panel on CGA with Joystick selected in its list. The dot is up and to the right, X +86 and Y -66, and button 1 is lit. Below are Type: 2-button stick, Dead zone 8% with minus and plus buttons, Invert Y and Swap A/B boxes, Calibrate and a greyed Reset, and the status Not calibrated and 2.1ms.
The same settings in black and white on a CGA screen, with the time one reading took. MartyPC, an IBM PC at 4.77 MHz.
Drivers, VGA
The Drivers page on its Input tab. USB Mouse and Olivetti PC1 Mouse are Off. Joystick is selected, Loaded, about 11K, with Start at boot ticked. The Details pane says Joystick, JOYSTICK.DRV, game port joysticks and paddles, set up once here and shared by every game.
The machine found the stick when it started and loaded the driver by itself. Nothing was ticked by hand. MartyPC, VGA.
The Joystick page, VGA
The wide Joystick page on VGA with the stick in the upper-left corner: X -127 and Y -127, button 1 lit green, the 2-button joystick type chosen, Dead zone 8%, Calibrate and Reset buttons, the status Stick A found, and the read time.
After calibration each corner reads exactly -127 or +127. A frame from the clip above. MartyPC, VGA.

03 / How it works

How it works

A reading switches interrupts off, starts the card’s timers and the PC’s own clock together, and watches the port until every axis the controller uses has settled, or 2.3 thousandths of a second have passed. The clock is read again only between short runs of port reads, so the moment an axis settles is seen within a few millionths of a second. An axis with nothing plugged into it is dropped from the next readings, so a missing second stick costs nothing. On the 4.77 MHz XT a whole reading takes between 1.1 and 2.2 thousandths of a second, and the page shows that time as it runs.

Calibration takes three steps: the stick to the upper left, then to the lower right, then let go to the centre, pressing a button at each. The driver keeps the counts it saw and works out each axis from them, with a dead zone around the centre so a stick at rest reads 0. Before you calibrate, it uses the first reading as the centre, so a stick already works on the first day. The settings are kept on the system disk and come back at the next start.

Buttons are counted as presses as well as read as held. A tap that falls between two of a game’s readings is still reported once, the way OS/2’s game port driver did it.

The driver loads only when a stick answers at start-up or you tick it, and takes about 11KB while it is loaded. The kernel itself grew by a few dozen bytes for it.

04 / Who reads it

Who reads it

WireBall and Arkanoid

The paddle goes where the stick points, as with a real paddle controller.

1942 and ARCADE

The stick steers in eight directions in 1942 and works as the cabinet’s stick in ARCADE. In 1942, button 1 fires.

The C64 and Apple II emulators

Built to pass the stick to their games, as the C64’s control ports and the Apple II’s paddles. This has not yet been tried with a stick on the emulated machine.

Every one of them

Keeps its keys. A stick adds a way to play; it never takes the keyboard away.

05 / What it does not do

What it does not do

Other programs do not see it as keys. A game that was not written for the driver does not move with the stick. Turning the stick into arrow keys for every program needs room in the resident system, and has not been decided.

DOS and Windows programs read the port themselves. They already do so on real hardware. The driver does not answer the AT BIOS joystick call or the Windows 3.1 joystick functions.

Not on every disk. The driver is on the 720KB, 1.2MB and 1.44MB system disks and the 286 system disks. The 360KB system disk had no room for it; copy JOYSTICK.DRV into its SYSTEM folder from another disk. The emulator disk and the 128KB system have no joystick, since the emulators they target have no game port.

06 / Set it up

Set up a joystick

  1. Plug the stick into the game port and boot a 720KB, 1.2MB or 1.44MB system disk. The driver loads by itself when the stick answers.

  2. If it did not, open Control Panel from the menu at the left of the menu bar, open Drivers, tick Joystick and press Load.

  3. Open the Joystick page, pick the controller type, and press Calibrate. Follow the three steps, pressing a stick button at each corner and at the centre.

  4. Close the panel to save, then start WireBall, Arkanoid, 1942 or ARCADE and play with the stick.