Downloading and Unloading Effects

Before an effect can be played, it must be downloaded to the device. Downloading an effect means telling the driver to prepare the effect for playback. It is entirely up to the driver to determine how this is done. Generally the driver will place the parameters of the effect in hardware memory in order to minimize the subsequent transfer of data between the device and the system. The consequent reduction in latency is particularly important for conditions and for effects played in response to a trigger, such as a "fire" button. Ideally the device will not have to communicate with the system at all in order to respond to axis movements and button presses.

Downloading is done automatically when you create an effect, provided the device is not full and is acquired at the exclusive cooperative level. By default it is also done when you start the effect or change its parameters. If you specify the DIEP_NODOWNLOAD flag when changing parameters, you must subsequently use the IDirectInputEffect::Download method to download or update the effect.

When the device is unacquired — for example, when it has been acquired with the exclusive foreground cooperative level and the application moves to the background — effects are unloaded and must be downloaded again when the application regains the foreground. As stated above, this will be done automatically when you call the IDirectInputEffect::Start method, but you may choose to download all effects immediately on reacquiring the device. You always have to download effects associated with a trigger button, since the Start method will not normally be called for such effects.

If your application gets the DIERR_DEVICEFULL error when downloading an effect, you have to make room for the new effect by unloading an old one. You can remove an effect from the device by calling the IDirectInputEffect::Unload method. You can also remove all effects by resetting the device through a call to IDirectInputDevice2::SendForceFeedbackCommand.

When you create a force feedback device, the hardware and driver are reset, so any existing effects are cleared.