@mitu Thanks for replying. My gamepads mirror each other, and have the same number of buttons installed and mapped to the same keys. I'm aware that the gamepads won't work correctly if there are any differences at all. In fact, I had to add two extra buttons to the player 2 USB encoder in order to make it mirror the player 1 USB encoder precisely. Initially, we had installed two extra joypad 1 buttons to serve as a hotkey/escape and as a pause button, but they wouldn't work without identical buttons set up in joypad 2. The joypad 2 buttons are actually inside of the cabinet, because there are no holes for them on the control panel. I've already used jstest many times, too. So, I can promise that the two joypads are configured identically, and I haven't set up any player 1 buttons in the 800/5200 emulator that map differently from player 2. I know better.
I really do think the problem is that the Atari 5200 emulator isn't yet set up to recognize multiple fire buttons for player 2. I found a discussion on this forum from May 2016 entitled "Atari 5200: New version of Atari800 (Beta): two triggers (Moon Patrol), hat start and exit buttons" where user jfroco discussed a new port of Atari800 that added trigger1, trigger2, asterisk and hash support for joystick buttons, but only for player 1. A later post from user Veramacor (April 2017) detailing atari800.cfg settings also reflected trigger1 and trigger2 support on Joystick 0, but not Joystick 1. Then, in May 2017 user Used2BeRX asked user future.child if they would be able to properly code the player 2 controller to allow two-player games. It's not clear from the subsequent conversation that this ever got done in the way I'm discussing here.
I'm guessing from this discussion and my experiences this weekend that the Atari800 emulator must still be in that same developmental place, because when I tested the 5200 Moon Patrol ROM (I do own an original cartridge), sure enough, player 1 could use the second trigger (button X on my arcade cabinet config), but not player 2. The X button did nothing for player 2. Again, I'm not having this problem in any of the other emulators I'm using with Retroarch (MAME2003, MAME 2003-Plus, Final Burn Alpha, MAME2010, Stella, CoolCV, or the NES and SNES emulators). On those emulators, all buttons work the same for both gamepads. There are no discrepancies.
However, if someone can verify that they are able to use both fire buttons for both player 1 and player 2 in Atari 5200 Moon Patrol (one to fire, one to jump), RealSports Football, etc., I will be more than happy to try to get it working for Player 2 in Retropie. I just haven't seen anyone confirm that there is trigger1, trigger2, * and # support for Player 2 in the 5200 emulator. The only evidence I've found is that there isn't such support, and I don't want to spend days futilely trying to set up something that isn't actually supported. In fact, a post from three months ago said that the controller upgrades future.child made from 2016-18 aren't part of the current libretro version of atari800. (That thread also suggested that RealSports Football is viewed as a lost cause because of its need for keypad input.) Maybe the best way to ask this question is, does Moon Patrol work properly for player 2 on the 5200? Can you jump and fire?