From b1d3ff55329758f413864f68608c20ef33202a5c Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 23 Jul 2022 10:48:05 -0400 Subject: Move all of the mouse consumption and aggregation --- MouseInput.gd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'MouseInput.gd') diff --git a/MouseInput.gd b/MouseInput.gd index e47e3c7..5805a02 100644 --- a/MouseInput.gd +++ b/MouseInput.gd @@ -9,3 +9,20 @@ func get_mouse_movement(): func add_mouse_movement(relative): mouse_movement += relative + +func _ready(): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + +func _notification(what): + if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + +func _input(event): + if event.is_action_pressed("ui_cancel"): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: + if event.is_action_pressed("click"): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + else: + if event is InputEventMouseMotion: + add_mouse_movement(event.relative) -- cgit v1.2.3