Microsoft DirectX 8.1 (C++) |
Microsoft® DirectInput® is an API for input devices including the mouse, keyboard, joystick, and other game controllers, as well as for force-feedback (input/output) devices.
This topic provides a brief overview of the capabilities of DirectInput and how to set it up in an application. It includes the following:
For a more comprehensive view of how DirectInput works, see Understanding DirectInput.
For a step-by-step guide to using the DirectInput application programming interface (API), see the following topics.
Apart from providing services for devices not supported by the Microsoft® Win32® API, Microsoft DirectInput® gives faster access to input data by communicating directly with the hardware drivers rather than relying on Microsoft Windows® messages.
DirectInput enables an application to retrieve data from input devices even when the application is in the background. It also provides full support for any type of input device, as well as for force feedback.
Through action mapping, applications can retrieve input data without needing to know what kind of device is being used to generate it.
The extended services and improved performance of DirectInput make it a valuable tool for games, simulations, and other real-time interactive applications running under Windows.
DirectInput does not provide any advantages for applications that use the keyboard for text entry or the mouse for navigation. For more information, see Interaction with Windows.
This topic is an overview of what is involved in setting up and using Microsoft® DirectInput® in a simple application.
For details and examples of these steps, see Using DirectInput and DirectInput C/C++ Tutorials.
Note To understand DirectInput, it is essential to understand the following terms.
The following steps represent a simple implementation of DirectInput in which the application takes responsibility for ascertaining what device object (button, axis, and so on) generated each item of data.
This is not the only approach to implementing DirectInput. To take advantage of the great variety of input devices available now and later, and to simplify configuration for the user, you can use action mapping.
By setting an action map for a device, you let DirectInput decide which device object to use for each application action. For example, instead of specifying that the throttle in your racing game must always be controlled by the y-axis, you can create an action called AXIS_THROTTLE and have DirectInput assign that action to the most appropriate axis available on the device. When you retrieve events, you identify them by their associated actions rather than by the device objects that generated them.
For more information, see Action Mapping.