SDL icon indicating copy to clipboard operation
SDL copied to clipboard

DirectInput FFB: Calculate appropriate update flags

Open dwillbarron opened this issue 3 weeks ago • 1 comments

Hi there. Same guy, different account--It's been a while, but I finally got the time to write the PR for this.

Currently in draft

Since FFB is a famously treacherous territory (hence how we got here), I'm going to try and round up some folks to test and make sure there are no unforeseen consequences to these changes.

In the meantime, if you have the time to look, please let me know if you have any feedback on the code itself.

Context

Anecodtally, some force-feedback wheels have been reported to experience a reduced "definition", "texture", "precision", or "je ne sais quoi", which appears to be caused by sending more update flags than necessary to DirectInput.

This may be related to the fact that there are two USB PID packets that are sent when updating a device: One contains the "general" force data, and the other contains the "type-specific" data. My speculation is that many wheels expect to only receive the latter, and misbehave when receiving both.

This has been tested and validated anecdotally by others who have received a hacked-together version of PCSX2 that corrects the flags sent to DirectInput, who noted a significant improvement in the "feeling" of the FFB effects.

The only way to validate this at a technical level is to grab a wheel that uses the "generic" DirectInput FFB drivers (which map nearly 1:1 with the USB PID specification), and inspect the USB packets (e.g. with USBPcap) to check whether redundant data is being sent.

Description

This PR adjusts the DirectInput Haptic implementation to compare the requested haptic update to the previous state of the haptic effect. Using this, it calculates which update flags to pass on to DirectInput, which prevents redundant flags from being sent. This appears to fix subjective FFB quality problems on certain specific FFB wheels.

Existing Issue(s)

Issue #12511: SDL_DINPUT_HapticUpdateEffect sends unnecessary flags to IDirectInputEffect_SetParameters, which harms FFB quality in certain devices/usecases

dwillbarron avatar Dec 03 '25 00:12 dwillbarron

Welcome back! Offhand the code looks good.

slouken avatar Dec 03 '25 02:12 slouken