Periodic effects are waveform effects. DirectInput defines the following forms:
An envelope can be applied to periodic effects. See the example at Basic Concepts of Force Feedback.
The phase of a periodic effect is the point along the waveform where the effect begins. Phase is measured in hundredths of a degree, from 0 to 35,999. The following table indicates where selected phase values (in degrees) lie along the various waveforms. Max is the top (+) or bottom (-) of the wave and Mid is the midpoint, where no force is applied in either direction.
0 | 90 | 180 | 270 | |
---|---|---|---|---|
Square | +Max | +Max | -Max | -Max |
Sine | Mid | +Max | Mid | -Max |
Triangle | +Max | Mid | -Max | Mid |
SawtoothUp | -Max | -Max/2 | Mid | +Max/2 (reaches +Max just before the cycle repeats) |
SawtoothDown | +Max | +Max/2 | Mid | -Max/2 (reaches -Max just before the cycle repeats) |
A driver may round off a phase value to the nearest supported value. For example, for a sine effect some drivers support only values of 0 and 9,000 (to create a cosine); for other effects, only values of 0 and 18,000 are supported.
To create a periodic force, pass one of the following values in the rguid parameter of the IDirectInputDevice2::CreateEffect method:
You can also pass any other GUID obtained by the IDirectInputDevice2::EnumEffects method, provided the low byte of the dwEffType member of the DIEFFECTINFO structure (DIEFT_GETTYPE(dwEfftype)) is equal to DIEFT_PERIODIC. In this way you can use hardware-specific forces designed by the manufacturer. For example, a hardware device might support a periodic effect that rotates the stick in a small circle.
The type-specific structure for periodic effects is DIPERIODIC. For more information on the dwPhase member of this structure, see the overview of Periodic Effects.