OK, so I was able to solve it; a couple of steps I think were necessary, the others I did as precautions.
Basically, the main issue was that my runcommand-onstart.sh and runcommand-onend.sh files were empty; these need lines to trigger xboxdrvstart.sh, which in turn should allow the GPI controls to be recognised by Mame4All. Here's what I did:
In /opt/retropie/configs/all/runcommand-onstart.sh I added the following:
#!/bin/sh
source /opt/retropie/configs/all/xboxdrvstart.sh > /dev/null 2>&1
sudo pkill -STOP mpg123 > /dev/null 2>&1
fbset -g 320 240 640 480 16
In /opt/retropie/configs/all/runcommand-onend.sh I added the following:
#!/bin/sh
source /opt/retropie/configs/all/xboxdrvend.sh > /dev/null 2>&1
sudo pkill -CONT mpg123 > /dev/null 2>&1
fbset -g 320 240 320 240 8
fbset -g 320 240 320 240 32
(the lines about mpg123 are, I think, related to background music or something like that; probably not needed, but I borrowed these from a pre-made GPI image so thought safer just to copy everything.)
Then, after a restart/reboot, I switched the GPi's D-Pad to axis mode by by pressing START+DPAD LEFT for 5 seconds, until the purple light flashed.
I deleted default.cfg in /opt/retropie/configs/mame-mame4all/cfg
Finally, I the went to GPI's 'Controls Updater Menu' and ran that script, just in case.