You can use this to do that:
https://github.com/x360ce/x360ce
This software basically provide Xinput dll wrapper around DirectInput or RawInput. It requires you to place custom Xinput dll file next to game executable and no need to change a line in your code.