feat(input): Invert aiming X and Y, the right stick while you aim with ZR, apart from Invert camera #3188
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
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/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3188
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:feat/aim-invert"
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?
Summary
Invert camera X and Y flip the controller's right stick everywhere, aiming included, so there was no way to aim the slingshot, bow, hookshot or longshot inverted while keeping the camera as it is, or the other way round (#1084). This adds two Controls rows under Invert camera X/Y:
"Aiming" is ZR held with an aiming item on it: the slingshot or bow (any arrows), the hookshot or longshot, as the game's trigger state (
game_trigger_state) says what is on ZR. ZR counts as the game is given it: held on a pad, or kept by the Controls page's Toggle column, whose second press ends the aim at once though the button stays held. The rows change the pads' right stick only: the mouse and the keyboard have their own rows (Invert mouse X/Y), and the gyro has Invert motion X/Y. The boomerang and looking around in first person have no such signal and follow Invert camera; their rows' help says so.The pad threads (
host/pad_sdl.c, the XInput thread inhost/nn_hid.c) apply Invert camera as before.read_input(host/nn_hid.c) takes the pads' stick in throughpads_stick_in, in front and with Controller in background, and keeps their right stick inpad_aim. Thennpad_statescallsaim_invertright after the toggles (hold_toggle_apply), on the buttons the game is given. Where the aiming row differs from the camera row, it flips an axis only while the game is given just the pads' value: a scripted, control-bridge, mouse or key tilt is never turned.Read first:
host/nn_hid.cpads_stick_in,aim_invertand its call innpad_states;game/mods/controls/mod.tomlinvert_aim_x/invert_aim_y.Fixes #1084
Testing
Tested: Windows 10, RTX 4090, driver 617.42; an Xbox-style controller; a copy of my own save, with the bow and the hookshot. Runtime
v3.2.0-335-ga9db7e2ae(the heada9db7e2ae, after BeanBot's review), Controls page, Controller section:Checks:
tests/test_aim_invert.py(new): production'spads_read,read_input's pad block,pads_stick_in,hold_toggle_applyandaim_invertwith fakes, the item on ZR from a fakegame_trigger_state; it compiles with the runner's compiler ({cc}, elseCC, else gcc). It fails onmain(FAIL:418 right stick 1000,2000 (camera 0,0, aiming 0,2, ZR item 1, ZR held): got 1000,2000, want 1000,-2000) and passes here with gcc and clang. Its cases: not aiming (ZR up, the hammer or nothing on ZR, no Link in play), each row against each camera setting for the bow and the hookshot, the Toggle column (kept, let go, pressed again and held: the aim ends; kept again while held), a scripted tilt with and without the pads', a camera key's tilt past the pads', and the left stick never changed. It also checks that production callsaim_invertonce, innpad_states, afterhold_toggle_applyand before the free camera, and takes the pads' stick in throughpads_stick_inon both paths. Each fails when undone: the flip judged before the toggles, as before the review (FAIL:481 ... got 1000,-2000, want 1000,2000, pressed again and held); the flip regardless ofpad_aim(the scripted rows); the background path merged in place; the call moved before the toggles.read_input's pad block compilepads_stick_in(andtest_input_background.pyanaim_invertstub fornpad_states):tests/test_pads_after_menu.py,tests/test_input_background.py,tests/test_walk_key.py. All pass, as dotests/test_stick_inversion_rest.py,tests/test_menu_ini_keys.pyandtests/test_settings_area_keys.py(FROZEN: the two new keys),tests/test_i18n_complete.py(the rows' texts in all 13 languages), and the menu mod's tests (cargo test -p modtool: the rows' place, the docs table).schema-gen --checkandffi-gen --checkare current (the settings snapshot's two new fields);scripts/check_host_compile.py: 83 host units, 0 failed.--stricton the heada9db7e2aeagainstmain3a0f7d8f7: 846 passed, 53 failed, 13 skipped against 845, 53, 13 (the new check), the same 53 files failing on both (they fail onmainin this WSL);scripts/check_host_compile.pypasses for Linux and Windows (llvm-mingw) ona9db7e2ae;schema-gen --checkandffi-gen --checkcurrent there. The rebase onto3a0f7d8f7had no conflict.87b0d76d8: L1 (the flip judged before the Toggle, so a press ending a kept aim stayed inverted while held), L2 (the background path flipped the merged stick, a scripted tilt included) and L3 (the check hard-coded gcc) are fixed ina9db7e2ae, as above.Still to test:
Measurements
Nothing on the frame path: one read of the input a frame, which asks the game's trigger state only while a row is not Same as camera and ZR is held.
Risks
None with the rows at Same as camera, the default: the stick is as before. With a row set, the right stick's axis while ZR aims goes as the row says. A revert is enough; the two new keys in the options file are then ignored.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZhRaNmRu5soDyrEw1o
Tested in game: Windows 10, RTX 4090, driver 617.42, Xbox-style controller, a copy of my save (bow, hookshot); runtime of 269b1da04 (this head's code). Invert camera Y Off + Invert aiming Y On: aiming inverted, camera not; camera On + aiming Off: aiming not inverted, camera is; Same as camera: as before; X likewise; ZR on the Toggle column, tapped: aiming inverted as its row says.
WIP: feat(input): Invert aiming X and Y, the right stick while you aim with ZR, apart from Invert camerato feat(input): Invert aiming X and Y, the right stick while you aim with ZR, apart from Invert camera@review
Recommendation: Request changes. The aiming direction can remain inverted after a toggled aim is released, and background controller input can invert scripted stick input. The new test also hard-codes GCC, so it can be skipped on supported compiler setups.
Adds independent right-stick aiming inversion settings while preserving the previous camera setting by default. The input ordering needs correction for toggle transitions and background input, and the test needs to use the selected compiler.
Blocking (2): must change before merging.
host/nn_hid.c:1159: The inversion uses the raw ZR press and the previous latch instead of the toggle result delivered to the game. (more on the line) Do: Determine the effective ZR state after applying the toggle, then apply inversion to the saved pad axes using that state. Test both latching and unlatching while the button stays held.@​fixor@​rebasetry first). (for the author)Should fix (2): not blocking, but worth doing before merging.
host/nn_hid.c:1234: The background path inverts the already merged stick, including input that did not come from a controller. (more on the line) Do: Read and invert the pad into a separate zeroed stick array, then merge it into the existing stick as the foreground path does.tests/test_aim_invert.py:21: The new check hard-codes GCC instead of using the compiler selected by the test runner. (more on the line) Do: Use the runner's {cc} placeholder and honor CC for direct invocation.@fixcan do L1, L2 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested controller cases: the author reports both inversion combinations, both axes, the default, and a latched ZR working in game on Windows. This is not a performance change.
Other systems: The default leaves pad axes unchanged. The new path also affects background controller input and can interact with scripted input and toggle state. Mouse, keyboard axes and gyro are merged or handled separately. The reported game run was on Windows; the input logic is shared across platforms.
Switches: No environment switches added, changed or removed. Invert aiming X and Y are player settings, both defaulting to Same as camera; that preserves existing behavior.
Reviewed:
30c89fea54against9f76a4379c: Read the repository rules and PR template, commit messages, changed input implementation, settings definitions, new test and surrounding toggle and trigger code. Skimmed translation and generated settings changes and the other changed test diffs. The full changed files and every caller were not read in full; docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. The author reports an in-game Windows run and game-free checks; the supplied CI checks are still running.
Overlaps and merge order: Not checked; network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1151,0 +1156,4 @@static void aim_invert(uint64_t buttons, int32_t stick[4]) {const int aim_x = HOS_SETTING(invert_aim_x, 0), aim_y = HOS_SETTING(invert_aim_y, 0);int zr_item = RENHDRUM_ITEM_NONE;if (!(aim_x || aim_y) || !((buttons | toggles.latched) >> B_ZR & 1) || !game_trigger_state(&zr_item, NULL, NULL) ||L1 (blocking): The inversion uses the raw ZR press and the previous latch instead of the toggle result delivered to the game.
When: With ZR Toggle enabled and a bow latched on, press ZR again and keep it held. hold_toggle_apply clears the latch and releases ZR to the game, but this condition remains true for the whole physical press, so the camera uses the aiming inversion after aiming has ended.
Do: Determine the effective ZR state after applying the toggle, then apply inversion to the saved pad axes using that state. Test both latching and unlatching while the button stays held.
@ -1217,1 +1232,3 @@if (pads_in_background(env, PADS_IN_BACKGROUND_SETTING)) pads_read(buttons, stick, NULL), sprint_now = pad_sprint_down();if (pads_in_background(env, PADS_IN_BACKGROUND_SETTING)) {pads_read(buttons, stick, NULL);aim_invert(*buttons, stick); /* (the pads alone here: the stick is theirs) */L2 (should fix): The background path inverts the already merged stick, including input that did not come from a controller.
When: With Controller in background enabled, a scripted or control-bridge right-stick input can already be in stick before pads_read. If ZR is held with a bow and the aiming setting differs from the camera setting, aim_invert reverses that scripted axis even when the pad contributes no stick movement.
Do: Read and invert the pad into a separate zeroed stick array, then merge it into the existing stick as the foreground path does.
@ -0,0 +18,4 @@import test_pads_after_menu as pads # noqa: E402from area_settings import HOS_SETTING_C # noqa: E402RUN_ALL_ARGS = ["--cc", "gcc"]L3 (should fix): The new check hard-codes GCC instead of using the compiler selected by the test runner.
When: On a supported machine with Clang and CC set but no gcc executable, run_all skips this test, or fails it in strict mode, although a suitable C compiler is available.
Do: Use the runner's {cc} placeholder and honor CC for direct invocation.
30c89fea5487b0d76d8cRebased onto main
5dffd615b: head87b0d76d8(testb322d3139). The only conflict was the generated settings ABI (game/settings_abi.h, host-sys settings_abi.rs: layout hash and count after main's new settings), regenerated with schema-gen; schema-gen and ffi-gen --check pass. git range-diff: host/nn_hid.c, the controls mod and the strings unchanged, so the in-game runs stand. Linux: test_aim_invert fails on the test commit (FAIL:418) and passes on the head; compile check passes (Linux, Windows); strict suite 841/53/13 against main's 840/53/13, the same 53 files.@review
Recommendation: Request changes. The aiming inversion still disagrees with the ZR toggle result on toggle transitions, and the background path can invert input from other sources. The new test also still selects GCC instead of the runner’s compiler.
The change adds independent right-stick aiming inversion while preserving the existing camera setting by default. It gives players more control, but the input ordering and background merge need correction.
Blocking (1): must change before merging.
host/nn_hid.c:1159: The inversion uses the raw ZR press and the previous latch instead of the toggle result delivered to the game. When: With ZR Toggle enabled and a bow latched on, press ZR again and keep it held. hold_toggle_apply clears the latch and releases ZR to the game, but this condition remains true for the whole physical press, so the camera uses the aiming inversion after aiming has ended. Do: Determine the effective ZR state after applying the toggle, then apply inversion to the saved pad axes using that state. Test both latching and unlatching while the button stays held.Should fix (2): not blocking, but worth doing before merging.
host/nn_hid.c:1234: The background path inverts the already merged stick, including input that did not come from a controller. When: With Controller in background enabled, a scripted or control-bridge right-stick input can already be in stick before pads_read. If ZR is held with a bow and the aiming setting differs from the camera setting, aim_invert reverses that scripted axis even when the pad contributes no stick movement. Do: Read and invert the pad into a separate zeroed stick array, then merge it into the existing stick as the foreground path does.tests/test_aim_invert.py:21: The new check hard-codes GCC instead of using the compiler selected by the test runner. When: On a supported machine with Clang and CC set but no gcc executable, run_all skips this test, or fails it in strict mode, although a suitable C compiler is available. Do: Use the runner's {cc} placeholder and honor CC for direct invocation.@fixcan do L1, L2 and L3.Since the last review (on
30c89fea54)Resolved: L4 (It conflicts with its base branch: bring it up to date (
@​fixor@​rebasetry first).)Still open: L1 (The inversion uses the raw ZR press and the previous latch instead of the toggle result de…); L2 (The background path inverts the already merged stick, including input that did not come fr…); L3 (The new check hard-codes GCC instead of using the compiler selected by the test runner.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven as a complete fix: the author reports successful Windows in-game checks for both axes and a latched ZR, but the toggle transition cases remain incorrect.
Other systems: The foreground and background controller paths, keyboard, mouse, scripted and control-bridge input share the input pipeline. The author reports Linux and Windows compile checks and Windows game testing; the background path still operates on a merged stick.
Switches: Invert aiming X and Y each default to Same as camera, preserving existing behavior; Off and On override the corresponding camera inversion while aiming. The defaults are appropriate.
Reviewed:
87b0d76d8cagainst5dffd615b9: Read the repository rules, the relevant input and toggle code, the aiming test and the settings ABI diff. Skimmed the remaining changed tests, controls declarations and documentation; translations and generated ABI files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No tests were run during this read-only review. The author reports Windows in-game testing and Linux and Windows compile checks; CI is still running.
Overlaps and merge order: None identified.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
87b0d76d8ca9db7e2ae4BeanBot's L1, L2 and L3 are fixed in
a9db7e2ae, after a rebase onto main3a0f7d8f7(no conflicts).aim_invertnow runs innpad_statesright afterhold_toggle_apply, on the buttons the game is given. The press that ends a kept aim ends the flip at once, though ZR stays held; a press that keeps it again while held flips again.pads_stick_inon both paths (in front, and Controller in background into a zeroed array, thenstick_max). It keeps the pads' right stick inpad_aim, andaim_invertflips an axis only while the game is given just that value. A scripted, bridge, mouse or key tilt is never turned.RUN_ALL_ARGS = ["--cc", "{cc}"], and--ccdefaults toCC, else gcc.tests/test_aim_invert.pyruns the realhold_toggle_apply. New cases: latch, let go, press again and hold (no flip for the whole press), latch again while held; a scripted tilt with and without the pads'; a camera key past the pads'. It also checks where production calls both functions. Each undo fails: the old order (FAIL:481, pressed again and held), flipping regardless ofpad_aim, the background merged in place, the call before the toggles.In game on
a9db7e2ae(v3.2.0-335-ga9db7e2ae, Windows 10, RTX 4090, Xbox-style controller, my own save, bow): the four Toggle steps, including press again and hold, all as above. Linux: host compile (Linux and Windows) and schema/ffi-gen current; strict suite 846/53/13 against main's 845/53/13, the same 53 files failing on both.@rebase
I rebased this pull request onto
main(3145d9d48f): the new head is2f10b8fb74.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
a9db7e2ae42f10b8fb74Recommendation: Approve. The three ledger items are resolved, and the reported in-game run shows the aiming settings and toggle behavior working. An equal-value input collision remains a minor edge case. Recommend approval; not approved on the forge.
Players can set right-stick aiming inversion independently of camera inversion while preserving existing behavior by default. The change adds two settings and input-source tracking.
Should fix (1): not blocking, but worth doing before merging.
host/nn_hid.c:1217: Equality with the pad value does not establish that the merged axis came from the pad. (more on the line) Do: Track which source won each axis during merging and flip only axes won by the pad.@fixcan do L5.Since the last review (on
87b0d76d8c)Resolved: L1 (The inversion uses the raw ZR press and the previous latch instead of the toggle result de…); L2 (The background path inverts the already merged stick, including input that did not come fr…); L3 (The new check hard-codes GCC instead of using the compiler selected by the test runner.)
New: L5 (Equality with the pad value does not establish that the merged axis came from the pad.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports successful Windows in-game checks for both axes, camera settings, and the ZR toggle; this is not a performance change.
Other systems: The input path covers SDL and XInput controllers, foreground and background input, toggle handling, and scripted input. The author reports Linux and Windows host compile checks; the in-game run was on Windows.
Switches: Invert aiming X and Y are new saved choices, each defaulting to Same as camera. That default preserves existing behavior; the controls documentation and settings keys were updated.
Reviewed:
2f10b8fb74against3145d9d48f: Read the repository rules, the changed host input path and relevant test changes; reviewed the controls and settings ABI diffs. Skimmed generated settings and translation changes. The complete changed files and all referenced project rules were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports in-game Windows testing, game-free checks, and Linux and Windows host compile checks; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.
@ -1192,0 +1214,4 @@const int flip[2] = {aim_x && (aim_x == 2) != (HOS_SETTING(invert_camera_x, 0) != 0),aim_y && (aim_y == 2) != (HOS_SETTING(invert_camera_y, 0) != 0)};for (int i = 0; i < 2; i++)if (flip[i] && pad_aim[i] && stick[2 + i] == pad_aim[i]) stick[2 + i] = -stick[2 + i];L5 (should fix): Equality with the pad value does not establish that the merged axis came from the pad.
When: If a script or control bridge supplies an axis value of 1000 and the pad supplies the same value, stick_max keeps the existing scripted value, but aim_invert sees it equal pad_aim and reverses it while aiming.
Do: Track which source won each axis during merging and flip only axes won by the pad.
@rebase
I rebased this pull request onto
main(df19b74049): the new head isf6a8fe3976.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
2f10b8fb74f6a8fe3976Recommendation: Approve. The aiming options work in the reported controller tests and preserve the existing behavior by default. L5 remains a minor input-source ambiguity in mixed scripted and controller input. Recommend approval; not approved on the forge.
Adds separate horizontal and vertical controller aiming inversion settings. The default follows camera inversion; the added input handling has a minor ambiguity when two sources provide the same axis value.
Should fix (1): not blocking, but worth doing before merging.
host/nn_hid.c:1217: Equality with the pad value does not establish that the merged axis came from the pad. When: If a script or control bridge supplies an axis value of 1000 and the pad supplies the same value, stick_max keeps the existing scripted value, but aim_invert sees it equal pad_aim and reverses it while aiming. Do: Track which source won each axis during merging and flip only axes won by the pad.@fixcan do L5.Since the last review (on
2f10b8fb74)Still open: L5 (Equality with the pad value does not establish that the merged axis came from the pad.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports in-game tests of both axes, both inversion directions, and ZR toggle behavior on Windows with an Xbox-style controller. This is not a performance change.
Other systems: The input path also serves SDL and XInput controllers, background controller input, scripts, the control bridge, mouse and keyboard. The reported game run covers Windows and one controller; the game-free checks cover several mixed-input and toggle cases.
Switches: Invert aiming X and Invert aiming Y each default to Same as camera, preserving existing behavior. Off and On select independent aiming inversion. The controls documentation includes both rows.
Reviewed:
f6a8fe3976againstdf19b74049: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the input-path changes and surrounding merge and toggle code, the controls settings and ABI diffs, and the new aiming test. Skimmed the remaining changes and translations; did not read every changed code file in full.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code or tests were executed. The author reports game-free checks and an in-game Windows run; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.
Linux checks for this PR after main's Ocarina controls row (#3253), on a local rebase whose PR changes are the same as BeanBot's head
f6a8fe397(git range-diff: the test and fix commits are identical; the feat commit differs only in context, and the PR's own diff differs only in the generatedLAYOUThash andSETTINGScount, because main differs).WSL (Ubuntu 22.04), head e9ad06951 (on main
3131b1ddc) against main3131b1ddc:scripts/check_host_compile.py: Linux 83 host units, 0 failed; Windows (llvm-mingw) 81 units, 0 failed.ffi-gen --checkfails the same way on main (rx_menu_openinhost/game_host.hhas no doc comment); this PR doesn't touch that file.test_aim_invert,test_menu_ini_keys,test_pads_after_menu,test_input_background,test_walk_keypass on head; all buttest_aim_invertpass on main too.tests/run_all.py --strict: head 855 passed, 50 failed, 13 skipped; main 854 / 50 / 13. The same 50 files fail on both sides.Not covered: main's #352 (native mouse look for the aim cameras,
df19b7404) landed after3131b1ddc. This PR inverts only the pads' own tilt, but the in-game test predates #352, so mouse aim with Invert aiming on is untested on this head.