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

Created function that returns whether an action is being triggered or not #37833

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/input/input_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void InputFilter::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &InputFilter::is_key_pressed);
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &InputFilter::is_mouse_button_pressed);
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &InputFilter::is_joy_button_pressed);
ClassDB::bind_method(D_METHOD("is_action_empty"), &InputFilter::is_action_empty);
ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputFilter::is_action_pressed);
ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &InputFilter::is_action_just_pressed);
ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &InputFilter::is_action_just_released);
Expand Down Expand Up @@ -215,6 +216,10 @@ bool InputFilter::is_joy_button_pressed(int p_device, int p_button) const {
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
}

bool InputFilter::is_action_empty() const {
return action_state.empty();
}

bool InputFilter::is_action_pressed(const StringName &p_action) const {

return action_state.has(p_action) && action_state[p_action].pressed;
Expand Down
1 change: 1 addition & 0 deletions core/input/input_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class InputFilter : public Object {
bool is_key_pressed(int p_keycode) const;
bool is_mouse_button_pressed(int p_button) const;
bool is_joy_button_pressed(int p_device, int p_button) const;
bool is_action_empty() const;
bool is_action_pressed(const StringName &p_action) const;
bool is_action_just_pressed(const StringName &p_action) const;
bool is_action_just_released(const StringName &p_action) const;
Expand Down