The semantics of version numbers are left to the manufacturer of the device. The only guarantee is that newer versions have larger numbers.
Applications do not typically need to create a
Applications that need to create a
The following code example sets a data format for a device that has an X-axis and a Y-axis:
// Suppose an application uses the following // structure to read device data. typedef struct MYDATA { LONG lX; // X-axis goes here. LONG lY; // Y-axis goes here. BYTE bButtonA; // One button goes here. BYTE bButtonB; // Another button goes here. BYTE bPadding[2]; // Must be DWORD multiple in size. } MYDATA; // Then, it can use the following data format. DIOBJECTDATAFORMAT rgodf[ ] = { { &, FIELD_OFFSET(MYDATA, lX), | , 0, }, { & , FIELD_OFFSET(MYDATA, lY), | , 0, }, { & , FIELD_OFFSET(MYDATA, bButtonA), | , 0, }, { & , FIELD_OFFSET(MYDATA, bButtonB), | , 0, }, }; #define numObjects (sizeof(rgodf) / sizeof(rgodf[0])) df = { sizeof( ), // Size of this structure sizeof(DIOBJECTDATAFORMAT), // Size of object data format , // Absolute axis coordinates sizeof(MYDATA), // Size of device data numObjects, // Number of objects rgodf, // And here they are };
Applications use the methods of the
Method | Description |
---|---|
Obtains access to the input device. | |
Builds an action map for the device and retrieves information about it. | |
Creates and initializes an instance of an effect identified by the effect globally unique identifier ( | |
Enumerates all the currently created effects for this device. | |
Enumerates all the effects supported by the force-feedback system on the device. | |
Enumerates all the effects in a file created by the Force Editor utility or another application using the same file format. | |
Enumerates the input and output objects available on a device. | |
Sends a hardware-specific command to the force-feedback driver. | |
Obtains the capabilities of the DirectInputDevice object. | |
Retrieves buffered data from the device. | |
Obtains information about the device's identity. | |
Retrieves immediate data from the device. | |
Obtains information about an effect. | |
Retrieves the state of the device's force-feedback system. | |
Retrieves information about a device image for use in a configuration property sheet. | |
Retrieves information about a device object, such as a button or axis. | |
Retrieves information about the input device. | |
Initializes a DirectInputDevice object. | |
Retrieves data from polled objects on a DirectInput device. | |
Runs the DirectInput control panel associated with this device. | |
Sends data to a device that accepts output. | |
Sends a command to the device's force-feedback system. | |
Sets the data format for a device and maps application-defined actions to device objects. | |
Establishes the cooperative level for this instance of the device. | |
Sets the data format for the DirectInput device. | |
Specifies an event that is to be set when the device state changes. | |
Sets properties that define the device behavior. | |
Releases access to the device. | |
Saves information about one or more force-feedback effects to a file that can be read by using EnumEffectsInFile. |
The
The LPDIRECTINPUTDEVICE8 type is defined as a reference to the
typedef struct*LPDIRECTINPUTDEVICE8;
For compatibility with DirectX 3, it is also valid to pass a DIDEVCAPS_DX3 structure with the dwSize member initialized to sizeof(DIDEVCAPS_DX3).
The number of objects returned in the
For compatibility with DirectX 3, it is also valid to pass a DIDEVICEINSTANCE_DX3 structure with the dwSize member initialized to sizeof(DIDEVICEINSTANCE_DX3).
If the method succeeds, the return value is
For compatibility with DirectX 3, it is also valid to pass a DIDEVCAPS_DX3 structure with the dwSize member initialized to sizeof(DIDEVCAPS_DX3).
The number of objects returned in the
If the method succeeds, the return value is
The
Applications should not rely on this method to determine whether certain keyboard keys or indicator lights are present, as these objects might be enumerated even though they are not present. Although the basic set of available objects can be determined from the device subtype, there is no reliable way of determining whether extra objects such as the menu key are available.
Predefined property that allows the application to access the information that DirectInput uses to manipulate axes that require calibration. This property exists primarily for applications of the control panel type. Normal applications should not need to deal with calibration information.
You can access the calibration mode property for a particular axis by setting the dwHow member of the
Control panel applications that set new calibration data must also invoke the IDirectInputJoyConfig::SendNotify method to notify other applications of the change in calibration. For more information about IDirectInputJoyConfig::SendNotify, see the DirectInput Driver Development Kit (DDK).
Specifies whether device objects are self centering. This setting applies to the entire device, rather than to any particular object, so the dwHow member of the associated
The dwData member can be one of the following values.
DIPROPAUTOCENTER_OFF: The device should not automatically center when the user releases the device. An application that uses force feedback should disable autocentering before playing effects.
DIPROPAUTOCENTER_ON: The device should automatically center when the user releases the device.
Not all devices support the autocenter property.
Predefined property that allows the application to access the information that DirectInput uses to manipulate axes that require calibration. This property exists primarily for applications of the control panel type. Normal applications should not need to deal with calibration information.
You can access the calibration mode property for an axis by setting the dwHow member of the
Control panel applications that set new calibration data must also invoke the IDirectInputJoyConfig::SendNotify method to notify other applications of the change in calibration. For more information about IDirectInputJoyConfig::SendNotify, see the DirectX Driver Development Kit (DDK).
Enables the application to specify whether DirectInput should retrieve calibrated or uncalibrated data from an axis. By default, DirectInput retrieves calibrated data.
Setting the calibration mode for the entire device is equivalent to setting it for each axis individually.
The dwData member of the
DIPROPCALIBRATIONMODE_COOKED: DirectInput should return data after applying calibration information. This is the default mode.
DIPROPCALIBRATIONMODE_RAW: DirectInput should return raw, uncalibrated data. This mode is typically used only by applications of the control panel type. Note that raw data might include negative values.
Setting a device into raw mode causes the dead zone, saturation, and range settings to be ignored.
The dwData member contains a gain value that is applied to all effects created on the device. The value is an integer in the range from 0 through 10,000, specifying the amount by which effect magnitudes should be scaled for the device. For example, a value of 10,000 indicates that all effect magnitudes are to be taken at face value. A value of 9,000 indicates that all effect magnitudes are to be reduced to 90 percent of their nominal magnitudes.
DirectInput always checks the gain value before setting the gain property. If the gain is outside of the range (less than zero or greater than 10,000),
Setting a gain value is useful when an application wants to scale down the strength of all force-feedback effects uniformly, based on user preferences.
Unlike other properties, the gain can be set when the device is in an acquired state.
This property exists for advanced applications that want to change the friendly instance name of a device (as returned in the tszInstanceName member of the
This setting applies to the entire device, so the dwHow member of the associated
The pdiph parameter must be a reference to the diph member of a
This property exists for advanced applications that want to change the friendly product name of a device (as returned in the tszProductName member of the
This setting applies to the entire device, so the dwHow member of the associated
The pdiph parameter must be a reference to the diph member of a
Setting the product name is only useful for changing the user-defined name of an analog joystick on Microsoft Windows 98, Windows 2000, and Windows Millennium Edition (Windows Me) computers. In other cases, attempting to set this property will still return
For some devices, this is a read-only property.
You cannot set a reverse range; lmax must be greater than lmin.
If the method succeeds, the return value is
The buffer size determines the amount of data that the buffer can hold between calls to the
If the method succeeds, the return value is
Before a device can be acquired, a data format must be set by using the
Devices must be acquired before calling the
Device acquisition does not use a reference count. Therefore, if an application calls the
If
The return value is
If the method succeeds, the return value is
Before device data can be obtained, set the cooperative level by using the
The five predefined data formats require corresponding device state structures according to the following table:
Data format | State structure |
---|---|
c_dfDIMouse | DIMOUSESTATE |
c_dfDIMouse2 | DIMOUSESTATE2 |
c_dfDIKeyboard | array of 256 bytes |
c_dfDIJoystick | DIJOYSTATE |
c_dfDIJoystick2 | DIJOYSTATE2 |
For example, if you passed the c_dfDIMouse format to the
If the method succeeds, the return value is
Note |
---|
If the method returns |
In the debug version of DirectInput, if a call is made to
Before device data can be obtained, you must set the data format and the buffer size by using the
The maximum number of events that the buffer will hold is one less than the buffer size set with the
The following code example reads up to ten buffered data elements, removing them from the device buffer as they are read.
rgdod[10]; DWORD dwItems = 10; hres = idirectinputdevice9_GetDeviceData( sizeof( ), rgdod, &dwItems, 0); if (SUCCEEDED(hres)) { // dwItems = Number of elements read (could be zero). if (hres == ) { // Buffer had overflowed. } }
Your application can flush the buffer and retrieve the number of flushed items by specifying
dwItems = INFINITE; hres = idirectinputdevice9_GetDeviceData( pdid, sizeof(), null , &dwItems, 0); if (SUCCEEDED(hres)) { // Buffer successfully flushed. // dwItems = Number of elements flushed. if (hres ==) { // Buffer had overflowed. } }
Your application can query for the number of elements in the device buffer by setting the rgdod parameter to
dwItems = INFINITE; hres = idirectinputdevice9_GetDeviceData( pdid, sizeof(), null , &dwItems, DIGDD_PEEK); if (SUCCEEDED(hres)) { // dwItems = Number of elements in buffer. if (hres ==) { // Buffer overflow occurred; not all data // was successfully captured. } }
To query about whether a buffer overflow has occurred, set the rgdod parameter to
dwItems = 0; hres = idirectinputdevice9_GetDeviceData( pdid, sizeof(), null , &dwItems, 0); if (hres ==) { // Buffer overflow occurred. }
c_dfDIKeyboard
c_dfDIMouse
c_dfDIMouse2
c_dfDIJoystick
c_dfDIJoystick2
If the method succeeds, the return value is
The data format must be set before the device can be acquired by using the
If the application is using action mapping, the data format is set instead by the call to
The application can create the handle as either a manual-reset or autoreset event by using the Win32 CreateEvent function. If the event is created as an autoreset event, the operating system automatically resets the event when a wait has been satisfied. If the event is created as a manual-reset event, it is the application's responsibility to call the Win32 ResetEvent function to reset it. DirectInput does not call the Win32 ResetEvent function for event notification handles. Most applications create the event as an automatic-reset event.
For compatibility with DirectX 3, it is also valid to pass a DIDEVICEOBJECTINSTANCE_DX3 structure with the dwSize member initialized to sizeof(DIDEVICEOBJECTINSTANCE_DX3).
If the method succeeds, the return value is
For compatibility with DirectX 3, it is also valid to pass a DIDEVICEINSTANCE_DX3 structure with the dwSize member initialized to sizeof(DIDEVICEINSTANCE_DX3).
If the method succeeds, the return value is
If the method succeeds, the return value is
If this method fails, the underlying object should be considered to be in an indeterminate state and must be reinitialized before use.
If the method succeeds, the return value is
If the return value is
If the method succeeds, the return value is
If the callback stops the enumeration prematurely, the enumeration is considered to have succeeded.
An application can use the dwEffType member of the DIEffectInfo structure to obtain general information about the effect, such as its type and which envelope and condition parameters are supported by the effect.
To exploit an effect to its fullest, contact the device manufacturer to obtain information about the semantics of the effect and its effect-specific parameters.
Note |
---|
If this method is called on an non-Force Feedback device, E_POINTER will be returned. |
The value is a combination of the following constants.
Applications should ignore any flags that are not currently defined.
The device must be acquired at the exclusive cooperative level for this method to succeed.
The
Note |
---|
When calling |
While the device is paused, new effects cannot be started, and existing ones cannot be modified. Doing so can cause the subsequent
To abandon a pause and stop all effects, use the
If the method succeeds, the return value is
The device must be acquired at the exclusive cooperative level for this method to succeed.
Note |
---|
When calling |
If the method succeeds, the return value is
The results are unpredictable if you create or destroy an effect while an enumeration is in progress. However, the callback function can safely release the effect passed to it.
If the method succeeds, the return value is
Other device-specific error codes are also possible. Ask the hardware manufacturer for details.
Because each driver implements different escapes, it is the application's responsibility to ensure that it is sending the escape to the correct driver by comparing the value of the guidFFDriver member of the
If the method succeeds, the return value is
Before a device data can be polled, the data format must be set by using the
Note |
---|
There are no devices that accept output from |
If the method succeeds, the return value is
Applications should not use
If the method succeeds, the return value is
If the callback stops the enumeration prematurely, the enumeration is considered to have succeeded.
If the method succeeds, it returns
If the method succeeds, the return value is
The method returns
If
If DIEFF_MAPFILEFAIL is returned, an error has occurred either reading the vendor supplied file for the device or reading or writing the user configuration file for the device.
If
If the method succeeds, the return value can be one of the following error values:
This method provides the mechanism to change action-to-control mapping from the device defaults. An application must use this method to map its in-game actions to virtual controls.
The user name passed to this method binds a set of action mappings for a device to a specific user. Settings are automatically saved to disk when they differ from the currently applied map. Applications that accept input from multiple users should be very careful when applying action maps to the system mouse or keyboard, as the action maps for each user may conflict.
The method can be called only when the device is not acquired.
If
If the method succeeds, the return value is
The buffer at lprgImageInfoArray must be large enough to hold all required image information structures. Applications can query for the required size by calling the
The following device types and subtypes are defined for use in the dwDevType member.
First-person action game device. The following subtypes are defined.
Device that does not provide the minimum number of device objects for action mapping.
Device designed for first-person shooter games.
Device with six degrees of freedom; that is, three lateral axes and three rotational axes.
Unknown subtype.
Device that does not fall into another category.
Input device used to control another type of device from within the context of the application. The following subtypes are defined.
Control used to make communications selections.
Device that must use its default configuration and cannot be remapped.
Unknown subtype.
Device for steering. The following subtypes are defined.
Steering device that reports acceleration and brake pedal values from a single axis.
Steering device that reports acceleration and brake pedal values from separate axes.
Hand-held steering device.
Steering device that does not provide the minimum number of device objects for action mapping.
Steering device that reports acceleration, brake, and clutch pedal values from separate axes.
Controller for flight simulation. The following subtypes are defined.
Flight controller that does not provide the minimum number of device objects for action mapping.
Flight device based on a remote control for model aircraft.
Joystick.
Yoke.
Gamepad. The following subtypes are defined.
Gamepad that does not provide the minimum number of device objects for action mapping.
Standard gamepad that provides the minimum number of device objects for action mapping.
Gamepad that can report x-axis and y-axis data based on the attitude of the controller.
Joystick. The following subtypes are defined.
Joystick that does not provide the minimum number of device objects for action mapping.
Standard joystick that provides the minimum number of device objects for action mapping.
Keyboard or keyboard-like device. The following subtypes are defined.
Subtype could not be determined.
IBM PC/XT 83-key keyboard.
Olivetti 102-key keyboard.
IBM PC/AT 84-key keyboard.
IBM PC Enhanced 101/102-key or Microsoft Natural keyboard.
Nokia 1050 keyboard.
Nokia 9140 keyboard.
Japanese NEC PC98 keyboard.
Japanese NEC PC98 laptop keyboard.
Japanese NEC PC98 106-key keyboard.
Japanese 106-key keyboard.
Japanese AX keyboard.
Japanese J3100 keyboard.
A mouse or mouse-like device (such as a trackball). The following subtypes are defined.
Mouse that returns absolute axis data.
Fingerstick.
Touchpad.
Trackball.
Traditional mouse.
Subtype could not be determined.
Remote-control device. The following subtype is defined.
Subtype could not be determined.
Screen reference. The following subtypes are defined.
Unknown subtype.
Light gun.
Light pen.
Touch screen.
Specialized device with functionality unsuitable for the main control of an application, such as pedals used with a wheel. The following subtypes are defined.
Secondary handheld controller.
Device whose primary function is to report acceleration and brake pedal values from a single axis.
Device whose primary function is to report acceleration and brake pedal values from separate axes.
Device that tracks hand movement.
Device that tracks head movement.
Device with rudder pedals.
Device that reports gear selection from an axis.
Device that reports gear selection from button states.
Device whose primary function is to report at least two throttle values. It may have other controls.
Device whose primary function is to report acceleration, brake, and clutch pedal values from separate axes.
Device whose primary function is to report a single throttle value. It may have other controls.
Unknown subtype.
Versions of DirectInput earlier than DirectX 8.0 have a somewhat different scheme of device types and subtypes. See the DIDEVTYPExxx defines in Dinput.h.
Note |
---|
The value in dwOfs is the offset within the raw data returned by the device, regardless of whether the data format has been set for the device. |
Applications can use the wUsagePage and wUsage members to obtain additional information about how the object was designed to be used. For example, if wUsagePage has the value 0x02 (vehicle controls) and wUsage has the value 0xB9 (elevator trim), the object was designed to be the elevator trim control on a flight stick. A flight simulator application can use this information to provide more reasonable defaults for objects on the device. HID usage codes are determined by the USB standards committee.
Applications use the methods of the
Method | Description |
---|---|
IDirectInput8::ConfigureDevices | Displays property pages for connected input devices and enables the user to map actions to device controls. |
Creates and initializes an instance of a device based on a given globally unique identifier ( | |
Enumerates available devices. | |
Enumerates devices that most closely match the application-specified action map. | |
Retrieves the instance globally unique identifier ( | |
Retrieves the status of a specified device. | |
Initializes a DirectInput object. Applications normally do not need to call this method. The DirectInput8Create function automatically initializes the DirectInput object after creating it. | |
Runs Control Panel to enable the user to install a new input device or modify configurations. |
The LPDIRECTINPUT8 type is defined as a reference to the
typedef struct*LPDIRECTINPUT8;
If the method succeeds, the return value is
Calling this method with pUnkOuter =
Calling this method with pUnkOuter !=
To restrict the enumeration to a particular type of device, set this parameter to a DI8DEVTYPE_* value. See
To enumerate a class of devices, use one of the following values.
If the method succeeds, the return value is
All installed devices can be enumerated, even if they are not present. For example, a flight stick might be installed on the system but not currently plugged into the computer. Set the dwFlags parameter to indicate whether only attached or all installed devices should be enumerated. If the
A preferred device type can be passed as a dwDevType filter so that only the devices of that type are enumerated.
On Microsoft Windows XP, DirectInput enumerates only one mouse and one keyboard device, referred to as the system mouse and the system keyboard. These devices represent the combined output of all mice and keyboards respectively on a system. For information about how to read from multiple mice or keyboards individually on Windows XP, see the WM_INPUT documentation.
Note |
---|
The order in which devices are enumerated by DirectInput is not guaranteed. |
If the method succeeds, the return value is
If the method succeeds, the return value is
If the method succeeds, the return value is
If the method succeeds, the return value is
The keyboard and mouse are enumerated last.
Note |
---|
The order in which devices are enumerated by DirectInput is not guaranteed. |
Use the DIDFT_GETTYPE macro to extract the effect type from the dwEffType flags.
Note |
---|
The rglDirection array must contain cAxes entries, even if polar or spherical coordinates are given. In these cases, the last element in the rglDirection array is reserved and must be 0. |
The DIJOYTYPEINFO structure contains information about a joystick type.
A "joystick type" describes how DirectInput should communicate with the device and how it should report device data. For example, "A Frobozz Industries SuperStick 5X is a three-axis, five-button joystick with the third axis reported as the first bit on the second port."
DirectInput comes with the following predefined joystick types, all with axes in their default locations:
Two-axis, two-button joystick.
Two-button game pad.
Two-button flight yoke.
Two-button flight yoke with throttle.
Three-axis, two-button joystick.
Three-axis, four-button joystick.
Four-button game pad.
Four-button flight yoke.
Four-button flight yoke with throttle.
If the joystick type has the JOY_HWS_ISGAMEPORTDRIVER flag set in the dwFlags member of the JOYHWSETTINGS structure, then the wszCallout member of the DIJOYTYPEINFO structure contains the name of a driver that can be used as a global driver. The joystick type should be shown on the list of global drivers and not shown on the list of joystick types that can be assigned.
New in DirectX 8.0
The dwFlags2 member was added to the DIJOYCONFIG structure. This member carries information that controls how DirectInput enumerates the device to applications. The dwFlags2 member carries device type and subtype override flags in the low word, and device enumeration "hiding" flags in the high word. The device type and subtype override flags control how DirectInput portrays your device to applications that use DirectInput. These are the same flags that applications receive from DirectInput during device enumeration. For example, if your device is described in its firmware as a telephony device, it would not normally be enumerated to games because telephony devices aren't considered relevant to games. However, if you used
The high word of dwFlags2 can be set to contain flags that scope how DirectInput enumerates the device to DirectInput applications. For example, some devices declare multiple top-level HID collections. Such a device might declare that it can act as a keyboard, a mouse, and a joystick all in one. Generally, one or more of these top-level collections is merely a phantom device, which shouldn't be enumerated to games. For this device, the high word of dwFlags2 could be set to a combination of the JOYTYPE_HIDEACTIVE, JOYTYPE_MOUSEHIDE, and JOYTYPE_KEYBHIDE flags. The JOYTYPE_HIDEACTIVE flag indicates that DirectInput should not enumerate the device by all its types. The JOYTYPE_MOUSEHIDE and JOYTYPE_KEYBHIDE flags also present in the high word indicate to DirectInput that enumeration of the phantom mouse and keyboard on the device should be suppressed. Note that applications can include the
Specifies the size of the structure in bytes. This member must be initialized before the structure is used.
Joystick hardware settings.
Specifies a CLSID for the joystick type configuration object. Pass this CLSID to CoCreateInstance to create a configuration object. This field is zero if the type does not have custom configuration.
The display name for the joystick type. The display name is the name that should be used to display the name of the joystick type to the end user.
The device responsible for handling polling for devices of this type. This is a null string if the global polling callout is to be used.
The hardware ID for the joystick type. The hardware ID is used by Plug and Play on Windows 2000 and Windows 98 (DirectX 7.0 only) to find the drivers for the joystick.
Joystick type flags. This member can be set to a combination of the following flags.
Zero GameEnum's OEM data field.
Device does not support Autodetect gameport.
Do not use HID directly for this device. (Windows 98 only.)
CPL overrides custom property sheet.
To load effects, call the
In the following code example, the first three standard effects are loaded from a file and created as DirectInputEffect objects.
// g_lpdid is a validreference to a // force feedback device. // The array of effect references is declared globally. LPDIRECTINPUTEFFECT pEff[3]; . . . g_lpdid->EnumEffectsInFile("FEdit1.ffe", EnumEffectsInFileProc, null ,); . . .
The following callback function is called once for each effect in the file or until it returns DIENUM_STOP. Note that because the
CALLBACK EnumEffectsInFileProc(LPCDIFILEEFFECT lpdife, LPVOID pvRef) { hr; static int i; hr = g_lpdid->CreateEffect(lpdife->GuidEffect, lpdife->lpDiEffect, &pEff[i], null ); if (FAILED(hr)) { // Error handling } if (++i > 2) return DIENUM_STOP; else return DIENUM_CONTINUE; }
Note |
---|
The rglDirection array must contain cAxes entries, even if polar or spherical coordinates are given. In these cases, the last element in the rglDirection array is reserved and must be 0. |
You can modify the basic magnitude of some effects by applying an envelope and an offset. For an overview, see Basic Concepts of Force Feedback.
To apply an envelope when creating or modifying an effect, initialize a
The device driver determines which effects support envelopes. Typically, you can apply an envelope to a constant force, a ramp force, or a periodic effect, but not to a condition. To determine whether a particular effect supports an envelope, call the
To apply an offset, set the lOffset member of the
You cannot apply an offset to a constant force or ramp force. In these cases, you can achieve the same effect by altering the magnitude.
Joystick device constants represent offsets within a joystick device's data packet, the DIJOYSTATE structure. The data at a given offset is associated with a device object; that is, a button or axis. Typically, these values are used in the dwOfs member of the
The following macros return a constant indicating the offset of the data for a particular button or axis relative to the beginning of the DIJOYSTATE structure.
The following alternate names are available:
Alternate name | Regular name | Note |
---|---|---|
DIK_BACKSPACE | | BACKSPACE |
DIK_CAPSLOCK | | CAPS LOCK |
DIK_CIRCUMFLEX | | On Japanese keyboard |
DIK_DOWNARROW | | On arrow keypad |
DIK_LALT | | Left ALT |
DIK_LEFTARROW | | On arrow keypad |
DIK_NUMPADMINUS | DIK__SUBTRACT | MINUS SIGN (-) on numeric keypad |
DIK_NUMPADPERIOD | | PERIOD (decimal point) on numeric keypad |
DIK_NUMPADPLUS | | PLUS SIGN (+) on numeric keypad |
DIK_NUMPADSLASH | DIK__DIVIDE | Forward slash (/) on numeric keypad |
DIK_NUMPADSTAR | | Asterisk (*) on numeric keypad |
DIK_PGDN | | On arrow keypad |
DIK_PGUP | | On arrow keypad |
DIK_RALT | | Right ALT |
DIK_RIGHTARROW | | On arrow keypad |
DIK_UPARROW | | On arrow keypad |
For information about Japanese keyboards, see DirectInput and Japanese Keyboards.
The data at a given offset is associated with a keyboard key. Typically, these values are used in the dwOfs member of the
The data at a given offset is associated with a device object (button or axis). Typically, these values are used in the dwOfs member of the
Before you begin asking for input from a device, you need to know something about its capabilities. Does the joystick have a point-of-view hat? Is the mouse currently attached to the user's computer?
DIMouseCaps; hr; BOOLEAN WheelAvailable; DIMouseCaps.dwSize = sizeof( ); hr = lpdiMouse->GetCapabilities(&DIMouseCaps); WheelAvailable = ((DIMouseCaps.dwFlags & ) && (DIMouseCaps.dwAxes > 2));
Another way to check for a button or axis is to call
didoi; didoi.dwSize = sizeof( ); hr = lpdiMouse->GetObjectInfo(&didoi, , ); WheelAvailable = SUCCEEDED(hr);
If the function succeeds, the return value is
The DirectInput object created by this function is implemented in Dinput8.dll. Versions of interfaces earlier than DirectX 8.0 cannot be obtained in this implementation.
To create a DirectX 8.x interface with the latest DirectX SDK without using CoCreateInstance:
Set "#define
Call DirectInput8Create instead of DirectInputCreateEx.
Link to the Dinput8.lib library instead of Dinput.lib.
To create a DirectX 8.x interface with the DirectX 8.x SDK without using CoCreateInstance:
Call DirectInput8Create instead of DirectInputCreateEx.
Link to the Dinput8.lib library instead of Dinput.lib.
To create a DirectX 7.0 interface from the DirectX 8.x or latest DirectX SDK without using CoCreateInstance:
Set "#define
Call DirectInputCreateEx instead of DirectInput8Create.
Link to the Dinput.lib library instead of Dinput8.lib.
To create a DirectX 7.0 interface from the DirectX 8.x or latest DirectX SDK using CoCreateInstance:
Call CoInitializeEx.
Call CoCreateInstance using CLISID_DirectInput.
Use IDirectInput7::Initialize to initialize the DirectInput object.
To create a DirectX 8.x or DirectX 9.0 interface from the DirectX 8.x or latest DirectX SDK using CoCreateInstance:
Call CoInitializeEx.
Call CoCreateInstance using CLISID_DirectInput8.
Use
Calling the function with pUnkOuter =
Calling the function with pUnkOuter !=
Describes a mapping of one game action to one device semantic. An array of
typedef struct _DIACTION {MembersuAppData; DWORD dwSemantic; DWORD dwFlags; union { LPCTSTR lptszActionName; UINT uResIdString; }; guidInstance; DWORD dwObjID; DWORD dwHow; } , *LPDIACTION; typedef const *LPCDIACTION;
Flags used to request specific attributes or processing. Can be zero or one or more of the following values.
When the structure is returned by
The ftTimeStamp member can contain special values that apply to new and unused devices. New devices have never been enumerated for this application and have never had an action map applied to them. Unused devices have been enumerated for the application before but have never had an action map applied. New devices always have DIAFTS_NEWDEVICELOW and DIAFTS_NEWDEVICEHIGH in the low and high DWORDs respectively of the
Applications should not use ftTimeStamp to check for new devices. Instead, they should look for the DIEDBS_RECENTDEVICE and DIEDBS_NEWDEVICE flags in the enumeration callback. For more information, see DIEnumDevicesBySemanticsCallback.
A reference to an array of
Different types of conditions interpret the parameters differently, but the basic idea is that force resulting from a condition is equal to A(q - q0) where A is a scaling coefficient, q is some metric, and q0 is the neutral value for that metric.
The preceding simplified formula must be adjusted if a nonzero deadband is provided. If the metric is less than lOffset - lDeadBand, the resulting force is given by the following formula:
force = lNegativeCoefficient * ( q - ( lOffset - lDeadBand))
Similarly, if the metric is greater than lOffset + lDeadBand, the resulting force is given by the following formula:
force = lPositiveCoefficient * ( q - ( lOffset + lDeadBand))
A spring condition uses axis position as the metric.
A damper condition uses axis velocity as the metric.
An inertia condition uses axis acceleration as the metric.
If the number of
If there is a single
The system time returned in dwTimeStamp comes from the same clock used by the Microsoft Win32 GetTickCount or timeGetTime functions, but it produces potentially more precise values. For example, on Microsoft Windows 95, the GetTickCount timer is updated only every 55 milliseconds, but the dwTimeStamp value is accurate to within 1 millisecond. Therefore, if you call GetTickCount and it returns n, and you then receive an event with a timestamp of n + n1, you cannot assume that the event took place exactly n1 milliseconds after the call to GetTickCount.
The diph member must be initialized as follows:
Member | Value |
---|---|
dwSize | sizeof( |
dwHeaderSize | sizeof( |
dwObj | For this structure, this member must be set to 0. |
dwHow | Specifies how the dwObj member should be interpreted. For this structure, dwHow should be |
The
The application calls the
The diph member must be initialized as follows:
Member | Value |
---|---|
dwSize | sizeof( |
dwHeaderSize | sizeof( |
dwObj | If the dwHow member is If the dwHow member is If the dwHow member is If the dwHow member is |
dwHow | Specifies how the dwObj member should be interpreted. See the preceding description of the dwObj member for details. |
The range values for devices whose ranges are unrestricted wraparound.
The structure describes a constant force effect.
A reference to a single