sdlRumbleGamepad function

bool sdlRumbleGamepad(
  1. Pointer<SdlGamepad> gamepad,
  2. int lowFrequencyRumble,
  3. int highFrequencyRumble,
  4. int durationMs,
)

Start a rumble effect on a gamepad.

Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.

This function requires you to process SDL events or call SDL_UpdateJoysticks() to update rumble state.

\param gamepad the gamepad to vibrate. \param low_frequency_rumble the intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF. \param high_frequency_rumble the intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF. \param duration_ms the duration of the rumble effect, in milliseconds. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)

Implementation

bool sdlRumbleGamepad(Pointer<SdlGamepad> gamepad, int lowFrequencyRumble,
    int highFrequencyRumble, int durationMs) {
  final sdlRumbleGamepadLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlGamepad> gamepad, Uint16 lowFrequencyRumble,
          Uint16 highFrequencyRumble, Uint32 durationMs),
      int Function(Pointer<SdlGamepad> gamepad, int lowFrequencyRumble,
          int highFrequencyRumble, int durationMs)>('SDL_RumbleGamepad');
  return sdlRumbleGamepadLookupFunction(
          gamepad, lowFrequencyRumble, highFrequencyRumble, durationMs) ==
      1;
}