RPI4 Model B Arcade Joystick Controller 2 Swaps A and B button When Exiting RetroPie Game
-
Currently have Raspberry 4 Model B with RetroPie 4.7.1 (retropie-buster-4.7.1-rpi4_400) flash written on a 128GB microSD card. Currently using two Generic USB encoded Joysticks and buttons I purchased on Amazon. These are connected on the two USB 2.0 ports of Raspberry Pi 4. I also have a wireless USB mouse/keyboard connected to one USB 3.0 port of the Raspberry PI 4. Booting from Raspberry works successfully and EmulationStation boots up.
EmulationStation appears to have detected my two USB Joystick controller setups with the message "2 Gamepads detected". I set "Gamepad 1" using my 1st Joystick Controller and buttons. Afterwards, main menu appears. Tried loading some games for MAME, Atari 8-bit, and SNES. They all worked and controls correctly. I then decided to configure the second USB Joystick by going to the UI settings and selecting to "Configure Input". This brought back the same initial prompt from before with the message of "2 Gamepads detected". Instead of pressing and holding the button on Controller #1, I held a button on Controller #2. Prompt now has "Gamepad 2" appearing with me setting up my Joystick directions and button configuration. Once complete, Controller #2 appears to be working fine. At this point, Controller #1 and Controller #2 have the exact same button and joystick configuration. Navigating the EmulationStation menu and selecting the emulators with the A button work correctly.
My problem starts as soon as I enter any game. As soon as I exit said game and return to menu, Controller #1 works as usual but Controller #2's A and B buttons are swapped. At first I found it strange it had it swapped, thinking I had made a mistake. Re-tried setting up Controller #2 input configuration. Prompt says "2 Gamepads Detected". However, once holding a button on Controller #2, prompt now shows message with "Gamepad 4". I set up my controls as usual and all seems to work fine. Navigating the menu works, hitting A button enters my selected emulator and B button returns to previous page.
Attempted to enter a game and then exit. Controller #1 now is the one that has A and B buttons swapped. I reconfigure its controls and EmulationStation now sees Controller #1 as Gamepad 9. Attempted this multiple times going back and forth re-configuring Controller #1 and #2. Each time EmulationStation would also show a different Gamepad number such as 8, 5, 10 or 16. This to me makes no sense as I only have two controllers plugged in.
I am not sure what is wrong with my controls. I made sure both USB encoders had the same physical wires plugged in with the exact same configuration between both controllers. I even tried clearing out configuration file of controls using Retropie-setup and choosing "Clear/Reset Emulation Station input configuration". Rebooting and re-setting up my controllers made no difference.
I've tried looking at other posts by using the following commands such as:
cat /proc/bus/input/devicesThis command gave me the following console message:
I: Bus=0003 Vendor=0079 Product=0006 Version=0110
N: Name="DragonRise Inc. Generic USB Joystick "
P: Phys=usb-0000:01:00.0-1.3/input0
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/0003:0079:0006.0003/input/input4
U: Uniq=
H: Handlers=event4 js0
B: PROP=0
B: EV=1b
B: KEY=fff 0 0 0 0 0 0 0 0 0
B: ABS=3002f
B: MSC=10I: Bus=0003 Vendor=0079 Product=0006 Version=0110
N: Name="DragonRise Inc. Generic USB Joystick "
P: Phys=usb-0000:01:00.0-1.4/input0
S: Sysfs=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:0079:0006.0004/input/input5
U: Uniq=
H: Handlers=event5 js1
B: PROP=0
B: EV=1b
B: KEY=fff 0 0 0 0 0 0 0 0 0
B: ABS=3002f
B: MSC=10I've also looked in under /dev/input and using ls -lah to see if two joysticks are detected. The following is the output I got:
total 0
drwxr-xr-x 4 root root 280 Mar 16 18:31 .
drwxr-xr-x 17 root root 3.8K Mar 16 18:31 ..
drwxr-xr-x 2 root root 160 Mar 16 18:31 by-id
drwxr-xr-x 2 root root 200 Mar 16 18:31 by-path
crw-rw---- 1 root input 13, 64 Mar 16 18:31 event0
crw-rw---- 1 root input 13, 65 Mar 16 18:31 event1
crw-rw---- 1 root input 13, 66 Mar 16 18:31 event2
crw-rw---- 1 root input 13, 67 Mar 16 18:31 event3
crw-rw----+ 1 root input 13, 68 Mar 16 18:31 event4
crw-rw----+ 1 root input 13, 69 Mar 16 18:31 event5
crw-rw----+ 1 root input 13, 0 Mar 16 18:31 js0
crw-rw----+ 1 root input 13, 1 Mar 16 18:31 js1
crw-rw---- 1 root input 13, 63 Mar 16 18:31 mice
crw-rw---- 1 root input 13, 32 Mar 16 18:31 mouse0Last thing I have tried is making sure which event is associated with the two USB encoders. Found a post to try the command evtest.
The following is the output message:Available devices:
/dev/input/event0: HID 0513:0318
/dev/input/event1: HID 0513:0318 Mouse
/dev/input/event2: HID 0513:0318 Consumer Control
/dev/input/event3: HID 0513:0318 System Control
/dev/input/event4: DragonRise Inc. Generic USB Joystick
/dev/input/event5: DragonRise Inc. Generic USB JoystickI would appreciate any helpful advice on how I can correct my issue with both controllers not acting the same after returning to main menu of EmulationStation. Please let me know on any commands I should run that may provide even further information to resolve this problem.
-
Attempted to enter a game and then exit. Controller #1 now is the one that has A and B buttons swapped. I reconfigure its controls and EmulationStation now sees Controller #1 as Gamepad 9. Attempted this multiple times going back and forth re-configuring Controller #1 and #2. Each time EmulationStation would also show a different Gamepad number such as 8, 5, 10 or 16. This to me makes no sense as I only have two controllers plugged in.
That's a red herring. The # (index) of the controller is incremented internally by libSDL when the joystick system is initialized, it's not relevant to your issue.
The configuration of the controller is tied to its name, so if you configure one controller, the other one will be configured similarly - you don't need to configure it. If you're configuring the 2nd controller, the configuration is re-generated, based on the 2nd controller's inputs.
As such, I think the problem is most likely caused by different wiring for the controllers - A on P1 produces the same input as B on the P2 and vice-versa. Check the wiring again and then configure just P1 or P2, it will be enough. -
@mitu Before I considered dismantling the buttons from my arcade, I found this other command called jstest, which allowed me to see on the command line what each button was configured to on the USB encoder.
Once I ran jstest /dev/input/js0 for player 1 controls and jstest /dev/input/js1 for player 2 controls, Player 1 appeared to be configured correctly with buttons A and B. However, Player 2 clearly is the one not configured correctly. Here I finally found my problem where player 2 had buttons A and B setup to the wrong physical pins of the USB encoder.
Now that I had SW proof of my mistake, I disassembled my controller case and flipped the connections for those two buttons on player 2 onto the USB encoder. Put everything back the way it was, and behold my arcade is now acting correctly with both controls synced up.
Thank you very much @mitu for your suggestion. I do appreciate it.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.