summaryrefslogtreecommitdiff
path: root/core/input/input_event.h
diff options
context:
space:
mode:
authorEricEzaM <itsjusteza@gmail.com>2020-12-14 00:22:42 +1000
committerEric M <itsjusteza@gmail.com>2020-12-15 09:14:18 +1000
commitb2f032e1a5ffc1332278be33075c2d19c336a457 (patch)
treea8f8f180f5e4f2c8ed4fe0d323ab51396e1ccbd8 /core/input/input_event.h
parent0762484473c1330c5d524d5cc3644d5e2b2e557c (diff)
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) ```
Diffstat (limited to 'core/input/input_event.h')
-rw-r--r--core/input/input_event.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 6a71a24c8b..d70883fcf7 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -122,11 +122,11 @@ public:
void set_device(int p_device);
int get_device() const;
- bool is_action(const StringName &p_action) const;
- bool is_action_pressed(const StringName &p_action, bool p_allow_echo = false) const;
- bool is_action_released(const StringName &p_action) const;
- float get_action_strength(const StringName &p_action) const;
- float get_action_raw_strength(const StringName &p_action) const;
+ bool is_action(const StringName &p_action, bool p_exact_match = false) const;
+ bool is_action_pressed(const StringName &p_action, bool p_allow_echo = false, bool p_exact_match = false) const;
+ bool is_action_released(const StringName &p_action, bool p_exact_match = false) const;
+ float get_action_strength(const StringName &p_action, bool p_exact_match = false) const;
+ float get_action_raw_strength(const StringName &p_action, bool p_exact_match = false) const;
// To be removed someday, since they do not make sense for all events
virtual bool is_pressed() const;