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

Fix InputEvent actions. #8936

Merged
merged 1 commit into from
May 27, 2017
Merged

Fix InputEvent actions. #8936

merged 1 commit into from
May 27, 2017

Conversation

27thLiz
Copy link
Contributor

@27thLiz 27thLiz commented May 26, 2017

The InputEvent::is_action(pressed|released) methods weren't implemented yet.
Also fixed a typo in InputDefault that prevented Input.is_action(pressed|released) from working.

Fixes #8914

@27thLiz 27thLiz added this to the 3.0 milestone May 26, 2017
Copy link
Contributor

@bojidar-bg bojidar-bg left a comment

Choose a reason for hiding this comment

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

LGTM

}
bool InputEvent::is_action_released(const StringName &p_action) const {

if (is_action(p_action)) {
return !is_pressed();
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if I'm being clueless on this matter but.... Why is !is_pressed() used for action_released?
Shouldn't release be when pressed was true and then pressed becomes false? Otherwise as long as I'm not pressing the key, action_released() will always return true... which seems wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you're calling this on individual InputEvents. That would be the case if it was implemented this way for Input.is_action_released(action), yes.
But since this is for events, there's just no way is_action_released will return true if the event is something other than specified in the action.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, no, there is only one pressed=false event when the key is released. So, this is going to catch just that one

Copy link
Contributor

Choose a reason for hiding this comment

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

oh ok, thanks for the explanation :)

@@ -62,10 +62,16 @@ bool InputEvent::is_action(const StringName &p_action) const {

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

return false; // InputMap::get_singleton()->event_is_action(Ref<InputEvent>(this),p_action);
if (is_action(p_action)) {
return is_pressed();
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, just thought about it, I guess you might want to add && !is_echo() here, but I'm not completely sure about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mhh, I'll check how 2.1 handled this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely should be ignoring echo events. ^^

The `InputEvent::is_action(pressed|released)` methods weren't implemented yet.
Also fixed a typo in `InputDefault` that prevented `Input.is_action(pressed|released)` from working.
@akien-mga akien-mga merged commit 378ebff into godotengine:master May 27, 2017
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.

InputEvent's is_action{,_pressed,_released} don't work
4 participants