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

Check action exists in Input.action_press and action_release #87324

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

jsjtxietian
Copy link
Contributor

Fixes #87311

@jsjtxietian jsjtxietian requested a review from a team as a code owner January 18, 2024 04:54
@Sauermann Sauermann added this to the 4.3 milestone Jan 18, 2024
@akien-mga
Copy link
Member

How about action_release? It would be worth reviewing all APIs that take action names.

@jsjtxietian
Copy link
Contributor Author

jsjtxietian commented Jan 18, 2024

Yes it should, but unlike action_press, pass an invalid name to action_release won't cause a crash as it just modifies the state of that invalid action.

void Input::action_release(const StringName &p_action) {
	// Create or retrieve existing action.
	ActionState &action_state = action_states[p_action];
	action_state.cache.pressed = 0;
	action_state.cache.strength = 0.0;
	action_state.cache.raw_strength = 0.0;
	action_state.released_physics_frame = Engine::get_singleton()->get_physics_frames();
	action_state.released_process_frame = Engine::get_singleton()->get_process_frames();
	action_state.device_states.clear();
	action_state.exact = true;
	action_state.api_pressed = false;
	action_state.api_strength = 0.0;
}

@AThousandShips AThousandShips changed the title Check action exists in Input.action_press Check action exists in Input.action_press/release Jan 18, 2024
@AThousandShips AThousandShips changed the title Check action exists in Input.action_press/release Check action exists in Input.action_press and action_release Jan 18, 2024
Copy link
Contributor

@YuriSizov YuriSizov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like other methods that take action names already do the same. So makes sense.

@YuriSizov YuriSizov merged commit 2ababdc into godotengine:master Jan 18, 2024
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@jsjtxietian jsjtxietian deleted the action-exist branch January 19, 2024 03:25
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.

Executing Input.action_press function crashes Godot
4 participants