Microsoft DirectX 8.1 (Visual Basic)

Understanding DirectInput

This topic covers the underlying structure of Microsoft® DirectInput® and its relationship to the Microsoft Windows® message system.

For practical information on how to implement the elements of DirectInput introduced here, see Using DirectInput.

DirectInput Objects

An input-only Microsoft® DirectInput® implementation consists of a single DirectInput8 object along with DirectInputDevice8 objects for each input device that is being used by the application. The DirectInputDevice8 object is used for retrieving the input data.

Any available device, regardless of whether it is being used by DirectInput, can also be represented by a DirectInputDeviceInstance8 object, which can be used to retrieve miscellaneous information about that device.

Each DirectInputDevice8 object represents one input device, such as a mouse, keyboard, or joystick. (The DirectInput API uses the term joystick for all game controllers other than a mouse or a keyboard.) A piece of hardware that is really a combination of different types of input devices, such as a keyboard with a touchpad, can be represented by two or more DirectInputDevice8 objects. A force-feedback device is represented by a single joystick object that handles both input and output.

Each device in turn has device objects, which are individual controls or switches, such as keys, buttons, or axes. Each device object is represented by an instance of the DirectInputDeviceObjectInstance class, whose methods can be used to retrieve information about the device object. (The input data, however, is always retrieved by DirectInputDevice8.)

Devices and device objects can be enumerated, and the resulting collections are represented by DirectInput8.GetDIDevices and DirectInputDevice8.GetDeviceObjectsEnum objects.

Force-feedback effects are represented by the DirectInputEffect class. Methods of this interface are used to create, modify, start, and stop effects.

Interaction with Windows

Because Microsoft® DirectInput® works directly with the device drivers, it either suppresses or ignores Microsoft Windows® mouse and keyboard messages. It also ignores mouse and keyboard settings made by the user in Control Panel. It does, however, use the calibrations set for a joystick or other game controller.

DirectInput does not recognize keyboard character repeat settings. When using buffered data, DirectInput interprets each press and release as a single event with no repetition. When using immediate data, DirectInput is concerned only with the present physical state of the keys, not with keyboard events as interpreted by Windows.

DirectInput does not perform any character conversion or translation. For example, the SHIFT key is treated like any other key, not as a modifier of another keypress. Keys return the same identifiers regardless of the user's system language settings.

Under Windows 2000, acquiring the keyboard in exclusive mode prevents any applications that are subsequently launched from receiving keyboard data.

Because DirectInput works directly with the mouse driver, it bypasses the subsystem of Windows that interprets mouse data for windowed applications. Applications that rely on the Windows cursor for navigation should continue to use the standard Windows mouse messages and Microsoft® Win32® functions.

When using the system mouse in exclusive mode, DirectInput suppresses mouse messages, and therefore Windows is unable to show the standard cursor.

DirectInput ignores Control Panel settings such as acceleration and swapped buttons. However, DirectInput recognizes settings in the driver itself. For example, if the user has a three-button mouse and uses the driver-utility software to make the middle button a double-click shortcut, DirectInput reports a click of the middle button as two clicks of the primary button.