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

Function perform_scroll_input

packages/server/src/api/action_execution.rs:603–651  ·  view source on GitHub ↗
(
    state: AppState,
    udid: String,
    plan: ScrollInputPlan,
)

Source from the content-addressed store, hash-verified

601}
602
603async fn perform_scroll_input(
604 state: AppState,
605 udid: String,
606 plan: ScrollInputPlan,
607) -> Result<(), AppError> {
608 let swipe = plan.swipe;
609 match plan.backend {
610 ScrollInputBackend::Android => {
611 run_android_action(state, move |android| {
612 android.send_swipe(
613 &udid,
614 swipe.start_x,
615 swipe.start_y,
616 swipe.end_x,
617 swipe.end_y,
618 swipe.duration_ms,
619 )
620 })
621 .await
622 }
623 ScrollInputBackend::Native => {
624 run_bridge_action(state, move |bridge| {
625 if bridge_simulator_is_tvos(&bridge, &udid) {
626 let key_code = tvos_remote_key_for_touch_motion(
627 swipe.start_x,
628 swipe.start_y,
629 swipe.end_x,
630 swipe.end_y,
631 );
632 return press_tvos_remote_key(&bridge, &udid, key_code);
633 }
634 let input = bridge.create_input_session(&udid)?;
635 let delay = Duration::from_millis(swipe.duration_ms / u64::from(swipe.steps));
636 input.send_touch(swipe.start_x, swipe.start_y, "began")?;
637 for step in 1..swipe.steps {
638 let t = f64::from(step) / f64::from(swipe.steps);
639 input.send_touch(
640 swipe.start_x + (swipe.end_x - swipe.start_x) * t,
641 swipe.start_y + (swipe.end_y - swipe.start_y) * t,
642 "moved",
643 )?;
644 std::thread::sleep(delay);
645 }
646 input.send_touch(swipe.end_x, swipe.end_y, "ended")
647 })
648 .await
649 }
650 }
651}
652
653fn normalized_scroll_coordinates(
654 direction: Option<&str>,

Callers 2

perform_back_payloadFunction · 0.85

Calls 9

run_android_actionFunction · 0.85
run_bridge_actionFunction · 0.85
send_swipeMethod · 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