Microsoft DirectX 8.1 (Visual Basic)

Effect Playback

There are two principal ways to start playback of an effect: manually by a call to the DirectInputEffect.Start method, or automatically in response to a button press. Playback also starts when you change an effect by calling the DirectInputEffect.SetParameters method with the DIEP_START flag.

Passing –1 in the iterations parameter of the Start method has the effect of playing the effect repeatedly, with the envelope being applied each time. If you want to repeat an effect without repeating the envelope—for example, to begin with a strong kick, then settle down to a steady throb—set iterations to 1 and set the lDuration member of the DIEFFECT type to –1. (This is the type passed to the DirectInputDevice8.CreateEffect method.)

Note  Some devices do not support multiple iterations of an effect and accept only the value 1 in the iterations parameter to the Start method.

To associate an effect with a button press, set the lTriggerButton member of the DIEFFECT type. Also set the lTriggerRepeatInterval member to the desired delay between playbacks when the button is held down. This is the interval, in microseconds, between the end of one playback and the start of the next.

Note  On some devices, multiple effects cannot be triggered by the same button; if you associate more than one effect with a button; the last effect downloaded is the one triggered. Also, trigger repeat interval might not be supported.

To dissociate an effect from its trigger button, either call the DirectInputEffect.Unload method or set the parameters for the effect with lTriggerButton set to -1 or DIEB_NOTRIGGER.

Triggered effects, like all others, are lost when the application loses access to the device. To make them active again, download them as soon as the application reacquires the device. This step is not necessary for effects not associated with a trigger because they are automatically downloaded if necessary whenever the Start method is called.

If an effect has a finite duration and is started by a call to the Start method, it stops playing when the time has elapsed. If an effect has been instructed to play continually, playback ends only when the DirectInputEffect.Stop method is called. An effect associated with a trigger button starts when the button is pressed and stops when the button is released or the duration has elapsed, whichever comes sooner.