feat(tools): humanize tap coordinates; default off in tests

This commit is contained in:
2026-07-15 19:29:57 +08:00
parent d8e7be4ccb
commit 85f0d6e188
4 changed files with 60 additions and 3 deletions
+7 -2
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
from device.manager import DeviceManager
from tools._device import get_driver
from tools.humanize import get_rng, jitter_point, load_humanize_config
def tap(
@@ -11,5 +12,9 @@ def tap(
device_id: str | None = None,
manager: DeviceManager | None = None,
) -> dict[str, object]:
get_driver(device_id, manager=manager).tap(x, y)
return {"ok": True, "action": "tap", "x": x, "y": y}
cfg = load_humanize_config()
px, py = x, y
if cfg.enabled:
px, py = jitter_point(x, y, radius=cfg.tap_radius_px, rng=get_rng())
get_driver(device_id, manager=manager).tap(px, py)
return {"ok": True, "action": "tap", "x": px, "y": py}