DRAFT |
SDL_HapticEffect
A union that contains the generic template for any haptic effect.
Data Fields
Uint16 |
type |
effect type |
constant |
constant effect; see Remarks for details |
|
periodic |
periodic effect; see Remarks for details |
|
condition |
condition effect; see Remarks for details |
|
ramp |
ramp effect; see Remarks for details |
|
custom |
custom effect; see Remarks for details |
Code Examples
You can add your code example here
Remarks
All structs 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 also can be negative. Time values, unless specified otherwise, are in milliseconds.
You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value. Neither delay, interval, attack_length nor fade_length support SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. green
Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of SDL_HAPTIC_INFINITY. green
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 they joystick. <<Color2: execution failed [No argument named "Does this mean that the joystick itself is index 0 and the buttons are index >"] (see also the log)>>
If both attack_length and fade_level are 0, the envelope is not used, otherwise both values are used.
Here we have is an example of a constant effect evolution in time:
Strength
^
|
| effect level --> _________________
| / \
| / \
| / \
| / \
| attack_level --> | \
| | | <--- fade_level
|
+--------------------------------------------------> Time
[--] [---]
attack_length fade_length
[------------------][-----------------------]
delay lengthNote that either the attack_level or the fade_level may be above the actual effect level.
green
Related Structures
SDL_HapticDirection ??? (from header but not referenced in the union)
