Input mapping hell

Is there a way for an avarage guy to figure out what input configuration is actually used by an emulator?
My goal is to use two different joypads each having its own keyboard encoder to play 4P games, at least on MAME 2010 emulator. I’ve configured both encoder to produce unique values for each joy directions and buttons, no conflict among them.
I’m not a scripting guy, but take a look at the emuelecRunEmu.sh, it does a hell lot of input mapping, and I guess EmulationStation and RetroArch also do their tricks. I can’t figure out what is the content of an input configuration and/or where it is stored.
When I start a 4P mame game, the 3P joy controls the movement of the 1P character which seems odd as they produce different keystrokes. There must be some misconfiguration along the way but I have no clue where to find it. Starting RetroArch shows the input mapping for all four players correctly in the menu.
P3 joy configured to produce up/down/left/right keys, I guess default mame settings are not overridden during configuration but extended.