For attractmode you will have to set them up one by one.
For mame you do this:
1. Copy the controller cfg file to the ctrl folder if it is not already there.
2. In your mame.ini file (create a mame.ini by typing mame -cc at the command line.) look for:
#
# CORE INPUT OPTIONS
#
coin_lockout 1
ctrlr HotRodSE <-here type your ctrl file name
mouse 1
joystick 1
lightgun 0
multikeyboard 0
multimouse 0
-----cut-----
3. Then save the changes
4. test the settings (play a game

) to see if it worked.