There are two principal ways to start playback of an effect: manually by a call to the IDirectInputEffect::Start method, and automatically in response to a button press. Playback also starts when you change an effect by calling the IDirectInputEffect::SetParameters method with the DIEP_START flag.
Passing INFINITE in the dwIterations parameter 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 dwIterations to 1 and set the dwDuration member of the DIEFFECT structure to INFINITE. (This is the structure passed to the IDirectInputDevice2::CreateEffect method.)
Note Some devices do not support multiple iterations of an effect and accept only the value 1 in the dwIterations parameter to the Start method. You should always check the return value from Start to make sure the effect played successfully.
To associate an effect with a button press, you set the dwTriggerButton member of the DIEFFECT structure. You also set the dwTriggerRepeatInterval 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. 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 will be the one triggered.
To dissociate an effect from its trigger button, you must either call the IDirectInputEffect::Unload method or set the parameters for the effect with dwTriggerButton set to DIEB_NOTRIGGER.
Triggered effects, like all others, are lost when the application loses access to the device. In order to make them active again, you must 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 will stop playing when the time has elapsed. If its duration was set to INFINITE, playback ends only when the IDirectInputEffect::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.