0 votes

I want to add mobile functionality by converting touch inputs (e.g. tap, hold, double tap) to mouse inputs but not sure how.

Specifically I would like for single tap to be mouse hover, double tap to be left mouse, and hold to be right mouse.

Is there anyway I can just convert the inputs to be mouse inputs using something like the input map?

Godot version 3.5.1
in Engine by (12 points)

Wait what? I'm really confused for some reason, do mind elaborating just a little bit more.

Also what device are you targeting?

So I have some code for a 4D minesweeper game which I wanted to port to my android phone.

In the input function it uses the mouse position and button_index properties to highlight and click certain squares. How do I make it so that the hover code activates on tap? Likewise with the other actions.

I can post the _input function if helpful but I mostly just want to find a way to convert a tap to be a mouse hover, a double tap to be a mousedown with buttonindex 1, and a hold to be a mousedown with buttonindex 2

1 Answer

0 votes

Double tap, Longpress unfortunately these concepts do not exist in InputEvent

There is an option in project settings that lets you emulate ScreenTouch as mouse events, you'll be wanting to enable that.

The preferably have an autoload to pool unhandled events

func _unhandled_input(event):
    var new_event
    if event is InputEventScreenTouch:
        if event.pressed:
            new_event = InputEventMouseMotion.new()
            new_event.position = event.position

    Input.parse_event(new_event)

As mentioned before the other conditions do not exist and you will have to code it on your lonesome

by (6,876 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.