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

Function run_multitouch_frames

packages/server/src/main.rs:5358–5390  ·  view source on GitHub ↗
(
    bridge: &NativeBridge,
    udid: &str,
    frames: Vec<MultiTouchFrame>,
    duration_ms: u64,
)

Source from the content-addressed store, hash-verified

5356}
5357
5358fn run_multitouch_frames(
5359 bridge: &NativeBridge,
5360 udid: &str,
5361 frames: Vec<MultiTouchFrame>,
5362 duration_ms: u64,
5363) -> Result<(), crate::error::AppError> {
5364 let Some(first) = frames.first().copied() else {
5365 return Err(crate::error::AppError::bad_request(
5366 "Multi-touch gesture requires at least one frame.",
5367 ));
5368 };
5369 let step_delay = if frames.len() > 1 {
5370 duration_ms / (frames.len() as u64 - 1)
5371 } else {
5372 duration_ms
5373 };
5374 let input = bridge.create_input_session(udid)?;
5375 input.send_multitouch(first.x1, first.y1, first.x2, first.y2, "began")?;
5376 for frame in frames
5377 .iter()
5378 .copied()
5379 .skip(1)
5380 .take(frames.len().saturating_sub(2))
5381 {
5382 sleep_ms(step_delay);
5383 input.send_multitouch(frame.x1, frame.y1, frame.x2, frame.y2, "moved")?;
5384 }
5385 if let Some(last) = frames.last().copied() {
5386 sleep_ms(step_delay);
5387 input.send_multitouch(last.x1, last.y1, last.x2, last.y2, "ended")?;
5388 }
5389 Ok(())
5390}
5391
5392fn sleep_ms(duration_ms: u64) {
5393 if duration_ms > 0 {

Callers 2

mainFunction · 0.85
run_batch_stepFunction · 0.85

Calls 3

sleep_msFunction · 0.85
create_input_sessionMethod · 0.80
send_multitouchMethod · 0.45

Tested by

no test coverage detected