Skip to content

Commit

Permalink
USB: Work around FFB dropouts with modern wheels
Browse files Browse the repository at this point in the history
Certain modern direct-drive wheels such as the Moza R5, R9, etc. implement
timeouts for FFB constant forces, requiring them to be stopped and restarted
regularly, regardless of whether the effect is regularly being updated.
  • Loading branch information
badfontkeming committed Oct 12, 2024
1 parent c087fc4 commit 3862b7c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ namespace usb_pad
if (m_constant_effect_id < 0)
return;

// Temporarily stop the constant force. This works around issues with
// certain FFB devices such as the Moza R5, R9, etc which have safety
// timeouts that ignore FFB commands that have been running for too
// long without being restarted, typically 10-15 seconds.
if (m_constant_effect_running)
{
SDL_HapticStopEffect(m_haptic, m_constant_effect_id);
m_constant_effect_running = false;
}

const s16 new_level = static_cast<s16>(std::clamp(level, -32768, 32767));
if (m_constant_effect.constant.level != new_level)
{
Expand All @@ -187,13 +197,10 @@ namespace usb_pad
Console.Warning("SDL_HapticUpdateEffect() for constant failed: %s", SDL_GetError());
}

if (!m_constant_effect_running)
{
if (SDL_HapticRunEffect(m_haptic, m_constant_effect_id, SDL_HAPTIC_INFINITY) == 0)
m_constant_effect_running = true;
else
Console.Error("SDL_HapticRunEffect() for constant failed: %s", SDL_GetError());
}
if (SDL_HapticRunEffect(m_haptic, m_constant_effect_id, SDL_HAPTIC_INFINITY) == 0)
m_constant_effect_running = true;
else
Console.Error("SDL_HapticRunEffect() for constant failed: %s", SDL_GetError());
}

template <typename T>
Expand Down

0 comments on commit 3862b7c

Please sign in to comment.