Repository: godot
Issue: Android - InputEventScreenTouch is canceled when pressing with 2 fingers then dragging
Labels: bug,platform:android,topic:input

### Tested versions

-Reproducible in version: 4.3.stable

### System information

Godot v4.3.stable - Windows 10.0.22621 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 32.0.15.6603) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)

### Issue description

In a Camera3D node, I have attached a script to handle basic touch screen input for panning, zooming, and rotation. However, I encountered an issue with multi-touch gesture detection:

1. When I touch the screen with two fingers simultaneously and begin dragging with both fingers, the InputEventScreenDrag event is not called.
2. Upon further investigation, I observed that as soon as I start dragging, the InputEventScreenTouch event is triggered with event.canceled = true for both finger indices.

Interestingly, this behavior does not occur if I:

- Touch with one finger, drag, and then add a second finger. In this scenario, the InputEventScreenTouch events are not canceled, and multi-touch gestures work as expected.

**Expected Behavior**
    
Touch events should not be canceled when two fingers are placed on the screen simultaneously and begin dragging. This behavior disrupts the ability to seamlessly perform pinch-and-zoom gestures.


**Note:**

Enable Pan and Scale Gestures for android is enabled

### Steps to reproduce

Create a Camera3D node and attached a script with the following code:


```gdscript
extends Camera3D


@export_range(0,10) var pan_speed: float = 1.0
@export var zoom_speed: float = 0.1
@export var rotation_speed: float = 1.0
@export var can_pan: bool
@export var can_zoom: bool
@export var can_rotate: bool
#To limit camera movement and zoom
@export var x_min: float = -10.0
@export var x_max: float = 10.0
@export var z_min: float = -10.0
@export var z_max: float = 10.0
@export var fov_min: float = 30
@export var fov_max: float = 60

var start_fov: float
var start_dist: float
var touch_points: Dictionary = {}
var start_angle: float
var current_angle: float
var button_states : Dictionary = {
	MOUSE_BUTTON_LEFT: false,
	MOUSE_BUTTON_RIGHT: false,
	MOUSE_BUTTON_WHEEL_DOWN: false,
	MOUSE_BUTTON_WHEEL_UP: false
}
var is_mobile := false

func _ready() -> void:
	start_fov = fov
	if OS.get_name() == "Android" or OS.get_name() == "iOS":
		is_mobile = true


func _input(event: InputEvent) -> void:
	if is_mobile:
		if event is InputEventScreenTouch:
			_handle_touch(event)
		elif event is InputEventScreenDrag:
			_handle_drag(event)
	else:	
		if event is InputEventMouseButton:
			button_states[event.button_index] = event.pressed
			_handle_mouse_click(event)	
		elif event is InputEventMouseMotion:
			_handle_mouse_drag(event)
		



func _handle_touch(event: InputEventScreenTouch) -> void:
	printt(event.pressed, event.index, event.canceled)
	if event.pressed:
		touch_points[event.index] = event.position
	else:
		touch_points.erase(event.index)
	
	if touch_points.size() == 2:

		var touch_point_positions = touch_points.values()
		start_dist = touch_point_positions[0].distance_to(touch_point_positions[1])
		start_angle = get_angle(touch_point_positions[0],touch_point_positions[1])
		start_fov = fov
	elif touch_points.size() < 2:
		start_dist = 0
	
func _handle_drag(event: InputEventScreenDrag):
	touch_points[event.index] = event.position
	if touch_points.size() == 1:
		if can_pan:
			h_offset -= event.relative.x * pan_speed / fov
			v_offset += event.relative.y * pan_speed / fov
	elif touch_points.size() == 2:
		var touch_point_positions = touch_points.values()
		var current_dist = touch_point_positions[0].distance_to(touch_point_positions[1])
		var current_angle = get_angle(touch_point_positions[0], touch_point_positions[1])

		var zoom_factor = start_dist / current_dist
		if can_zoom:
			fov = start_fov / zoom_factor
		if can_rotate:
			rotation.y -= (current_angle - start_angle) * rotation_speed
			start_angle = current_angle # Update the start_angle to the current_angle for the next drag event
		
		fov = clamp(fov,fov_min,fov_max)
		
func _handle_mouse_click(event: InputEventMouseButton) -> void:
	if button_states[MOUSE_BUTTON_WHEEL_DOWN]:
		fov = clamp(fov+2,fov_min,fov_max)
	elif button_states[MOUSE_BUTTON_WHEEL_UP]:
		fov = clamp(fov-2,fov_min,fov_max)
	
	
func _handle_mouse_drag(event: InputEventMouseMotion):
	if button_states[MOUSE_BUTTON_LEFT]:
		if can_pan:
			h_offset -= event.relative.x * pan_speed
			v_offset += event.relative.y * pan_speed

func get_angle(p1: Vector2, p2: Vector2) -> float:
	var delta = p2 - p1
	return fmod((atan2(delta.y, delta.x) + PI), (2 * PI))
```

### Minimal reproduction project (MRP)

N/A