#!/bin/zsh # FPV Drone Obby launcher for Mac: starts Roblox with your EdgeTX radio as a game controller. # It changes nothing permanent on your Mac. The controller setting applies only to the Roblox started # from here; quit Roblox (and its menu-bar icon) and the next Roblox you open is back to normal. # # Two ways to run it, same file: paste # curl -fsSL https://droneteleofpv.com/obby/fly-mac.sh | zsh # into Terminal, or save it once with # curl -fsSLo ~/Desktop/fly-obby.command https://droneteleofpv.com/obby/fly-mac.sh # chmod +x ~/Desktop/fly-obby.command # and double-click it from then on (a file curl saves isn't marked as downloaded, so Gatekeeper never # stops it, wherever it is moved). Everything is inside main(), which runs only after the whole file has arrived, and # nothing reads from the pipe, so the curl way can't run half a script. main() { local map="0300000009120000544f000000020000,EdgeTX Radio,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:+a7,start:b7,leftx:a0,lefty:a2~,rightx:a3,righty:a1,lefttrigger:a4,righttrigger:a5,leftstick:+a6,rightstick:-a6,platform:Mac OS X," local place=118449712855714 local me=$(id -un) # 1. Which Roblox to start. Installed without an admin password, Roblox lives in that user's own # ~/Applications, and other accounts on the Mac run that copy too (the website's Play button # does; seen 2026-10-09 on a Mac where only a second account had installed it). So: this # user's copy, then the shared one, then any other account's. local app="" c for c in ~/Applications/Roblox.app /Applications/Roblox.app /Users/*/Applications/Roblox.app(N); do [[ -d $c/Contents/MacOS ]] && { app=$c; break } done if [[ -z $app ]]; then say_stop "Roblox isn't installed on this Mac. Install it from roblox.com/download, open it once, then run this again." return 1 fi # 2. Roblox only finds the radio when it starts, so check it's plugged in first. # EdgeTX radios in USB Joystick mode report USB vendor 1209 (4617), product 4F54 (20308). local usb=$(ioreg -p IOUSB -l -w0) if [[ $usb != *'"idVendor" = 4617'* || $usb != *'"idProduct" = 20308'* ]]; then say_stop "No EdgeTX radio found. Plug it in, pick USB Joystick (HID) on the radio, then run this again." return 1 fi local ok=0 attempt i for attempt in 1 2 3; do # 3. Quit this user's Roblox, including its menu-bar icon: that icon keeps the settings Roblox # started with and would hand the game the old ones. Other users' Roblox is left alone. pkill -u $me -x RobloxPlayer 2>/dev/null; pkill -u $me -x RobloxMenuBar 2>/dev/null for i in {1..50}; do mine RobloxPlayer || mine RobloxMenuBar || break; sleep 0.1; done pkill -9 -u $me -x RobloxPlayer 2>/dev/null; pkill -9 -u $me -x RobloxMenuBar 2>/dev/null for i in {1..30}; do mine RobloxPlayer || break; sleep 0.1; done # 4. Open Roblox with the controller mapping, for this launch only: Mode 2, AETR channel order. # SDL_JOYSTICK_MFI=0 works around a macOS bug that hides the radio from games. # In the game, radio setup (key K) fixes Mode 1, TAER and reversed channels. if ! open -a "$app" --env SDL_JOYSTICK_MFI=0 --env "SDL_GAMECONTROLLERCONFIG=$map"; then say_stop "macOS wouldn't start Roblox ($app). Check Roblox opens by itself (a parental-control or screen-time block stops it too), then run this again." return 1 fi for i in {1..80}; do mine RobloxPlayer && break; sleep 0.25; done sleep 2 if good; then ok=1; break; fi echo "Roblox didn't pick up the controller setting (try $attempt of 3); trying again..." done if (( ! ok )); then say_stop "Couldn't start Roblox with the controller setting. Quit Roblox (Cmd+Q), wait a few seconds, and run this again." return 1 fi # 5. Straight into the game, in the Roblox that has the setting. sleep 2 open "roblox://placeId=$place" echo "Opening FPV Drone Obby. You can close this window." } # True if this user has a process with exactly this name. mine() { pgrep -qx -u $(id -un) $1 } # The Player we want is this user's only one, and it carries both settings. good() { local p e p=$(pgrep -x -u $(id -un) RobloxPlayer) || return 1 [[ $p == *$'\n'* ]] && return 1 e=$(ps eww -o command= -p $p) [[ $e == *"SDL_JOYSTICK_MFI=0"* && $e == *"a:b0"* ]] } # Print the message and, in a window of its own, wait for a key so it can be read. say_stop() { echo "$1" if { : /dev/null; then read -k1 "?Press any key to close."