Start mame, hit Tab, and you can then navigate a menu...
Go to the Input (general) menu....
..where you can change controls for all the players. Select the control (e.g. Player 2, button 1). Hit enter to let you remap the button, then hit the left mouse button (or whatever button you want mame to use for that button) and it will detect it and fill it in....