elishacloud / dinputto8

A dll module that is designed to improve compatibility in games using DirectInput 1-7 (dinput.dll) by converting all API calls to their equivalent DirectInput 8 (dinput8.dll) ones. This allows older games to be able to use newer tools and wrappers written for DirectInput 8.
zlib License
116 stars 11 forks source link

NFS: Porsche Unleashed crashes on race load #15

Open sdether opened 3 years ago

sdether commented 3 years ago

Following instructions from PCGamingWiki I installed dinputto8 v1.0.39.0 and devreorder to try to add support for my Fanatec CSL Elite Wheel.

However this combination crashes the game once you try to start a race. I did some experimentation to try to narrow down what causes this:

My guess is that there's something in the way the Fanatec uses Direct Input that is not compatible with the API mapping that dinputto8 does. If there is anything I can do on my end to provide a more useful bug report or diagnostic data, please let me know.

sdether commented 3 years ago

Tried installing dinput_debug for v1.0.39.0 to get logging, however that complains about a bunch of missing DLLs (including VCRUNTIME140.DLL). Seemed to track back to missing Visual C++ Redistributable for Visual Studio 2015, however I already have a redistributable called Visual C++ Redistributable for Visual Studio 2015-2019 which prevents the install of the former, so not sure what I'm missing to get the debug version working

sdether commented 3 years ago

Also tired dinput_debug v1.0.30.0 since that still had logging enabled. That one, however crashes NFS:PU on launch even when only XBox360 controller is configured which works with v1.0.39.0. Just in case this is the log it writes:

12592 10:25:32.439 Starting dinputto8 v1.0.30.0
12592 10:25:32.439 ASUSTeK COMPUTER INC. TUF H310-PLUS GAMING Rev X.0x (Desktop)
12592 10:25:32.440 Windows 10 64-bit (10.0.19041)
12592 10:25:32.440 "nfs5.exe" (PID:7788)
12592 10:25:32.444 Redirecting 'DirectInputCreate' IID_IDirectInputA version 0x500 to --> 'DirectInput8Create'
12592 10:25:32.508 Creating device m_IDirectInputX::m_IDirectInputX(04D33650) converting device from v1 to v8 using ANSI
12592 10:25:32.509 Creating device m_IDirectInputDeviceX::m_IDirectInputDeviceX(04CE6558) converting device from v1 to v8 using ANSI
12592 10:25:32.509 Creating device m_IDirectInputDeviceX::m_IDirectInputDeviceX(04CE64C8) converting device from v2 to v8 using ANSI
12592 10:25:32.509 m_IDirectInputDeviceX::~m_IDirectInputDeviceX(04CE6558) deleting device!
12592 10:25:32.509 m_IDirectInputDeviceX::~m_IDirectInputDeviceX(04CE64C8) deleting device!
12592 10:25:32.509 m_IDirectInputX::~m_IDirectInputX(04D33650) deleting device!
12592 10:25:32.509 DirectInputCreateW
12592 10:25:32.509 Redirecting 'DirectInputCreate' IID_IDirectInputW version 0x50a to --> 'DirectInput8Create'
12592 10:25:32.526 Creating device m_IDirectInputX::m_IDirectInputX(04D33608) converting device from v1 to v8 using UNICODE
12592 10:25:32.526 Redirecting 'DirectInputCreate' IID_IDirectInputA version 0x500 to --> 'DirectInput8Create'
12592 10:25:32.526 Creating device m_IDirectInputX::m_IDirectInputX(04D3AA88) converting device from v1 to v8 using ANSI
12592 10:25:32.527 Creating device m_IDirectInputDeviceX::m_IDirectInputDeviceX(04CE65E8) converting device from v1 to v8 using ANSI
12592 10:25:32.527 m_IDirectInputDeviceX::~m_IDirectInputDeviceX(04CE65E8) deleting device!
12592 10:25:36.370 m_IDirectInputX::~m_IDirectInputX(04D33608) deleting device!
12592 10:25:36.370 m_IDirectInputX::~m_IDirectInputX(04D3AA88) deleting device!
elishacloud commented 3 years ago

Here is the latest debug file. Go ahead and try this one, attaching the logs.

dinput.zip

sdether commented 3 years ago

Tried to keep the test cases as minimal as possible: xbox360_dinput.log - only Xbox controller were mapped prior to this run. Game is launched, race is started. Shortly after it loads properly I exit

fanatec_dinput.log - Steering on the Fanatec wheel was mapped prior to this run, while the other Xbox bindings remained. Game is launched, race is started. Crashes on completion of load.

Didn't see anything obvious in the logs, except that the fanatec case had a couple of cases of two threads writing log lines at the same time, messing up line feeds, but doubt that's related to crashes. Hope the logs shed more light for you.

thanks!

elishacloud commented 3 years ago

Thanks for the help here. Am I correct in saying that the Xbox controller works fine?

I can see that Fanatec wheel calls the CreateEffect function and it looks like it is failing on this function. There may be something I need to convert to DirectInput8. I am not sure if this is why it is crashing.

I created an update with more logging here. Can you test this one and upload the logs: dinput.zip

sdether commented 3 years ago

Yes, when just using the Xbox controller everything works. And it does look like the Fanatec controller is failing on CreateEffect. There's a bunch of Trying followed by Failed entries in the logs now. dinput.log

Not sure if this is helpful or related, but in case CreateEffect is related to Force Feedback, I should note that when running the game without dinput and mapping the Fanatec wheel the wheel is definitely receiving Force Feedback. It's just that the analog controls are not bound. But the game starts going straight on full throttle and you can feel the FFB pushing against turning the wheel and you can feel the texture of the road as its going down the road, so in principle the wheels FFB and what NFS:PU is sending seem to be compatible.

elishacloud commented 3 years ago

It looks like it is sending 0x80070057 which means a parameter is incorrect. I created an update to fix some of the parameter issues.

Can you test this one and upload the logs: dinput.zip

sdether commented 3 years ago

Took a little longer to crash. Usually it crashes as soon as it the loading bar gets to the end. This time it just hung there, making me think it had locked up. But a couple of seconds later it did crash. I see more debug information on the CreateEffect calls, but otherwise it seems like it's the same calls that are failing. dinput.log

Really appreciating you working on this, btw. Pretty awesome that a game from 2000 can still be tweaked independently of the original developer.

elishacloud commented 3 years ago

There is still a bad parameter, but I don't know which one. I added more logging and tried a slightly different way of creating the effect.

Here is one more try: dinput.zip

sdether commented 3 years ago

Alright this is fantastic. Does not crash, mapping works, and it works in race.

dinput.log

That solves the main problem. I did come across two other issues:

elishacloud commented 3 years ago

It looks like the crash was coming from the failed CreateEffect function. The new way I am creating the effects is not a permanent solution, and it does not solve the core issue of invalid parameter, as seen by this log:

10204 23:20:56.703 m_IDirectInputDeviceX::CreateEffect (0B119838) tying 'SetParameters' hr = DIERR_INVALIDPARAM

For this update I hard coded some of the parameters based on Microsoft's SDK. This will help isolate the issue: dinput.zip

sdether commented 3 years ago

Back to crashing. Hope there's enough info in this one dinput.log

elishacloud commented 3 years ago

@sdether, thanks for your continued help here! I have no other way to test this.

It looks like the issue with the parameters may be caused by a previous call to SetDataFormat. I added more logs there. I hope this will give me all the data I need.

Here is another test build: dinput.zip

sdether commented 3 years ago

This one works again. Input in configuration screen still super laggy and still no forcefeedback in-race, but otherwise the controls work as they should.

dinput.log

And I should be the one thanking you. I'm the one with the odd combination of old game and new hardware that's crashing after all. Gladly provide all the debugging support I can since my C++ is atrocious. I've sworn off all languages that require manual memory management, since the only thing I ever effectively managed to create was memory leaks and crashes :)

elishacloud commented 3 years ago

Input in configuration screen still super laggy

This could just because the wrapper is running in debug mode. Here is a release build to test with to see if it is still slow with the release build: dinput.zip

still no forcefeedback in-race

There are no errors and the functions seem to be passing, so I am not sure what is happening here. I added logs when the game tries to start the force feedback to see if it is getting any errors.

I should be the one thanking you. I'm the one with the odd combination of old game and new hardware that's crashing after all.

I would like to fix this if possible, since I have had reports of similar issues and I think they are related.

I've sworn off all languages that require manual memory management, since the only thing I ever effectively managed to create was memory leaks and crashes :)

