Record Class SDL_HapticPeriodic

java.lang.Object
java.lang.Record
club.doki7.sdl3.datatype.SDL_HapticPeriodic
All Implemented Interfaces:
IPointer, ISDL_HapticPeriodic

@ValueBasedCandidate @UnsafeConstructor public record SDL_HapticPeriodic(@NotNull MemorySegment segment) extends Record implements ISDL_HapticPeriodic

A structure containing a template for a Periodic effect.

The struct handles the following effects:

  • SDL_HAPTIC_SINE
  • SDL_HAPTIC_SQUARE
  • SDL_HAPTIC_TRIANGLE
  • SDL_HAPTIC_SAWTOOTHUP
  • SDL_HAPTIC_SAWTOOTHDOWN

A periodic effect consists in a wave-shaped effect that repeats itself over time. The type determines the shape of the wave and the parameters determine the dimensions of the wave.

Phase is given by hundredth of a degree meaning that giving the phase a value of 9000 will displace it 25% of its period. Here are sample values:

  • 0: No phase displacement.
  • 9000: Displaced 25% of its period.
  • 18000: Displaced 50% of its period.
  • 27000: Displaced 75% of its period.
  • 36000: Displaced 100% of its period, same as 0, but 0 is preferred.

Examples:

SDL_HAPTIC_SINE
__      __      __      __
/  \    /  \    /  \    /
/    \__/    \__/    \__/

SDL_HAPTIC_SQUARE
__    __    __    __    __
|  |  |  |  |  |  |  |  |  |
|  |__|  |__|  |__|  |__|  |

SDL_HAPTIC_TRIANGLE
/\    /\    /\    /\    /\
/  \  /  \  /  \  /  \  /
/    \/    \/    \/    \/

SDL_HAPTIC_SAWTOOTHUP
/|  /|  /|  /|  /|  /|  /|
/ | / | / | / | / | / | / |
/  |/  |/  |/  |/  |/  |/  |

SDL_HAPTIC_SAWTOOTHDOWN
\  |\  |\  |\  |\  |\  |\  |
\ | \ | \ | \ | \ | \ | \ |
\|  \|  \|  \|  \|  \|  \|

Since: This struct is available since SDL 3.2.0.

See also:

  • SDL_HAPTIC_SINE
  • SDL_HAPTIC_SQUARE
  • SDL_HAPTIC_TRIANGLE
  • SDL_HAPTIC_SAWTOOTHUP
  • SDL_HAPTIC_SAWTOOTHDOWN
  • SDL_HapticEffect

Structure

typedef struct SDL_HapticPeriodic {
    Uint16 type;
    SDL_HapticDirection direction;
    Uint32 length;
    Uint16 delay;
    Uint16 button;
    Uint16 interval;
    Uint16 period;
    Sint16 magnitude;
    Sint16 offset;
    Uint16 phase;
    Uint16 attack_length;
    Uint16 attack_level;
    Uint16 fade_length;
    Uint16 fade_level;
} SDL_HapticPeriodic;

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.