Hey mate,
drop into terminal (F4) or ssh and do this..
cd ~/RetroPie/emulators/RetroArch/tools
sudo ./retroarch-joyconfig -o p1.cfg -p 1 -j 0
( -o for output file, -p for player, -j for joystick id )
then do this
sudo cat p*.cfg >> ~/RetroPie/configs/all/retroarch.cfg
this will setup the controls for the emulators.
good luck