this will let you see what buttons are being pushed on the joystick, so write down what each button number is associated with, and the axis’s of your joystick.
ctrl-c exits the jstest
Now you need to edit /RetroPie/configs/all/retroarch.cfg manually with the correct button numbers you found using jstest. Here is an example of mine. The last two lines are so I can press two buttons to exit the emulation.