Microsoft DirectX 8.1 (Visual Basic) |
Periodic effects are waveform effects. Microsoft® DirectInput® defines the following waveforms:
An envelope can be applied to periodic effects. See the example in 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.
Waveform | 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 guid parameter of the DirectInputDevice8.CreateEffect method:
You can also pass any other GUID obtained by the DirectInputEnumEffects.GetEffectGuid method, provided the low byte of the value returned by DirectInputEnumEffects.GetType is equal to DIEFT_PERIODIC. In this way, you can use hardware-specific periodic forces designed by the manufacturer.
The type-specific parameters for periodic effects are contained in a DIPERIODICFORCE type in the periodicForce member of DIEFFECT.
Do not confuse the period of a periodic effect (DIEFFECT.periodic.lPeriod) with the sample period (DIEFFECT.lSamplePeriod). The period is the length of time it takes to go through a complete wave cycle. The sample period, as for all effects, is the minimum time between actual adjustments of magnitude.