I have this in an autoload:
signal swipe
var swipe_start = null
var minimum_drag = 100
func _unhandled_input(event):
if event.is_action_pressed("click"):
swipe_start = get_global_mouse_pos()
if event.is_action_released("click"):
_calculate_swipe(get_global_mouse_pos())
func _calculate_swipe(swipe_end):
if swipe_start == null:
return
var swipe = swipe_end - swipe_start
print(swipe)
if abs(swipe.x) > minimum_drag:
if swipe.x > 0:
emit_signal("swipe", "right")
else:
emit_signal("swipe", "left")
It just emits a signal with one argument that can be "right" or "left". If you don't know how to start maybe this helps.
Basically, if you don't care about the whole curve, your swipe is swipeend - swipestart where swipestart and swipeend are the return value of getglobalmouse_pos() when the user touches the screen and when she lifts her finger, respectively.