I have an optipac for my trackball and an ipac.   I wired the last two buttons of a six button layout for player one, to the optipac mouse buttons.  Then I went into mame and redefined the button configuration for all games.  This will set the mouse buttons to B5 and B6 for all games that you don't have a config file for already.  If you had it set up otherwise and did configure buttons for "this game" in any of them, you'll have to reconfig them individually.