for retroarch in opt/retropie/configs/all/retroarch.cfg copy all the input_player1 lines but make them input_player2 and put the correct button mapping.
For mupen64plus id like to know too. Ive read that in /opt/retropie/configs/n64/AutoInputCfg.ini you do the same thing but put
inbetween first and second player controls. That didnt work for me though