Microsoft DirectX 8.1 (Visual Basic)

Conditions

Conditions are forces applied in response to current sensor values within the device. In other words, conditions require information about device motion, such as position or velocity of a joystick handle.

In general, conditions are not associated with individual events during a game or other application. They represent ambient phenomena, such as the stiffness or looseness of a flight stick, or the tendency of a steering wheel to return to a straight-ahead position.

A condition does not have a predefined magnitude. The magnitude is scaled in proportion to the movement or position of the input object.

Microsoft® DirectInput® defines the following types of condition effects:

Most hardware devices do not support the application of envelopes to conditions.

Conditions have the following type-specific parameters:

Offset
The offset from the zero reading of the appropriate sensor value at which the condition begins to be applied. For a spring effect, the neutral point—that is, the point along the axis at which the spring would be considered at rest—would be defined by the offset for the condition. For a damper, the offset would define the greatest velocity value for which damping force is zero. Offset is not normally used for inertia or friction effects.
Coefficient
A multiplier that scales the effect. For some devices, you can set separate coefficients for the positive and negative direction along the axis associated with the condition. For example, a flight stick controlling a damaged aircraft might move more easily to the right than to the left.
Saturation
In force feedback, saturation is an expression of the maximum possible force for an effect. For example, suppose a flight stick has a spring condition on the x-axis. The offset is 0 and the coefficient is 10,000, so the maximum force is normally exerted when the stick is furthest from the center. But if you define a positive and negative saturation of 5,000, the force does not increase after the stick has been moved halfway to the right or left.

Not all devices support saturation.

Deadband
The deadband is a zone around the offset of an axis at which the condition is not active. In the case of a spring that is at rest in the middle of an axis, the deadband enlarges this area of rest.

Not all devices support deadband.

Conditions can have duration, although in most cases you would probably want to set the duration to infinite (–1) and stop the effect only in response to some event in the application.

To create a condition, pass one of the following values in the rguid 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_CONDITION. In this way, you can use hardware-specific conditions designed by the manufacturer.

The type-specific parameters for a condition are described in a DICONDITION type in the conditionX and conditionY members of the DIEFFECT type.

An application should call the DirectInputEnumEffects.GetType method and examine the return value member to determine whether both a positive and a negative coefficient and saturation for the effect are supported on the device. If the effect does not return the DIEFT_POSNEGCOEFFICIENTS flag, it ignores the value in DICONDITION.lNegativeCoefficient, and the value in lPositiveCoefficient is applied to the entire axis. Likewise, if the effect does not return the DIEFT_POSNEGSATURATION flag, it ignores the value in lNegativeSaturation and the value in lPositiveSaturation is used as the negative saturation level. Finally, if the effect does not return the DIEFT_SATURATION flag, it ignores both the lPositiveSaturation and lNegativeSaturation values, and no saturation is applied.

You can set a coefficient to a negative value, and this has the effect of generating the force in the opposite direction. For example, for a spring effect, it would cause the spring to push away from the offset point, rather than pulling toward it.

You should also check the value returned by GetType for the DIEFT_DEADBAND flag, to see if deadband is supported for the condition. If it is not supported, the value in the lDeadBand member of the DICONDITION type will be ignored.

To create a single-axis effect, set the coefficients for the unused axis to 0 in the conditionX or conditionY member of the DIEFFECT type.

DirectX® for Microsoft Visual Basic® does not support rotation of conditions.