feat(tools): humanize tap coordinates; default off in tests
This commit is contained in:
+7
-2
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user