Wiki Page Content

DRAFT

SDL_HapticEffect

A union that contains the generic template for any haptic effect.

Data Fields

Uint16

type

effect type; see SDL_HapticPeriodic for details

SDL_HapticConstant

constant

constant effect; see Remarks for details

SDL_HapticPeriodic

periodic

periodic effect; see Remarks for details

SDL_HapticCondition

condition

condition effect; see Remarks for details

SDL_HapticRamp

ramp

ramp effect; see Remarks for details

SDL_HapticLeftRight

leftright

left/right effect; see Remarks for details

SDL_HapticCustom

custom

custom effect; see Remarks for details

Code Examples

You can add your code example here

Remarks

All structures in this union contain the following common parts:

Replay (all effects have this)

Uint32

length

duration of effect (ms)

Uint16

delay

delay before starting effect

Trigger (all effects have this)

Uint16

button

button that triggers effect

Uint16

interval

how soon before effect can be triggered again

Envelope (all effects except condition effects have this)

Uint16

attack_length

duration of the attack (ms)

Uint16

attack_level

level at the start of the attack

Uint16

fade_length

duration of the fade out (ms)

Uint16

fade_level

level at the end of the fade

All values max at 32767 (0x7FFF). Signed values can be negative. Time values, unless specified otherwise, are in milliseconds.

You can pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value. Neither delay, interval, attack_length, nor fade_length support SDL_HAPTIC_INFINITY. The SDL_HAPTIC_RAMP effect does not support a duration of SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.

Button triggers may not be supported on all devices. It is advised not to use them if possible. Buttons start at index 1 instead of index 0 like the joystick.

If both attack_length and fade_level are 0 the envelope is not used, otherwise both values are used.

Here is an example of a constant effect evolution in time:

Strength
^
|
|    effect level -->  _________________
|                     /                 \
|                    /                   \
|                   /                     \
|                  /                       \
| attack_level --> |                        \
|                  |                        |  <---  fade_level
|
+--------------------------------------------------> Time

                   [--]                 [---]
               attack_length          fade_length

[------------------][-----------------------]
       delay                 length

Note that either the attack_level or the fade_level may be above the actual effect level.


CategoryStruct, CategoryForceFeedback

None: SDL_HapticEffect (last edited 2015-05-31 19:55:45 by PhilippWiesemann)

Feedback
Please include your contact information if you'd like to receive a reply.
Submit