Got you covered… Well partially anyways- its in the works. See the diagram here for Atari 2600 :
We’ve done it for about half of the controllers or so. Just check each page: taalas and I maintain a github page for our progress:
The libretro wiki supposedly has some but unfortunately it isn’t complete
Retroarch uses the concept of retropad which is essentially what you are describing- a joypad abstraction with mappings for each emulator. We’ve tried to replicate that as much as possible and it will hopefully be implemented with inputstation: an experimental module petrockblog is working on that will be a one time controller configuration script for all emulators.
There is another added complication in button mappings as my button 1 on my SNES gamepad might be “B” but maybe on yours your “B” is button 3 in the code. Ideally that should be addressed when you run retroarch-joyconfig but it can still add to the confusion then on top of that you different mappings for different games… Probably a lot more than you wanted to know I’m sure but as you’ve seen with controller configurations it can get pretty complicated.