Forked from gingerbeardman/pair-wii-remote-macos.sh
Created
October 16, 2023 01:32
-
-
Save madhuravius/368b3438c1454f6c1ccb4c8a7d954d8c to your computer and use it in GitHub Desktop.
Automatically pair a Wii Remote to macOS using blueutil command-line tool (Intel-only? fails on Apple silicon)
This file contains 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
#!/usr/bin/env bash | |
# requirements: blueutil | |
echo "Hold both 1+2 buttons on Wii Remote and wait for 30 seconds" | |
# get MAC Address of Wii Remote | |
MAC=`$(which blueutil) --inquiry 5 2>&1 | grep 'address' | awk '{print substr($2,1,17)}'` | |
(killall -m 'blueutil*' 2>&1) >/dev/null | |
echo "MAC: $MAC" | |
# prepare HEX | |
HEX=`echo $MAC | tr -d '-'` | |
# PIN is MAC Address HEX pairs in reverse order | |
PIN="\x${HEX:10:2}\x${HEX:8:2}\x${HEX:6:2}\x${HEX:4:2}\x${HEX:2:2}\x${HEX:0:2}" | |
# try to PAIR with PIN | |
echo "ATTEMPTING PAIR" | |
echo "$PIN" | $(which blueutil) --pair $MAC >/dev/null 2>&1 | |
# fail? | |
if [ $? -ne 0 ]; then | |
echo "PAIR FAILED" | |
else | |
# now we can CONNECT | |
echo "ATTEMPTING CONNECT" | |
$(which blueutil) --connect $MAC >/dev/null 2>&1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment