SDL_RunHapticEffect(3)

πŸ’– SDL_RunHapticEffect(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we make your controller go brrrrr on purpose 🫢 this one's about running a haptic effect on its associated haptic device. yes, that's the whole vibe. let's get into it.


✨ NAME ✨

SDL_RunHapticEffect β€” Run the haptic effect on its associated haptic device.

it's giving "push the go button on the buzz". iconic πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_haptic.h>

bool SDL_RunHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, Uint32 iterations);

copy it exactly, no cap, don't freestyle the signature πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie πŸ“ there's two whole different ways to make a thing go forever, and the way that people mix them up is literally the classic haptic blunder.

  • Wanna repeat the effect over and over indefinitely? Set iterations to SDL_HAPTIC_INFINITY. This repeats the envelope β€” the attack and the fade. So every loop does the whole rise-and-fall thing again. πŸ”
  • Wanna make one single instance of the effect last indefinitely, so the effect does not fade? Then instead set the effect's length in its structure/union to SDL_HAPTIC_INFINITY. one long smooth buzz, no envelope re-runs. 😌
these are two different knobs and they do two different things, so pick the one that matches the actual vibe you want. no guessing, bestie. πŸ’€

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • haptic β€” the SDL_Haptic device to run the effect on. the main character device in question πŸ‘‘
  • effect β€” the ID of the haptic effect to run. you gotta have an ID, fr fr.
  • iterations β€” the number of iterations to run the effect; use SDL_HAPTIC_INFINITY to repeat forever. ♾️ forever-ever? forever-ever. πŸ’–

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and when it fails, call SDL_GetError() for more information. always check your return values, bestie, it's self care 🌈


πŸ’œ AVAILABILITY πŸ’œ

This function is available since SDL 3.2.0. if you're on anything older, it's simply not there and that's not a you problem, that's a version problem 🧚


🌟 SEE ALSO 🌟

go read those too, iykyk ✨


lowkey reminder: you can start effects, you can stop effects, you can even ask about their status. you're basically a haptic sommelier now. πŸ·πŸ’…

and that's the page, bestie! this came to you from the Simple Directmedia Layer girlies, SDL 3.4.18 edition πŸŽ€ go forth and make things vibrate responsibly. mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from