Godot: "Emulate Mouse from Touch" on Android export not receiving actions as expected

Created on 10 Mar 2019  路  9Comments  路  Source: godotengine/godot

Godot version:
Godot 3.1 RC1

OS/device including version:
Android 6.0/Huawei Mate 7

Issue description:
On previous beta builds this option works on android exports using this line of code:

# "ui_touch" binds to mouse left button in project setting Input Map
if Input.is_action_pressed("ui_touch"):
    mouse_pos = get_global_mouse_position()

but in current RC1 build this not works on android and on my phone input touchs not detected.
Sure I currently solve my problem using this:

if event is InputEventScreenTouch and event.is_pressed():
       mouse_pos = get_global_mouse_position()

Just report this issue that may helps make godot excellent as is!

Sorry for my bad English!

bug discussion android input

Most helpful comment

The simplest 'workaround' in the current 3.1 release appears to be modifying the Input Map in an existing project to say 'all devices, left button' - that has me up and running again without any code changes.

All 9 comments

@RandomShaper Might be related to #26669 (not #26851 as this one was not merged for RC 1 yet).

The problem is that now emulated mouse events are reported as coming from device id -1, so the input map must be set accordingly.

I think the best way to fix this is listing the "touch mouse" explicitly in the dialog used to map mouse to actions.

I'll submit a PR shortly.

After thinking about it a bit more, I can say it's a gotcha indeed, but fixing it probably needs more discussion and ideas. Adding the emulated device to the list doesn't seem right to me (I almost had it done, but I don't like it).

I'd advise @zarsystem to use _All Devices_ for his mapping to work on touchscreens and us to revisit this topic if we find more users in the future affected by this.

@akien-mga, closing this is up to you if you agree.

@RandomShaper Isn't it simpler to just add a flag to mouse events (InputEventMouse) that is set when it comes from emulation? This way you can discard them properly in Viewport and users dont have to worry about the device.

Something like bool InputEventMouse::is_emulated_from_touch()

IMO explicit usage is always better :P

Sounds good, but what to do with "internal" events?
a) InputEventMouse::is_engine_internal()
b) Keep using an special device id.
c) Add instead a flags or nature field that can be set to emulated and/or internal.

The simplest 'workaround' in the current 3.1 release appears to be modifying the Input Map in an existing project to say 'all devices, left button' - that has me up and running again without any code changes.

Just ran into this today at work!

Thanks @sneaker333, this workaround worked great!

The simplest 'workaround' in the current 3.1 release appears to be modifying the Input Map in an existing project to say 'all devices, left button' - that has me up and running again without any code changes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timoschwarzer picture timoschwarzer  路  3Comments

Zylann picture Zylann  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments

blurymind picture blurymind  路  3Comments

nunodonato picture nunodonato  路  3Comments