DirectInput, Xinput and controller adventures
Saturday, 15. August 2009, 16:42:47
Some people already prepared Xinput replacements that emulate vibration and other controls for third party controllers to work like Xbox 360 Controller for Windows. They didn't work for me with Rainbow Six Vegas 2 game, probably because DirectInput's IDirectInputDevice8::Acquire doesn't return success and game has exclusive access before Xinput library exclusively acquires the device.
After downloading this Xinput replacement source code, I started hacking dinput8.dll - the DirectInput library. It turned out that DirectInput doesn't provide vibration API for separate vibration effects (e.g. left and right vibrations); both sides either vibrate or not. So my stub for dinput8.dll seemed like useless.
Gamepad's control panel applet has a Vibration Test tab which can vibrate motors separately. I am currently debugging that to figure out how it actually vibrates two separate motors. That is, I am trying to understand whether it's a generic functionality or a driver/hardware-specific API. In latter case, I need to debug more and probably write more. Besides, I am not exactly sure whether I can achieve a result. Luckily, it's not a huge library. I have located dialog callback functions and I think driver is doing all these things in a WM_TIMER handler (ticks 10ms intervals).
It may not be right to blame game companies for not using DirectInput always. I think Microsoft and third-party producers should find out how to get these controllers to work with Xinput. Also, these OEMs should provide open source drivers as well. I hope I can understand how these separate motors work. I may get my gamepad to vibrate both sides, but that's not what I want; I want to be able to control vibration on each side much like an Xbox controller, because hardware already supports it.









