Bluetooth controller auto connect
-
Pi 5 (Canakit with SSD)
RetroPie Version 4.8
Built From: On top of Full Raspberry Pi OS 64 bit using Imager
USB Devices connected: one SNES style USB wireless controller that shows up as an XBox controller when configuring buttons.
Controller used: AceGamer for PS4 Controller, wireless (Bluetooth)
Error messages received: auto connects with white light (lost connection) instead of blue or red light showing player 1 or 2
Guide used: I attempted a few different methods and this worked the best... https://retropie.org.uk/forum/topic/31160/solved-can-i-pair-a-ps4-dualshock-controller-with-two-pi-4s/16?_=1687103003103
File: /opt/retropie/configs/all/autostart.sh
sudo bluetoothctl remove [Mac Address]
sudo timeout 6 bluetoothctl scan on
sudo bluetoothctl connect [Mac Address]
sudo bluetoothctl trust [Mac Address]
emulationstation #auto
How to replicate the problem: I can manually add the controller via the Bluetooth configuration and then configure the buttons okay, but upon restart I have to reaccomplish all of that. I attempted the modification to the autostart.sh above but that only gets it to connect with a solid white light (lost connection). I would like for it to be able to reconnect on reboot, and better yet already have the buttons configured if possible.
I did attempt the process here https://retropie.org.uk/docs/Bluetooth-Controller/
and Step 2.5 the last command gave me a sudo systemctl enable "bad message" error -
Usually it's not necessary to do anything special to make a controller re-connect when using Bluetooth. Once paired - either through RetroPie's Bluetooth setup or through OS's Bluetooth pairing utility - they should re-connect when started again.
if
When you say 'upon restart I have to reaccomplish all of that`, is this the restart of the Pi or the controller ? Some controllers may have issues reconnecting to the OS if the OS is restarted, but they work if they're stopped and started again.I don't understand why the buttons need re-configuring, since the configuration is saved by EmulationStation and it should recognize the controller once it's paired (even if the controller is re-configured) - did you modify any of the EmulationStation configuration files manually ?
I'd advise to remove any commands from
autostart.sh
and redo the pairing vie Bluetooth again. Make sure the controller is configured ok (in EmulationStation) and then - when the reconnection doesn't work - try to re-connect the controller from RetroPie's Bluetooth menu.If that doesn't work, you should enable debugging (see https://wiki.archlinux.org/title/Bluetooth, on the debugging section) and post the error/info messages shown by
bluetoothd
. -
@mitu said in Bluetooth controller auto connect:
Usually...they should re-connect when started again.
They aren't reconnecting but I can try again a few times. It does seem to be holding their info (MAC Address), but the controllers don't connect.
if
When you say 'upon restart I have to reaccomplish all of that`, is this the restart of the Pi or the controller ? Some controllers may have issues reconnecting to the OS if the OS is restarted, but they work if they're stopped and started again.When I restart the Pi, the controllers don't reconnect. I'll try again manually connecting them, but it does seem that the button configuration isn't being saved.
did you modify any of the EmulationStation configuration files manually ?
I haven't modified any of that to my knowledge, but I have attempted a few different methods to get this to work unsuccessfully.
I'd advise to remove any commands from autostart.sh and redo the pairing vie Bluetooth again. Make sure the controller is configured ok (in EmulationStation) and then - when the reconnection doesn't work - try to re-connect the controller from RetroPie's Bluetooth menu.
Will do.
If that doesn't work, you should enable debugging (see https://wiki.archlinux.org/title/Bluetooth, on the debugging section) and post the error/info messages shown by bluetoothd.
Thank you, I will try that.
-
@mxs said in Bluetooth controller auto connect:
When I restart the Pi, the controllers don't reconnect. I'll try again manually connecting them, but it does seem that the button configuration isn't being saved.
Can you post the contents of
$HOME/.emulationstation/es_input.cfg
? If the configuration of the buttons is not saved, the file may be missing the necessary configuration. -
@mitu
I am a bit of a Linux novice, but I do not see that file or even that folder on this machine. I have RetroPie and RetroPie Setup folders in the /home/username folder, but nothing for Emulation Station there. Could it be elsewhere, hidden, or not show up in the desktop environment?Probably related to the lack of that file above, I got those lines out of the autostart file, paired and used the Bluetooth controllers, then restarted the machine and the controllers won't connect.
The "Wireless Controller" (s) show up as paired devices in the Configure Bluetooth menu, but will not connect unless I manually reconnect them.
Update I was able to find the es_input.cfg file using the File Manager in RetroPie. I do have three controllers in there, an "Xbox 360 Controller" which is my USB wireless SNES controller, a "Sony Interactive Entertainment Wireless Controller", and a "Wireless Controller". The configurations look okay, but because I can't get the Controllers to connect without manually adding them as Bluetooth, I think that is the issue.
-
@mxs said in Bluetooth controller auto connect:
The "Wireless Controller" (s) show up as paired devices in the Configure Bluetooth menu, but will not connect unless I manually reconnect them.
So they do reconnect if you use the Bluetooth RetroPie menu's connect all devices ? What if you restart the controller - does it reconnect ? I'm trying to understand what 'manually' means here.
The configurations look okay, but because I can't get the Controllers to connect without manually adding them as Bluetooth, I think that is the issue.
Please post the file's contents here in the topic. You can access the file also via file shares from
\\retropie\configs\all\emulationstation
. -
@mitu said in Bluetooth controller auto connect:
So they do reconnect if you use the Bluetooth RetroPie menu's connect all devices ? What if you restart the controller - does it reconnect ? I'm trying to understand what 'manually' means here.
The only way I can get the Controllers to connect is to remove them(option X) from Bluetooth Device list in the Bluetooth menu, them Pair and Connect them (option P), which I believe erases their button configuration.
-
The only way I can get the Controllers to connect is to remove them(option X) from Bluetooth Device list in the Bluetooth menu
Ok, so the automatic re-pairing doesn't work. You may want to try the different 'connect modes' in the Bluetooth menu, one of them may work for your case.
them Pair and Connect them (option P), which I believe erases their button configuration.
No, this operation does not remove the configuration.
-
@mitu said in Bluetooth controller auto connect:
Please post the file's contents here in the topic. You can access the file also via file shares from \retropie\configs\all\emulationstation.
<?xml version="1.0"?> <inputList> <inputAction type="onfinish"> <command>/opt/retropie/supplementary/emulationstation/scripts/inputconfiguration.sh</command> </inputAction> <inputConfig type="joystick" deviceName="Xbox 360 Controller" deviceGUID="030081b85e0400008e02000014010000"> <input name="left" type="hat" id="0" value="8"/> <input name="right" type="hat" id="0" value="2"/> <input name="pagedown" type="button" id="5" value="1"/> <input name="down" type="hat" id="0" value="4"/> <input name="pageup" type="button" id="4" value="1"/> <input name="y" type="button" id="2" value="1"/> <input name="x" type="button" id="3" value="1"/> <input name="b" type="button" id="0" value="1"/> <input name="a" type="button" id="1" value="1"/> <input name="up" type="hat" id="0" value="1"/> <input name="select" type="button" id="6" value="1"/> <input name="start" type="button" id="7" value="1"/> </inputConfig> <inputConfig type="joystick" deviceName="Sony Interactive Entertainment Wireless Controller" deviceGUID="0300d0424c050000cc09000011810000"> <input name="rightanalogdown" type="axis" id="4" value="1"/> <input name="left" type="hat" id="0" value="8"/> <input name="rightanalogleft" type="axis" id="3" value="-1"/> <input name="right" type="hat" id="0" value="2"/> <input name="pagedown" type="button" id="5" value="1"/> <input name="down" type="hat" id="0" value="4"/> <input name="rightanalogup" type="axis" id="4" value="-1"/> <input name="pageup" type="button" id="4" value="1"/> <input name="rightanalogright" type="axis" id="3" value="1"/> <input name="y" type="button" id="3" value="1"/> <input name="x" type="button" id="2" value="1"/> <input name="b" type="button" id="0" value="1"/> <input name="a" type="button" id="1" value="1"/> <input name="up" type="hat" id="0" value="1"/> <input name="select" type="button" id="8" value="1"/> <input name="start" type="button" id="9" value="1"/> <input name="leftanalogright" type="axis" id="0" value="1"/> <input name="leftanalogup" type="axis" id="1" value="-1"/> <input name="leftanalogdown" type="axis" id="1" value="1"/> <input name="leftanalogleft" type="axis" id="0" value="-1"/> </inputConfig> <inputConfig type="joystick" deviceName="Wireless Controller" deviceGUID="05009b514c050000cc09000000810000"> <input name="rightanalogdown" type="axis" id="4" value="1"/> <input name="left" type="hat" id="0" value="8"/> <input name="rightanalogleft" type="axis" id="3" value="-1"/> <input name="right" type="hat" id="0" value="2"/> <input name="pagedown" type="button" id="5" value="1"/> <input name="down" type="hat" id="0" value="4"/> <input name="rightanalogup" type="axis" id="4" value="-1"/> <input name="pageup" type="button" id="4" value="1"/> <input name="rightanalogright" type="axis" id="3" value="1"/> <input name="y" type="button" id="3" value="1"/> <input name="x" type="button" id="2" value="1"/> <input name="b" type="button" id="0" value="1"/> <input name="a" type="button" id="1" value="1"/> <input name="up" type="hat" id="0" value="1"/> <input name="select" type="button" id="8" value="1"/> <input name="start" type="button" id="9" value="1"/> <input name="leftanalogright" type="axis" id="0" value="1"/> <input name="leftanalogup" type="axis" id="1" value="-1"/> <input name="leftanalogdown" type="axis" id="1" value="1"/> <input name="leftanalogleft" type="axis" id="0" value="-1"/> </inputConfig> </inputList>
-
I tried all 3 connect options (default, boot, and background) and none of those are working. Let me make sure I am attempting this correctly. When I start the system it automatically starts Emulation Station and RetroPie. When I first turn it on, I then click the home button on the controllers which makes it give a slow constant white light flash while it looks for a connection. Is this the right mode as opposed to the pairing mode when it does a short blast of white flashes every 3 or 4 seconds?
When I turn on the controller it attempts to connect for maybe 30 seconds then turns back off.I just removed the Bluetooth controller then paired/connected it again, and see that it held the button configuration. I may have been having difficulty because I have had other controllers, a mouse, and a keyboard connected at different times and they may have interfered or been taking the 'Port 1' in games.
So now I am down to the issue being that the controller will not connect unless I readd it each time I restart the machine in the Bluetooth menu.
-
@mxs said in Bluetooth controller auto connect:
. Is this the right mode as opposed to the pairing mode when it does a short blast of white flashes every 3 or 4 seconds?
Yes, most likely. Assuming the same behavior as a genuine DS4 controller, the flashing lights are specific to the pairing mode.
When I turn on the controller it attempts to connect for maybe 30 seconds then turns back off.
Right, so no automatic re-connection. Any chance on getting the debug log I mentioned a while ago ?
I may have been having difficulty because I have had other controllers, a mouse, and a keyboard connected at different times and they may have interfered or been taking the 'Port 1' in games.
A keyboard/mouse will not take over the 'Port 1', only a controller.
So now I am down to the issue being that the controller will not connect unless I readd it each time I restart the machine in the Bluetooth menu.
Unfortunately I think this is a controller issue, not something that's caused by RaspiOS/Linux (RetroPie just uses the OS's Bluetooth stack). Maybe a debug log would show something of help, but ultimately any paired device should re-connect automatically to it's partner when it's powered on.
Does the controller work with another PC ? Leaving aside a PS4, does it work properly (i.e. reconnects after a start/restart) to a PC running Windows/Linux ?
EDIT: just to make sure, is your RetroPie system updated - with the OS packages also ?
-
@mitu said in Bluetooth controller auto connect:
Right, so no automatic re-connection. Any chance on getting the debug log I mentioned a while ago ?
I'm not completely familiar with how to do the debug part. I did open a terminal and attempt to connect to the controllers while in desktop and was unsuccessful. I then attempted to connect via the Manage Bluetooth devices icon in the tray with the Wireless Controller -> Connect option and this is what it said in terminal...
[NEW] Device 8D:AB:C5:B3:48:0E Wireless Controller
[CHG] Device 8D:AB:C5:B3:48:0E Modalias: usb:v054Cp09CCd0100
[CHG] Device 8D:AB:C5:B3:48:0E UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device 8D:AB:C5:B3:48:0E UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 8D:AB:C5:B3:48:0E Connected: yes
[CHG] Device 8D:AB:C5:B3:48:0E Bonded: yes
[CHG] Device 8D:AB:C5:B3:48:0E UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device 8D:AB:C5:B3:48:0E UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 8D:AB:C5:B3:48:0E ServicesResolved: yes
[CHG] Device 8D:AB:C5:B3:48:0E Paired: yes
[CHG] Device 8D:AB:C5:B3:48:0E WakeAllowed: yes
[CHG] Device 8D:AB:C5:B3:48:0E ServicesResolved: no
[CHG] Device 8D:AB:C5:B3:48:0E Connected: no
[CHG] Device 8D:AB:C5:B3:48:0E Trusted: yes
[CHG] Device 8D:AB:C5:B3:48:0E Connected: yes
[CHG] Device 8D:AB:C5:B3:48:0E ServicesResolved: yes[CHG] Device 16:3F:AD:A3:05:C4 Connected: yes
[CHG] Device 16:3F:AD:A3:05:C4 Bonded: yes
[CHG] Device 16:3F:AD:A3:05:C4 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device 16:3F:AD:A3:05:C4 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 16:3F:AD:A3:05:C4 ServicesResolved: yes
[CHG] Device 16:3F:AD:A3:05:C4 Paired: yes
[CHG] Device 16:3F:AD:A3:05:C4 WakeAllowed: yes
[CHG] Device 16:3F:AD:A3:05:C4 ServicesResolved: no
[CHG] Device 16:3F:AD:A3:05:C4 Connected: no
[CHG] Device 16:3F:AD:A3:05:C4 Trusted: yes
[CHG] Device 16:3F:AD:A3:05:C4 Connected: yes
[CHG] Device 16:3F:AD:A3:05:C4 ServicesResolved: yesThey did connect with the blue and red lights on the controller so that was successful.
If you can let me know what I need to do for the debug part I can attempt that.
-
@mxs said in Bluetooth controller auto connect:
If you can let me know what I need to do for the debug part I can attempt that.
See:
If that doesn't work, you should enable debugging (see https://wiki.archlinux.org/title/Bluetooth, on the debugging section) and post the error/info messages shown by bluetoothd.
-
@mitu said in Bluetooth controller auto connect:
Does the controller work with another PC ? Leaving aside a PS4, does it work properly (i.e. reconnects after a start/restart) to a PC running Windows/Linux ?
EDIT: just to make sure, is your RetroPie system updated - with the OS packages also ?
I don't really have another bluetooth computer to test the controllers with.
All of the OS packages are updated.
-
@mitu I read the debugging part but I don't really understand it as I am very new with Linux. I attempted and did the stop and start commands it said, but I don't know what I am supposed to be looking for after that.
-
@mxs If you've enabled debugging, then run the following command
journalctl -f -u bluetoothd
This will print the
bluetoothd
debug messages in real-time. Power up the controller and see what's printed on the terminal after the power up. Leave it to time-out and then post the messages on the screen.Press
Ctrl+C
to interrupt thejournalctl
command and get back to the command prompt.
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.