garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

cartopolis-agent · 2026-11-30T15:17:02Z

feat(xtask): pinebook-demo, the system used with a Pinebook Pro's input alone

Boots with no virtio input, only a keyboard and a mouse on OHCI, as a
Pinebook Pro's keyboard and touchpad are: the data's password typed on
that keyboard, Settings opened by moving the pointer and clicking.
README.md         |   1 +
 xtask/src/main.rs | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 94 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 11daf5e..de6fdda 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,7 @@ cargo xtask files-demo                 # Files: notes found in Notes' folder, on
 cargo xtask notices-demo               # past notifications: two texts, their list, one opened from it, cleared
 cargo xtask network-demo               # Settings' network page: online, switched off, on again
 cargo xtask bluetooth-demo             # the devices around, one paired, then found again after it moved its address
+cargo xtask pinebook-demo              # a Pinebook Pro's input only: the password typed, Settings clicked open, on USB 1.1 (OHCI)
 cargo xtask access-demo                # five scripts, Settings in Dutch, larger text, high contrast, the screen reader
 cargo xtask sound-demo                 # the volume kept at a restart, Settings' slider moved, its tone as loud as it says
 cargo xtask updates-demo               # an app's new version: told, then installed by itself
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index b386f9c..8764cc3 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -105,6 +105,7 @@ fn main() -> ExitCode {
         ["notices-demo"] => notices_demo(),
         ["network-demo"] => network_demo(),
         ["bluetooth-demo"] => bluetooth_only_demo(),
+        ["pinebook-demo"] => pinebook_demo(),
         ["access-demo"] => access_demo(),
         ["sound-demo"] => sound_demo(),
         ["updates-demo"] => updates_demo(),
@@ -1019,6 +1020,9 @@ struct Guest {
     /// A disk labelled `backup` (`docs/backup-and-sync.md`), kept between
     /// runs as a USB stick would be: [`new_image`] makes it.
     backup: Option<PathBuf>,
+    /// A Pinebook Pro's input rather than virtio's: a keyboard and a mouse
+    /// (its touchpad) on USB 1.1, an OHCI controller, and nothing else.
+    pinebook: bool,
 }
 
 impl Default for Guest {
@@ -1034,6 +1038,7 @@ impl Default for Guest {
             data: Some(root().join("target/data.img")),
             hardware: false,
             backup: None,
+            pinebook: false,
         }
     }
 }
@@ -1295,13 +1300,27 @@ fn qemu_guest(machine: &str, load: &Load, snapshot: bool, guest: &Guest) -> Comm
         Some(_) => vec!["-device", "virtio-gpu-gl-pci,venus=on,blob=on,hostmem=256M"],
         None => vec![],
     })
