It can be done with Windows APIs. I have never done it myself so I will just name the APIs and then you can go on to the API Viewer and experiment with them. Here they are: JoyGetDevCaps, JoyGetNumDevs and JoyGetPos. This is everything you need to use the gamepad/joystick.