I am afraid the maker of this game maybe should have done the same thing. The game fails to check the Effect interface address and uses it blindly, thus the crash. I fixed this by creating the interface with no parameters and then adding the parameters later. This way when the game uses the interface it does not crash.

Here is another debug test build. It just has additional logs: dinput.zip

sdether commented 3 years ago

Input in configuration screen still super laggy

This could just because the wrapper is running in debug mode. Here is a release build to test with to see if it is still slow with the release build: dinput.zip

That fixed it. Makes sense.

still no forcefeedback in-race

There are no errors and the functions seem to be passing, so I am not sure what is happening here. I added logs when the game tries to start the force feedback to see if it is getting any errors.

Here's the latest debug output. Hope it sheds more light on things: dinput.log

elishacloud commented 3 years ago

It is possible some other functions may be causing the failure in CreateEffect so I added logging for other functions that may affect it. I also made one change to SetDataFormat, which may have been the issue.

Can you try this update: dinput.zip

sdether commented 3 years ago

Crashes on race start. Log attached. Not seeing anything obvious. dinput.log

elishacloud commented 3 years ago

Ok, looks like I had a bug in my code. This one should no longer crash, but it still does not get us closer to solving the force feedback issue.

New update: dinput.zip

I did see one entry in the log:

2716 15:25:02.559 m_IDirectInputDeviceX::SetCooperativeLevel (0081F740) Trying! 0x6
2716 15:25:02.559 m_IDirectInputDeviceX::SetCooperativeLevel (0081F740) Failed! E_HANDLE

But this may be normal for the game and it shouldn't have any impact on the force feedback issue.

sdether commented 3 years ago

Alright. No crashes and this one looks like it's got some useful info. Plenty of failures around CreateEffect, and GetEffectGUID along the lines of

908 18:02:04.302 m_IDirectInputEffect::SetParameters (104112B8) Failed! hr: DIERR_INVALIDPARAM
908 18:02:04.302 m_IDirectInputEffect::Start (104112B8) Trying! 1 0x0
908 18:02:04.302 m_IDirectInputEffect::Start (104112B8) Failed! hr: DIERR_INCOMPLETEEFFECT

etc. dinput.log

BloodDeath commented 3 years ago

Hello, I have similiar issue with crashing in the end of race oad when I use Logitech Driving Force GT or Logitech Formula Force EX. My Xbox one controller works fine. I've tried to use different versions of dinput posted here with no luck. I'm attaching my latest dinput.log

elishacloud commented 3 years ago

Can you try with the attached update? I made a few changes that might solve the issue and enabled full logging.

Here is the update: dinput.zip

BloodDeath commented 3 years ago

Thank you very much, loading works and I can drive, but just like above case, Force Feedback is not working. dinput.zip

elishacloud commented 3 years ago

Attached is another debug log. This probably won't solve the issue, but will give me a bit more debug info. Since I don't have the correct hardware I need to get some logs from you.

Here is the new update: dinput.zip

BloodDeath commented 3 years ago

Ok, nothing changed in gameplay. Here is log: dinput.zip

pierre313 commented 3 years ago

Hi. I had exact same problem with a Logitech G27 and was ready to give up trying to play this old game but in last moment found this thread. I'm using the Release build that was posted here on Jan 4 which working good for me. It's no force feedback but I'm still happy to be able to play this game with a steering wheel.

MythTW commented 2 years ago

wow this thread saves me...I have an old wheel Logitech Winman Forumla Force, and after a long tedious process it finally works in windows 10 but NFS Prosche just keep getting other USB device even I changed the controller to the wheel. So I came here from https://www.pcgamingwiki.com/wiki/Need_for_Speed:_Porsche_Unleashed However, the game crashes after loading the track, I then found this thread. And the build from Jan 4 works for me though without force feedback. But I'm happy that I can finally play the game. Much thanks to your work!

hjalmberi commented 2 years ago

Jan 4 build also works with Logitech G923 (without force feedback). The only issue I have is the inability to adjust how heavy the steering is. Logitech G Hub has a separate setting for non force feedback games where I can make steering easier, but it doesn't apply in NFS Porsche probably because it is still counted as a force feedback game. Is there some setting I'm missing here?

thorr2 commented 2 years ago

I also am experiencing the same issues with my Logitech G25. I spent hours getting everything working today on my old-school CRT TV, and this is the last hurdle. I hope this can get fully fixed. As the original poster said, Force Feedback was working with devreorder without dinputto8, but the analog controls did nothing. The latest released version of dinputto8 crashes the game. The January version in this thread breaks force feedback and fixes the analog controls. This is my favorite NFS game, so I hope this can be worked on again. Thanks for all of your efforts.

thorr2 commented 2 years ago

Ok, sort of good news! I got my Logitech G25 to work with Force Feedback. It is not ideal, but it works. The trick is to completely not use devreorder or dinputto8 (get rid of those files) and to remove all the other devices including USB hubs. I unplugged anything and everything USB except the keyboard and mouse dongle and the USB wheel. Then I went into the Device Manager in Windows and Showed Hidden Devices, just for good measure, and I removed everything under Human Interface Devices except the Logitech G25 items and the keyboard/mouse dongle. It is unknown which one of these is the keyboard and mouse dongle, so when I figured out which one, I had to unplug and reinsert the USB dongle and I think I scanned for new devices and deleted everything again (this may not be necessary).

Then inside the game, the Logitech was showing up as the default controller and the extra devices were gone. It still didn't work right, so when I started the race, while it was loading, I unplugged the keyboard and mouse dongle. Then the wheel worked with force feedback. Then I plugged the keyboard and mouse dongle back in and the wheel stayed in first place and worked together with the keyboard and mouse.

The only issue I still have is I can physically turn the wheel past the 200 degrees points, and I haven't figured out how to get the Logitech software to stop that from happening yet. You can see the behavior of everything in the Deadzone section in the game. Edit: I fixed this by reducing the centering spring strength to around 50% or slightly higher in the Logitech app. At 100%, you can't feel the edge very well.

Here are my current in game settings: Stick volume 75 Road effects 40 Collision 99 Engine 20 Road grip 70

And in the Logitech app: Overall 100 Spring 100 Damper 100 Centering Spring 50 Do not report combined pedals Rotation 200 degrees Allow game to adjust settings

rock5917 commented 2 years ago

Attached is another debug log. This probably won't solve the issue, but will give me a bit more debug info. Since I don't have the correct hardware I need to get some logs from you.

Here is the new update: dinput.zip

I'm in the same boat as BloodDeath. Only Force Feedback is not working. Log: dinput.zip

amagony98 commented 2 years ago

I wish the force feedback would work... everything else works fine with Logitech G29+Thrustmaster th8a shifter.

thorr2 commented 2 years ago

If you read up a few posts, I posted that I got it working by removing all the USB devices and only plugging in the wheel, then plugging in the keyboard/mouse dongle after starting the race. Part of this was deleting the devices from the device manager also. It is hard to know which USB devices are the mouse and keyboard so when you delete it, you can no longer control anything. I think unplugging and replugging in the mouse dongle makes it work again. I think I had to start the game, remove the dongle, start the race, and then put the mouse dongle back in. It is a total pain, but I got it working. This is without using dinputto8 at all. I think once you get it working, it will continue to work until the next time you want to play again. Hope this helps.

On Mon, Sep 12, 2022 at 3:26 PM amagony98 @.***> wrote:

I wish the force feedback would work... everything else works fine with Logitech G29+Thrustmaster th8a shifter.

— Reply to this email directly, view it on GitHub https://github.com/elishacloud/dinputto8/issues/15#issuecomment-1244607784, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMVRPLXTQNDWOZO3OBMVC53V56UY3ANCNFSM4VQZ5IPQ . You are receiving this because you commented.Message ID: @.***>

amagony98 commented 2 years ago

