Microsoft DirectX 8.1 (C++) |
This topic covers the following specialized programming tips.
In the DirectInput8Create, IDirectInput8::Initialize, IDirectInputDevice8::Initialize, and IDirectInputEffect::Initialize methods, you are required to pass the Microsoft® DirectInput® version number. This parameter specifies which version of Microsoft DirectX® the DirectInput subsystem should emulate.
Applications designed for the latest version of DirectInput should pass the value DIRECTINPUT_VERSION as defined in Dinput.h.
Applications designed to run under previous versions should pass a value corresponding to the version of DirectInput for which they were designed, with the main version number in the high-order byte. For example, an application designed to run on DirectInput 3.0 should pass a value of 0x0300.
If you define DIRECTINPUT_VERSION as 0x0300 before including the Dinput.h header file, the header file generates structure definitions compatible with DirectInput 3.0.
If you do not define DIRECTINPUT_VERSION before including the Dinput.h header file, the header file generates structure definitions compatible with the current version of DirectInput. However, the DirectX 3–compatible structures are available under the same names with "_DX3" appended. For example, the DirectX 3–compatible DIDEVCAPS structure is called DIDEVCAPS_DX3.
You must also use the appropriate versions of the DirectInput and DirectInputDevice interfaces. For versions of DirectX prior to DirectX 7.0, you must use IDirectInput and either IDirectInputDevice or IDirectInputDevice2 (the latter is available for DirectX 5.0 or later).
When using the keyboard or mouse with DirectInput under Microsoft Windows® 2000, you might notice short delays in response when you step through code during a debugging session. This behavior occurs only in debug mode, so it is not seen by your application's end users. However, this behavior can be eliminated in debug mode as well by adding the emulation value to the following registry key.
HKEY_LOCAL_MACHINE SOFTWARE Microsoft DirectInput
Name | Type | Data |
---|---|---|
Emulation | DWORD | 0x08 (for the keyboard)
0x10 (for the mouse) 0x18 (for both) |
Without changing how DirectInput returns data, this value invokes an emulation mode that is not susceptible to those delays. The Microsoft software development kit (SDK) includes two registry files—Mouse and Keyboard Emulation On.reg and Mouse and Keyboard Emulation Off.reg—to activate and deactivate this emulation mode. The files are located under (SDK root)\Samples\Multimedia\DirectInput\Bin.
Note The emulation value is supported only in debug mode when your device is using an Exclusive and Foreground cooperative level. You can switch to debug mode in the SDK Control Panel if you are using DirectX 8.0 or later. If you are using earlier versions of DirectX, you must do a debug SDK install in order to get the correct debug DLL onto your machine.
For every application that uses DirectInput 8.0 or later versions, DirectInput creates a key in the following registry.
HKEY_CURRENT_USER SOFTWARE Microsoft DirectInput
This allows the independent hardware vendors (IHVs) to turn off their own device mapping for certain applications. During debugging, however, each build will generate a new key which contains a time stamp and the file size. To avoid generating multiple keys in the registry, use the binary value, AppldFlag.
The following table lists the possible values for AppldFlag.
1 | The time stamp is ignored when generating the key. |
2 | The file size is ignored when generating the key. |
3 | Both the time stamp and file size are ignored when generating the key. |
If AppldFlag is set to 3, all builds of applications with the same file name will use the same key.
Note The AppldFlag value should be set only on test machines to avoid the possibility of two applications that ship with the same file name interfering with each other's input control mappings.
The Force Editor application enables you to design force-feedback effects and test them singly or in combination. Effects can be saved to file and then loaded into DirectInput applications.
Executable: (SDK root)\Bin\Dxutils\Fedit.exe
The Force Editor has its own documentation. Once you've launched Fedit.exe, press F1 for online Help. The Help file can also be launched directly.
(SDK root)\Bin\Dxutils\Fedit.chm
When using the debug version of Microsoft DirectPlay®, you may notice some unusual behavior from the GetDeviceData method when a device is unacquired. If you call GetDeviceData and the device is not acquired, random bytes will be placed in the device data buffer and the value of the pdwInOut parameter will not be changed. Therefore, if your application does not check for the DPNERR_UNACQUIRED error code, your application will mistakenly determine that there is data in the buffer.