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

Method press_button

packages/server/src/android.rs:551–572  ·  view source on GitHub ↗
(&self, id: &str, button: &str, duration_ms: u32)

Source from the content-addressed store, hash-verified

549 }
550
551 pub fn press_button(&self, id: &str, button: &str, duration_ms: u32) -> Result<(), AppError> {
552 match button {
553 "home" => self.press_home(id),
554 "lock" | "side-button" => {
555 let serial = self.serial_for_id(id)?;
556 self.run_adb(["-s", &serial, "shell", "input", "keyevent", "26"])?;
557 if duration_ms > 500 {
558 thread::sleep(Duration::from_millis(u64::from(duration_ms)));
559 self.run_adb(["-s", &serial, "shell", "input", "keyevent", "26"])?;
560 }
561 Ok(())
562 }
563 "back" => {
564 let serial = self.serial_for_id(id)?;
565 self.run_adb(["-s", &serial, "shell", "input", "keyevent", "4"])?;
566 Ok(())
567 }
568 _ => Err(AppError::bad_request(format!(
569 "Unsupported Android hardware button `{button}`."
570 ))),
571 }
572 }
573
574 pub fn rotate_right(&self, id: &str) -> Result<(), AppError> {
575 self.rotate_by_quarter_turns(id, 1)

Callers 1

mainFunction · 0.45

Calls 4

serial_for_idMethod · 0.80
run_adbMethod · 0.80
sleepFunction · 0.50
press_homeMethod · 0.45

Tested by

no test coverage detected