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

"Emulate Mouse from Touch" on Android export not receiving actions as expected #26880

Closed
dorjoosoft opened this issue Mar 10, 2019 · 10 comments · Fixed by #59514
Closed

"Emulate Mouse from Touch" on Android export not receiving actions as expected #26880

dorjoosoft opened this issue Mar 10, 2019 · 10 comments · Fixed by #59514

Comments

@dorjoosoft
Copy link

dorjoosoft commented Mar 10, 2019

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!

@akien-mga
Copy link
Member

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

@RandomShaper
Copy link
Member

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.

@RandomShaper
Copy link
Member

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.

@reduz
Copy link
Member

reduz commented Mar 11, 2019

@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.

@reduz
Copy link
Member

reduz commented Mar 11, 2019

Something like bool InputEventMouse::is_emulated_from_touch()

@reduz
Copy link
Member

reduz commented Mar 11, 2019

IMO explicit usage is always better :P

@RandomShaper
Copy link
Member

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.

@sneaker333
Copy link

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.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Apr 8, 2019
@akien-mga akien-mga modified the milestones: 3.2, 4.0 Jan 14, 2020
@akien-mga akien-mga changed the title The project setting "Emulate Mouse from touch" on android export not works on 3.1 RC1 "Emulate Mouse from Touch" on Android export not receiving actions as expected Jan 14, 2020
@eh-jogos
Copy link

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.

@Calinou
Copy link
Member

Calinou commented Oct 27, 2021

The solution for this is likely to create new input actions for All Devices by default. This is generally the better option for singleplayer games anyway. I wanted to open a PR for this, but #53708 is currently blocking it in master.

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

Successfully merging a pull request may close this issue.

7 participants