SDL_RumbleGamepad(3)

πŸ’– SDL_RumbleGamepad πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_RumbleGamepad β€” she makes your gamepad go brrrrr πŸŽ€


✨ NAME ✨

SDL_RumbleGamepad β€” Start a rumble effect on a gamepad. that's it, that's the vibe 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gamepad.h>

bool SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• every single call to this function cancels any previous rumble effect β€” like, no stacking, no layering, the new one just replaces the old one, periodt. and if you call it with an intensity of 0, that stops any rumbling entirely. bye bye buzz πŸ’…

also important, bestie: this function requires you to process SDL events or call SDL_UpdateJoysticks() to actually update the rumble state. like, it's not gonna magically keep vibrating on its own, you gotta do your part πŸ”₯

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • gamepad β€” the gamepad you wanna vibrate. the one getting the shimmy ✨
  • low_frequency_rumble β€” the intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF. that's the deep, rumbly one 🧚
  • high_frequency_rumble β€” the intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF. that's the buzzy, tingly one πŸ’œ
  • duration_ms β€” the duration of the rumble effect, in milliseconds. how long she goes brrr ⭐

πŸ’€ RETURN VALUE πŸ’€

returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, she'll tell you what went wrong 😭


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this function from any thread. go off, multithreaded queen πŸ‘‘


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older... no rumble for you, sorry bestie πŸ™ˆ


that's the whole page!! now go make something shake πŸ’–βœ¨

kisses from the Simple Directmedia Layer girlies β€” this is SDL 3.4.18, and the page you just read was SDL_RumbleGamepad(3) πŸŽ€πŸ«ΆπŸ’…

πŸ“¦ where this page comes from