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.


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.