Stabilize camera drag and Tab menu input

This commit is contained in:
Alexander Sellite 2026-08-21 21:33:02 -04:00
parent 86e5980019
commit bb1942a057
4 changed files with 43 additions and 38 deletions

View file

@ -20,10 +20,11 @@ func _run() -> void:
press.button_index = MOUSE_BUTTON_RIGHT
press.button_mask = MOUSE_BUTTON_MASK_RIGHT
press.pressed = true
player.call("_input", press)
Input.parse_input_event(press)
await process_frame
assert(bool(player.get("_camera_dragging")))
if DisplayServer.get_name() != "headless":
assert(Input.mouse_mode == Input.MOUSE_MODE_VISIBLE)
assert(Input.mouse_mode == Input.MOUSE_MODE_CAPTURED)
var yaw := player.get_node("%CameraYaw") as Node3D
var previous_yaw: float = yaw.rotation.y
@ -31,9 +32,9 @@ func _run() -> void:
motion.button_mask = MOUSE_BUTTON_MASK_RIGHT
motion.relative = Vector2(18.0, -4.0)
motion.screen_relative = motion.relative
player.call("_input", motion)
assert(not is_equal_approx(yaw.rotation.y, previous_yaw))
Input.parse_input_event(motion)
await process_frame
assert(not is_equal_approx(yaw.rotation.y, previous_yaw))
assert(bool(player.get("_camera_dragging")))
if DisplayServer.get_name() != "headless":
assert(Input.mouse_mode == Input.MOUSE_MODE_CAPTURED)
@ -41,12 +42,14 @@ func _run() -> void:
var release := InputEventMouseButton.new()
release.button_index = MOUSE_BUTTON_RIGHT
release.pressed = false
player.call("_input", release)
Input.parse_input_event(release)
await process_frame
assert(not bool(player.get("_camera_dragging")))
if DisplayServer.get_name() != "headless":
assert(Input.mouse_mode == Input.MOUSE_MODE_VISIBLE)
player.call("_input", press)
Input.parse_input_event(press)
await process_frame
assert(bool(player.get("_camera_dragging")))
player.notification(NOTIFICATION_APPLICATION_FOCUS_OUT)
assert(not bool(player.get("_camera_dragging")))