There's probably a device list that has the gamepad in it. Look for a console command to see if you can poll a service or get a list of devices, and see if the controller is in it, and if not, re-run the connection script. Could be as simple as a dumb script to see if *gamepad* is present in the output of some command. Astericks being the wildcard character, so it would check for the phrase anywhere in the returned message. I don't know what command searches through text, but if you put the output of a command to a file i.e. command --list >> /home/user/output.txt, that would put the output of the command in a text file. Another program could search for the string of your gamepad.JasperSlade wrote:
Many thanks! It worked to connecter the bluetooth keyboard and touchpad of my nexdockJasperSlade wrote:Recently got my first RPi, used it to setup RetroPie. Been working to get a bluetooth gamepad working. Used the info at https://github.com/RetroPie/RetroPie-Se ... controller so I now, provided the gamepad is on during startup, it will connect. otherwise I have to drop to the command line and use bluetoothctl to get a connection.
Here are the exact instructions I followed:
Step 2.5 - Forcing the Pi to reconnect to the controller
If you find your controller doesn't automatically reconnect when you restart the Pi, this process should force the connection.
Some users have reported it will work without this if you wait for Emulation Station to fully load before turning on your controller - this is possibly model or firmware specific.
sudo nano /bin/connect-bluetooth.sh
In that file add
sudo bluetoothctl << EOF
connect [MAC Address]
Save that file.
Make it executable
sudo chmod +x /bin/connect-bluetooth.sh
Then create a new file
sudo nano /etc/systemd/system/connect-bluetooth.service
Add this text:
Save that file.
Then run this command to enable that process
sudo systemctl enable /etc/systemd/system/connect-bluetooth.service
Video Guide for this: https://youtu.be/RsybSJEPZJM
Here is what I'm really hoping to figure out: If the gamepad loses connection for any reason (walk out of range, gamepad goes to sleep, etc) when it powers back on, i have to drop to the command line again to re-connect. is there a script i could write to periodically check for the gamepad and re-connect?
(Sorry if i'm a total newb)
Good question - the answer is "probably not", as the Bluetooth is currently controlled by a plugin that only loads when the GUI is up and running.LeFauve wrote:Is there a way to use the BT keyboard to log from the console?
It's all D-Bus control of the BlueZ stack. The source is on the raspberrypi GitHub - look in the lxpanel project, under plugins/bluetooth. All the code is in the bluetooth.c file. (It's quite long...)Douglas6 wrote:What does the plugin do at start up? Source code?spl23 wrote:Bluetooth is currently controlled by a plugin that only loads when the GUI is up and running.
Code: Select all
sudo apt-get install pulseaudio pulseaudio-module-bluetooth
Code: Select all
[email protected]:~ $ sudo service bluetooth status ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled) Active: active (running) since Mon 2017-01-30 20:35:17 EST; 29min ago Docs: man:bluetoothd(8) Main PID: 2076 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service └─2076 /usr/lib/bluetooth/bluetoothd Jan 30 20:35:17 raspberrypi bluetoothd: Bluetooth daemon 5.23 Jan 30 20:35:17 raspberrypi bluetoothd: Starting SDP server Jan 30 20:35:17 raspberrypi systemd: Started Bluetooth service. Jan 30 20:35:17 raspberrypi bluetoothd: Bluetooth management interface...d Jan 30 20:35:17 raspberrypi bluetoothd: [b]Sap driver initialization failed.[/b] Jan 30 20:35:17 raspberrypi bluetoothd: sap-server: Operation not perm...) Jan 30 20:40:25 raspberrypi systemd: Started Bluetooth service. [b]Jan 30 20:48:42 raspberrypi bluetoothd: a2dp-source profile connect fa...e Jan 30 21:00:32 raspberrypi bluetoothd: a2dp-source profile connect fa...e[/b] Hint: Some lines were ellipsized, use -l to show in full.
Code: Select all
[email protected]:~ $ sudo apt-get install pulseaudio-module-bluetooth Reading package lists... Done Building dependency tree Reading state information... Done pulseaudio-module-bluetooth is already the newest version. The following packages were automatically installed and are no longer required: libboost-filesystem1.55.0 libboost-program-options1.55.0 libboost-regex1.55.0 libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1 libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 ri1.9.1 ruby1.9.1 ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova tcl8.5 tk8.5 Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. [email protected]:~ $ sudo killall pulseaudio pulseaudio: no process found [email protected]:~ $ sudo pulseaudio --start W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified). W: [pulseaudio] authkey.c: Failed to open cookie file '/root/.config/pulse/cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to load authorization key '/root/.config/pulse/cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to open cookie file '/root/.pulse-cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to load authorization key '/root/.pulse-cookie': No such file or directory