[SOLVED] Controller Detection & Switching? GPIO/USB/Bluetooth
-
How does RetroPie handle controller detection when it comes to using different controllers at different times? What I'm specifically wondering is if I have the Pi wired up to use GPIO inputs, but then plug in a USB controller, and or connect a Bluetooth controller, how will the Pi determine which controller to use as Player 1, 2, etc? Is there a way to switch it on the fly? I've seen things about fussing with config files, but I'm hoping there's a way to easily switch once the system is configured.
I'm in the planning stages of putting a Pi3 in a Super Famicom and I want to have the original controller ports functional via GPIO, but I'm wondering if or how RetroPie would handle using a Bluetooth controller if I wanted to get some 8bitdo pads at some point in the future. I've been using a Pi2 with a USB controller for over a year and it's great, but I've not ventured into the Bluetooth stuff yet and I wasn't able to find it discussed anywhere. I assume if it was a USB controller that was unplugged the Pi would know it. But I don't know how it "sees" things connected via GPIO.
-
@obsidianspider said in Controller Detection & Switching? GPIO/USB/Bluetooth:
if I have the Pi wired up to use GPIO inputs, but then plug in a USB controller, and or connect a Bluetooth controller, how will the Pi determine which controller to use as Player 1, 2, etc?
I can only talk about Linux and the RetroArch emulators (I'm assuming you are talking about joystick assignment at boot):
- Linux set
/dev/input/js*
files to these controllers as they are connected. So, the first detected controller isjs0
, the second isjs1
and so on... I've never used GPIO controllers, but I can say that at boot the USB controllers comes first and then the bluetooth. If you plug in/out these numbers will change. There are some udev tricks to make a device stick with a specificjs#
number, but I never tried. - RetroArch usually gets the first available
/dev/input/js*
as the index 0, the second as the index 1. Look, I'm NOT saying thatjs0
is the index 0,js1
is the index 1, for RetroArch!- Example: I have one USB adapter to two PlayStation2 controller ports. The Linux detects this adapter and set
js0
andjs1
to it, even if I have no actual controllers plugged. If I connect only one controller at the first PlayStation2 port, it will get thejs0
; and then I connect my bluetooth 8bitdo NES30, it will getjs2
. RetroArch will set thejs0
as the index 0, andjs2
as index 1.
- Example: I have one USB adapter to two PlayStation2 controller ports. The Linux detects this adapter and set
Is there a way to switch it on the fly?
For RetroArch, yes! You can have some issues, but if you update RetroArch from source it'll be solved. I'm talking about it here: https://retropie.org.uk/forum/topic/3882/change-retroarch-controllers-index-on-the-fly-with-no-issues
I've seen things about fussing with config files, but I'm hoping there's a way to easily switch once the system is configured.
You can use this tool to simplify some configs: https://github.com/meleu/RetroPie-joystick-selection
- Linux set
-
@meleu Thanks, this will help. I'm going to look into your script once I have the rest of my Super Famicom system built. (More parts are on the way! :) ) I'll be using Raphnet's USB adapter for SNES and that will be plugged in all the time and inside the case, so unplugging before booting won't really be an option. What I want to have happen is that if I have the SFC controllers unplugged and I turn on a Bluetooth controller that the system will see that and use the Bluetooth controller. I haven't purchased a Pi 3 or a Bluetooth controller yet, but I also dont' really want to invest in an 8bitdo setup if I can't easily go back and forth between wired and wireless. I'm probably going to be using the wired SFC controllers (via USB adapter) most of the time.
-
@obsidianspider said in Controller Detection & Switching? GPIO/USB/Bluetooth:
(...) I also dont' really want to invest in an 8bitdo setup if I can't easily go back and forth between wired and wireless.
The 8Bitdo controllers are lovely things, but, indeed, they are not necessary. I found them specially useful because my younger kid is 1 year old and was stumbling on the controller wires. :D
For RetroArch it's really easy to change the controllers. There are several ways to achieve it, in some of them you don't even need a keyboard:
- https://retropie.org.uk/forum/topic/3882/change-retroarch-controllers-index-on-the-fly-with-no-issues
- the RetroPie-joystick-selection tool I mentioned above.
- the RetroPie-Setup config editor.
-
@meleu I guess I'll have to think about if I want to go Bluetooth, but you answered my question so I'm going to mark this as solved and get back to messing with Python and Bash while I wait for more parts to arrive…
-
@obsidianspider I use a USB and 8bitdo, they work well with eachother as far as I can tell. Both 1 player and 2 player.
-
@Floob This is probably a dumb question, but when using both together, or switching back and forth, how does that work? I assume you can't just switch while in a game, but do you have to reboot the Pi before switching controllers? Do you have to unplug the USB controller to have the Bluetooth take over as Player 1? Since my USB adapter will be plugged in all the time that's where my concern comes in.
My ideal situation would be something like "Oh, hey, that Bluetooth controller you previously set up has connected, I'm going to use that instead of the USB one" and then if the Bluetooth controller isn't connected, fall back to the USB one. With multiplayer and all sorts of other variables I have a feeling I may need to just buy a Bluetooth controller and mess around with it.
-
@obsidianspider said in [SOLVED] Controller Detection & Switching? GPIO/USB/Bluetooth:
when using both together, or switching back and forth, how does that work? I assume you can't just switch while in a game, but do you have to reboot the Pi before switching controllers?
Your question make it seem like you didn't read my previous posts... :)
Is there a way to switch it on the fly?
For RetroArch, yes! You can have some issues, but if you update RetroArch from source it'll be solved. I'm talking about it here: https://retropie.org.uk/forum/topic/3882/change-retroarch-controllers-index-on-the-fly-with-no-issues
I've seen things about fussing with config files, but I'm hoping there's a way to easily switch once the system is configured.
You can use this tool to simplify some configs: https://github.com/meleu/RetroPie-joystick-selection
-
Just to make it really clear: when I say "switch controllers on-the-fly", I mean "switch controllers during a game". You definetely don't need to reboot to change the controllers between players.
The only emulator I know that is very limited in doing these controller changes is pifba. But you are probably using a libretro fba core, right?
-
@meleu I did read your earlier posts and I appreciate them. I was just asking Floob how it was working with his setup as it looks like the very new RetroArch solution (so new that version of RetroArch isn't in RetroPie) that you found requires something I would assume most people haven't done.
-
@obsidianspider
Indeed, thatall_users_control_menu
option is a new feature. In my opinion this option is needed to switch controllers on-th-fly with no issues (the issues I'm talking about basically happens when switching the player1 joypad, details here).But the other methods (RetroPie-joystick-selection, RetroPie-Setup config editor, or manually edit the
retroarch.cfg
) works out-of-the-box. You only have to exit the emulator. There's no need to reboot your raspi.Keep in mind that the joystick connection method (USB, GPIO, Bluetooth, whatever) is the OS responsibility. For RetroArch the connection method doesn't matter, it only gets the available joysticks from the OS. Therefore, all the switching controllers methods I showed you works fine for GPIO, USB, and Bluetooth joysticks. (I saw some posts here in the forum saying that some devices (eg: IPAC2) are recognized as a keyboard in RetroPie, but I think it's not your case.)
BTW: yours SuperFamicom build looks really great! I would like to have this enough electronics knowledge to build one for me! :-)
Cheers!
-
@meleu said in [SOLVED] Controller Detection & Switching? GPIO/USB/Bluetooth:
Keep in mind that the joystick connection method (USB, GPIO, Bluetooth, whatever) is the OS responsibility. For RetroArch the connection method doesn't matter, it only gets the available joysticks from the OS. Therefore, all the switching controllers methods I showed you works fine for GPIO, USB, and Bluetooth joysticks. (I saw some posts here in the forum saying that some devices (eg: IPAC2) are recognized as a keyboard in RetroPie, but I think it's not your case.)
That makes sense. I was just asking here because I don't want to end up buying a $35 controller and then not be able to use it the way I want.
BTW: yours SuperFamicom build looks really great! I would like to have this enough electronics knowledge to build one for me! :-)
Thanks. I really don't know what I'm doing. It's been a lot of reading, followed by trial and error. I had more parts show up today so hopefully I can make some progress this weekend on the hardware.
-
@obsidianspider No need to reboot the Pi to get the game to detect which controller is plugged in. Its happy to detect whats plugged in at the time, although I havent tested to see how easy it is to force a controller to be player 1 - I'm using a Pi3.
-
@Floob If you have a USB controller plugged in, then pair a Bluetooth controller (USB still plugged in) how does the system choose which controller to use? (I'm assuming it'll use the one that's USB, maybe making the Bluetooth Player 2?)
I think I'm going to run into issues because I'm never going to be unplugging the USB SNES controller adapter as it'll be built into the case.
-
@obsidianspider said in [SOLVED] Controller Detection & Switching? GPIO/USB/Bluetooth:
how does the system choose which controller to use?
forgive me if you just want a second opinion... but I explained you what happens in my first response to your post. ;-)
-
@meleu It was more of me asking in layman's/simpler terms. Like "Ok, I did this, now what did the Pi do?" I'm going to stop asking follow up questions until I actually get a Bluetooth controller and can't figure it out. :-P
-
@obsidianspider
you may have some issues in connecting and configuring the buttons of your bluetooth controllers. But once it's done, it's really easy to switch between the available controllers in RetroArch.Trying to ask your question "how does the system choose which controller to use?" (assuming system = RetroArch). Like I said in my first response, RetroArch define some indexes for the controllers. The default is player1 = index 0, player2 = index 1, and so on (I didn't make it clear in my first post). But you can change it in retroarch.cfg. What the RetroPie-Setup config editor and my joystick-selection tool do is just this: change these options in retroarch.cfg.
BTW: the options related to what we are talking about here are
input_player1_joypad_index
,input_player2_joypad_index
, etc...
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.