Put this file into your /opt/retropie/emulators/retroarch/configs folder. Retroarch will auto-detect your gamepad…the problem is there is no built in F310 profile. There is, however, a Logitech 710 profile (same controller, just wireless). I basically just saved that file with a new name, and everything within Retroarch works flawlessly. When the emulator starts, you will see that it fines the Gamepad and tells you which one is connected.
Obviously, you can edit this file to change your button config around. Of note, I didn’t mess with the switch on the back of the F310. So whichever was the default is the one I used.
EDIT: BE SURE TO RENAME THE FILE TO .CFG