Class SDL_HapticEffect


  • public final class SDL_HapticEffect
    extends com.sun.jna.Union
    The generic template for any haptic effect.

    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, attackLength nor fadeLength support SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.

    Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of SDL_HAPTIC_INFINITY.

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

    If both attackLength and fadeLevel are 0, the envelope is not used, otherwise both values are used.

    Common parts:

     // Replay - All effects have this
     int length;           // Duration of effect (ms).
     short delay;          // Delay before starting effect.
    
     // Trigger - All effects have this
     short button;         // Button that triggers effect.
     short interval;       // How soon before effect can be triggered again.
    
     // Envelope - All effects except condition effects have this
     short attackLength;   // Duration of the attack (ms).
     short attackLevel;    // Level at the start of the attack.
     short fadeLength;     // Duration of the fade out (ms).
     short fadeLevel;      // Level at the end of the fade.
     
    Here we have an example of a constant effect evolution in time:
     Strength
     ^
     |
     |    effect level -->  _________________
     |                     /                 \
     |                    /                   \
     |                   /                     \
     |                  /                       \
     |  attackLevel --> |                        \
     |                  |                        |  <---  fadeLevel
     |
     +--------------------------------------------------> Time
                        [--]                 [---]
                        attackLength         fadeLength
    
     [------------------][-----------------------]
     delay               length
     

    Note either the attackLevel or the fadeLevel may be above the actual effect level.

    See Also:
    SDL_HapticConstant, SDL_HapticPeriodic, SDL_HapticCondition, SDL_HapticRamp, SDL_HapticLeftRight, SDL_HapticCustom
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.sun.jna.Structure

        com.sun.jna.Structure.ByReference, com.sun.jna.Structure.ByValue, com.sun.jna.Structure.FieldOrder, com.sun.jna.Structure.StructField
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void read()  
      void setType​(int hapticEffectType)  
      • Methods inherited from class com.sun.jna.Union

        getFieldOrder, getNativeAlignment, getTypedValue, readField, readField, setType, setType, setTypedValue, writeField, writeField, writeField
      • Methods inherited from class com.sun.jna.Structure

        allocateMemory, allocateMemory, autoAllocate, autoRead, autoRead, autoWrite, autoWrite, cacheTypeInfo, calculateSize, clear, createFieldsOrder, createFieldsOrder, createFieldsOrder, createFieldsOrder, dataEquals, dataEquals, ensureAllocated, equals, fieldOffset, getAutoRead, getAutoWrite, getFieldList, getFields, getNativeSize, getNativeSize, getPointer, getStringEncoding, getStructAlignment, hashCode, newInstance, newInstance, setAlignType, setAutoRead, setAutoSynch, setAutoWrite, setStringEncoding, size, sortFields, toArray, toArray, toString, toString, useMemory, useMemory, write
    • Constructor Detail

      • SDL_HapticEffect

        public SDL_HapticEffect()
      • SDL_HapticEffect

        public SDL_HapticEffect​(com.sun.jna.Pointer p)
    • Method Detail

      • read

        public void read()
        Overrides:
        read in class com.sun.jna.Structure
      • setType

        public void setType​(int hapticEffectType)