The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I have been having some issues with InputEvent when exporting to android.
I have instanced child scene which holds panel and 4 Buttons, I am trying to use this like on screen D-pad.
Layout
Nodes

I have used following code.

extends Container


func _on_Left_pressed():
    var ev = InputEvent()
    ev.type = InputEvent.MOUSE_BUTTON
    # set as move_left, pressed
    ev.set_as_action("ui_left", true)
    # feedback
    get_tree().input_event(ev)


func _on_Up_pressed():
    var ev = InputEvent()
    ev.type = InputEvent.SCREEN_TOUCH
    # set as move_left, pressed
    ev.set_as_action("ui_up", true)
    # feedback
    get_tree().input_event(ev)


func _on_Right_pressed():
    var ev = InputEvent()
    ev.type = InputEvent.ACTION
    # set as move_left, pressed
    ev.set_as_action("ui_right", true)
    # feedback
    get_tree().input_event(ev)

func _on_Down_pressed():
    var ev = InputEvent()
    ev.type = InputEvent.SCREEN_DRAG
    # set as move_left, pressed
    ev.set_as_action("ui_down", true)
    # feedback
    get_tree().input_event(ev)

All 4 buttons work on linux desktop, None work on android. Why is this?
What is the best way to make this portable from one OS to the next?
In essence i do not actually need the controller on windows or linux (or in fact any device with physical keys) so if it is possible to make work only with android mayb i can do that.

edit - Forgot to mention that i have tried with project settings > display > emulate_touchscreen both on and off
Thank you for all your great work.

edit2 - I have been further exploring the issue and using the above code for left i did actually manage to get it to recognise touch input. Sadly when i rebuilt the apk it no longer worked and hasn't since.

in Engine by (201 points)
edited by

Is there nobody who can help with this?

Please log in or register to answer this question.

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.