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

Function perform_swipe

packages/server/src/main.rs:5462–5491  ·  view source on GitHub ↗
(
    bridge: &NativeBridge,
    udid: &str,
    gesture: GestureCoordinates,
    steps: u32,
)

Source from the content-addressed store, hash-verified

5460}
5461
5462fn perform_swipe(
5463 bridge: &NativeBridge,
5464 udid: &str,
5465 gesture: GestureCoordinates,
5466 steps: u32,
5467) -> Result<(), crate::error::AppError> {
5468 if bridge_simulator_is_tvos(bridge, udid) {
5469 let key_code = tvos_remote_key_for_touch_motion(
5470 gesture.start_x.clamp(0.0, 1.0),
5471 gesture.start_y.clamp(0.0, 1.0),
5472 gesture.end_x.clamp(0.0, 1.0),
5473 gesture.end_y.clamp(0.0, 1.0),
5474 );
5475 return press_tvos_remote_key(bridge, udid, key_code);
5476 }
5477 let step_count = steps.max(1);
5478 let delay = Duration::from_millis(gesture.duration_ms / u64::from(step_count));
5479 let input = bridge.create_input_session(udid)?;
5480 input.send_touch(gesture.start_x, gesture.start_y, "began")?;
5481 for step in 1..step_count {
5482 let t = f64::from(step) / f64::from(step_count);
5483 input.send_touch(
5484 lerp(gesture.start_x, gesture.end_x, t),
5485 lerp(gesture.start_y, gesture.end_y, t),
5486 "moved",
5487 )?;
5488 std::thread::sleep(delay);
5489 }
5490 input.send_touch(gesture.end_x, gesture.end_y, "ended")
5491}
5492
5493fn type_text(
5494 bridge: &NativeBridge,

Callers 2

mainFunction · 0.85
run_batch_stepFunction · 0.85

Calls 8

lerpFunction · 0.85
maxMethod · 0.80
create_input_sessionMethod · 0.80
bridge_simulator_is_tvosFunction · 0.70
press_tvos_remote_keyFunction · 0.70
sleepFunction · 0.50
send_touchMethod · 0.45

Tested by

no test coverage detected