Game: Mod API Windows sandbox blocks controller input #2010

Open
opened 2026-11-21 04:51:56 +00:00 by snaildev99 · 3 comments
Contributor

Reporter-confirmed broker fix: PR #2016

The reporter has now confirmed that controller input works with the game sandbox enabled using the native SDL controller broker implementation. Both the PS4 and Nintendo Switch Pro remain connected. The WGI-only approach below was insufficient and has been replaced.

Fix: #2016, targeting mod-api as a focused contribution to #1958. Gameplay was confirmed at local implementation 9ac1daf6; its six changed controller/broker source files are identical to PR head dd7027bf. Fifteen targeted checks pass. The PR remains WIP for complete suite/baseline validation, Linux builds and performance measurements; physical gyro, rumble and reconnect testing are also listed as pending.

Earlier WGI-only follow-up: unresolved

The user tested the patched game (8b6b7c9d) and reports that controller input still does not work. The new log confirms that the patched executable is running inside AppContainer and both controllers open through SDL. Enabling WGI restores discovery/opening only; it is not a verified fix for usable controller input. At that point, the sandbox-off diagnostic was the only configuration the user had confirmed working. The patch branch is a partial candidate and should not be treated as resolving this issue.

Problem

On the Windows Mod API preview in #1958, enabling the AppContainer sandbox prevents SDL from detecting either of two connected controllers. The same game, controllers and SDL DLL work with HOS_SANDBOX=0.

This is a report against the unmerged mod-api branch, not a claim that current main has this sandbox regression. Disabling the sandbox was a diagnostic, not the proposed fix.

Environment and reproduction

  • Windows 11 Pro 23H2, build 22631; NVIDIA RTX 3090.
  • SDL 3.4.20, shipped beside the game.
  • PS4 controller over USB and Nintendo Switch Pro controller over Bluetooth, both connected throughout.
  • Original game: v3.0.0-660-g66cf1bee, based on API commit 3e92b24957ad923e45dd3ba9f232987bb887bd52, plus a local Windows near macro compile fix in vk_texture.cpp.
  • Start the API game with the sandbox enabled (or HOS_SANDBOX=1 to force it), then try the controller. Keyboard input works; controller input does not.
  • Start the same build with HOS_SANDBOX=0: both controllers connect, and the user confirmed the controller works in the game. Neither controller was unplugged.

Evidence and cause

Sandbox on: the log confirms an AppContainer with no capabilities, SDL controller support initializes, but there are no controller-connected lines and prompts select controller "(none)": keyboard.

Sandbox off:

sandbox: off (HOS_SANDBOX=0): the game runs with everything its user can do
hid: controller "PS4 Controller" connected (SDL), with a gyroscope
hid: controller "Nintendo Switch Pro Controller" connected (SDL), with a gyroscope
prompts: auto: controller "PS4 Controller": ps4

A game-free native probe using that same SDL DLL and the existing Longshot.Game AppContainer isolated the backend difference:

Context / SDL hints Controllers enumerated and opened
Outside AppContainer, defaults 2
Inside AppContainer, defaults 0
Inside AppContainer, SDL_JOYSTICK_WGI=1 2
Inside AppContainer, WGI only 2
Inside AppContainer, SDL_JOYSTICK_GAMEINPUT=1 alone 0

SDL3's Windows.Gaming.Input backend is off by default (SDL documentation). Longshot's sandbox documentation identifies WGI as the route around direct HID access, but pads_start() does not enable it.

Partial candidate for #1958: detection only

Patch branch: fix/windows-sandbox-controllers, based on API head 443f7d3d, with two cherry-pickable commits:

  1. 8ac87857: regression test
  2. d7ca0247: enable WGI in Windows AppContainer

The change calls hos_sdl_hint("SDL_JOYSTICK_WGI", "1") before controller subsystem initialization, only on Windows when hos_sandbox_confined() is true. It uses normal SDL hint priority, so an explicit environment override still wins. It adds no capabilities and does not disable the sandbox or the other controller backends.

The same patch was built and run locally on the original API test base as 8b6b7c9d. The later API head was not rebuilt; the branch above carries just the test and fix onto that head for the API author to take. This avoids opening a second main-targeted PR containing the whole unmerged API.

In the patched game, a bounded headless run with HOS_SANDBOX=1 and no WGI environment setting logs:

sandbox: confined (an AppContainer with no capabilities: no network; ...)
hid: controller "PS4 Controller" connected (SDL)
hid: controller "HID-compliant game controller" connected (SDL)
prompts: auto: controller "PS4 Controller": ps4

The Switch Pro appears under the generic WGI name. Repeating with SDL_JOYSTICK_WGI=0 keeps confinement but restores zero controllers, confirming the override and the backend cause. Each check used fresh isolated saves, skipped pipeline precompilation, rendered frames, and terminated only its own test process.

