feat(tools): add long_press tool with humanize hook
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from device.manager import DeviceManager
|
||||
from tools._device import get_driver
|
||||
from tools.humanize import (
|
||||
get_rng,
|
||||
jitter_duration,
|
||||
jitter_point,
|
||||
load_humanize_config,
|
||||
)
|
||||
|
||||
|
||||
def long_press(
|
||||
x: float,
|
||||
y: float,
|
||||
*,
|
||||
duration_ms: int = 1200,
|
||||
device_id: str | None = None,
|
||||
manager: DeviceManager | None = None,
|
||||
) -> dict[str, object]:
|
||||
cfg = load_humanize_config()
|
||||
px, py = x, y
|
||||
dms = duration_ms
|
||||
if cfg.enabled:
|
||||
rng = get_rng()
|
||||
px, py = jitter_point(x, y, radius=cfg.tap_radius_px, rng=rng)
|
||||
dms = jitter_duration(duration_ms, spread=cfg.duration_spread, rng=rng)
|
||||
get_driver(device_id, manager=manager).long_press(px, py, dms)
|
||||
return {"ok": True, "action": "long_press", "x": px, "y": py, "duration_ms": dms}
|
||||
Reference in New Issue
Block a user