NetDesk 1.5.0 — source release
This commit is contained in:
commit
40318aafdd
227 files changed
+80798
No files matched your search
@@ -0,0 +1,64 @@
|
||||
//! Tiny viewer that connects to a host and sends ONE tap (mouse down+up) at
|
||||
//! TAP_X,TAP_Y (in the host's capture pixel space). Used to verify Android-host
|
||||
//! input injection on BlueStacks: send a tap, then screencap to confirm effect.
|
||||
//! E2E_HOST_ID=.. E2E_PASSWORD=.. TAP_X=.. TAP_Y=.. tap-probe
|
||||
use netdesk_core::{connect, ConnectConfig, SessionEvent};
|
||||
use std::time::Duration;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let id = std::env::var("E2E_HOST_ID").expect("E2E_HOST_ID");
|
||||
let pw = std::env::var("E2E_PASSWORD").expect("E2E_PASSWORD");
|
||||
let x: i32 = std::env::var("TAP_X").unwrap_or_else(|_| "480".into()).parse().unwrap();
|
||||
let y: i32 = std::env::var("TAP_Y").unwrap_or_else(|_| "800".into()).parse().unwrap();
|
||||
let swipe = std::env::var("SWIPE").ok(); // "x2,y2" -> drag instead of tap
|
||||
|
||||
let (tx, mut rx) = mpsc::unbounded_channel::<SessionEvent>();
|
||||
let cfg = ConnectConfig {
|
||||
ws_url: "wss://netdesk.space/ws".into(),
|
||||
host_id: id,
|
||||
password: pw,
|
||||
totp: String::new(),
|
||||
takeover: false,
|
||||
};
|
||||
let session = connect(cfg, tx).await.expect("connect");
|
||||
// drain until Connected
|
||||
let mut connected = false;
|
||||
for _ in 0..50 {
|
||||
if let Ok(Some(ev)) = tokio::time::timeout(Duration::from_millis(200), rx.recv()).await {
|
||||
if matches!(ev, SessionEvent::Connected { .. }) {
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !connected {
|
||||
println!("TAP_PROBE_FAIL not connected");
|
||||
return;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(400)).await;
|
||||
|
||||
// press
|
||||
session.mouse(x, y, 1, 0.0, 0.0);
|
||||
if let Some(s) = swipe {
|
||||
// drag: move with button held to (x2,y2), then release
|
||||
let parts: Vec<i32> = s.split(',').filter_map(|v| v.trim().parse().ok()).collect();
|
||||
let (x2, y2) = (parts[0], parts[1]);
|
||||
for i in 1..=8 {
|
||||
let ix = x + (x2 - x) * i / 8;
|
||||
let iy = y + (y2 - y) * i / 8;
|
||||
tokio::time::sleep(Duration::from_millis(25)).await;
|
||||
session.mouse(ix, iy, 1, 0.0, 0.0);
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(40)).await;
|
||||
session.mouse(x2, y2, 0, 0.0, 0.0);
|
||||
println!("SWIPE_SENT {x},{y} -> {x2},{y2}");
|
||||
} else {
|
||||
tokio::time::sleep(Duration::from_millis(80)).await;
|
||||
session.mouse(x, y, 0, 0.0, 0.0); // release = tap
|
||||
println!("TAP_SENT {x},{y}");
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(600)).await;
|
||||
session.close();
|
||||
}
|
||||
Reference in new issue
Block a user