Platform SDK: DirectX

Periodic Effects

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, at which 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 can round off a phase value to the nearest supported value. For example, for a sine effect some drivers support only values in the range from 0 through 9,000 (to create a cosine); for other effects, only values in the range from 0 through 18,000 are supported.

[C++]

To create a periodic force, pass one of the following values in the rguid parameter of the IDirectInputDevice7::CreateEffect method:

You can also pass any other GUID obtained by the IDirectInputDevice7::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.

Do not confuse the period of a periodic effect (DIPERIODIC.dwPeriod) with the sample period (DIEFFECT.dwSamplePeriod). The period is the length of time that 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.

[Visual Basic]

To create a periodic force, pass one of the following values in the guid parameter of the DirectInputDevice.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.