WIP: fix(hid): HOS_INPUT_SCRIPT_BACKGROUND no longer lets the player's keyboard into a test run #319
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!319
Loading…
Reference in a new issue
No description provided.
Delete branch "d4nkn3ss/Longshot:fix/input-script-background"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
A test run started with
HOS_INPUT_SCRIPT_BACKGROUND=1takes the keyboard of whoever is using the PC, even when its window is behind another one. Typing in another window, even in a chat, moves Link, makes him jump, and Enter pauses the game, which spoils the run.What changed
read_input()inhost/nn_hid.ckeeps the focus gate withHOS_INPUT_SCRIPT_BACKGROUNDset. Scripted presses (HOS_INPUT_SCRIPT,HOS_INPUT_LIVE) and the control bridge's are added byscripted_input()andhos_control_input()before the gate, so they already count with the window behind; the existingscript-backgroundcase shows it. Skipping the gate let through only the player's devices: the keyboard (GetAsyncKeyStatesees every key, whatever window is in front, so headless runs too) and the mouse. The switch is now only said in the log, as no longer needed.tests/test_input_background.pygets a case,script-background-switch: the window behind,HOS_INPUT_SCRIPT_BACKGROUND=1, a bound key held. It fails on main (FAIL:125 G64(address + 8) == buttons: the key's X reaches the game) and passes here.docs/development.md; two rows indocs/tested-configurations.md.Flags and settings
HOS_INPUT_SCRIPT_BACKGROUND(changed)GetAsyncKeyState)Measurements
main:
dc390e59(2026-11-14); the A/B ran on 514591a3's code; the old build ran isfbd42024, whosehost/nn_hid.cis the same as514591a3this PR: fix/input-script-background @
d6b5679f, rebased onto maindc390e59. Since the A/B, main changedhost/nn_hid.c(the Walk key, #66); this PR's lines are unchanged andtests/test_input_background.py(all cases) andtests/test_keys_player_input.pypass ond6b5679f. The game ran in the A/B is 3fb77017.Hardware: RTX 3080 10 GB, NVIDIA 621.14, i9-12900K, 64 GB, Windows 11 Pro 26300
Scene: the test save, in play, a window that never takes focus (
scripts/run-vk.ps1 -Window), default settingsMethod: one run each. The script presses A into the save, then stops; the user presses Enter twice in other windows, holds W, and types in a chat window. Counted: the
control: state play -> menulines inlongshot_log.txt, and what the user saw.How to reproduce:
scripts/run-vk.ps1 -Window -Env "HOS_INPUT_SCRIPT_BACKGROUND=1;HOS_INPUT_LIVE=<file>;HOS_SKIP_OPENING=1", append0:Alines to the file until in play, then click into another window and press Enter.fbd42024(nn_hid.cas514591a3)Testing
Tested:
python -I -B tests/run_all.pyon Windows: 497 passed, 3 failed, 33 skipped. The 3 failed on main514591a3too:test_check_third_party.py(#80),test_menu_i18n.py(fixed on main by #273, passes after the rebase),test_release.py(#119). After the rebases ontoe4b5b4d4andba700f58,test_input_background.pypasses again. Of the 17 tests that readhost/nn_hid.c, 16 pass on 96f3047d (the same nn_hid.c ase5b4789e);test_pad_layout.pyfails on mainba700f58too since #137 (fixed by #331). Every test that readshost/nn_hid.c(17, all pass). In the game, on the PC above: the A/B above, with the user at the keyboard. On this PR the script's presses still drove the game into play with the window behind.Not tested:
read_input()gate, so it should behave the same. I didn't run it.HOS_INPUT_BACKGROUNDand the menu's "Controller in background" row, as without the switch (thepads-envandpads-menucases).Needs other testers: None.
Screenshots
Nothing on screen
Risk and rollback
A script that counted on the switch to let a person's keyboard or mouse into a game behind another window loses that. None in this repository sets it. Reverting the commit is enough.
Reviewer notes
The window counts as in front while a tool window or overlay is in front (the taskbar, a notification) if the game was the last normal window in front:
game_in_front(). So a test window someone clicked into still takes their keys after they click the taskbar; that is the player's case and unchanged here.Issues
See #389 on Hookshot (the issue that added the switch).
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).If applicable
Assisted-by:/Co-Authored-By:trailers.docs/tested-configurations.mdfor each measured run.mainand passing here.🤖 Generated with Claude Code
2a8f33153238f9d90fb638f9d90fb696f3047d7296f3047d720268a234ca0268a234ca5dee9c7b545dee9c7b54e5b4789ef4e5b4789ef4d6b5679f4aView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.