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

Support composite binds with + commands, fix handling of composite binds with F1-F24 keys, fix incorrect key names with multiple modifiers, refactoring #8685

Merged
merged 7 commits into from
Aug 4, 2024

Conversation

Robyt3
Copy link
Member

@Robyt3 Robyt3 commented Aug 4, 2024

See commit messages.

Closes #8314.

Checklist

  • Tested the change ingame
  • Provided screenshots if it is a visual change
  • Tested in combination with possibly related configuration options
  • Written a unit test (especially base/) or added coverage to integration test
  • Considered possible null pointers and out of bounds array indexing
  • Changed no physics that affect existing maps
  • Tested the change with ASan+UBSan or valgrind's memcheck (optional)

This was only affecting the key names displayed in the voting HUD, e.g. with `bind "ctrl+alt+f3" "vote yes"` the voting HUD previously showed `+f3` as the key name.
- Use `UnbindAll` function in destructor to reduce duplicate code.
- Use appropriate constants instead of magic number `0`.
- Remove redundant comments.
- Remove redundant `else if` condition.
- Rename generic loop variables `i` and `j` to `Modifier` and `Key` for clarity.
The handling of F1-F24 keys in `CBindsSpecial` was not correct for composite binds, leading to stuck inputs if modifier keys are released first. Now, the `CBindsSpecial::OnInput` function simply delegates to `CBinds::OnInput` for F-key presses/releases so the behavior is consistent with regular binds.
Previously, binding `+` commands like `+hook` to composite keys like `shift+x` or `ctrl+alt+mouse1` was not possible, as it would lead to stuck inputs when one of the modifiers is released first before the primary key. When binding `+` commands to composite binds the modifier was instead ignored to prevent this.

Now, binding `+` commands to composite keys is also possible. Active binds (key, modifier) are stored and when a modifier key is released all binds using that modifier are also released.

Closes ddnet#8314.
@Robyt3 Robyt3 changed the title Support composite binds with + commands, fix handling of composite binds with F1-F24 keys, fix incorrect key names with multiple modifiers, refactoring Support composite binds with + commands, fix handling of composite binds with F1-F24 keys, fix incorrect key names with multiple modifiers, refactoring Aug 4, 2024
@def- def- enabled auto-merge August 4, 2024 20:43
@def- def- added this pull request to the merge queue Aug 4, 2024
Merged via the queue into ddnet:master with commit 8d609b9 Aug 4, 2024
16 checks passed
@Robyt3 Robyt3 deleted the Client-Binds-Fixes branch August 4, 2024 21:53
Robyt3 added a commit to Robyt3/ddnet that referenced this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding ctrl+key to multiple actions like +right;+jump binds to key without ctrl modifier instead
2 participants