joystick-selection not switching to retroarch default when controller unplugged
-
I'm having an issue where the joystick-selection script is working fine when my USB controller is connected, but not when it is disconnected, the only thing I've seen in the forums is setting the script to use "by name", which I have done. I have a Pi 3 running RetroPie 4.2.3 from a clean SD image install. I installed retropie-joystick-selection so that when I launch the SNES core, my SNES usb controller would take player 1 over my dragonrise attached to the cabinet. But when the SNES usb controller is not plugged in, I want to use the dragonrise, which is how it is supposed to work as I understand. I set the global player 1 and 2 to the 2 dragonrise controllers and in SNES I set player 1 to the SNES usb controller. Basically the SNES controller is the only thing that will work player 1 in the SNES retroarch core. If it's not plugged in, I need to plug it in to quit back to emulation station.
It seems like the runcommand script isn't running, the line to run js-onstart is added to the runcommand-onstart script and setting the player bindings in joystick-selection does update the retroarch config files for the emulators, it just doesn't change them if the controller isn't plugged in.
Things that I have tried include unsetting everything global and snes and re-setting, leaving global as unset for all players and just putting player 1 in snes, updating retropie-joystick-selection and runcommand, toggling by name off and back on, and testing similar situations with player 2, but that doesn't go back to retroarch default either. I should also include that all other emulator cores are working fine with my dragonrise controllers.
Any ideas as to what it could be? -
-
@meleu thanks and let me know if you want me to test anything out to help you troubleshoot
-
@moeman I introduced this bug in 4-Mar-2017, and I've just fixed it. Can you update and test it again, please?
-
@meleu You are awesome. Everything is working exactly as it should now, the controller will work when plugged in and when not plugged in the dragonrise takes over. However, there is one more thing and I'm not sure it's an easy solve, I've seen the other threads about multiple controllers. I have 2 of these USB SNES controllers that show up as "usb gamepad ", but when they are both plugged in, I get "usb gamepad #1" and "usb gamepad #2", so if I set it to a player when they are both plugged in, I can only use the controllers when both are plugged in, likewise if I set it when just one is plugged in, I can't use either controller if both are plugged in, it will default to dragonrise, seeing the controllers as not being connected because the names are different. Any ideas how to get around that? Could your script ignore the #1 and #2 at the end of the name string when checking for connection?
-
@moeman I predicted this issue about 9 months ago and already have a solution in mind. Will try to fix it tomorrow and let you know when it's ready.
Thanks for testing! :-)
-
@meleu thanks for your help!
-
@moeman I am and will be away from my RetroPie for ~12 hours. But your OP makes me believe that you're comfortable with Linux commands. Then if you wanna test my solution beforehand, you can try it on your end. You just need to change one single character in the code.
If you wanna test it, open the file
/opt/retropie/supplementary/joystick-selection/jsfuncs.sh
and go to line 196. You'll see this obscureawk
command:awk -F: 'FNR==NR {count[$2]++; next} count[$2]>1 {$0=$0 OFS "#"++times[$2]} 1' "$temp_file" "$temp_file" > "$jslist_file"
In the second line (actually line 197), change the
count[$2]>1
tocount[$2]>0
, and save the file (it requires root privileges).What does this change do?
Adds the trailing
#N
in every joystick name, not only the repeated ones. I think it can solve your issue (at least in the vast majority of cases). -
@meleu Success! Your solution works perfectly. Player 1 will work with the controller if plugged in, whether or not a second usb controller is plugged in. If just one controller is plugged in, player 2 will fall back to retroarch default as it should. Thank you for making this tool and your quick responses
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.