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

InputEventMouseMotion is being indefinitely generated when a drag ends on top of a PhysiscsBody2d that has the input_event() signal connected #26460

Closed
eh-jogos opened this issue Mar 1, 2019 · 5 comments

Comments

@eh-jogos
Copy link

eh-jogos commented Mar 1, 2019

Godot version:
Godot 3.1 beta 8 official

OS/device including version:
Android (Asus Zenfone m1?)

Steps to reproduce:
1.Open the MRP and run it from the editor in a android phone.
2.Start Draging your finger from anywhere on the screen to any Godot Icon and release your finger on top of it.
3. Touch anywhere on the screen except the monster to see it create a line by detecting a input drag that shoudn't exist or just watch the ouput from Godot Editor, there will be endless prints of a InputEventMouseMotion with relative (0,0) and speed (0,0)
4. I put a commented line of code on the script on the RigidBody's _on_RigidBody2d_input_event() that checks if it's an MouseMotion with no relative and get's out, "fixing" the issue for our game, but the InputEvents keep being generated and being processed even though there's no real input.

Issue description:
On the game we are making we have some monsters that are RigidBodies that we can drag over and connect them. To check that, the Monster Scene connects the input_event(viewport, event, shape_idx) signal connected to itself, and there it checks if it's a InputEventMouseButton on top of the monster, or a InputEventMouseMotion.

On Android, if you just touch any monster everything works fine, if you drag from anywhere, and release your finger on top of any monster, and then touch anywhere on the screen outside the monsters, it will try to draw a connection to where you're touching, as it you were dragging from the monster to that point. You can touch multiple times in different places of the screen and it will keep doing that.

While this is happening If you touch anywhere and drag in any direction releasing your finger outside the monsters, or if you touch any monster and drag and release outside of the monsters, this stops happening.

If you take a closer look at the output you'll see that whenever you release a InputEventMouseMotion on top of a monster, it will print a MouseMotion event indefinitely.

When I try this on 3.0.6 it woks fine, there's no inifnite MouseMotion, this only happens on 3.1 beta. I'm sending the MRP in both a 3.0 and 3.1 version for comparison.

Minimal reproduction project:
android_mousemotion_emulation.zip
android_mousemotion_emulation3.1.zip

@akien-mga akien-mga added this to the 3.1 milestone Mar 1, 2019
@akien-mga
Copy link
Member

Seems related to/potential duplicate of #26395.

@volzhs
Copy link
Contributor

volzhs commented Mar 4, 2019

facing same issue.

func _ready():
	$Area2D.connect("input_event", self, "on_input_event")

func on_input_event(viewport:Node, event:InputEvent, shape_idx:int ):
	printt(event.as_text())

InputEventMouseMotion event is generated indefinitely even when mouse is not moved at all.

@realkotob
Copy link
Contributor

realkotob commented Mar 5, 2019

Just tried the example that @volzhs posted and seems it's still broken and that ecd8795 didn't fix it.

I got infinite log messages even when the mouse was not moved at all (but was inside the area).

@volzhs
Copy link
Contributor

volzhs commented Mar 5, 2019

i confirmed that too.

RandomShaper added a commit to RandomShaper/godot that referenced this issue Mar 5, 2019
Acknowledge mouse button events as position tellers (to make picking more solid; for instance, the touch mouse is raised with a mouse unpressed event that may have a more current position)
Forget mouse position for physics if touch mouse raised (because the position known as last is no longer meaningful)
Remove needless check for mouse over/exit (now there's code to inject an spurious move for cases where camera/objects have moved)
Restrict 2D mouse over/exit to mouse events (including emulated from touch; true touches shouldn't trigger the signals)

Fixes godotengine#26460.
@RandomShaper
Copy link
Member

I'm reopening this since my PR addressed the part of the issue about wrong event stream on Android (which is the most important), but did nothing to fix the repated null-motion events, which is the issue the title describes.

I'll try to fix that as well and submit a new PR.

@RandomShaper RandomShaper reopened this Mar 6, 2019
RandomShaper added a commit to RandomShaper/godot that referenced this issue Mar 9, 2019
This commit also improves a bit the code quality by making the intent of fake events (and themselves) more explicit.

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

No branches or pull requests

6 participants