Created
April 12, 2020 00:35
-
-
Save sarcasticadmin/4558eee3093e68b46374b2ea0d7ffd3e to your computer and use it in GitHub Desktop.
Lakka 8bitdo bluetooth controller autoadd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tried this on Lakka (official): 2.3.2 (Generic.x86_64) | |
# | |
# This script is a WIP (work in progress | |
# Refs | |
# https://www.pcsuggest.com/linux-bluetooth-setup-hcitool-bluez/ | |
# https://wiki.archlinux.org/index.php/Bluetooth | |
# https://stackoverflow.com/questions/12888589/linux-command-line-howto-accept-pairing-for-bluetooth-device-without-pin | |
# | |
# Once 8bitdo controllers are paired they do not get remembered after reboot | |
# Even though their configs are still present in ~/.config/bluetooth | |
# Because bluetoothctl doesnt allow a non-color option... | |
NOCOLOR="sed \"s,$(printf '\033')\\[[0-9;]*[a-zA-Z],,g\" | tr \"[:cntrl:]\" \"\n\"" | |
# --agent is being used to tell bluetoothd that there is no input or output interact during pair | |
paired(){ | |
raw_pair=$(echo -e 'paired-devices\nexit\n' | bluetoothctl --agent="NoInputNoOutput" | eval ${NOCOLOR}) | |
#echo -e "$raw_pair" | grep -i paired-devices -A - | |
echo -e "$raw_pair" | sed -n '/paired-devices/,$p' | grep Device | |
} | |
finddev(){ | |
# Sample output from scan | |
#Scanning ... | |
# E4:17:D8:BE:09:6A 8Bitdo SFC30 GamePad | |
# Get all 8bitdo controllers | |
# Typically start with E4:17:D8 | |
DEVICES=$(hcitool scan --length=10 --flush | grep 8Bitdo | grep -ioE '([a-z0-9]{2}:){5}..') | |
echo "${DEVICES} list" | |
for DEVICE in ${DEVICES}; do | |
test "$DEVICE" != '' && echo -e "pair $DEVICE\ntrust $DEVICE\nconnect $DEVICE\nexit\n" | bluetoothctl --agent="NoInputNoOutput" | eval ${NOCOLOR} | |
#hcitool cc $DEVICE; hcitool auth $DEVICE | |
done | |
} | |
# It appears this seems to be done by default at boot | |
prepbluetooth(){ | |
echo -e "power on\ndiscoverable on\npairable on\nscan on\nexit\n" | bluetoothctl --agent="NoInputNoOutput" | eval ${NOCOLOR} | |
echo "Bluetooth prepped..." | |
sleep 5 | |
} | |
removedevice(){ | |
local DEVICE=$1 | |
echo -e "disconnect $DEVICE\nuntrust $DEVICE\nremove $DEVICE\nexit\n" | bluetoothctl --agent="NoInputNoOutput" | eval ${NOCOLOR} | |
} | |
# Toggling on steps during testing | |
#prepbluetooth | |
finddev | |
#paired | |
#removedevice $1 |
@franzbischoff I havent tried this but it would appear that you can create /storage/.config/autostart.sh
and have it call this script then lakka's config should just pick it up based on looking at the existing systemd services: https://github.com/libretro/Lakka-LibreELEC/blob/8c3a7e6e3cea81788f13d6d40e3f2628940e7e58/packages/libretro/retroarch/system.d/retroarch-autostart.service
Hope that helps
That works, thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I make lakka run this at start?
Thanks