NFSIISE icon indicating copy to clipboard operation
NFSIISE copied to clipboard

Any way to have FFB on windows?

Open sonik-br opened this issue 2 years ago • 35 comments

Hi, I've set up the conf file to enable ffb. On the game options menu if I go the ffb settings it opens and the strength set at max. But in game there's no ffb. Nothing.

Tested on win7 and win10. Both x64. Logitech G27 with drivers installed.

sonik-br avatar Dec 31 '21 03:12 sonik-br

It can be complicated - open config file (I remember there is a bat script to open the config file) and change line #WindowsForceFeedbackDevice=-1 to e.g. WindowsForceFeedbackDevice=0, save file and run the game. If not, change from 0 to 1 and try again (restart game).

Don't forget to remove # from line.

zaps166 avatar Feb 16 '22 13:02 zaps166

Can't get ffb to work at all in windows on this game. When enabled in the config, the game's FFB menu activates. But no effect at all when playing. Also if I set the wrong index on WindowsForceFeedbackDevice the game will disable the FFB menu. In my case I think the correct value is zero, as I only have one controller (g27 wheel) connected.

sonik-br avatar Feb 16 '22 19:02 sonik-br

Ah on wheels like G27 it will not work. It now supports regular rumble for gamepads. I was unable to manage it for wheels. Does the game support it? If you know C/C++ - PR welcome (if game supports it).

I was trying to do it with UseSpringForceFeedbackEffect, but it never worked as expected.

zaps166 avatar Feb 17 '22 10:02 zaps166

On the same machine I can get the FFB working inside linux on a VM, passing through usb from host to guest machine.

Best I could find is that the POLAR effect does not works correctly on sdl2 windows. (and the game seems to use SDL_HAPTIC_POLAR) https://discourse.libsdl.org/t/sdl2-win32-forcefeedback-sdl-polar-not-working-on-steering-wheel/20712/3

sonik-br avatar Feb 17 '22 12:02 sonik-br

I just tested it on windows with a 2 axis ffb device. A Sidewinder Flightstick. And I can confirm that the FFB works as expected!

Looks like the problem is indeed the polar effect with a single axix device (a racing wheel).

sonik-br avatar Feb 24 '22 21:02 sonik-br

Good to hear it's working!

zaps166 avatar Mar 13 '22 17:03 zaps166

Well... It only works with a joystick but not with a racing wheel. Any chance of fixing it?

sonik-br avatar Mar 13 '22 17:03 sonik-br

I don't have Logitech wheel... Try to cross-compile it for Windows from Arch/Manjaro Linux, if you do, you can try to change FFB effects for Windows or test with newest SDL2. Soon I'll release with new SDL2 for Windows, too. Do you know if the effect can work on new SDL2?

zaps166 avatar Mar 13 '22 17:03 zaps166

I don't know if it will work on sdl2. the only info I could find is that the "polar effect" only work on multi axis device on windows. So it will not work with any racing wheel on windows. I will wait for the sdl2 version and test it then. Thanks.

sonik-br avatar Mar 13 '22 20:03 sonik-br

Hi. I've found this patch for SDL: https://github.com/libsdl-org/SDL/commit/65ad45340d23bfa86f0f163dec753b57026c1091

I don't have a build environment for doing tests. Please could you try to change the effect from SDL_HAPTIC_POLAR to SDL_HAPTIC_STEERING_AXIS and generate a new build?

I can help testing it on windows.

sonik-br avatar Jun 06 '22 14:06 sonik-br

I can do it, I'll notify you when finished. Why change SDL_HAPTIC_POLAR ? Is it needed?

zaps166 avatar Jun 08 '22 15:06 zaps166

The Polar effect on windows requires a dual axis device. The racing wheel only have feedback on a single axis. Looks like SDL_HAPTIC_STEERING_AXIS will send the effect to the correct axis on the wheel. :)

Edit: The problem with the Polar effect also happens on the original game. Makes it impossible to have FFB on a racing wheel on windows.

sonik-br avatar Jun 08 '22 16:06 sonik-br

The problem with the Polar effect also happens on the original game. Makes it impossible to have FFB on a racing wheel on windows.

I remember I fixed one bug with FFB in game.


I can apply

diff --git a/src/DInput.c b/src/DInput.c
index d7efb36..e0019d2 100644
--- a/src/DInput.c
+++ b/src/DInput.c
@@ -122,7 +122,7 @@ static void setEffect(DirectInputEffect *dinputEffect, const DIEFFECT *di_eff)
                                if (di_constant)
                                        constant->level = CONVERT(di_constant->magnitude);
                                constant->length = CONVERT_LENGTH(di_eff->duration);
-                               constant->direction.type = SDL_HAPTIC_POLAR; //di_eff->flags shows that POLAR is used (0x20)
+                               constant->direction.type = SDL_HAPTIC_STEERING_AXIS; //di_eff->flags shows that POLAR is used (0x20)
                                for (i = 0; i < di_eff->cAxes; ++i)
                                        constant->direction.dir[i] = di_eff->rglDirection[i];
 //                             printf("Constant: %d %d %d, %X\n", constant->length, constant->level, di_eff->cAxes, di_eff->flags);

and recompile with SDL 2.0.22. Do you still want it?

zaps166 avatar Jul 15 '22 23:07 zaps166

Yes, please.

sonik-br avatar Jul 16 '22 01:07 sonik-br

Try this nfs2se-SDL_HAPTIC_STEERING_AXIS-sdl2.0.22.zip (sha1 822bf15d264c977a729cbc3f9e593b1f449e8cfa) :smile:

zaps166 avatar Jul 16 '22 11:07 zaps166

Yay!!! \o/ I did a quick test and it's working perfectly on windows! I will play more during this weekend and report back.

Thank you very much for doing this change and make it possible to play on modern windows with ffb.

Would be possible to have an option in the ini to use the default (4 axis ffb) or the new (2 axis ffb)? The 4 axis mode can be useful if anyone wants to play with an joystick instead of a wheel.

And I see it being useful if anyone have a "racing chair" with FFB. The game tries to simulate the g force even on the Y axis. When the car speeds up, it pulls the stick back. When the car brakes, it pulls the stick up. Cool feature but I don't imagine anyone using it for this game as it's not an simulator but an arcade game.

sonik-br avatar Jul 16 '22 13:07 sonik-br

It's working fine. One thing I noticed is that FFB only kicks in when the car collides.

sonik-br avatar Jul 16 '22 14:07 sonik-br

Good to hear it's working!

Would be possible to have an option in the ini to use the default (4 axis ffb) or the new (2 axis ffb)? The 4 axis mode can be useful if anyone wants to play with an joystick instead of a wheel.

Can you show me in code what I should do about it?

zaps166 avatar Jul 16 '22 14:07 zaps166

The line that you changed from SDL_HAPTIC_POLAR to SDL_HAPTIC_STEERING_AXIS. If you can add a condition to use one or the other based on a ini setting. Just to have an option to use the original POLAR effect or the new STEERING effect.

sonik-br avatar Jul 16 '22 17:07 sonik-br

Ok!

Btw. what about this: https://github.com/zaps166/NFSIISE/blob/9a483a088bfcac311338657a1e95e1c782beebf6/src/DInput.c#L167 ? Did you try it? I don't remember, but probably It never worked, should I remove it?

zaps166 avatar Jul 16 '22 19:07 zaps166

I did not see any difference with spring on/off. At least on windows. Do you know why ffb only acts on car collision? I remember it pushing left and right during corners.

sonik-br avatar Jul 16 '22 20:07 sonik-br

Do you know why ffb only acts on car collision? I remember it pushing left and right during corners.

In original game?


Look here: https://github.com/zaps166/NFSIISE/commit/eb9f82f477e435fc83544df6653e2959c753b4c2

zaps166 avatar Jul 17 '22 14:07 zaps166

Yes in original. I've made this video playing on keyboard but with the game sending FFB to a joystick.

https://www.youtube.com/shorts/EW0PKr6Bbf8

See how if forces the stick to move sideways during when doing some corners

Edit: Your linux version seems to have all the FFB effects working. But I can't test it as my Ubuntu VM crashes when run this game.

sonik-br avatar Jul 17 '22 16:07 sonik-br

I have only PS3/PS5 gamepad with vibrations and once I was trying it on Logitech wheel with FFB, but it was many years ago, but it was not working good IIRC. I never had such game controller

See how if forces the stick to move sideways during when doing some corners

Yes, but now I'm lost :D Is it original game or this project using SDL2?

Do you know why ffb only acts on car collision?

Original or this?

zaps166 avatar Jul 17 '22 21:07 zaps166

The video is from original game. It apply force effect during corner.

Your version is only applying FFB or car collision. At least on windows. On linux looks like the FFB is correct but I can't test as I only have ubuntu running inside a virtual machine and the game crashes.

sonik-br avatar Jul 17 '22 21:07 sonik-br

You can try to compile it and fix the issue - I don't have such device.

Compilation for Windows is easy on Arch Linux or Manjaro linux - install mingw, sdl2 for mingw (from AUR) and just run ./compile_nfs win32. You can boot Manjaro Linux from USB stick, install AUR client yay and mingw-w64-sdl2 + some needed deps and compile. Also you can try to run linux version from USB stick.

On linux looks like the FFB is correct but I can't test as I only have ubuntu running inside a virtual machine and the game crashes.

What VM do you use? Do you passthrough GPU? Can you try to force software OpenGL (llvmpipe)?

zaps166 avatar Jul 17 '22 22:07 zaps166

Currently I have Ubuntu running inside VMware Workstation Player. It does support OpenGL and it kinda run ok... But game have some hangs from time to time and it can crash and close.

I might just install linux on another disk/partition just to play this game :) Do you recommend any distro to install just for playing this game? Ubuntu seems over bloated with features.

sonik-br avatar Jul 17 '22 22:07 sonik-br

Do you recommend any distro to install just for playing this game? Ubuntu seems over bloated with features.

Install Manjaro Mate, run this script and confirm all. It will also install my lightweight X11 compositor. Email me for any questions.

Currently I have Ubuntu running inside VMware Workstation Player. It does support OpenGL and it kinda run ok... But game have some hangs from time to time and it can crash and close.

For games - GPU passthrough only (never did it on Windows). For testing simple game you can use software opengl - it shouldn't crash.


But it will be nice to have FFB working on Windows, too :smile: If you manage to compile it, you can try to make it work (if possible) and create a PR.

zaps166 avatar Jul 17 '22 23:07 zaps166

Thanks. I will install Manjaro.

I don't have any experience with SDL but I will give it a shot. I see some print codes commented out. Those will output to console/terminal? Would be handy to debug.

sonik-br avatar Jul 18 '22 02:07 sonik-br

I see some print codes commented out. Those will output to console/terminal? Would be handy to debug.

yes, run game in windowed mode, you'll see them

zaps166 avatar Jul 18 '22 16:07 zaps166