FE: the menu process applies NO platform profile -- the preset leak fix

Steam-host report ('no glass panel, plasma yes'): a direct btl4.exe start ran
the MENU under the DEV profile, whose putenv(L4CONTROLS=KEYBOARD) leaked into
the relaunched mission child -- the child's glass preset (sets-when-unset)
could then never select PAD: no PadRIO, no panel; the plasma appeared only
because DEV never touches L4PLASMA.  Menu-mode is now detected FIRST and the
front-end process skips the profile putenvs entirely (profiles belong to game
processes); boot line reads 'MENU (front end -- no profile applied)'.
Verified: zero-arg start -> menu -> launch -> child boots GLASS, PadRIO up,
72-control panel present, plasma present.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-18 19:13:03 -05:00
co-authored by Claude Fable 5
parent bfe7c223ac
commit 1e6f5fd347
+26 -6
View File
@@ -239,6 +239,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// `-platform pod` ATTEMPTS the path (FindBestAdapterIndices degrades to the
// primary adapter) -- selectable for bring-up, not fully validated off-pod.
// ---------------------------------------------------------------------------
//
// MENU-MODE detection FIRST (glass): the front-end process must NOT
// apply a platform profile -- its putenv()s would leak into the
// relaunched mission child and defeat the child's own preset (found
// live: a direct btl4.exe start ran the menu under the DEV profile,
// the child inherited L4CONTROLS=KEYBOARD, and the glass preset could
// never select PAD -- no PadRIO, no panel, plasma only).
//
int fe_menu_mode = 0;
#ifdef BT_GLASS
{
int fe_has_egg = lpCmdLine && strstr(lpCmdLine, "-egg") != NULL;
int fe_has_net = lpCmdLine && strstr(lpCmdLine, "-net") != NULL;
fe_menu_mode = !fe_has_egg && !fe_has_net && getenv("BT_FE_EGG") == NULL;
}
#endif
int gBTPlatformPod = 0;
int gBTPlatformGlass = 0;
{
@@ -267,7 +284,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
#endif
}
if (gBTPlatformPod)
if (fe_menu_mode)
{
// the front end owns this process; no profile putenvs (see above)
}
else if (gBTPlatformPod)
{
// POD profile. RIO cockpit input, which falls back to KEYBOARD when the
// serial port isn't present (e.g. a dev box: "RIO initialization failed!
@@ -329,9 +350,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
putenv("L4GAUGE=640x480x16");
std::cout << "[boot] platform profile: "
<< (gBTPlatformPod ? "POD (RIO cockpit input; multi-surface gauges/MFDs via pod hardware or explicit L4GAUGE)"
<< (fe_menu_mode ? "MENU (front end -- no profile applied)"
: gBTPlatformPod ? "POD (RIO cockpit input; multi-surface gauges/MFDs via pod hardware or explicit L4GAUGE)"
: gBTPlatformGlass ? "GLASS (PadRIO + on-screen panel + dev MFDs + plasma window)"
: "DEV (single window + keyboard)")
: "DEV (single window + keyboard)")
<< std::endl << std::flush;
#ifdef BT_GLASS
@@ -346,9 +368,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// sees a real connected console (btl4console.cpp).
//
{
int fe_has_egg = lpCmdLine && strstr(lpCmdLine, "-egg") != NULL;
int fe_has_net = lpCmdLine && strstr(lpCmdLine, "-net") != NULL;
if (!fe_has_egg && !fe_has_net && getenv("BT_FE_EGG") == NULL)
if (fe_menu_mode)
{
BTFeLaunchSpec fe_spec;
if (BTFrontEnd_Run(&fe_spec) != 0 || fe_spec.mode == BTFeLaunchNone)