TouchScreen Input doesn't work on Android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BarbOn

I’m trying to make touchscreen controls on my game for android , i added a new input in the InputMap called “click” that is simply the left click of the mouse.
Now on PC the controls work very well but after exporting to android the mouse emulation from touch seems to not work at all
Here’s the code for the controls:

extends Node2D

var first_point=Vector2(0,0)
var second_point=Vector2(0,0)

func _physics_process(delta):
    update_position()
    pass 

func update_position():
    if(Input.is_action_just_pressed("click")):
	    first_point=get_viewport().get_mouse_position()
	    self.show()
    if(Input.is_action_pressed("click")):
	    var app=get_viewport().get_mouse_position()-first_point
	    second_point=app
    else:
	    self.hide()
	    first_point=Vector2()
	    second_point=Vector2()

Here’s a video that shows that on PC works normally

:bust_in_silhouette: Reply From: BarbOn

Ok problem found
In the InputMap set the mouse click to “all devices” and not “device 0”

Thank you so much!
TBH I think “all devices” should be default setting.

AdamRatai | 2020-02-08 05:38

Omg thanks for this solution. I thought I had to do some serious refactoring, because I have similar code.

hidemat | 2020-03-23 17:37