Add an add_scancode function and call it from keyboard interrupt handler

This commit is contained in:
Philipp Oppermann
2020-03-27 13:25:43 +01:00
parent 71b10a70df
commit b1be646e46
2 changed files with 15 additions and 18 deletions

View File

@@ -1,4 +1,18 @@
use crate::println;
use conquer_once::spin::OnceCell;
use crossbeam_queue::ArrayQueue;
static SCANCODE_QUEUE: OnceCell<ArrayQueue<u8>> = OnceCell::uninit();
/// Called by the keyboard interrupt handler
///
/// Must not block or allocate.
pub(crate) fn add_scancode(scancode: u8) {
if let Ok(queue) = SCANCODE_QUEUE.try_get() {
if let Err(_) = queue.push(scancode) {
println!("WARNING: scancode queue full; dropping keyboard input");
}
} else {
println!("WARNING: scancode queue uninitialized");
}
}