Validation and remaining coverage

  • The regression fixture compiles the real pads_start() with stand-ins. It fails before the fix (wgi == confined) and passes after. It checks initialization order, confined/unconfined Windows, the non-Windows preprocessor path, and SDL initialization failure.
  • Full Windows game build passed; 7 targeted checks passed, 0 failed, 0 skipped: test_pad_appcontainer, test_headless_sigterm, test_sdl_pad_diagnostics, test_steam_pads, test_gyro_rearm, test_rumble_refresh, test_stick_rest.
  • The fixture also passes after transplanting the patch onto API head 443f7d3d.
  • Not yet verified by hand with WGI: gameplay buttons/sticks, reconnect, motion and rumble. The WGI log does not advertise the gyroscopes that the direct HID backend did; this fix establishes discovery/opening, not full feature parity.
  • Full suite, other Windows versions, Xbox controllers, Linux hardware and other SDL releases were not tested for this patch. No performance claim.

The two original game logs and the controller probes are retained locally; excerpts above omit machine-specific paths. No game files or saves are attached.

## Reporter-confirmed broker fix: PR #2016 The reporter has now confirmed that controller input works with the game sandbox enabled using the native SDL controller broker implementation. Both the PS4 and Nintendo Switch Pro remain connected. The WGI-only approach below was insufficient and has been replaced. Fix: https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2016, targeting `mod-api` as a focused contribution to #1958. Gameplay was confirmed at local implementation `9ac1daf6`; its six changed controller/broker source files are identical to PR head `dd7027bf`. Fifteen targeted checks pass. The PR remains WIP for complete suite/baseline validation, Linux builds and performance measurements; physical gyro, rumble and reconnect testing are also listed as pending. ## Earlier WGI-only follow-up: unresolved The user tested the patched game (`8b6b7c9d`) and reports that controller input still does not work. The new log confirms that the patched executable is running inside AppContainer and both controllers open through SDL. Enabling WGI restores discovery/opening only; it is not a verified fix for usable controller input. At that point, the sandbox-off diagnostic was the only configuration the user had confirmed working. The patch branch is a partial candidate and should not be treated as resolving this issue. ## Problem On the Windows Mod API preview in #1958, enabling the AppContainer sandbox prevents SDL from detecting either of two connected controllers. The same game, controllers and SDL DLL work with `HOS_SANDBOX=0`. This is a report against the unmerged `mod-api` branch, not a claim that current `main` has this sandbox regression. Disabling the sandbox was a diagnostic, not the proposed fix. ## Environment and reproduction - Windows 11 Pro 23H2, build 22631; NVIDIA RTX 3090. - SDL 3.4.20, shipped beside the game. - PS4 controller over USB and Nintendo Switch Pro controller over Bluetooth, both connected throughout. - Original game: `v3.0.0-660-g66cf1bee`, based on API commit `3e92b24957ad923e45dd3ba9f232987bb887bd52`, plus a local Windows `near` macro compile fix in `vk_texture.cpp`. - Start the API game with the sandbox enabled (or `HOS_SANDBOX=1` to force it), then try the controller. Keyboard input works; controller input does not. - Start the same build with `HOS_SANDBOX=0`: both controllers connect, and the user confirmed the controller works in the game. Neither controller was unplugged. ## Evidence and cause Sandbox on: the log confirms an AppContainer with no capabilities, SDL controller support initializes, but there are no controller-connected lines and prompts select `controller "(none)": keyboard`. Sandbox off: ```text sandbox: off (HOS_SANDBOX=0): the game runs with everything its user can do hid: controller "PS4 Controller" connected (SDL), with a gyroscope hid: controller "Nintendo Switch Pro Controller" connected (SDL), with a gyroscope prompts: auto: controller "PS4 Controller": ps4 ``` A game-free native probe using that same SDL DLL and the existing Longshot.Game AppContainer isolated the backend difference: | Context / SDL hints | Controllers enumerated and opened | | --- | --- | | Outside AppContainer, defaults | 2 | | Inside AppContainer, defaults | 0 | | Inside AppContainer, `SDL_JOYSTICK_WGI=1` | 2 | | Inside AppContainer, WGI only | 2 | | Inside AppContainer, `SDL_JOYSTICK_GAMEINPUT=1` alone | 0 | SDL3's Windows.Gaming.Input backend is off by default ([SDL documentation](https://wiki.libsdl.org/SDL3/SDL_HINT_JOYSTICK_WGI)). Longshot's sandbox documentation identifies WGI as the route around direct HID access, but `pads_start()` does not enable it. ## Partial candidate for #1958: detection only [Patch branch: fix/windows-sandbox-controllers](https://git.magicbean.dev/snaildev99/Longshot/src/branch/fix/windows-sandbox-controllers), based on API head `443f7d3d`, with two cherry-pickable commits: 1. [8ac87857: regression test](https://git.magicbean.dev/snaildev99/Longshot/commit/8ac87857) 2. [d7ca0247: enable WGI in Windows AppContainer](https://git.magicbean.dev/snaildev99/Longshot/commit/d7ca0247) The change calls `hos_sdl_hint("SDL_JOYSTICK_WGI", "1")` before controller subsystem initialization, only on Windows when `hos_sandbox_confined()` is true. It uses normal SDL hint priority, so an explicit environment override still wins. It adds no capabilities and does not disable the sandbox or the other controller backends. The same patch was built and run locally on the original API test base as `8b6b7c9d`. The later API head was not rebuilt; the branch above carries just the test and fix onto that head for the API author to take. This avoids opening a second main-targeted PR containing the whole unmerged API. In the patched game, a bounded headless run with `HOS_SANDBOX=1` and no WGI environment setting logs: ```text sandbox: confined (an AppContainer with no capabilities: no network; ...) hid: controller "PS4 Controller" connected (SDL) hid: controller "HID-compliant game controller" connected (SDL) prompts: auto: controller "PS4 Controller": ps4 ``` The Switch Pro appears under the generic WGI name. Repeating with `SDL_JOYSTICK_WGI=0` keeps confinement but restores zero controllers, confirming the override and the backend cause. Each check used fresh isolated saves, skipped pipeline precompilation, rendered frames, and terminated only its own test process. ## Validation and remaining coverage - The regression fixture compiles the real `pads_start()` with stand-ins. It fails before the fix (`wgi == confined`) and passes after. It checks initialization order, confined/unconfined Windows, the non-Windows preprocessor path, and SDL initialization failure. - Full Windows game build passed; 7 targeted checks passed, 0 failed, 0 skipped: `test_pad_appcontainer`, `test_headless_sigterm`, `test_sdl_pad_diagnostics`, `test_steam_pads`, `test_gyro_rearm`, `test_rumble_refresh`, `test_stick_rest`. - The fixture also passes after transplanting the patch onto API head `443f7d3d`. - Not yet verified by hand with WGI: gameplay buttons/sticks, reconnect, motion and rumble. The WGI log does not advertise the gyroscopes that the direct HID backend did; this fix establishes discovery/opening, not full feature parity. - Full suite, other Windows versions, Xbox controllers, Linux hardware and other SDL releases were not tested for this patch. No performance claim. The two original game logs and the controller probes are retained locally; excerpts above omit machine-specific paths. No game files or saves are attached.
Member

