Skip to content

Make Sneak and Aux1 optionally togglable#15785

Merged
sfan5 merged 27 commits into
luanti-org:masterfrom
maplemedley:master
Mar 6, 2025
Merged

Make Sneak and Aux1 optionally togglable#15785
sfan5 merged 27 commits into
luanti-org:masterfrom
maplemedley:master

Conversation

@maplemedley

@maplemedley maplemedley commented Feb 14, 2025

Copy link
Copy Markdown
Contributor

What and why

This PR adds two accessibility settings to the control options for toggling sneak and aux1.

When these are enabled, their respective keys in-game will toggle when you press them. This lets you e.g. press sneak to toggle on sneaking until you're done building over a ledge or bridging, and then press it again to stop sneaking, instead of having to keep the button pressed for the entire duration.

This addresses the same issue as #15234, but uses a more generic and platform-independent implementation, as suggested in the comments, which will also work for mobile. The implementation is different enough that I thought it best to open a new PR.

Notably, this doesn't affect how the aux1 and sneak keys are read by the formspec, because it only changes the input handling of game.cpp, not keycodes.cpp. I imagine that would be outside the behaviour most people expect and want from this option, and it might also interfere with mobile formspec interaction.

Environment

I'm compiling on Windows 11, with Visual Studio Community 2022 (Microsoft now restricts access to the 2019 version).
If more specific information is desired let me know.

To do

This PR is Ready for Review.

  • Determine if toggling should be added to keycodes.cpp as well, which is used by the inventory. Currently it only affects player movement, e.g. shift-clicking a node in the inventory works as normal regardless of if shift is toggled for the players movement. Choosing to do this might interfere with item managing on mobile.

How to test

Launch the game, go to Options -> Controls -> General and enable Toggle aux1 key and Toggle sneak key.
Then start any world and press the sneak key, release it and it will persist. Pressing it again will stop the player from sneaking.

@maplemedley

This comment was marked as resolved.

@grorp grorp added the Concept approved Approved by a core dev: PRs welcomed! label Feb 28, 2025
@grorp
grorp self-requested a review February 28, 2025 03:14
Comment thread src/player.cpp Outdated
Comment thread src/script/common/c_converter.h
Comment thread src/gettext.cpp Outdated
Comment thread builtin/settingtypes.txt Outdated
Comment thread src/client/game.cpp Outdated
Comment thread src/client/game.cpp Outdated
Comment thread src/client/game.cpp Outdated
@grorp grorp added Action / change needed Code still needs changes (PR) / more information requested (Issues) Rebase needed The PR needs to be rebased by its author Possible close and removed Rebase needed The PR needs to be rebased by its author Possible close labels Mar 1, 2025

@y5nw y5nw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Code review only. I'm fine with both approaches so I'll leave it to grorp to decide whether this is better.)

Comment thread src/client/game.cpp Outdated
Comment thread src/client/game.cpp Outdated
@maplemedley
maplemedley requested a review from grorp March 2, 2025 00:59
Comment thread src/client/game.cpp Outdated
maplemedley and others added 14 commits March 2, 2025 21:18
This makes the Sneak and Aux1 keys toggle-actions, if toggling them is enabled in settings. Since this is done in the game logic, it doesn't affect things like sneak-clicking nodes in inventories, as that uses keycodes.cpp instead.
This function call restarts the console application, which can make Visual Studio lose sight of it and prevent debugging. Using Visual Studio Community 2022.
This is handled by another pr.

@grorp grorp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(rebased)

Comment thread src/client/game.cpp Outdated
Comment thread src/client/game.cpp Outdated
Comment thread src/client/game.cpp Outdated
@y5nw y5nw linked an issue Mar 3, 2025 that may be closed by this pull request
@maplemedley

Copy link
Copy Markdown
Contributor Author

Btw how is squashing handled, does GitHub sort that out or should I it be done manually

@y5nw

y5nw commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

Btw how is squashing handled, does GitHub sort that out or should I it be done manually

Github handles that (there is a "Squash and merge" button for us).

@y5nw
y5nw self-requested a review March 3, 2025 23:13
@Zughy Zughy removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Mar 4, 2025
@y5nw

y5nw commented Mar 4, 2025

Copy link
Copy Markdown
Contributor

Do we want to also show feedback to users (e.g. "Aux1 held down"/"Aux1 released")? IMO you should generally be able to tell that from interaction (e.g. moving down while flying) so I'm not sure whether it is needed.

@maplemedley

Copy link
Copy Markdown
Contributor Author

Yeah I agree, I think that'd be overkill and contribute to clutter. The user knows if they enabled toggling, and will see whether sneak/aux1 is toggled the moment they move in most cases

@y5nw y5nw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested and works.

@sfan5
sfan5 merged commit 63701de into luanti-org:master Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@ Client / Controls / Input Concept approved Approved by a core dev: PRs welcomed! Feature ✨ PRs that add or enhance a feature >= Two approvals ✅ ✅

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sneaking toggleable

5 participants