If you're only running MAME, go into the menu in-game where you remap controls (usually TAB).
I'm at work and don't have access to MAME at the moment, this is from memory so the menu titles might not be correct.
Select the option to set controls for All Games, then Other Controls.
Look for the option that says UI Cancel. Remap that to one of the buttons on your ipac or apac.
That will now function to exit MAME. (map it, then immediately map it again to ESC and then either will work)
You can do the same thing with UI Select for enter, but if you're launching games from a front-end, you'll need something that works outside of MAME.
If you're using Mala, you should be able to map one of the Apac buttons to start the game.
If not, Autohotkey can post keys when you press the apac buttons.
I haven't used it for a gamepad before (which the apac shows up as), but I don't think it's that much more complicated than remapping keys.
After a quick search, it looks like it would just be:
Joy1::Enter
return
(looks like joy1 is button 1, joy2 would be button 2)
Install autohotkey, post that in notpad, save it as joyenter.ahk(all file types), throw that in your startup folder(google it) so it runs every time windows starts, and every time you press the joystick button, autohotkey will post Enter.
I wouldn't use the mouse buttons for this because the script will still be running when you're trying to use a real mouse to do stuff in windows.
Having it press enter every time you click could be bad. You might get away with the middle button (Mbutton::Enter). I'm using the middle button on a trackball to post ESC and haven't come across any issues yet.
Since MAME gets its inputs directly instead of through windows, autohotkey doesn't work inside MAME.