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

[3.x] Allow checking for exact matches with Action events. #50874

Merged
merged 1 commit into from Jul 30, 2021

Conversation

raulsntos
Copy link
Member

@raulsntos raulsntos commented Jul 26, 2021

Backport of #44355
Backport of #51064

@raulsntos raulsntos requested review from a team as code owners July 26, 2021 00:44
@EricEzaM
Copy link
Contributor

May close godotengine/godot-proposals#2464

@raulsntos
Copy link
Member Author

Rebased on top of #50788

@raulsntos
Copy link
Member Author

Rebased on top of #50985

@akien-mga
Copy link
Member

akien-mga commented Jul 30, 2021

The class reference needs to be updated (make sure to keep the descriptions): https://github.com/godotengine/godot/pull/50874/checks?check_run_id=3200490164

The master branch lacks details about what exact_match does in the documentation, this should be added for both branches.

@akien-mga
Copy link
Member

Could you squash the commits? Otherwise we'd been merging an intermediate commit that actually fails CI.

Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.

Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True

Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.

Usage:

```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)

InputMap.event_is_action(p_event, "my_action", true)

func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```

Co-authored-by: Eric M <itsjusteza@gmail.com>
@akien-mga akien-mga merged commit 18f0949 into godotengine:3.x Jul 30, 2021
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants