https://bugs.winehq.org/show_bug.cgi?id=51922
--- Comment #15 from RĂ©mi Bernon rbernon@codeweavers.com --- (In reply to Ivo Ivanov from comment #14)
Created attachment 71221 [details] winebus-fixes.patch
I remember that comment in the SDL code :) I got confused by it when I was writing a Linux FFB driver for a Fanatec device and found it on the net. Maybe they mean the 90 deg difference between polar and spherical. Anyway, it is visible from the SDL code that they just rescale the source polar coords to the Linux FF range.
You're right, I've been so much confused by the comment that I even read the code as if it was actually doing what it described, but it isn't...
So your previous code was correct. I have reverted the lnxev part of the patch, and immediately the "set effect" output reports started showing the correct direction 0x2d similar to the other backends and Windows.
What I'm still puzzled with is that the legacy dinput evdev backend we previously had was using the same direction rotations as we are now. I wouldn't trust it too much though, it's possible that it also got it wrong, or that the inversion was indeed here in the Linux kernel, a long time ago.
The FFB was still absent, though, so I looked at some captured usb traffic, and found two interesting things. The FF gain was set to 0 on the lnxev backend, and the duration field of the "set effect" report was 0x7fff on the both SDL and lnxev backends.
For the first issue appeared that FF_GAIN needed to be rescaled for the Linux FF range.
For the second issue, we pass correctly 0xffff for infinite duration, but Linux just clamps it to the max allowed value of 0x7fff, as it doesn't consider that value an infinite duration. The Linux FF uses 0 for that, while SDL uses SDL_HAPTIC_INFINITY.
So, attached patches that correct the issues. Tested thoroughly both the SDL and lnxev backends with various games - rFactor 2, Assetto Corsa Competizione, Automobilista 2, BeamNG, etc. The FFB worked properly and on par with hidraw and Windows. The only problem I could still spot is that the damper condition effect is very weak in comparison to hidraw and Windows. Assetto Corsa Competizione uses such effect when the car is stand still.
The patches are based on 3f6102080e632b9f4d8a97c0f0b1231fbd8e759b
Thanks for the fixes, they look right indeed.