Microsoft DirectX 8.1 (Visual Basic)

Programming Tips and Tools

This topic covers the following specialized programming tips.

Designing for Previous Versions of DirectInput

If you want to design for DirectX 7 (the only previous version of DirectX that supports Microsoft Visual Basic®), you must include the DirectX 7 for Visual Basic type library. Refer to the DirectX 7 documentation for more information.

Preventing Response Delays During Debugging

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.

Avoiding Duplicate Registry Keys

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.

1The time stamp is ignored when generating the key.
2The file size is ignored when generating the key.
3Both 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.

Force Editor

Description

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.

Path

Executable: (SDK root)\Bin\Dxutils\Fedit.exe

User's Guide

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

GetDeviceData and an Unacquired Device

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.