Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Sneak and Aux1 optionally togglable #15785

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

maplemedley
Copy link

@maplemedley maplemedley commented Feb 14, 2025

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 impementation 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.

Other changes

I also fixed some errors appearing on my end by adding include <string> to some files.
Another change is that now, the locale workaround which reboots the program isn't used in debug builds, only release builds, as it prevented debugging.

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.

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.
@maplemedley
Copy link
Author

maplemedley commented Feb 14, 2025

There seems to be some merge complaints from GitHub when using the "new merge experience" preview:

Merge is not an allowed merge method in this repository.
This branch must not contain merge commits.

But this is not recognized as an issue with the "classic merge experience", so it might just be a bug of the preview. If its a problem I can make a clean PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Controls / Input Feature ✨ PRs that add or enhance a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants