Figure 1   Components of DirectX 5.0

Component Purpose
DirectDraw High-speed 2D graphics
DirectSound Low-latency sound output
Direct3D High-speed 3D graphics
DirectInput Game-oriented access to joysticks and other input devices
DirectSetup Convenient installation of DirectX components
DirectPlay Game-oriented communication and networking support
DirectShow Video streaming support
DirectAnimation Animation playback support


Figure 2    DirectInput Objects

Object Description
DirectInput Encapsulates high-level DirectInput functionality, and allows you to enumerate devices and create DirectInputDevice objects.
DirectInputDevice Interface to a physical input device, such as a joystick. It includes interfaces allowing you to gather state information about the device, set information for the device, and create DirectInputEffect objects (for force feedback devices).
DirectInputEffect Encapsulates a single effect that can be "played" on a force feedback device. Provides functions to start, stop, and setup force feedback effects.


Figure 3   The IDirectInput Interface

Member Function Description
CreateDevice Creates a DirectInputDevice object and returns a pointer to its IDirectInputDevice interface.
EnumDevices Calls a callback function for every device found that matches the given criteria. Provides the callback function with a GUID that can be used in calls to CreateDevice to create DirectInputDevice objects.
GetDeviceStatus Allows an application to tell if a physical device is attached to the system.
Initialize If a DirectInput object is created using CoCreateInstance, then the Initialize member must be called before it is used. If DirectInputCreate is used to create the object, then it has already been initialized.
RunControlPanel Runs the Windows Control Panel applet for devices. This will allow the user to install a new device or change the configuration of an existing device. Joystick calibration can be done here.


Figure 4    Defines for Enumerating Input Devices

The following defined values can be passed to EnumDevices to choose which type of input device to enumerate. Subtypes are also supported. See the documentation for the DIDEVICEINSTANCE structure in the SDK.
Value Descriptor
DIDEVTYPE_MOUSE Enumerate mouse devices (standard, trackball, and so on)
DIDEVTYPE_KEYBOARD Enumerate keyboard devices (standard, keypads, and so on)
DIDEVTYPE_JOYSTICK Enumerate joystick devices (joysticks, steering wheels, rudders, and so on)
DIDEVTYPE_DEVICE Enumerate other devices


Figure 5    DirectInput Effect Types

GUID Description Usage Notes
GUID_ConstantForce A constant pull in a given direction at a set strength. Use the DICONSTANT force structure as the type-specific portion of the DIEFFECT structure to implement a constant force.
GUID_CustomForce An array of constant forces downloaded to the device, to be played in sequence. The DICUSTOMFORCE structure is used for custom forces.
GUID_Damper A condition effect that increases with the movement along an axis. Type-specific structure required to implement this effect is the DICONDITION structure. Condition effects don't usually support envelopes.
GUID_Friction A condition effect that describes resistance to movement along an axis. Type-specific structure required to implement this effect is the DICONDITION structure. Condition effects don't usually support envelopes.
GUID_Inertia A condition effect that increases with the acceleration of movement along an axis. Type-specific structure required to implement this effect is the DICONDITION structure. Condition effects don't usually support envelopes.
GUID_RampForce A pull in a given direction that increases or decreases in magnitude linearly. The DIRAMPFORCE structure is used for the type-specific portion of the DIEFFECT structure.
GUID_SawtoothDown A periodic effect that goes full force instantaneously, and then linearly decreases to minimum force. Type-specific structure required is the DIPERIODIC structure.
GUID_SawtoothUp A periodic effect that goes from minimum to full force linearly, and then drops to minimum force instantaneously. Type-specific structure required is the DIPERIODIC structure.
GUID_Sine A periodic effect whose force follows a sine wave. Type-specific structure required is the DIPERIODIC structure.
GUID_Spring A condition effect whose strength increases with the relative distance from a defined neutral point. Type-specific structure required to implement this effect is the DICONDITION structure. Condition effects don't usually support envelopes.
GUID_Square A periodic effect that switches between maximum and minimum forces instantaneously. Type-specific structure required is the DIPERIODIC structure.
GUID_Triangle A periodic effect that linearly moves between maximum and minimum force values. Type-specific structure required is the DIPERIODIC structure.


Figure 8    DXInput.cpp Functions

Member Function Description
InitDirectInput Sets up the DirectInput object and the DirectInputDevice object for the system keyboard.
EnumJoy The callback function for device enumeration. This function creates a DirectInputDevice for the first joystick installed on the system.
InitForceFeedback If the joystick found is force feedback-compliant, this function does some setup for force feedback effects.
InitRampEffect, InitBumpEffects, InitWavyEffect These functions set up one effect each. These effects illustrate several of the different possible effects for DirectInput and should be useful in creating new effects.