I can't get my game to differentiate/distinguish between Swipes and Touches

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

My input detector looks like this:

func _input(event):
	if event is InputEventScreenDrag:
		if event.speed.y < -10:
			emit_signal('up')
		elif event.speed.y > 10:
			emit_signal('down')
		return
	elif event is InputEventScreenTouch:
		if event.pressed:
			if event.position.x < get_node("../ship").get_viewport_rect().size.x/2:
				emit_signal('touched', "left")
			else:
				emit_signal('touched', "right")
			return

The main issue currently is that no matter if it’s a Touch or a Swipe, both if event is InputEventScreenDrag and elif event is InputEventScreenTouch: seems to be coming true, all the time.

:bust_in_silhouette: Reply From: ishfwilf

I solved it like this:

if event is InputEventScreenDrag:
    swiped = true
    
if event is InputEventScreenTouch:
        if event.is_pressed():
            print("pressed...")
        if not event.pressed:
            if swiped:
                calculate_swipe(event)
                get_tree().set_input_as_handled()
                return
            calculate_touch(event)
            #emit_signal("none")

swiped is set to false in calculate_swipe