fix(input): Invert mouse horizontal swaps the mouse's left and right, in native look and as the stick #1028
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1028
Loading…
Reference in a new issue
No description provided.
Delete branch "Victor/Longshot:fix/native-mouse-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?
Type: fix · Risk: low · Tested on: Linux, RTX 3050 Ti Laptop 4 GB · Needs: none
Why
With Mouse camera on Native, a player who looks inverted could not turn the mouse's left and right around. The game's own camera inversion and the menu's Invert camera X and Y act on the right stick, and in that mode the mouse is not the stick: it turns the camera's angles itself. Only up and down could be swapped, with Invert mouse vertical. Fixes #931.
How to reproduce
Seen on: reported on Windows 11, RTX 4080 (#931). Here on Linux (Arch), RTX 3050 Ti Laptop 4 GB, NVIDIA 615.78.08: read from main's source and shown by the checks below failing on main; the game itself was run on this change only, not on main.
Settings and switches: Insert → Controls → Mouse camera: Native; defaults otherwise
Steps: load a save, click in the window so the mouse is captured, turn Invert camera X on (or the game's own camera inversion), move the mouse to the right
Expected: some setting makes the camera turn the other way
Actual: the camera turns the same way whatever they say:
host/mouse_native.creads Invert mouse vertical (option 8) and nothing elseWhat changed
A Controls row, Invert mouse horizontal, off by default, swaps the mouse's left and right wherever Invert mouse vertical already swaps its up and down: in native look, and where the mouse is the right stick. Nothing changes for a player who leaves it off.
hos_mouse_camerainhost/mouse_native.cturns the yaw the other way wheninvert_x()says so (option 61, orHOS_MOUSE_INVERT_X=1).mouse_stickinhost/nn_hid.cdoes the same to the stick's x, which is the path of Mouse camera As the stick, and of Native while the game takes the stick for itself (a lock-on, the bow's aim, a menu).gpu/vk/vk_menu.cpp(opts.mouse_invert_x,vk_menu.h), answered to the host asHOS_OPT_MOUSE_INVERT_X(61) by the option callback invk_replay.cpp: no new member invk_api.h, so noMKWVK_API_VERSIONbump. It is saved asinvert_mouse_horizontalinlongshot_options.ini, as every row is.gpu/vk/menu_i18n.h.HOS_MOUSE_INVERT_Xin docs/development.md's Running a test, withHOS_MOUSE_INVERT_Y, which had no line.tests/test_mouse_native.py(native look),tests/test_mouse_stick.py(new:mouse_stickcut out of the source and run),tests/test_mouse_settings.py(the row and its option reach both paths).Choices a reviewer may want changed:
fixorfeat. It fixes #931 by adding a row; the title's type is yours to change.Overlap: #352 (WIP) reshapes
host/mouse_native.cand sends every pitch throughinvert_y(). Its new cameras would needinvert_x()for the yaw the same way; whichever lands second rebases.Measurements
Verdict: it passes. The three checks fail on main and pass here, and in the game the row swaps the mouse's left and right with either Mouse camera. No speed to measure: two integer compares a controller read.
Hardware: Arch Linux (kernel 7.2.11), NVIDIA GeForce RTX 3050 Ti Laptop GPU 4 GB, driver 615.78.08, Intel Core i7-11800H, 31 GB RAM
Scene: Kokiri Forest (child), in a 1920x1080 window, the settings the PC's installed build had; not a speed measurement
Method: the game-free checks' output at each commit; in the game, which way the camera turns for a move of the mouse to the right, by eye, with the row off and on in each Mouse camera mode
How to reproduce:
python -I -B tests/test_mouse_native.py,python -I -B tests/test_mouse_stick.py,python -I -B tests/test_mouse_settings.py; in the game, Insert → Controls, Mouse camera Native or As the stick, Invert mouse horizontal Off or On, and move the mouse to the right5f3bb44b8ade42fatests/test_mouse_native.pyFAIL line 86: near(getf(YAW), 1.0f) && near(getf(PITCH), 0.4f) (pitch 0.4 yaw -1)tests/test_mouse_stick.pyFAIL line 144: rx < 0 && ry == 0 (stick 32767 0)tests/test_mouse_settings.pythe menu lost a mouse row: "Invert mouse horizontal"The Before column's checks are this PR's, run at its first commit (
355207e5: main's sources with the new checks).The game rows are from two runs of this change built over main @
dbad7d12, the commit the local base was built from: 15 minutes with the option still numbered 59 (both Mouse camera modes, the row off and on), and 2 minutes with it renumbered to 61 as on this head (Native, the row on: right turns left). That build'shost/mouse_native.candhost/nn_hid.care this head's, byte for byte. This head was not run in the game: main's shader translator changed since that base, and a game folder of it prepares every shader program again.Both pictures are the real menu drawn by
scripts/screenshots/capture_menu.py(no game, English, 1280x720), with the row above the new one selected on main and the new row selected here. That script's fixture does not link on main any more (five stand-ins are missing:xess_built,xess_why,options_path,gpu_device_cards,present_native_pq); I added them in a local copy to take these, and they are not part of this PR.Flags and settings
A menu row, with its line in the options file, and a switch are added.
invert_mouse_horizontalinlongshot_options.ini; option 61)HOS_MOUSE_INVERT_X=1longshot_env.txt, asHOS_MOUSE_INVERT_Yis. Covered by the two checks; not run in the gameTesting
Tested:
tests/test_mouse_stick.pywith gcc and with clang. Each key line of the fix put back in turn (the yaw inmouse_native.c, the panning and the pointing innn_hid.c) makes its check fail, and so does a wrong fix that reads option 8 for the horizontal.python -I -B tests/run_all.pyon Linux. The whole suite, with this change on main @cefce0d1: 625 pass, 17 are skipped (Windows only, or they need the game or a Vulkan 1.3 device) and 16 fail, the same 16 that fail there without the change. After the rebases, the 190 checks that read a file this PR changes (--changed), at this head: 182 pass, 1 is skipped and 7 fail, the same 7 that fail on main @5f3bb44bon this PC:test_bug_report_defaults,test_crt_options,test_fsr_uniform_ownership,test_parallel_init_order,test_replay_write_order,test_vk_occlusion_queries,test_walk_key. Onlytest_walk_keyreads a file of this PR (host/nn_hid.c); it stops on main at its own fixture (scripted_input's arguments). The rest of the 16:test_guest_imported,test_import_reach,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_nonuniform_image_arrays,test_pending_guest_import,test_run_all_changed.scripts/dev_packs.py packover a base of main @dbad7d12, both modules compiled and linked.RX_TARGET=windows RX_VK_ONLY=1 python -I nx2/build.py --standalone):longshot_vk.dllcompiles and links at this head.host/mouse_native.candhost/nn_hid.ccompile for Windows with-fsyntax-only -Wall -Wextra: no error, and the warnings main @5f3bb44bhas (1 and 63). The game's own module was not linked for Windows: that takes the whole game.VK_ERROR_DEVICE_LOST(NVRM Xid 62 in the kernel log); a session on the installed nightly-189, without this change, had ended in a GPU hang the day before. Not looked into here; the second run closed normally.Not tested:
dbad7d12), and what the checks cover instead: the row together with Invert mouse vertical, the ability wheel's pointing, a lock-on or the bow's aim with Native, andHOS_MOUSE_INVERT_X.Must be tested: None
Risks
What could break: the mouse's horizontal direction, with either Mouse camera, for a player who turns the row on or sets
HOS_MOUSE_INVERT_X. With the row off both paths compute what they did.Turning it off: the row's Off, its default. Reverting the commit is enough otherwise.
Compatibility:
longshot_options.inigains one line,invert_mouse_horizontal=0; a file from before has none and the row reads Off. Saves, the shader and pipeline caches and the vk ABI are untouched (a new option number answered by the existing callback;MKWVK_API_VERSIONstays as it is).Issues
Fixes #931
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened.Tested in game: RTX 3050 Ti Laptop 4 GB, NVIDIA 615.78.08, Arch Linux: Kokiri Forest (child). Mouse camera Native, Invert mouse horizontal On: a move of the mouse to the right turns the camera left. Mouse camera As the stick: Off turns left, On turns right. Run on this change built over main @
dbad7d12, the last time with the option numbered 61 as on this head; this head itself was not run in the game (it builds on Linux, and its renderer for Windows).The two pictures of the Controls tab are in the description now: before on main @
5f3bb44b, after on this PR @8ade42fa. Nothing else changed.WIP: fix(input): Invert mouse horizontal swaps the mouse's left and right, in native look and as the stickto fix(input): Invert mouse horizontal swaps the mouse's left and right, in native look and as the stickzeldaootr referenced this pull request2026-11-16 05:05:57 +00:00