Add touch tap/hold selection and keep one-finger orbit

This commit is contained in:
Shard
2026-03-29 19:55:03 +00:00
parent b9e6dc6e80
commit 206ff9a212
@@ -851,16 +851,36 @@ func _unhandled_input(event: InputEvent) -> void:
var st := event as InputEventScreenTouch var st := event as InputEventScreenTouch
if st.pressed: if st.pressed:
_touch_points[st.index] = st.position _touch_points[st.index] = st.position
_touch_drag_active = false if _touch_points.size() == 1:
if _touch_points.size() >= 2: # Single-touch start: arm tap + hold (touch right-click) behavior.
_touch_drag_active = false
_press_was_on_board = true
_last_mouse = st.position
var touch_coord := _mouse_to_tile_coord(st.position)
if touch_coord.x >= 0:
_held_coord = touch_coord
_hold_timer.start()
else:
_held_coord = Vector2i(-1, -1)
elif _touch_points.size() >= 2:
_pinch_dist = _touch_pair_dist() _pinch_dist = _touch_pair_dist()
_last_mouse = _touch_pair_mid() _last_mouse = _touch_pair_mid()
_was_multi_touch = true _was_multi_touch = true
_held_coord = Vector2i(-1, -1)
_hold_timer.stop() _hold_timer.stop()
else: else:
var released_pos := st.position
var had_single_touch := (_touch_points.size() == 1 and _touch_points.has(st.index))
_touch_points.erase(st.index) _touch_points.erase(st.index)
if had_single_touch and not _touch_drag_active and not _was_multi_touch and _press_was_on_board:
_hold_timer.stop()
_handle_board_click(released_pos)
if _touch_points.is_empty(): if _touch_points.is_empty():
_was_multi_touch = false _was_multi_touch = false
_touch_drag_active = false
_press_was_on_board = false
_held_coord = Vector2i(-1, -1)
_hold_timer.stop()
elif event is InputEventScreenDrag: elif event is InputEventScreenDrag:
var sd := event as InputEventScreenDrag var sd := event as InputEventScreenDrag