I quote a pretty important guide that @bgelmini wrote:
Recommended way to setup external controllers for RetroArch(so you don’t get stuck without hotkeys):
Open RetroArch through the Applications menu.
Go to Settings>Input>RetroPad Binds>Port 2 Controls (It is important that you leave Port 1 alone for now)
In Device Index select your external controller, if not yet selected, then Set All Controls and configure your controls according to the instructions.
After setting the controls, get back to main RetroArch menu and go to Configuration File and Save Current Configuration. This way RA will remember your controler settings after you shut it down.
Now launch a game in any system you would like to. Open the Quick Menu with Menu+X on your handheld, and go to
Controls>Port 2 Controls and in Mapped Port select 1.
This way your external controller will behave as Controller 1 in game, but if something happens and your controler disconects, you won’t be locked in retroarch and will be able to leave it with the usual hotkeys. (If after doing this you still don’t have controls in game, try changing Port 1 Controls’s Mapped Port to anything else then 1)
Get back to the Controls menu and go to Manage Remap Files and Save Core Remap File, or Save Content Directory Remap File, as you wish. This way this core/directory will remember your choice next time you use it.
What about hotkeys?
Unfortunately the way retroarch works means that you need to map a direct controller button to the hotkey enabler and hotkeys, so if you set that for one external controller, only when using that specific controller your hotkeys will work, and not with another controller, and not with the handheld itself. . Until a better way to deal with this is found, my recommendation is to keep using the device itself for hotkeys and shortcuts.
If you feel corageous and want to set the hotkeys to yout external controler, you are free to do so. But when you get back here to ask for help, the ansewr will be for you to use the Restore Retroarch Configs script in Applications>Task Toolkit, but you will loose any custom setting you previosly changed in RetroArch