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

Prefer the longest key combination for events #36

Open
quasilyte opened this issue Nov 15, 2023 · 1 comment
Open

Prefer the longest key combination for events #36

quasilyte opened this issue Nov 15, 2023 · 1 comment

Comments

@quasilyte
Copy link
Owner

Let's imagine a situation where the user is pressing the ctrl+left mouse button.

The keymap may have these actions:

  • ctrl+lmb = ping (ActionPing)
  • lmb = move to the spot (ActionMove)

If we check for ActionMove while pressing ctrl+lmb, it would still match, as lmb is indeed being pressed. This could lead to a double action activation (ActionMove and ActionPing). This might not be the expected behavior.

We could try to resolve these conflicts in favor of the longest match, which would be ActionPing in this case.
This resolution is not implemented yet.

Or we can just document this behavior and make it a user's problem to solve.

This conflict resolution, even if implemented in the future, should be optional.
It should be configured via the SystemConfig upon system creation (default=false).
This would prevent the backward-incompatible behavior as well as give the user some freedom in the way they want the input events to be handled.

@quasilyte
Copy link
Owner Author

TODO: check what Godot does in this situation.

quasilyte added a commit that referenced this issue Nov 15, 2023
This is not the final implementation as it doesn't handle
some tricky combinations like joystick movements that emulate a D-pad.

It also ignores the taps as they're activated at the moment the gesture
is finished (i.e. the finger is detached from a screen).

Right now we can handle gamepad, keyboard and mouse key release events.

Key modifiers work too and it's not necessary to release the modifier
keys during the same frame as the main key.
So, a `ctrl+lmb` released event would trigger if `lmb` is released
while `ctrl` is still being pressed.

A new example demonstrates how to use this new feature.
It also demonstrates how to avoid some of the conflicts
described in #36 (this is not a novel issue and it's not related
to the release events directly).

Refs #25
quasilyte added a commit that referenced this issue Nov 15, 2023
This is not the final implementation as it doesn't handle
some tricky combinations like joystick movements that emulate a D-pad.

It also ignores the taps as they're activated at the moment the gesture
is finished (i.e. the finger is detached from a screen).

Right now we can handle gamepad, keyboard and mouse key release events.

Key modifiers work too and it's not necessary to release the modifier
keys during the same frame as the main key.
So, a `ctrl+lmb` released event would trigger if `lmb` is released
while `ctrl` is still being pressed.

A new example demonstrates how to use this new feature.
It also demonstrates how to avoid some of the conflicts
described in #36 (this is not a novel issue and it's not related
to the release events directly).

Refs #25
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

No branches or pull requests

1 participant