[FIXED] Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Discuss tools to aid in the modification and running of Rayman games.

Moderators: English moderators, Modding and utilities team

Post Reply
kataS
Électoon
Posts: 4
Joined: Wed Dec 02, 2020 9:15 pm
Tings: 20

[FIXED] Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Post by kataS »

So, some years ago I enjoyed a lot playing Rayman 2 for PC (GoG version) with my XBox 360 controller. Today, I want to play it again, so I installed the game in my Windows 10 computer (with latest updates) and adding the dinput.dll file to the game directory will make the game crash on the start. It just shows the Ubisoft logo and then goes back to desktop. Removing the dinput.dll file solves the problem but I don't really want to play with the keyboard...

I think that Microsoft recently updated Windows 10 for the new Xbox series X controller and their Xbox Accesories app. Maybe they changed something that broke the dinput.dll fix that has been used in Rayman 2 for years now.

Can someone confirm if they are having this crash too on an updated Windows 10 machine ?

If it happens to everyone else, does someone actually now how to replicate the fix with updated dlls ? (I'm a Software Engineer but honestly I don't have any experience on modding or hacking compiled binaries).

Also, I tried the dinput.dll from the keyboard remapping tool (viewtopic.php?f=89&t=25320) and the game works nice with the remapped keys, but not the controller (I assume that the dll is the original with just the remapping modifications, and not the actual fix).

Would be awesome if I can fix this, I just love this game. I guess I will have to go with Dreamcast/PlayStation emulation if I don't fix this :/

UPDATE: fixed

So... I solved the issue, and the solution is pretty creative xD.

TLDR
  • Download the dinput.zip from the latest release here. Extract the dinput.dll file in your Rayman 2 game folder (where the Rayman2.exe file is). If you downloaded the v1.0.39.0 release or previous, you must follow the next step. If your version is above v1.0.39.0, then you are done, your controller should work!
  • Download the controller fix for Rayman 3 here (yes, the Rayman 3, not the Rayman 2 fix). Extract the dinput8.dll file in your game folder, where you extracted the dinput.dll before.

    That's it :mryellow:
The long story

First I realised that the source code of the fixed dinput.dll is on the link that you provided before. You can download it here. It was made in Visual Studio 2010 but I had no problem compiling it on VS Comunitty 2019. Still the new compiled dll made the game crash.

I'm definitelly not in the C++ world so I couldn't do much with the source code, except from understanding it at a high level. There are just a bunch of files with few code and the original author made a really useful comment about what was the original Rayman 2 bug about. Basically the game expects that the gamepads are given first in the device enumeration while the official Microsoft API does not guarantee this. So the whole project is a dinput.dll wrapper that calls the original API, sorts the devices and returns it to the game. I tried to do some debugging but it seemed that the code was not even being executed, so probably the problem was in the way that the official API was hooked at the start (maybe this does not make any sense at all).

I kept diving on the internet and also tried out the dinput8.dll fix for Rayman 3, which is working perfectly on Rayman3 but, as expected, not on Rayman 2. I accidentally found out this project on GitHub, which is another dinput.dll wrapper to transform dinput calls to dinput8 (I don't even know what are this APIs, I just assume that it is a more modern version of dinput). The project was made for old games in general and has a compatibility list (not Rayman 2 :sad:). Also the latest commits are from the previous month so it seems that it is still active so it would probably won't make my game crash.

So I came up with the crazy idea of putting the dinput.dll from dinputto8 project along with the fixed Rayman 3 dinput8.dll, with the hope that Rayman would call the wrapper dinput, and this would call the Rayman 3 fixed dinput8. Guess what, it worked... :mrgreen:. The inputs were a bit dissordered though, probably because of the fact that the dinput8.dll file was made for Rayman 3, but still totally playable and probably easy to fix with some remapping tool.

Just as a curiosity and because I wanted to have some fun with the C++ code, I cloned the dinputto8 repo and tried to just copy the algorithm that sorts the input devices in the Rayman 2 fix project, since I could find that both were wrapping the same dinput API interfaces (IDirectInputA). So I copied the CreateDevice function code and made one minor tweak to adapt to the new implementation. I compilled the new dinput.dll and it worked!! Now I have the original mappings and don't need to use the Rayman 3 dinput8.dll anymore.

I will probably contact the author of the dinputto8 project, he may want to add this changes and have our beloved Rayman 2 in the compatibility list :winkgrin:. If I'm right and new Windows 10 updates are no longer compatible with the old dll fix, I hope that this will help others and last for another 8 years.

Update 2

I created a pull request on the dinputto8 project, with my changes for making it compatible with Rayman 2 without the need of the Rayman 3 fix. Let's see if the author answers soon and makes a release, if that does not happen you can either compile my forked project or I will probably make my own release.

Fork: https://github.com/katas94/dinputto8
Pull request: https://github.com/elishacloud/dinputto8/pull/14

Final update

dinputto8 author merged the pull request with some modifications. I have confirmed that this modifications didn't break the fix and the binary is still working. Whenever the author releases the next version (current is v1.0.39.0), it should contain the fix and we no longer need the Rayman 3 fix.
Last edited by kataS on Sun Dec 06, 2020 11:14 am, edited 3 times in total.
kataS
Électoon
Posts: 4
Joined: Wed Dec 02, 2020 9:15 pm
Tings: 20

Re: Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Post by kataS »

deton24 wrote: Wed Dec 02, 2020 9:33 pm Check this out
https://github.com/AntiMicro/antimicro
Thank you for the answer, but I'm already aware of different methods for mapping my controller to the keyboard. I just don't like this solution because I think that the experience is quite different since you cannot really map a joystick properly other than setting it as a DPad. As a last resource I guess that it is an option, but would be great to know if I'm the only one experiencing this or I'm actually right and the latest Windows 10 updates broke the dinput.dll fix (and maybe someone is able to fix it).
kataS
Électoon
Posts: 4
Joined: Wed Dec 02, 2020 9:15 pm
Tings: 20

Re: Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Post by kataS »

Yep, thats it, the game crashes whenever I dropt that dll into the game's folder, and fixes when removing it again. It happens the same if I enable the controller support using the Rayman Control Panel, which essentially just adds/removes the same dll. Do you have latest Windows 10 and Rayman 2 to confirm it?, it would be nice xD. Also, don't judge me, but I also bought the game in Ubisoft Connect, and it happens the exact same thing xD.
kataS
Électoon
Posts: 4
Joined: Wed Dec 02, 2020 9:15 pm
Tings: 20

Re: Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Post by kataS »

deton24 wrote: Thu Dec 03, 2020 8:41 pm I can't currently verify it on my end.

Did you check any compatibility settings?
Tried all compatibility settings, didn't work. I found a solution anyways, check the post update ^^
Hunchman801
Bad Rayman
Posts: 80243
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 578060

Re: [FIXED] Rayman 2 dinput.dll controller fix no longer working on Windows 10?

Post by Hunchman801 »

Great detective work here! Glad you got it to work. :up:
Image
Post Reply