Easiest way is to use a SSH client such as Putty (Windows) or use built in Terminal on a Mac.
Connect via SSH to the PI, you need the Pi’s IP. If you type ifconfig in the terminal on the Pi it will display this.
Port number is 22 for SSH
Username is pi and password is raspberry (you can change this once you have logged in with: passwd)
Then to edit retroarch.cfg:
sudo nano /opt/retropie/configs/all/retroarch.cfg
Copy from the template I posted and edit input_player1_joypad_index= as mentioned above. Ctrl X and press Y to save. You can also modify using jtest as mentioned above.
I recommend you read up on using SSH and FTP with the Pi, it makes things a lot easier.