DirectX SDK

DirectInputDevice.CreateCustomEffect

The DirectInputDevice.CreateCustomEffect method creates a force-feedback effect consisting of a series of constant forces of fixed duration.

object.CreateCustomEffect(effectinfo As DIEFFECT, _
    channels As Long, samplePeriod As Long, _
    nSamples As Long, sampledata() As Long) _
    As DirectInputEffect

Parameters

object
Object expression that resolves to a DirectInputDevice object.
effectinfo
DIEFFECT type containing general parameters of the effect.
channels
The number of channels (axes) affected by this force. Must be 1 or 2.

If there is only a single channel, then the effect will be rotated in the direction specified by the x member of the DIEFFECT type. Not all devices support rotation of custom effects.

If there is more than one channel, the first channel is applied to the x-axis and the second to the y-axis. Rotation is not allowed.

samplePeriod
The sample period in microseconds. See Remarks.
nSamples
Number of elements in the sampledata array.
sampledata
Array of magnitudes. If channels is greater than 1, then the values are interleaved. For example, if channels is 2, then the first element of the array is assigned to the x-axis, the second to the y-axis, the third to the x-axis, and so on.

Remarks

In theory, samplePeriod is the length of time for which each magnitude in sampledata is valid, whereas DIEFFECT.lSamplePeriod is the length of time between samplings of the data (and the minimum time between changes in magnitude). Since each element in the array needs to be sampled exactly once on each iteration through the array, and some drivers ignore samplePeriod in any case, it is best to make the values of lSamplePeriod and samplePeriod identical.

See Also

Custom Forces