Platform SDK: DirectX |
A ramp force is a force with defined starting and ending magnitudes and a finite duration. A ramp force can continue in a single direction, or it can start as a strong push in one direction, weaken, stop, and then strengthen in the opposite direction.
The following illustration shows a ramp force that starts at a magnitude of -5,000 and ends at 5,000:
You can apply an envelope to a ramp force to shape it further. The following diagram shows the effect of applying an envelope, shown in green, to the ramp force in the previous diagram.
During the sustain portion of the envelope, the magnitude of the effect follows the same straight line as before the envelope was applied. For the duration of the attack and fade, the slope of the ramp is modified by the attack and fade levels.
You cannot apply an offset to a ramp force.
To create a ramp force, pass GUID_RampForce to 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_RAMPFORCE. In this way, you can use hardware-specific ramp forces designed by the manufacturer.
A ramp force uses a DIRAMPFORCE structure to define the starting and ending magnitude of the force, whereas the duration is taken from the DIEFFECT structure. Duration must never be set to INFINITE.
To create a ramp force, pass "GUID_RampForce" to 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_RAMPFORCE. In this way, you can use hardware-specific ramp forces designed by the manufacturer.
The starting and ending magnitude of the force are defined in a DIRAMPFORCE type in the rampForce member of DIEFFECT. The duration cannot be infinite, and therefore DIEFFECT.lDuration must be a positive value.