I had some similar issues, and what happened with me was:
1. one time the permissions on my preferences file got corrupted, so I set them to 777
2. one time the preferences file itself somehow got deleted (this is why you try not to hard reset a pi during operation)
3. one time I had ultrastik 360 configured to only use 2-way, so couldn't do any scrolling.
4. I added a joystick and mame saw it as something other than joystick0, so I had to map it again even though it seemed to be the same thing I already had
Sounds like maybe you have issue 4.
To fix issue 1.
cd /opt/retropie/configs/YOURMAMEVS
sudo chmod 777 YOURFILE.CFG
To fix issue 2.
If the CFG file is missing, generally just reopen the emulator and it'll create the file for you. If it doesn't, then you might have to get the file from somewhere else and copy it in, or reinstall the emu. Once when a CFG file wouldn't recreate itself, I opened a backup image and got it off of that.
To fix issue 3.
Attach a keyboard, and use it until you've remapped your stuff... or go into a terminal and edit the CFG file itself... manually add your configurations. This isn't necessarily simple to do unless you understand the cfg file, and the mapping values of your buttons (they might be something like joystick0_btn1... or other things.
)
To fix issue 4... same as above. Try remapping using a donor keyboard. If you don't have a donor keyboard, map ANYTHING if possible in the interface. Then you can access the cfg file via SSH and edit it. Once in the CFG file, you can look for the recently mapped key to get an idea for how MAME is seeing your joystick mapping. If you know that it thinks it's joystick0 or joystick1 or whatever, it makes it a lot easier to manually add configurations.
I didn't detail everything possible. So let me know if I can be of further assistance.