MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / push_event

Method push_event

crates/virtual-machine/src/devices/keyboard.rs:48–57  ·  view source on GitHub ↗

Push a key event from the host. `scancode` is truncated to 16 bits; `pressed` distinguishes a key-down from a key-up. Drops the event when the queue is full so a stalled guest cannot make the host leak memory.

(&mut self, scancode: u16, pressed: bool)

Source from the content-addressed store, hash-verified

46 /// Push a key event from the host. `scancode` is truncated to 16 bits;
47 /// `pressed` distinguishes a key-down from a key-up. Drops the event when the
48 /// queue is full so a stalled guest cannot make the host leak memory.
49 pub fn push_event(&mut self, scancode: u16, pressed: bool) {
50 if self.queue.len() >= KBD_QUEUE_CAP {
51 return;
52 }
53 let mut ev = scancode as u32;
54 if pressed {
55 ev |= KBD_PRESSED_BIT;
56 }
57 self.queue.push_back(ev);
58 }
59
60 /// Number of events waiting to be read.

Callers 4

keyboard_pushMethod · 0.80
queue_is_boundedFunction · 0.80

Calls

no outgoing calls

Tested by 3

queue_is_boundedFunction · 0.64