Possibly related, for context:

  • PR #1958 WIP: feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Issue concerns controller detection in the open Modding API preview PR
  • PR #1937 WIP: feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Earlier Modding API PR with the same sandbox feature
Possibly related, for context: - PR #1958 WIP: feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Issue concerns controller detection in the open Modding API preview PR - PR #1937 WIP: feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Earlier Modding API PR with the same sandbox feature
snaildev99 changed title from Game: Mod API Windows sandbox hides HID controllers; enabling SDL WGI restores detection to Game: Mod API Windows sandbox blocks controller input; WGI restores detection only 2026-11-21 05:04:26 +00:00
Author
Contributor

Hands-on follow-up: the user reports that the WGI patch still does not make the controller usable. The latest log confirms v3.0.0-662-g8b6b7c9d, AppContainer confinement, and both SDL controller connections. Discovery/opening passed; gameplay input did not. I have corrected the issue title and description to mark the patch as partial. The sandbox-off run remains the confirmed working comparison. This issue tracks a bug in PR #1958; no duplicate API PR was opened.

Hands-on follow-up: the user reports that the WGI patch still does not make the controller usable. The latest log confirms `v3.0.0-662-g8b6b7c9d`, AppContainer confinement, and both SDL controller connections. Discovery/opening passed; gameplay input did not. I have corrected the issue title and description to mark the patch as partial. The sandbox-off run remains the confirmed working comparison. This issue tracks a bug in PR #1958; no duplicate API PR was opened.
snaildev99 changed title from Game: Mod API Windows sandbox blocks controller input; WGI restores detection only to Game: Mod API Windows sandbox blocks controller input 2026-11-21 05:52:43 +00:00
Author
Contributor

Reporter confirms actual controller input works with the sandbox enabled. The broker fix is now proposed in #2016 against mod-api. This replaces the WGI-only candidate; the issue remains open pending review/merge.

Reporter confirms actual controller input works with the sandbox enabled. The broker fix is now proposed in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2016 against `mod-api`. This replaces the WGI-only candidate; the issue remains open pending review/merge.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot#2010
No description provided.