Skip to content

Commit

Permalink
sdl: disable rumble when rumble power is set to 0
Browse files Browse the repository at this point in the history
Issue #1766
Issue #1783
  • Loading branch information
flyinghead committed Dec 26, 2024
1 parent 9bfd48c commit 9038ef6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/sdl/sdl_gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,12 @@ class SDLGamepad : public GamepadDevice
SDL_JoystickSetPlayerIndex(sdl_joystick, port <= 3 ? port : -1);
}

u16 getRumbleIntensity(float power) {
return (u16)std::min(power * 65535.f / std::pow(1.06f, 100.f - rumblePower), 65535.f);
u16 getRumbleIntensity(float power)
{
if (rumblePower == 0)
return 0;
else
return (u16)std::min(power * 65535.f / std::pow(1.06f, 100.f - rumblePower), 65535.f);
}
void doRumble(float power, u32 duration_ms)
{
Expand Down Expand Up @@ -389,6 +393,7 @@ class SDLGamepad : public GamepadDevice
SDL_HapticStopAll(haptic);
if (hasAutocenter)
SDL_HapticSetAutocenter(haptic, 0);
vib_inclination = 0;
}
if (!hapticRumble)
rumble(0, 0, 0);
Expand Down

0 comments on commit 9038ef6

Please sign in to comment.