I don't know if this is your issue, but perhaps it will help? DirectInput devices do not get recognized until the first frame of the game, meaning any attempt to detect them before then will result in failure. I have gamepad auto-detection as well, and this is something that "broke" at some point, and I ended up having to use a workaround to fix it. I just create an object that exists for that first frame to poll for connected devices and then destroys itself. There's also one OTHER issue that I've come across: for some reason, the same controller detection code will not work on some computers. As bizarre as this sounds, just compiling the game on another computer can fix the problem. I have no idea why this is because I can't reproduce it on my end, but I have had people send me their code, have it work perfectly, send it back to them compiled and it works. Or I'll send them my code, works fine on my end, but doesn't on theirs. It's a completely vexing issue that only affects some controllers on some PCs, but also apparently depending on what PC it was compiled on.
Again, don't know if that's particularly useful but it sounds a lot like a problem I'm familiar with.