http://html5gamepad.com/
This gives you a basic understanding of whether your gamepad works in your OS or not. In the case of the PS4 controller, for example, everything shows up under Safari (Google Chrome misses out on the PS Button as B12), which gives you a good first feeling that this joypad should work in MacOS software.
Second, if it works, you have two choices:
1. Leave it as is: My first joypad, for example was a Logitech F310 Gamepad, a good choice. Switched on the backside to Direct Input, it runs out of the box in QMC2. No drivers under MacOSX required.


As a second joypad, I went for a PS4 controller, and this thing rocks, both on USB and Bluetooth. No additional drivers required. Build quality is superb, this is a clear recommendation. It is still my favorite joypad for MAME.
Read further for MAME Joystick settings...