In the example above, I remapped all buttons to WASD on the keyboard and it seems to work fine. I think RetroPad L (left shoulder) and RetroPad R (right shoulder) are used for the Game A/Game B selection, if you wish to remap those.
TBH this project required a little more than that. Had to uncomment a line in a config file to make the screen come to life. Had to change default keyboard layout (I'm using US keyboard, couldn't type "|"). Had to localize system. Had to install gamepad driver and configure input. Mount system on my network. And of course install a romset in the proper directory. Still... WORTH IT.
I don't know why that error occurs, I don't think RetroArch uses directly this env var - may be a Wayland/screensaver warning.
So I fixed that error regarding XDG_RUNTIME_DIR, maybe RetroArch does use it after all. I was mistaken when I said it flashed up when launching, it actually flashes up when exiting! Same for the CD-ROM warning.
To solve it, I did the following:
sudo sudo -V
scrolled up a bit to see which environment variables are preserved. XDG_RUNTIME_DIR is not one of them.
I then had to edit the sudoers file (sudo visudo) and add the following in:
Defaults env_keep += "XDG_RUNTIME_DIR"
Save and exit, you can then run 'sudo sudo -V' again and you'll see XDG_RUNTIME_DIR is in the list of environment variables to preserve. Reboot the system and the error should go away when quitting Retroarch.
For whatever reason, sudo does not preserve this environment variable, and i'm guessing because Retroarch launches from the Retropie menu with root privileges, it cannot see or have access to this environment variable. Adding the above in preserves it, suppressing the error (after a reboot).
The CD error still pops up though, but not much that can be done about that at this time it seems.
FYI, this error only pops up when you quit Retroarch after launching it on its own from the Retropie menu - it doesn't come up when quitting out of a game. I guess this is because games are launched as the 'pi' user, rather than with root privileges.
My question would be, is there a reason Retroarch needs to be launched with root privileges from the Retropie menu? Maybe I am misunderstanding how it launches, but that is what it looks like to me.
@grant2258 Hi Grant - yes I think I've realised that this is the problem. The default RetroArch setup creates a virtual gamepad and binds both virtual gamepad and keyboard. I think the problem with Defender is that these mappings overlap - so the virtual gamepad is triggering as well as producing a keypress, and these are both bound to different things (eg thrust AND fire).
@gizmo90 you could also put them in the arcade folder. The arcade folder let's you select from multiple different arcade emulators (libretro mame, advmame, fba etc) it's used for organizing if you have multiple romsets and you want to keep them all in the same place.
If you have another controller, then this might not be the same problem. If this is the case, then I suggest you start a new thread, with detailed descriptions of your hardware, software versions, log file entries etc.
Update: changing the advmane.rc from alsa to sdl fixed the no audio problem right away. Tested it by loading some games into the advmame folder, reloading emulation station and firing up the emulator with a game. Yes! Success! Thank you all. :-)
As said by @mitu , what you're asking is not possible the way you want it.
I'll just add that, taking into account what you're saying about your technical knowledge, using your laptop with retropie will be IMHO far more complicated than downloading and using an official retropie image for the raspberry pi.