client server hid stream fix
This commit is contained in:
parent
42f9a0f4ff
commit
8bfe17e45c
@ -1,6 +1,6 @@
|
||||
// client/src/input/keyboard.rs
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::{collections::HashSet, sync::atomic::{AtomicU32, Ordering}};
|
||||
use evdev::{Device, EventType, InputEvent, KeyCode};
|
||||
use tokio::sync::broadcast::Sender;
|
||||
use tracing::{debug, error, warn};
|
||||
@ -16,6 +16,10 @@ pub struct KeyboardAggregator {
|
||||
pressed_keys: HashSet<KeyCode>,
|
||||
}
|
||||
|
||||
/*───────── helpers ───────────────────────────────────────────────────*/
|
||||
/// Monotonically‑increasing ID that can be logged on server & client.
|
||||
static SEQ: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
impl KeyboardAggregator {
|
||||
pub fn new(dev: Device, dev_mode: bool, tx: Sender<KeyboardReport>) -> Self {
|
||||
let _ = dev.set_nonblocking(true);
|
||||
@ -44,11 +48,10 @@ impl KeyboardAggregator {
|
||||
}
|
||||
|
||||
let report = self.build_report();
|
||||
if self.dev_mode { debug!(?report, "kbd"); }
|
||||
static COUNTER: AtomicU32 = AtomicU32::new(0);
|
||||
let id = COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||
// Generate a local sequence number for debugging/log‑merge only.
|
||||
let id = SEQ.fetch_add(1, Ordering::Relaxed);
|
||||
if self.dev_mode { debug!(seq = id, ?report, "kbd"); }
|
||||
let _ = self.tx.send(KeyboardReport {
|
||||
seq: id,
|
||||
data: report.to_vec()
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user