samuelgr / Xidi

DirectInput interface for XInput controllers
BSD 3-Clause "New" or "Revised" License
180 stars 10 forks source link

Silent Hill 4 - Force Feedback/Vibration not working #35

Closed r2rX closed 1 year ago

r2rX commented 1 year ago

Hey @samuelgr ,

After getting Silent Hill 4 working, I started a play-through and it seems that force feedback isn't working. This applies to both the retail and GOG version. Additionally, I also tried incorporating Hookshot but it didn't make a difference.

I also installed both versions of the game in a Win XP VM and used a Logitech Rumblepad 2 (w/ LGS 4.60 driver) and that did work...so vibration isn't inherently broken with the game. Silent Hill 2 and 3 work perfectly with Xidi dinput8, both with fully registered inputs and force feedback.

r2rX commented 1 year ago

Here's a log, verbose level 4, in case it can help debug/troubleshoot:

Xidi_DInput8_SILENT HILL 4.exe_308.log

samuelgr commented 1 year ago

Thank you, the log is very helpful.

[10/10/2022 17:02:36] [I] Invoked Xidi::VirtualDirectInputEffect<0>::SetParameters() on force feedback effect with identifier 0 associated with Xidi virtual controller 1, result = 0x00000003.

This doesn't appear to be a problem for Silent Hill 4, but it could potentially indicate issues in other games. 1d0102b50d3815e70a6b704a2a8d8eb0cf06aba9 should take care of it.

[10/10/2022 17:02:36] [D] Begin dump of effect parameters.
[10/10/2022 17:02:36] [D]   Control:
[10/10/2022 17:02:36] [D]     flags = 0x20000140 (DIEP_START | DIEP_DIRECTION | DIEP_TYPESPECIFICPARAMS)
[10/10/2022 17:02:36] [D]   Basics:
[10/10/2022 17:02:36] [D]     dwSize = 56 (sizeof(DIEFFECT))
[10/10/2022 17:02:36] [D]     dwFlags = 0x00000012 (DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS)
[10/10/2022 17:02:36] [D]   Direction:
[10/10/2022 17:02:36] [D]     cAxes = 1
[10/10/2022 17:02:36] [D]     rglDirection[ 0] = 10000
[10/10/2022 17:02:36] [D]   Type-Specific:
[10/10/2022 17:02:36] [D]     cbTypeSpecificParams = 4 (sizeof(DICONSTANTFORCE))
[10/10/2022 17:02:36] [D]     lpvTypeSpecificParams->lMagnitude = 14142
[10/10/2022 17:02:36] [D] End dump of effect parameters.
[10/10/2022 17:02:36] [I] Invoked Xidi::VirtualDirectInputEffect<0>::SetParameters() on force feedback effect with identifier 0 associated with Xidi virtual controller 1, result = 0x80070057.

This is the problem. The game uses a single effect and switches it between magnitude 0 and magnitude non-zero (14142 in this case). Technically the magnitude is only supposed to be from -10,000 to +10,000 but this game is sending in something that is out of range, and Xidi is rejecting it as an invalid parameter. Since it appears that the game works with DirectInput vibration, Xidi will need to be more flexible about force magnitudes in order to get games like this working.

r2rX commented 1 year ago

Really happy you determined the issue. I compiled the latest snapshot of Xidi and tested dinput8.dll. Unfortunately, it's still not working. Maybe the log will indicate something?

Xidi_DInput8_SILENT HILL 4.exe_304.log

samuelgr commented 1 year ago

I haven't fixed the main issue yet. Once I do that I will upload a development build for you to test.

r2rX commented 1 year ago

Hehe.....seems I jumped the gun when I saw https://github.com/samuelgr/Xidi/commit/1d0102b50d3815e70a6b704a2a8d8eb0cf06aba9 was added. :smile: . Ready when you are. :+1:

samuelgr commented 1 year ago

I think this should be fixed with c4005193e04fdc1d3b6016450a9521bec8566c12. Please give the attached development build a try.

Xidi-v4.0.3-dev.5.0+c4005193.zip

r2rX commented 1 year ago

Alrighty. Just tested it and, unfortunately, not working.

Xidi_DInput8_SILENT HILL 4.exe_304.log

samuelgr commented 1 year ago

Looks like the fix wasn't entirely complete. There was another spot in the code that was still being strict. I removed that and centralized all the logic in a5da9177dae34a65d8ebaf3b7f1fb54d851493d6, revised development build is attached. Please give it a try.

Xidi-v4.0.3-dev.8.0+a5da9177.zip

r2rX commented 1 year ago

@samuelgr , you're a star! Force feedback works with 4.0.3-dev.8.0! Good stuff and thank you. :)

samuelgr commented 1 year ago

Great to hear. The fix is officially released as v4.0.3.