There is a better way to do this.
If you press TAB and go in and change the controls, those controls will be saved in the CFG files, which are non-ascii i.e. hard to edit outside of Mame.
In the DOCS folder read about the ctrlr.txt
It allows you to define default controls and game specific controls using editable INI files. So you don't ever have to go back in and configure each game every time. The thing is, when you just do in in Mame, the CFG most likely will not work when you upgrade to the next version of Mame. But if you do everything with the INI files, those will work no matter what version of Mame you use (well...given that you use Mame 0.60 or above...which is the version in which this INI file thing was implemented).
Use the INI thing. It gives you lots of control and it a lot quicker that doing everything game by game...
Jakobud