MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / resolve_touch_point

Function resolve_touch_point

packages/server/src/main.rs:5785–5804  ·  view source on GitHub ↗
(
    bridge: &NativeBridge,
    udid: &str,
    x: f64,
    y: f64,
    normalized: bool,
)

Source from the content-addressed store, hash-verified

5783}
5784
5785fn resolve_touch_point(
5786 bridge: &NativeBridge,
5787 udid: &str,
5788 x: f64,
5789 y: f64,
5790 normalized: bool,
5791) -> Result<(f64, f64), crate::error::AppError> {
5792 if !x.is_finite() || !y.is_finite() || x < 0.0 || y < 0.0 {
5793 return Err(crate::error::AppError::bad_request(
5794 "Touch coordinates must be finite non-negative numbers.",
5795 ));
5796 }
5797 if normalized {
5798 return Ok((x.clamp(0.0, 1.0), y.clamp(0.0, 1.0)));
5799 }
5800 let (width, height) = accessibility_root_size(bridge, udid)
5801 .or_else(|| chrome_screen_size(bridge, udid))
5802 .unwrap_or((1.0, 1.0));
5803 Ok(((x / width).clamp(0.0, 1.0), (y / height).clamp(0.0, 1.0)))
5804}
5805
5806fn accessibility_root_size(bridge: &NativeBridge, udid: &str) -> Option<(f64, f64)> {
5807 let snapshot = bridge.accessibility_snapshot(udid, None).ok()?;

Callers 6

mainFunction · 0.85
run_batch_stepFunction · 0.85
resolve_tap_targetFunction · 0.85
gesture_coordinatesFunction · 0.85
pinch_framesFunction · 0.85
rotate_gesture_framesFunction · 0.85

Calls 2

accessibility_root_sizeFunction · 0.85
chrome_screen_sizeFunction · 0.85

Tested by

no test coverage detected