30 lines
826 B
Python
30 lines
826 B
Python
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}
|