Fix touch input: distinguish taps from swipes for camera vs click
Added _touch_drag_active flag set only when finger moves > 4px threshold. Camera orbit now requires meaningful drag; taps no longer jiggle camera or get swallowed — board clicks fire correctly for gameplay actions. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -123,7 +123,8 @@ var _pinch_dist : float = 0.0
|
||||
# True from the moment a second finger lands until ALL fingers lift.
|
||||
# Prevents single-finger orbit from triggering during a pinch gesture even
|
||||
# if a ScreenDrag for finger-0 arrives before finger-1's ScreenTouch is processed.
|
||||
var _was_multi_touch : bool = false
|
||||
var _was_multi_touch : bool = false
|
||||
var _touch_drag_active : bool = false # set when finger moves > threshold; suppresses tap-click
|
||||
|
||||
# ── Selection state ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -812,9 +813,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
_held_coord = Vector2i(-1, -1)
|
||||
else:
|
||||
_hold_timer.stop()
|
||||
if not _drag_active and _press_was_on_board:
|
||||
if not _drag_active and not _touch_drag_active and _press_was_on_board:
|
||||
_handle_board_click(mb.position)
|
||||
_drag_active = false
|
||||
_touch_drag_active = false
|
||||
_press_was_on_board = false
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
@@ -849,6 +851,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
var st := event as InputEventScreenTouch
|
||||
if st.pressed:
|
||||
_touch_points[st.index] = st.position
|
||||
_touch_drag_active = false
|
||||
if _touch_points.size() >= 2:
|
||||
_pinch_dist = _touch_pair_dist()
|
||||
_last_mouse = _touch_pair_mid()
|
||||
@@ -863,11 +866,13 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
var sd := event as InputEventScreenDrag
|
||||
_touch_points[sd.index] = sd.position
|
||||
if _touch_points.size() == 1 and not _was_multi_touch:
|
||||
_cam_yaw -= sd.relative.x * 0.4
|
||||
_cam_pitch = clampf(_cam_pitch + sd.relative.y * 0.3, 15.0, 75.0)
|
||||
_apply_camera()
|
||||
if sd.relative.length() > 2.0:
|
||||
if sd.relative.length() > 4.0:
|
||||
_touch_drag_active = true
|
||||
_hold_timer.stop()
|
||||
if _touch_drag_active:
|
||||
_cam_yaw -= sd.relative.x * 0.4
|
||||
_cam_pitch = clampf(_cam_pitch + sd.relative.y * 0.3, 15.0, 75.0)
|
||||
_apply_camera()
|
||||
elif _touch_points.size() >= 2:
|
||||
var keys := _touch_points.keys()
|
||||
var pos_a : Vector2 = _touch_points[keys[0]]
|
||||
|
||||
Reference in New Issue
Block a user