Record Class SDL_HapticEffect
- All Implemented Interfaces:
IPointer,ISDL_HapticEffect
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, attack_length nor fade_length 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 attack_length and fade_level are 0, the envelope is not used, otherwise both values are used.
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.
Here we have an example of a constant effect evolution in time:
Strength
^
|
| effect level --> _________________
| / \
| / \
| / \
| / \
| attack_level --> | \
| | | <--- fade_level
|
+--------------------------------------------------> Time
[--] [---]
attack_length fade_length
[------------------][-----------------------]
delay length
Note either the attack_level or the fade_level may be above the actual effect level.
\since This struct is available since SDL 3.2.0.
\sa SDL_HapticConstant \sa SDL_HapticPeriodic \sa SDL_HapticCondition \sa SDL_HapticRamp \sa SDL_HapticLeftRight \sa SDL_HapticCustom
Structure
typedef struct SDL_HapticEffect {
Uint16 type;
SDL_HapticConstant constant;
SDL_HapticPeriodic periodic;
SDL_HapticCondition condition;
SDL_HapticRamp ramp;
SDL_HapticLeftRight leftright;
SDL_HapticCustom custom;
} SDL_HapticEffect;
Contracts
The property segment() should always be not-null
(segment != NULL && !segment.equals(MemorySegment.NULL)), and properly aligned to
LAYOUT.byteAlignment() bytes. To represent null pointer, you may use a Java
null instead. See the documentation of IPointer.segment() for more details.
The constructor of this class is marked as UnsafeConstructor, because it does not
perform any runtime check. The constructor can be useful for automatic code generators.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a pointer to / an array of null structure(s) in native memory. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final UnionLayoutstatic final StructLayoutstatic final StructLayoutstatic final StructLayoutstatic final StructLayoutstatic final StructLayoutstatic final StructLayoutstatic final ValueLayout.OfShortstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final MemoryLayout.PathElementstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final long -
Constructor Summary
ConstructorsConstructorDescriptionSDL_HapticEffect(@NotNull MemorySegment segment) Creates an instance of aSDL_HapticEffectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic SDL_HapticEffectstatic SDL_HapticEffect.Ptrstatic SDL_HapticEffectclone(Arena arena, SDL_HapticEffect src) @NotNull SDL_HapticConditioncondition(@NotNull SDL_HapticCondition value) condition(Consumer<@NotNull SDL_HapticCondition> consumer) @NotNull SDL_HapticConstantconstant()constant(@NotNull SDL_HapticConstant value) constant(Consumer<@NotNull SDL_HapticConstant> consumer) @NotNull SDL_HapticCustomcustom()custom(@NotNull SDL_HapticCustom value) custom(Consumer<@NotNull SDL_HapticCustom> consumer) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull SDL_HapticLeftRightleftright(@NotNull SDL_HapticLeftRight value) leftright(Consumer<@NotNull SDL_HapticLeftRight> consumer) @NotNull SDL_HapticPeriodicperiodic()periodic(@NotNull SDL_HapticPeriodic value) periodic(Consumer<@NotNull SDL_HapticPeriodic> consumer) @NotNull SDL_HapticRampramp()ramp(@NotNull SDL_HapticRamp value) ramp(Consumer<@NotNull SDL_HapticRamp> consumer) @NotNull MemorySegmentsegment()Returns the value of thesegmentrecord component.final StringtoString()Returns a string representation of this record class.shorttype()type(short value)
-
Field Details
-
LAYOUT
-
BYTES
public static final long BYTES -
PATH$type
-
PATH$constant
-
PATH$periodic
-
PATH$condition
-
PATH$ramp
-
PATH$leftright
-
PATH$custom
-
LAYOUT$type
-
LAYOUT$constant
-
LAYOUT$periodic
-
LAYOUT$condition
-
LAYOUT$ramp
-
LAYOUT$leftright
-
LAYOUT$custom
-
SIZE$type
public static final long SIZE$type -
SIZE$constant
public static final long SIZE$constant -
SIZE$periodic
public static final long SIZE$periodic -
SIZE$condition
public static final long SIZE$condition -
SIZE$ramp
public static final long SIZE$ramp -
SIZE$leftright
public static final long SIZE$leftright -
SIZE$custom
public static final long SIZE$custom -
OFFSET$type
public static final long OFFSET$type -
OFFSET$constant
public static final long OFFSET$constant -
OFFSET$periodic
public static final long OFFSET$periodic -
OFFSET$condition
public static final long OFFSET$condition -
OFFSET$ramp
public static final long OFFSET$ramp -
OFFSET$leftright
public static final long OFFSET$leftright -
OFFSET$custom
public static final long OFFSET$custom
-
-
Constructor Details
-
SDL_HapticEffect
Creates an instance of aSDL_HapticEffectrecord class.- Parameters:
segment- the value for thesegmentrecord component
-
-
Method Details
-
allocate
-
allocate
-
clone
-
type
-
type
-
constant
-
constant
-
constant
-
periodic
-
periodic
-
periodic
-
condition
-
condition
-
condition
-
ramp
-
ramp
-
ramp
-
leftright
-
leftright
-
leftright
-
custom
-
custom
-
custom
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
segment
Returns the value of thesegmentrecord component.
-