Well, it's been a while, so my memory is hazy.
My patch fixes two problems:
- Rayman 3 doesn't detect gamepads and joysticks.
- Rayman 3 doesn't use the Vibration feature of Xbox 360 or Xbox One controllers.
Rayman 3 uses the DirectInput 8 API to detect devices, receive input and trigger force feedback.
To detect devices, it calls a function named EnumDevices in the DirectInput8A interface. EnumDevices returns (or enumerates) a list of all input devices connected to the machine. This includes gamepads, joysticks, keyboards and mice.
The problem is that Rayman 3 expects gamepads and joysticks to appear before keyboards and mice in the list. If it sees a keyboard in the list, it stops detecting devices there.
Now, this just happened to work on Windows XP and earlier because on those OSes, DirectInput always reported gamepads before keyboards. However, on Windows Vista and newer, the keyboard might be reported before the gamepad. Vista isn't wrong to do this -- Microsoft never made any guarantees about the order of detection. Ubisoft is at fault for using DirectInput wrong.
So to fix this problem, I created a replacement dinput8.dll. When placed in the game executable's directory, it hooks into EnumDevices and simply moves gamepads to the front of the list.
By the way, Rayman 2 has this exact same programming error. I also made a fix for that game.
The second problem is trickier. Microsoft released the Xbox 360 in 2005. What was unique about that system was that its controller had a USB plug. You could plug it into your PC and use it to play PC games, and Microsoft provided drivers for this purpose.
However, Microsoft's drivers kind of suck -- they don't provide force feedback for DirectInput-based games, meaning DirectInput-based games can't make the controller vibrate. Only games that use the newer XInput API can access the vibration motors.
So my fix includes a solution that allows Rayman 3 to vibrate the controller. It does this by detecting DirectInput calls and translating them to XInput.
Those are the problems that my Fix... fixes. (I don't call it a Patch because it doesn't really modify any existing code.)
Moving forward, I want to fix my Fix.
- It relies on xinput1_3.dll, which some players don't have on their system. I changed it to xinput9_1_0.dll, which I believe comes in the box in Windows Vista and up.
- The right thumbstick doesn't work. I don't know why.
The source code is now kept in a GitHub repository here:
https://github.com/beholdnec/rayman3-input-fix