Theres the autoconfig file in opt/retropie/emulators/retroarch/configs/yourgamepad.cfg that is created when you do the retroarch joyconfig. Then there is the retroarch.cfg in opt/retropie/configs/all that is set up for all retroarch emulators and then there is also a retroarch.cfg file for each individual retroarch based emulator in each respective folder in opt/retropie/configs/<systemname>
See this wiki page on controller configurations