This commit is contained in:
Brad Stein 2025-06-25 09:21:39 -05:00
parent 0e13ca7378
commit dbdfbe5aaa
3 changed files with 21 additions and 29 deletions

View File

@ -11,7 +11,7 @@ use tracing::{debug, error, info, warn};
use winit::{
event_loop::EventLoopBuilder,
platform::x11::EventLoopBuilderExtX11,
platform::unix::EventLoopBuilderExtUnix,
platform::wayland::EventLoopBuilderExtWayland,
event::Event,
};
@ -74,10 +74,6 @@ impl LesavkaClientApp {
let (video_tx, mut video_rx) = tokio::sync::mpsc::unbounded_channel::<VideoPacket>();
// let (event_tx, event_rx) = std::sync::mpsc::channel();
let (_event_tx, _event_rx) = std::sync::mpsc::channel::<()>();
let el = EventLoopBuilder::with_user_event()
.with_any_thread(true)
.build()
.unwrap();
std::thread::spawn(move || {
let el = EventLoopBuilder::<()>::new()
@ -87,7 +83,7 @@ impl LesavkaClientApp {
let win0 = MonitorWindow::new(0, &el).expect("win0");
let win1 = MonitorWindow::new(1, &el).expect("win1");
el.run(move |_: Event<'_, ()>, _| {
el.run(move |_: Event<()>, _| {
while let Ok(pkt) = video_rx.try_recv() {
match pkt.id {
0 => win0.push_packet(pkt),

View File

@ -44,7 +44,7 @@ fi
mapfile -t TAGS < <(
for v in "${GC_VIDEOS[@]}"; do
udevadm info -q property -n "$v" |
sudo udevadm info -q property -n "$v" |
awk -F= '/^ID_PATH_TAG=/{print $2}'
done
)
@ -56,17 +56,14 @@ LEFT_TAG=${TAGS[0]}
RIGHT_TAG=${TAGS[1]}
sudo tee /etc/udev/rules.d/85-gc311.rules >/dev/null <<EOF
# autogenerated by installserver.sh DO NOT EDIT
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \
ATTRS{index}=="0", ENV{ID_PATH_TAG}=="$LEFT_TAG", SYMLINK+="lesavka_l_eye"
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \
ATTRS{index}=="0", ENV{ID_PATH_TAG}=="$RIGHT_TAG", SYMLINK+="lesavka_r_eye"
# auto-generated by lesavka/scripts/install-server.sh - DO NOT EDIT
SUBSYSTEM=="video4linux", ENV{ID_PATH_TAG}=="$LEFT_TAG", SYMLINK+="lesavka_l_eye"
SUBSYSTEM=="video4linux", ENV{ID_PATH_TAG}=="$RIGHT_TAG", SYMLINK+="lesavka_r_eye"
EOF
sudo udevadm control --reload
sudo udevadm trigger --subsystem-match=video4linux
udevadm settle
sudo udevadm settle
echo "==> 3. Rust toolchain"
sudo rustup default stable

View File

@ -7,12 +7,11 @@ use std::{pin::Pin, sync::Arc, time::Duration};
use tokio::{fs::{OpenOptions}, io::AsyncWriteExt, sync::Mutex};
use tokio_stream::{wrappers::ReceiverStream};
use tonic::{transport::Server, Request, Response, Status};
use tracing::{info, trace};
use tracing::{info, trace, warn};
use tracing_subscriber::{fmt, EnvFilter};
use udev::{MonitorBuilder};
use usb_gadget::UsbGadget;
use lesavka_server::{video, usb_reset};
use lesavka_server::{usb_gadget::UsbGadget, video, usb_reset};
use lesavka_common::lesavka::{
relay_server::{Relay, RelayServer},
@ -196,18 +195,18 @@ async fn main() -> anyhow::Result<()> {
let handler = Handler::make(gadget.clone()).await?;
tokio::spawn({
let gadget = gadget.clone();
async move {
loop {
tokio::time::sleep(Duration::from_secs(4)).await;
if LAST_HID_WRITE.elapsed().as_secs() > 3 {
warn!("no HID traffic in 3s cycling UDC");
let _ = gadget.cycle();
}
}
}
});
// tokio::spawn({
// let gadget = gadget.clone();
// async move {
// loop {
// tokio::time::sleep(Duration::from_secs(4)).await;
// if LAST_HID_WRITE.elapsed().as_secs() > 3 {
// warn!("no HID traffic in 3s cycling UDC");
// let _ = gadget.cycle();
// }
// }
// }
// });
println!("🌐 lesavka-server listening on 0.0.0.0:50051");
Server::builder()