Ok, I will use my setup as an example.
Ok, I am going to use numbers and letter differently. Letters will be what keypress the button is assocciated to on my cabinet, numbers will be what order I want mame to see the buttons.
My cabinet is 2 players with 6 buttons. Player 1 has this wiring/IPAC setup for keypresses.
ASD
ZXC
Now, for default I want my button order to be
456
123
So my default.ini looks like this
P1_BUTTON1 "KEYCODE_Z | MOUSECODE_1_BUTTON1"
P1_BUTTON2 "KEYCODE_X | MOUSECODE_1_BUTTON2"
P1_BUTTON3 "KEYCODE_C"
P1_BUTTON4 "KEYCODE_A"
P1_BUTTON5 "KEYCODE_S"
P1_BUTTON6 "KEYCODE_D"
Note, yes I use those buttons as mouse buttons once and awhile, hence the mouse button code.
Now, for neogeo I want this layout
004
123
The 0s mean I don't care what button that is. My neogeo.ini file looks like this:
P1_BUTTON1 "KEYCODE_Z"
P1_BUTTON2 "KEYCODE_X"
P1_BUTTON3 "KEYCODE_C"
P1_BUTTON4 "KEYCODE_D"
now, what will happen is mame runs throught he ctrlr file heirarchy when loading these files. It will load the most general file first (the default.ini) and work it's way down the control types, driver, parents, then specific game and over write the more general config with the specific. So in this case it will load the default.ini and my button config would be
456
123
Then it will load the neogeo.ini which will overwrite my config giving me this
454
123
If I had a mslug.ini file then that mapped th top row to 123 then that would over the contronl config and you'd end up with
123
123
Turn verbose on (in the mame.ini file) and it will show you what ctrlr files it loaded for a particular game.