SDL_HapticCustom(3type)

πŸ’– SDL_HapticCustom β€” the tea on the SDL3 DATATYPES page, bestie πŸ’–

okay so you opened SDL_HapticCustom(3type) and you're like "what is this" β€” don't worry, I got you. This is the whole page, every last crumb, just with the vibes turned all the way up. ✨


✨ NAME ✨

SDL_HapticCustom β€” a structure containing a template for the SDL_HAPTIC_CUSTOM effect. that's it, that's the whole name section, she's simple and she knows it πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_haptic.h>

typedef struct SDL_HapticCustom
{
    /* Header */
    SDL_HapticEffectType type;      /**< SDL_HAPTIC_CUSTOM */
    SDL_HapticDirection direction;  /**< Direction of the effect. */

    /* Replay */
    Uint32 length;          /**< Duration of the effect. */
    Uint16 delay;           /**< Delay before starting the effect. */

    /* Trigger */
    Uint16 button;          /**< Button that triggers the effect. */
    Uint16 interval;        /**< How soon it can be triggered again after button. */

    /* Custom */
    Uint8 channels;         /**< Axes to use, minimum of one. */
    Uint16 period;          /**< Sample periods. */
    Uint16 samples;         /**< Amount of samples. */
    Uint16 *data;           /**< Should contain channels*samples items. */

    /* Envelope */
    Uint16 attack_length;   /**< Duration of the attack. */
    Uint16 attack_level;    /**< Level at the start of the attack. */
    Uint16 fade_length;     /**< Duration of the fade. */
    Uint16 fade_level;      /**< Level at the end of the fade. */
} SDL_HapticCustom;

like look at her. organized. labeled. comments in every single field. main character energy fr fr πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

This struct is exclusively for the SDL_HAPTIC_CUSTOM effect. no side quests, no sharing, she does one thing.

A custom force feedback effect is lowkey just like a periodic effect, except you get to define its exact shape. the whole shape. every bit of it. and bestie, that means you will have to allocate the data yourself β€” SDL is not doing it for you, she's not your mom 😭

Data should consist of channels * samples Uint16 samples. do the math, get the right count, that's the assignment.

If channels is one, the effect is rotated using the defined direction. Otherwise it uses the samples in data for the different axes. 🌈


πŸŽ€ AVAILABILITY πŸŽ€

This struct is available since SDL 3.2.0. so if you're on anything older, she's not there yet, sorry babe πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're besties with this one 🫢


quick reminder bestie: you allocate data, and it needs channels * samples Uint16 items. that's the one thing that'll bite you. πŸ’€

okay that's the whole page, nothing skipped, every field accounted for. this came from the Simple Directmedia Layer crew, page stamped SDL 3.4.18, and the whole thing lives under the SDL_HapticCustom(3type) name. slay, go make some shapes vibrate, ily πŸ’œπŸ’–βœ¨

πŸ“¦ where this page comes from