## Virtual Device Driver Reference for OS/2

[prev][next][parent][TOC]

### Understanding How the Joystick Device Driver Works

The pre-emptive multi-tasking nature of OS/2 can cause DOS applications reading the game adapter port to deduce incorrect positions for the joysticks connected. The solution to this potential inaccuracy, implemented in the joystick device driver, is to regularly sample the game adapter port inside the Physical Device Driver (PDD) and then return fabricated values to the DOS application that reflect that state. With the logic for regular sampling already in the PDD, it is simply a matter of activating the procedure.

Before any of this can be initiated, however, access to the game port by the DOS application must first be trapped. Whenever I/O ports are to be trapped or emulated, an OS/2 Virtual Device Driver (VDD) is required. The VDD works in conjunction with the PDD to provide the device emulation. The VDD does this by capturing port reads and returning values that reflect the current state as determined by the PDD. The VDD is also responsible for determining whether a given virtual DOS machine (VDM) is to have direct access to the port and, if it is, for obtaining ownership of the VDM.