Configuration of controller remaps in retroarch

Quick way to do it:

Start a game of the system you want to remap the buttons
Invoke RGUI (F1)

Go to Quick Menu and then Controls
Configure the buttons the way you want
Select Save Core Remap File
OR, if you want to save this remapping for the current game only, select Save Game Remap File

 

Video Tutorial