-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
event.actions for input actions matching in _Input() #497
Comments
This could not work, a single event can correspond to several actions. |
@groud good point Instead of the method
could be used. In certainty of only one action being assigned to the event,
could be used to simplify and speed up matching. I think it's not that complex and it would speed up input-action handling, especially with a growing number of actions, that an event could be assigned to. |
There seems to be an existing proposal which could help what you're trying to achieve: godotengine/godot#15681. |
@Xrayez there is a slight difference: godotengine/godot#15681 refers to extending I want to propose to pass an array of assigned actions by event itself, instead of querying if event of
|
I have a suggestion on how to fix this. But it breaks a little backward compatibility. There is If we make the func _input(event):
if not event is InputEventAction: return
match e.action:
"ui_left": ...
"ui_right": ...
"ui_up": ...
"ui_down": ... However, the old code using |
Yeah, I had this idea before, but apparently this was apparently not done this way for performance reasons. Each event has to traverse the whole tree, so duplicating events wasn't really an option apparently. I am personally still unsure if this would be a real problem though. |
I thought about it. In general, it is surprising that in Godot, every event is an object. But I did not think that this is a big problem, since now a high-level abstract interface is used for the input system. In this case, is it possible to use a low-level interface? For example, implement the virtual method |
Closing due to lack of support (see the lack of reactions on OP and lack of recent comments here). See also #1853. |
Describe the project you are working on:
Space grand strategy / X4 game
Describe the problem or limitation you are having in your project:
I have to use multiple 'if event.is_action("action_name")' statements instead of matching the event to actions in _unhandled_input(event).
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Using event.action is safer and more configurable than using event.scancode.
Matching an action is more convenient, easier to read and faster than using multiple if- or elif- statements.
Mostly it's about speed and low latency.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
instead of:
or:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Yes, with a lot of if- and elif- statements, one per assigned action.
I'm certain this feature could be used by pretty much any application that uses input.
Is there a reason why this should be core and not an add-on in the asset library?:
Input handling is pretty much a core task.
The text was updated successfully, but these errors were encountered: