v2 release prep: installer, README, packaging, notes; retire the v1 scripts
Installer rewritten around a preflight: distro, package manager, display manager, window manager, terminal, tmux, cargo, git, screen locker, touch device, device permissions and free disk are all checked BEFORE anything is installed, and the total cost is printed once for a single confirmation. Prompts read /dev/tty so they still work when the script is piped from curl, and fall back to defaults with a notice when there is no terminal at all. Several "[ test ] && action" statements were set -e landmines: under set -e an AND-OR list that ends up false aborts the script, so a box with no lightdm, no i3 or nothing to install would have exited silently partway through detection -- which is exactly the fresh-Debian case the installer exists for. Rewritten as if-statements and verified against a stripped PATH with no tmux, cargo, git or package manager present. Also fixed cargo detection reporting blank instead of NOT INSTALLED: the status of `cargo --version | cut` is cut's, and cut succeeds on empty input, so the fallback never fired. Device access now defaults to a udev rule matching touchscreens only, rather than the input group, which grants access to every input device including the keyboard and needs a full logout. README rewritten for someone who has not seen the project: what the photo shows, the hardware, install, then a config built up step by step, each step with the YAML and the resulting map. Every example is verified verbatim against the binary, and every relative link resolves. The mechanism and the reasoning move to notes/: DESIGN.md, HARDWARE-NOTES.md, V1-BASH.md, TODO.md. cad/README.md was a verbatim copy of the one inside geeekpi_rack_adapter_release_v1/, so every path in it -- including the screenshot -- was broken from where it sits. Corrected to its own level, and it now states once that the 9-inch screen, the 10-inch mini-rack mount and the 19-inch rack are three different measurements. The v1 shell implementation is removed; it stays recoverable at tag v1.2 and notes/V1-BASH.md carries the setting-by-setting migration table. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+48
-14
@@ -120,7 +120,10 @@ impl Touchpanel {
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(Self { device, cfg: cfg.clone() })
|
||||
Ok(Self {
|
||||
device,
|
||||
cfg: cfg.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Blocking gesture loop. Calls `on_event` for every completed gesture,
|
||||
@@ -144,7 +147,11 @@ impl Touchpanel {
|
||||
} else {
|
||||
slots.insert(
|
||||
current,
|
||||
Slot { start: (0, 0), last: (0, 0), active: true },
|
||||
Slot {
|
||||
start: (0, 0),
|
||||
last: (0, 0),
|
||||
active: true,
|
||||
},
|
||||
);
|
||||
peak = peak.max(slots.values().filter(|s| s.active).count());
|
||||
}
|
||||
@@ -161,8 +168,7 @@ impl Touchpanel {
|
||||
|
||||
// The gesture ends when the last contact lifts.
|
||||
if !slots.is_empty() && slots.values().all(|s| !s.active) {
|
||||
let tracks: Vec<Track> =
|
||||
slots.values().map(|s| (s.start, s.last)).collect();
|
||||
let tracks: Vec<Track> = slots.values().map(|s| (s.start, s.last)).collect();
|
||||
if let Some(ev) = classify(&self.cfg, &tracks, peak) {
|
||||
if !on_event(ev) {
|
||||
return Ok(());
|
||||
@@ -173,7 +179,6 @@ impl Touchpanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// One contact's journey: where it landed and where it lifted.
|
||||
@@ -190,7 +195,10 @@ pub fn classify(cfg: &Touch, tracks: &[Track], peak: usize) -> Option<Event> {
|
||||
return None;
|
||||
}
|
||||
let (dx, dy) = tracks.iter().fold((0.0, 0.0), |(ax, ay), (start, last)| {
|
||||
(ax + (last.0 - start.0) as f64 / n, ay + (last.1 - start.1) as f64 / n)
|
||||
(
|
||||
ax + (last.0 - start.0) as f64 / n,
|
||||
ay + (last.1 - start.1) as f64 / n,
|
||||
)
|
||||
});
|
||||
|
||||
let travel = (dx * dx + dy * dy).sqrt();
|
||||
@@ -207,28 +215,44 @@ pub fn classify(cfg: &Touch, tracks: &[Track], peak: usize) -> Option<Event> {
|
||||
if travel < cfg.threshold as f64 {
|
||||
return Some(Event::Discarded(
|
||||
direction,
|
||||
Rejected::TooShort { travel, threshold: cfg.threshold },
|
||||
Rejected::TooShort {
|
||||
travel,
|
||||
threshold: cfg.threshold,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Angle away from the dominant axis.
|
||||
let (along, across) = if horizontal { (dx.abs(), dy.abs()) } else { (dy.abs(), dx.abs()) };
|
||||
let (along, across) = if horizontal {
|
||||
(dx.abs(), dy.abs())
|
||||
} else {
|
||||
(dy.abs(), dx.abs())
|
||||
};
|
||||
let degrees = across.atan2(along).to_degrees();
|
||||
if degrees > cfg.leniency as f64 {
|
||||
return Some(Event::Discarded(
|
||||
direction,
|
||||
Rejected::OffAxis { degrees, leniency: cfg.leniency },
|
||||
Rejected::OffAxis {
|
||||
degrees,
|
||||
leniency: cfg.leniency,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if !cfg.fingers.contains(&peak) {
|
||||
return Some(Event::Discarded(
|
||||
direction,
|
||||
Rejected::WrongFingerCount { saw: peak, want: cfg.fingers.clone() },
|
||||
Rejected::WrongFingerCount {
|
||||
saw: peak,
|
||||
want: cfg.fingers.clone(),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
Some(Event::Swipe(Swipe { direction, fingers: peak }))
|
||||
Some(Event::Swipe(Swipe {
|
||||
direction,
|
||||
fingers: peak,
|
||||
}))
|
||||
}
|
||||
|
||||
fn update(slots: &mut HashMap<i32, Slot>, current: i32, f: impl Fn(&mut (i32, i32))) {
|
||||
@@ -251,7 +275,9 @@ pub fn list_touchscreens() -> Vec<(String, String)> {
|
||||
let entries = std::fs::read_dir(by_id).into_iter().flatten().flatten();
|
||||
for e in entries {
|
||||
let path = e.path();
|
||||
let Ok(dev) = Device::open(&path) else { continue };
|
||||
let Ok(dev) = Device::open(&path) else {
|
||||
continue;
|
||||
};
|
||||
let multitouch = dev
|
||||
.supported_absolute_axes()
|
||||
.is_some_and(|a| a.contains(AbsoluteAxisType::ABS_MT_POSITION_X));
|
||||
@@ -368,7 +394,11 @@ mod tests {
|
||||
// nothing ever fires, because the panel reports 2 contacts and the
|
||||
// config accepts only 1.
|
||||
let cfg = touch(80, 30, vec![1]);
|
||||
match swipe(&cfg, &[track((900, 300), -200, 0), track((905, 305), -200, 0)], 2) {
|
||||
match swipe(
|
||||
&cfg,
|
||||
&[track((900, 300), -200, 0), track((905, 305), -200, 0)],
|
||||
2,
|
||||
) {
|
||||
Event::Discarded(Direction::RL, r @ Rejected::WrongFingerCount { saw, .. }) => {
|
||||
assert_eq!(saw, 2);
|
||||
assert!(r.to_string().contains("touch.fingers"), "{r}");
|
||||
@@ -382,7 +412,11 @@ mod tests {
|
||||
// Otherwise a stray tap on a panel with ghost contacts reports the
|
||||
// finger-count problem, sending you to fix the wrong setting.
|
||||
let cfg = touch(80, 30, vec![1]);
|
||||
match swipe(&cfg, &[track((640, 360), -5, 0), track((641, 361), -5, 0)], 2) {
|
||||
match swipe(
|
||||
&cfg,
|
||||
&[track((640, 360), -5, 0), track((641, 361), -5, 0)],
|
||||
2,
|
||||
) {
|
||||
Event::Discarded(_, Rejected::TooShort { .. }) => {}
|
||||
other => panic!("expected the short-travel reason first: {other:?}"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user