-    // Touch (a tablet: absolute positions) and a keyboard.
-    .args([
-        "-device",
-        "virtio-tablet-device",
-        "-device",
-        "virtio-keyboard-device",
-    ])
+    // Touch (a tablet: absolute positions) and a keyboard; or a Pinebook
+    // Pro's, a keyboard and a touchpad on USB 1.1.
+    .args(if guest.pinebook {
+        [
+            "-device",
+            "pci-ohci,id=ohci",
+            "-device",
+            "usb-kbd,bus=ohci.0",
+            "-device",
+            "usb-mouse,bus=ohci.0",
+        ]
+        .as_slice()
+    } else {
+        [
+            "-device",
+            "virtio-tablet-device",
+            "-device",
+            "virtio-keyboard-device",
+        ]
+        .as_slice()
+    })
     .args(if guest.hardware {
         hardware(machine.split(',').next().unwrap_or("virt"), Arch::Arm).unwrap_or_default()
     } else {
@@ -3328,6 +3347,27 @@ impl Session {
         self.pointer(x, y, Some(false))
     }
 
+    /// Clicks at `x`, `y` with a mouse (a touchpad), which moves only by
+    /// how far: into the top left corner first, where the pointer stops,
+    /// then from there.
+    fn click_at(&mut self, x: i32, y: i32) -> Result {
+        let (w, h) = self.screen;
+        for (dx, dy) in [(-2 * w, -2 * h), (x, y)] {
+            self.call(&format!(
+                r#"{{"execute":"input-send-event","arguments":{{"events":[{{"type":"rel","data":{{"axis":"x","value":{dx}}}}},{{"type":"rel","data":{{"axis":"y","value":{dy}}}}}]}}}}"#
+            ))?;
+            // QEMU's mouse says at most 127 a report, a report a poll.
+            std::thread::sleep(Duration::from_millis(400));
+        }
+        for down in [true, false] {
+            self.call(&format!(
+                r#"{{"execute":"input-send-event","arguments":{{"events":[{{"type":"btn","data":{{"down":{down},"button":"left"}}}}]}}}}"#
+            ))?;
+            std::thread::sleep(Duration::from_millis(100));
+        }
+        Ok(())
+    }
+
     fn drag(&mut self, points: &[(i32, i32)]) -> Result {
         let Some((&(x, y), rest)) = points.split_first() else {
             return Ok(());
@@ -5462,6 +5502,50 @@ fn network_demo() -> Result {
     Ok(())
 }
 
+/// `cargo xtask pinebook-demo`: the system with a Pinebook Pro's input
+/// and no other: its keyboard and touchpad one USB 1.1 device on the
+/// RK3399's OHCI (here QEMU's keyboard and mouse on its OHCI). The data's
+/// password typed on that keyboard, then Settings opened with the
+/// touchpad's pointer and its click; a screenshot each.
+fn pinebook_demo() -> Result {
+    let dir = demo_dir("demo-pinebook")?;
+    disks(&serve()?)?;
+    let guest = Guest {
+        pinebook: true,
+        ..Guest::default()
+    };
+    let qemu = qemu_guest("virt", &Load::Image(image("qemu-virt")?, ""), true, &guest);
+    // The password chosen here, not by `attach`: on the OHCI keyboard.
+    let mut s = Session::attach(qemu, "", false, || Ok(()))?;
+    s.wait_for("display: choose a password for your data")?;
+    for line in [
+        "ohci0: OHCI, ",
+        "ohci0: port 1: keyboard (QEMU USB Keyboard)",
+        "ohci0: port 2: mouse (QEMU USB Mouse)",
+    ] {
+        if !s.read.iter().any(|l| l.starts_with(line)) {
+            return Err(format!("pinebook: no \"{line}\" in the output"));
+        }
+    }
+    s.type_keys(DEMO_PASSPHRASE)?;
+    std::thread::sleep(Duration::from_millis(600));
+    s.shot(&dir.join("1-password-typed.png"))?;
+    s.type_keys("\n")?;
+    std::thread::sleep(Duration::from_millis(300));
+    s.type_keys(&format!("{DEMO_PASSPHRASE}\n"))?;
+    s.wait_for("display: data opened")?;
+    s.wait_for(&home_apps(0))?;
+    // The touchpad: the pointer moved to Settings' tile, and a click.
+    let at = s.find_named("launcher: tile Settings")?;
+    let (x, y) = pinnacle_layout::shell::to_screen(s.screen.0, s.screen.1, at);
+    s.click_at(x, y)?;
+    s.wait_for("display: Settings connected")?;
+    std::thread::sleep(Duration::from_millis(600));
+    s.shot(&dir.join("2-settings-opened.png"))?;
+    println!("ok   pinebook: the password typed and Settings opened, on USB 1.1 (OHCI) alone");
+    Ok(())
+}
+
 /// The sound's volume: the one Settings kept (30 %) given to the mixer at
 /// start, Settings' slider tapped at its middle (50 %), and the tone it then
 /// plays as loud in what QEMU heard as that says.
@@ -5881,6 +5965,7 @@ fn two_devices(tag: &str, bo_audio: Option<PathBuf>) -> Result<(Session, Session
             data: Some(root().join(format!("target/{tag}-ada-data.img"))),
             hardware: false,
             backup: None,
+            pinebook: false,
         },
         "ada| ",
     )?;
@@ -5896,6 +5981,7 @@ fn two_devices(tag: &str, bo_audio: Option<PathBuf>) -> Result<(Session, Session
             data: Some(root().join(format!("target/{tag}-bo-data.img"))),
             hardware: false,
             backup: None,
+            pinebook: false,
         },
         "bo | ",
     )?;