MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / tvos_touch_sequence_key

Function tvos_touch_sequence_key

packages/server/src/api/routes.rs:608–642  ·  view source on GitHub ↗
(events: &[TouchSequenceEvent])

Source from the content-addressed store, hash-verified

606}
607
608fn tvos_touch_sequence_key(events: &[TouchSequenceEvent]) -> Result<u16, AppError> {
609 let first = events
610 .first()
611 .ok_or_else(|| AppError::bad_request("Touch sequence requires events."))?;
612 let mut start = (first.x.clamp(0.0, 1.0), first.y.clamp(0.0, 1.0));
613 let mut end = start;
614
615 for event in events {
616 let point = (event.x.clamp(0.0, 1.0), event.y.clamp(0.0, 1.0));
617 match event.phase.trim().to_ascii_lowercase().as_str() {
618 "began" | "down" => {
619 start = point;
620 end = point;
621 }
622 "moved" => {
623 end = point;
624 }
625 "ended" | "cancelled" | "up" => {
626 end = point;
627 return Ok(tvos_remote_key_for_touch_motion(
628 start.0, start.1, end.0, end.1,
629 ));
630 }
631 _ => {
632 return Err(AppError::bad_request(
633 "`phase` must be `began`, `moved`, `ended`, `cancelled`, `down`, or `up`.",
634 ))
635 }
636 }
637 }
638
639 Ok(tvos_remote_key_for_touch_motion(
640 start.0, start.1, end.0, end.1,
641 ))
642}
643
644fn bridge_simulator_is_tvos(bridge: &NativeBridge, udid: &str) -> bool {
645 bridge.simulator_is_tvos(udid).unwrap_or(false)

Callers 1

run_batch_stepFunction · 0.85

Calls 2

as_strMethod · 0.45

Tested by

no test coverage detected