Yeah, I read that, but I have so many virtual devices from various softwares that this is just not an option for me. :( And doing this every single time I launch the game is just too much.

Years ago, I was using a Logitech Momo wheel. With that everything worked perfectly. Although, I think that was with Windows 7, and not with dinput8.

hjalmberi commented 2 years ago

I can't physically unplug everything either as I only have access to a laptop at the moment :/

thorr2 commented 2 years ago

Another option may be to install Windows 7 on a separate hard drive or partition (if it will even install), and only use it for this and other older games that have problems. I thought about trying this, but haven't yet.

On Tue, Sep 13, 2022 at 5:22 PM hjalmberi @.***> wrote:

I can't physically unplug everything either as I only have access to a laptop at the moment :/

— Reply to this email directly, view it on GitHub https://github.com/elishacloud/dinputto8/issues/15#issuecomment-1246081865, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMVRPLQRJVQWUTLS4WY2PMDV6ELEPANCNFSM4VQZ5IPQ . You are receiving this because you commented.Message ID: @.***>

TheRealDadbeard commented 1 year ago

Anything on the horizon with force feedback?

elishacloud commented 1 year ago

Currently, I have put this on hold since I don't have the means to troubleshoot this remotely and I don't have a way, at this time, to reproduce this. The issue is that the Input Effect fails on creation. I'm not quite sure why it fails or what changes would be needed for it to succeed.

itais commented 1 year ago

I was excited to see a new release but the game still crashes on load (no log created). I'm back to this version:

Can you try with the attached update? I made a few changes that might solve the issue and enabled full logging.

Here is the update: dinput.zip

which works except for the force feedback, as also noted above. I'm attaching my log from this version. Hope it'll help. dinput_log.zip .

TheRealDadbeard commented 1 year ago

I was excited to see a new release but the game still crashes on load (no log created). I'm back to this version:

Can you try with the attached update? I made a few changes that might solve the issue and enabled full logging. Here is the update: dinput.zip

which works except for the force feedback, as also noted above. I'm attaching my log from this version. Hope it'll help. dinput_log.zip .

OMG this makes it work! https://cookieplmonster.github.io/2023/09/24/silentpatch-need-for-speed-classics/

Just remove dinputtto8 and i had instant force feedback it's amazing! just be sure to tweak the ff settings or you steering wheel will rumble everyhting of your desk LOL

itais commented 1 year ago

I was excited to see a new release but the game still crashes on load (no log created). I'm back to this version:

Can you try with the attached update? I made a few changes that might solve the issue and enabled full logging. Here is the update: dinput.zip

which works except for the force feedback, as also noted above. I'm attaching my log from this version. Hope it'll help. dinput_log.zip .

OMG this makes it work! https://cookieplmonster.github.io/2023/09/24/silentpatch-need-for-speed-classics/

Just remove dinputtto8 and i had instant force feedback it's amazing! just be sure to tweak the ff settings or you steering wheel will rumble everyhting of your desk LOL

It doesn't work for me unfortunately - the game crashes at the end of the loading screen.

TheRealDadbeard commented 1 year ago

I was excited to see a new release but the game still crashes on load (no log created). I'm back to this version:

Can you try with the attached update? I made a few changes that might solve the issue and enabled full logging. Here is the update: dinput.zip

which works except for the force feedback, as also noted above. I'm attaching my log from this version. Hope it'll help. dinput_log.zip .

OMG this makes it work! https://cookieplmonster.github.io/2023/09/24/silentpatch-need-for-speed-classics/ Just remove dinputtto8 and i had instant force feedback it's amazing! just be sure to tweak the ff settings or you steering wheel will rumble everyhting of your desk LOL

It doesn't work for me unfortunately - the game crashes at the end of the loading screen.

Bummer. I am using a version from the RRP Discord with Veroks Patch running opengl. Maybe try a clean install?

elishacloud commented 1 year ago

@TheRealDadbeard, can you see if this update works? I changed one of the parameters to see if that helps: dinput.zip

itais commented 12 months ago

@TheRealDadbeard, can you see if this update works? I changed one of the parameters to see if that helps: dinput.zip

For me it doesn't work. the game still crashes after the loading screen.

TheRealDadbeard commented 11 months ago

@TheRealDadbeard, can you see if this update works? I changed one of the parameters to see if that helps: dinput.zip

I think you tagged the wrong one as for me it just works with only silent patch and without dinputto8

itais commented 4 months ago

Release v1.0.75.0 fixed the crash after the loading screen for me, thank you! Still no force feedback, though.

elishacloud commented 4 months ago

Yes, I put in a fix to return an effect interface even if CreateEffect() failed. This should prevent crashing in games that are not coded correctly. But it does not solve the core issue of why CreateEffect() failed in the first place. So the effect (in this case force feedback) doesn't work.

elishacloud commented 4 months ago

Ok, just for a test can you try this build: dinput.zip

itais commented 4 months ago

Ok, just for a test can you try this build: dinput.zip

With this version the game again crashes after the loading screen.

elishacloud commented 4 months ago

Ok, that is what I thought. The game just ignores the return code and value. Thanks for testing! I will look into the force feedback issue when I have the right setup.