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

Implement secondary keybindings #15577

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

y5nw
Copy link
Contributor

@y5nw y5nw commented Dec 19, 2024

This PR allows players to define secondary keybindings, e.g. using left or right shift for sneaking in the SDL build.

This PR depends on #15152.
Note that this PR had some minor conflicts with #14964. IMO we should merge that PR first and then this one.

  • Goal of the PR
    Allow defining secondary keybindings (see description above).
  • How does the PR work?
    • Key settings are represented std::vector<KeyPress>. This allows keeping an order for keypresses (e.g. when saving the settings); it should not be problematic in terms of performance as the list of keybindings for a single setting will likely be very short (containing at most 2 entries) in most real-world cases.
    • Each entry in the string representation is delimited by the | character. It is not possible to escape |. This keep things simple at the cost of not allowing the | key in a key list if the key cannot be represented with a EKEY_CODE, but it should not be problematic as SDL: Use scancodes for keybindings #14964 implements a new keycode syntax that is used by default (and does not involve the | character). Note that a special case is created if the setting string includes only the | character, in which case it is parsed as a key instead of a list of keys.
  • Does it resolve any reported issue?
    No.
  • Does this relate to a goal in the roadmap?
    No.
  • If not a bug fix, why is this PR needed? What usecases does it solve?
    SDL: Use scancodes for keybindings #14964 (comment)

To do

This PR is a Work in Progress.

How to test

Change a key setting to have the form of (e.g.) KEY_KEY_Z|KEY_KEY_Y and observe that pressing (in this case) the Z or Y key performs the relevant action. Note that it is currently not possible to specify secondary keybindings in the "Controls" form/GUI (see To-Do).

@y5nw y5nw mentioned this pull request Dec 19, 2024
8 tasks
@Zughy Zughy added Roadmap The change matches an item on the current roadmap Feature ✨ PRs that add or enhance a feature @ Client / Controls / Input UI/UX Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand and removed Roadmap The change matches an item on the current roadmap labels Dec 20, 2024
@y5nw y5nw mentioned this pull request Dec 26, 2024
13 tasks
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 Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants