GamepadsSDL 3.2

SDL_RumbleGamepad

Makes the gamepad vibrate for a given time.

Signature

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

How it works

Pads have two motors: a heavy one on the left (low frequency, a deep rumble for explosions) and a light one on the right (high frequency, a buzz for footsteps or gunfire). Each intensity goes from 0 to 0xFFFF.

Each call replaces the previous rumble; calling with both intensities 0 stops it.

Parameters

gamepadSDL_Gamepad *

The gamepad.

low_frequency_rumbleUint16

Left, heavy motor: 0 to 0xFFFF.

high_frequency_rumbleUint16

Right, light motor: 0 to 0xFFFF.

duration_msUint32

How long, in milliseconds.

Return value

true on success; false if this pad cannot rumble.

Example

example.cpp
1SDL_RumbleGamepad(pad, 0x8000, 0x4000, 200);   // a 200 ms thump when hit
Official SDL wiki