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

Refactor input handler #15933

Merged
merged 12 commits into from
Mar 30, 2025
Merged

Refactor input handler #15933

merged 12 commits into from
Mar 30, 2025

Conversation

y5nw
Copy link
Contributor

@y5nw y5nw commented Mar 23, 2025

Mostly preparations for allowing more complex keyboard-related features (e.g. secondary keybindings); largely based on #15918 (which turned out to be useful after all after some more changes). The main changes (later ones can be dropped if we want to put them into later PRs that actually need the commits):

  • Implement operator< (for e.g. std::set) and std::hash (for std::unordered_map) for KeyPress. KeyList is dropped accordingly.

  • The event receiver now stores keypress information into a bitset indexed using GameKeyType. This architecture is useful as it avoids future headaches around e.g. wasKeyDown.

  • We continue to keep track of physical keys. This is useful for e.g. secondary keybindings, where (with the above change) we want to make sure that other keybindings are also unset before releasing a GameKeyType key (physical keys are still marked as relased when they are released, of course).

  • KeyCache is dropped and integrated into the event receiver, as the changes around the event receiver makes it no longer necessary for the input handler to hold information on keybindings, while it can become useful in the future for the event receiver to quickly look up keypresses (see above point for example).

  • Does it resolve any reported issue?
    No.

  • Does this relate to a goal in the roadmap?
    The first two commits qualify for 2.2 Internal code refactoring. Other the entire PR also eases development for future feature PRs.

To do

This PR is Ready for Review.

How to test

Check that keyboard input still works.

@y5nw y5nw added Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements @ Client / Controls / Input labels Mar 23, 2025
@y5nw y5nw mentioned this pull request Mar 23, 2025
2 tasks
@sfan5 sfan5 self-requested a review March 25, 2025 12:23
Copy link
Collaborator

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

(code review only)

@sfan5 sfan5 self-requested a review March 26, 2025 19:49
Copy link
Collaborator

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

seems to work

@sfan5 sfan5 merged commit 4cd2273 into luanti-org:master Mar 30, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Controls / Input Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements One approval ✅ ◻️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants