DirectX SDK |
There are two principal ways to start playback of an effect: manually by a call to the IDirectInputEffect::Start method, or 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 IDirectInputDevice7::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. Always check the return value from Start to be sure the effect played successfully.
To associate an effect with a button press, set the dwTriggerButton member of the DIEFFECT structure. 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.
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 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. 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 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.
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 Start 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 DirectInputDevice.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.
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 its duration was set to –1, 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.