Skip to content

Print suggestions when requesting a nonexistent InputMap action

Created by: Calinou

This should make debugging input actions a bit easier. In the future, we can extend this to get_node() errors, signal connection errors and much more. If no action name is close enough to the requested action, no suggestion will be made.

Preview

ERROR: event_get_action_status: The InputMap action "move_forwards" doesn't exist. Did you mean "move_forward"?
   At: core/input_map.cpp:241.

Note that this method is fairly slow (taking 2-5 ms to run in a debug build). Thankfully, it's only called in debug builds when the input action doesn't exist, so the impact should be minimal in a release build.

@Zylann Is there a way to optimize this? I'm not sure if putting the Comparator struct outside the function would improve the performance (to avoid creating it every time).

Edit: The method has been optimized, it takes about 100-150 µs to run now.

Merge request reports