Actually, we may be overanalyzing the problem. If you're using MAME 32, which I would assume you are since it's typically what most folks start with, there are check boxes to turn on gamepad support in the interface.
Here's how to do it:
1. Plug the controller into your PC before you fire up MAME.
2. select Options, Default Options, and then click on the Controllers tab. Click the box where it says "enable joystick input"
3. Then, you may have to also enable the controller for each individual game. To do that, right click on the game, again select "Properties", and again go to the "controllers" tab and check the box that says "enable joystick input".
Hope this helps!