mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Allow checking for exact matches with Action events.
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>
This commit is contained in:
@@ -54,6 +54,7 @@ class InputDefault : public Input {
|
||||
uint64_t physics_frame;
|
||||
uint64_t idle_frame;
|
||||
bool pressed;
|
||||
bool exact;
|
||||
float strength;
|
||||
float raw_strength;
|
||||
};
|
||||
@@ -221,11 +222,11 @@ public:
|
||||
virtual bool is_key_pressed(int p_scancode) const;
|
||||
virtual bool is_mouse_button_pressed(int p_button) const;
|
||||
virtual bool is_joy_button_pressed(int p_device, int p_button) const;
|
||||
virtual bool is_action_pressed(const StringName &p_action) const;
|
||||
virtual bool is_action_just_pressed(const StringName &p_action) const;
|
||||
virtual bool is_action_just_released(const StringName &p_action) const;
|
||||
virtual float get_action_strength(const StringName &p_action) const;
|
||||
virtual float get_action_raw_strength(const StringName &p_action) const;
|
||||
virtual bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;
|
||||
virtual bool is_action_just_pressed(const StringName &p_action, bool p_exact = false) const;
|
||||
virtual bool is_action_just_released(const StringName &p_action, bool p_exact = false) const;
|
||||
virtual float get_action_strength(const StringName &p_action, bool p_exact = false) const;
|
||||
virtual float get_action_raw_strength(const StringName &p_action, bool p_exact = false) const;
|
||||
|
||||
virtual float get_joy_axis(int p_device, int p_axis) const;
|
||||
String get_joy_name(int p_idx);
|
||||
|
||||
Reference in New Issue
Block a user