Why are mouse motion events occurring when I have "emulate mouse from touch" disabled?

Godot Version

4.6

Question

I am testing my game’s HTML export on an Android phone.

Even though I have set input_devices/pointing/emulate_mouse_from_touch to false, I still seem to get mouse motion input events when I drag the screen.

Is there a practical way to prevent those mouse events?

func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventMouseMotion:
		print("Mouse motion event occurred.")

Is it possible the phone itself is converting the touch input into mouse input?

So, I feel like I narrowed it down to be something that has to do with the browser or the way I have the engine configured, rather than the device. Unless, for some reason both of my devices are emitting mouse events.

I wonder if mouse events are always emitted on the web, regardless of the device? It would be nice if someone could confirm.

I don’t think this is the case, because I tried it on another Android device, and it is still getting mouse motion events.

1 Like

Still this issue is in Godot 4.7dev1.

I used this as a temporary fix :

if not OS.has_feature("web_android") and not OS.has_feature("web_ios"):
	if event is InputEventMouseMotion:
        #rest of the logic
1 Like

Thanks.

Interestingly, I saw this temporary fix on the Godot GitHub Issues earlier too. :smile:

I’m going to mark this as the solution because the problem seems like a bug, and there may not be a better solution at this time.

1 Like

This is actually intended behaviour because the Web, as a platform (not just for Godot) is a mess. Your browser will be translating your inputs into mouse events to make sure super old webpages work as well even on modern phones.

1 Like