@echo off
rem FPV Drone Obby launcher: starts Roblox with your EdgeTX radio as a game controller.
rem It changes nothing on your PC. The controller setting below applies only to the Roblox
rem started from here, so other Roblox games, Steam and other sims never see it.
setlocal

rem 1. Roblox only finds the radio when it starts, so check it's plugged in first.
rem    EdgeTX radios report USB vendor 1209, product 4F54.
powershell -NoProfile -Command "if (-not (Get-PnpDevice -PresentOnly -ErrorAction SilentlyContinue | Where-Object InstanceId -like 'USB\VID_1209&PID_4F54*')) { exit 1 }"
if errorlevel 1 (
  echo No EdgeTX radio found. Plug it in, pick USB Joystick ^(HID^) on the radio, then run this again.
  pause
  exit /b 1
)

rem 2. Close any Roblox already running, including the one in the tray. A running Roblox
rem    would take the game over without the controller setting.
taskkill /im RobloxPlayerBeta.exe /f >nul 2>&1
timeout /t 2 /nobreak >nul

rem 3. The controller mapping, for this launch only: Mode 2, AETR channel order. In the game,
rem    radio setup (key K) fixes Mode 1, TAER and reversed channels.
set "SDL_GAMECONTROLLERCONFIG=0300000009120000544f000000000000,EdgeTX Radio,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftx:a0,lefty:a2~,rightx:a3,righty:a1,lefttrigger:a4,righttrigger:a5,platform:Windows,"

rem 4. Straight into the game.
start "" "roblox://placeId=118449712855714"
