Skip to content

Commit

Permalink
Update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico-Ciuffardi committed Apr 30, 2023
1 parent 82bff8c commit 1560aeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions GDTIM-vgodot4support/CustomInputEvents/InputEventScreenCancel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class_name InputEventScreenCancel
extends InputEventAction

var raw_gesture : RawGesture
var event : InputEvent

func _init(_raw_gesture : RawGesture, _event : InputEvent) -> void:
raw_gesture = _raw_gesture
event = _event

func as_string() -> String:
return "gesture canceled"
10 changes: 10 additions & 0 deletions GDTIM-vgodot4support/InputManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ signal multi_long_press
signal pinch
signal twist
signal raw_gesture
signal cancel
signal any_gesture

########
Expand Down Expand Up @@ -154,6 +155,10 @@ func _handle_mouse_motion(event : InputEventMouseMotion) -> void:
_emit("twist", twist_event)

func _handle_screen_touch(event : InputEventScreenTouch) -> void:
if event.index < 0:
_emit("cancel", InputEventScreenCancel.new(raw_gesture_data, event))
_end_gesture()
return

# ignore orphaned touch release events
if !event.pressed and not event.index in raw_gesture_data.presses:
Expand Down Expand Up @@ -196,6 +201,11 @@ func _handle_screen_touch(event : InputEventScreenTouch) -> void:
_cancel_single_drag()

func _handle_screen_drag(event : InputEventScreenDrag) -> void:
if event.index < 0:
_emit("cancel", InputEventScreenCancel.new(raw_gesture_data, event))
_end_gesture()
return

raw_gesture_data._update_screen_drag(event)
_emit("raw_gesture", raw_gesture_data)
if raw_gesture_data.drags.size() > 1:
Expand Down

0 comments on commit 1560aeb

Please sign in to comment.