Make Sneak and Aux1 optionally togglable#15785
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
y5nw
left a comment
There was a problem hiding this comment.
(Code review only. I'm fine with both approaches so I'll leave it to grorp to decide whether this is better.)
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.
Will be put in another PR
This is handled by another pr.
Also removes braces in the if else statement
|
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). |
|
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. |
|
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 |
What and why
This PR adds two accessibility settings to the control options for toggling
sneakandaux1.When these are enabled, their respective keys in-game will toggle when you press them. This lets you e.g. press
sneakto 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
aux1andsneakkeys are read by the formspec, because it only changes the input handling ofgame.cpp, notkeycodes.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 tokeycodes.cppas 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->Generaland enableToggle aux1 keyandToggle 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.