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

Input Event action match returns false positives #44180

Closed
EricEzaM opened this issue Dec 8, 2020 · 1 comment · Fixed by #44355
Closed

Input Event action match returns false positives #44180

EricEzaM opened this issue Dec 8, 2020 · 1 comment · Fixed by #44355

Comments

@EricEzaM
Copy link
Contributor

EricEzaM commented Dec 8, 2020

Godot version:
4.0 master
3.2.3 stable

OS/device including version:
Win 10

Issue description:
Action match gives the wrong result, it completely ignores modifiers.
Originated from #9002, and @volzhs seemed to notice this same issue about a year later.

Steps to reproduce:
Set up an input action called "test" and give it an event of Alt+Shift+Enter.
In a script, create and InputEventKey with scancode/keycode = KEY_ENTER.
Print the result of InputMap.event_is_action(event, "test")
Note that the result is TRUE. It is comparing KEY_ENTER and SHIFT+ALT+KEY_ENTER. This should NOT return true!
image

Problem lines:

if (get_keycode() == 0) {
uint32_t code = get_physical_keycode_with_modifiers();
uint32_t event_code = key->get_physical_keycode_with_modifiers();
match = get_physical_keycode() == key->get_physical_keycode() && (!key->is_pressed() || (code & event_code) == code);
} else {
uint32_t code = get_keycode_with_modifiers();
uint32_t event_code = key->get_keycode_with_modifiers();
match = get_keycode() == key->get_keycode() && (!key->is_pressed() || (code & event_code) == code);
}

The actual problem is (!key->is_pressed() || (code & event_code) == code);

Minimal reproduction project:
For 3.2
InputEventActionMatch.zip

@EricEzaM
Copy link
Contributor Author

Note this also totally messes with InputMap::_find_event(), which is relied upon for InputMap::action_add_event, InputMap::action_has_event andInputMap::action_erase_event

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants