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)
| 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. |
no outgoing calls