Federico-Ciuffardi / GodotTouchInputManager

Asset that improves touch input support (includes new gestures) in the Godot game engine. It also translates mouse input to touch input.
MIT License
526 stars 35 forks source link

fix error caused by orphaned released events. #19

Closed Splizard closed 2 years ago

Splizard commented 2 years ago

I've turned "Emulate Mouse From Touch" off in the Godot settings and for some reason, Button controls like to steal/consume the initial touch pressed event and then ignore the released event. What does this result in?

Well this causes the InputManager to break because it expects every pressed to have a matching released. Perhaps this assumption/issue needs to be sorted out but I've made a quick patch that ignores released events when there is no matching pressed event.

Because of https://github.com/godotengine/godot/issues/24589 Buttons don't really work with touch so in my project, I've added a custom script. I noticed @Calinou commented on this issue referring to Godot Touch Input Manager as a possible solution. Should Godot Touch Input Manager have some sort of GUI Controls integration that fixes this? or is this a Godot engine issue? something to think about.

Federico-Ciuffardi commented 2 years ago

I've turned "Emulate Mouse From Touch" off in the Godot settings and for some reason, Button controls like to steal/consume the initial touch pressed event and then ignore the released event.

I guess this has to do with:

  1. InputManager.gd uses _unhandled_input to process touch input so it is possible that the button is consuming the press and thus not be processed by _unhandled_input.

  2. It seemed strange to me that it only happened with the press and not the release but I found this issue that may explain it.

What does this result in?

Well this causes the InputManager to break because it expects every pressed to have a matching released. Perhaps this assumption/issue needs to be sorted out but I've made a quick patch that ignores released events when there is no matching pressed event.

For now, I'll merge this PR and then make some minor changes to the implementation.

I think a better solution though might be to change from _unhandled_input to _input in InputManager.gd. Although this can lead to problems as gesture detection in the GUI may not be desirable and I don't see this being reasonably achievable using _input due to custom input events not being consumed by control nodes. While on the other hand it is farily easy to stop ignoring gestures when using _unhandled_input (see issue #8). It remains to be seen if it is possible to get the control nodes to consume the custom input events for it to be viable to use _input.

Because of https://github.com/godotengine/godot/issues/24589 Buttons don't really work with touch so in my project, I've added a custom script. I noticed @Calinou commented on this issue referring to Godot Touch Input Manager as a possible solution. Should Godot Touch Input Manager have some sort of GUI Controls integration that fixes this? or is this a Godot engine issue? something to think about.

Maybe @Calinou is talking only about gesture detection. I think https://github.com/godotengine/godot/issues/24589 is mostly a Godot problem, especially regarding native touch events. Regarding the custom events of GDTIM, I don't know if there is a way to make them work correctly with the control nodes, if it exists it would be good to implement it.