idk
idk
This commit is contained in:
@@ -70,6 +70,29 @@ impl KeyboardHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_keystroke(&mut self) -> Option<char> {
|
||||
if let Some(scancode) = self.scancodes.try_next() {
|
||||
if let Ok(Some(key_event)) = self.keyboard.add_byte(scancode) {
|
||||
if let Some(key) = self.keyboard.process_keyevent(key_event) {
|
||||
match key {
|
||||
DecodedKey::Unicode(character) => {
|
||||
if character == b'\x08' as char { // checks if the character is a backspace
|
||||
interrupts::without_interrupts(|| {
|
||||
RENDERER.lock().backspace(); // runs the backspace function of the vga buffer to remove the last character
|
||||
});
|
||||
return None;
|
||||
} else {
|
||||
return Some(character);
|
||||
}
|
||||
},
|
||||
DecodedKey::RawKey(key) => { print!("{:?}", key) },
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_string(&mut self) -> String {
|
||||
let mut val = String::new();
|
||||
@@ -116,6 +139,15 @@ impl ScanCodeStream {
|
||||
.expect("ScanCodeStream::new has already been called once");
|
||||
ScanCodeStream { _private: () }
|
||||
}
|
||||
|
||||
pub fn try_next(&mut self) -> Option<u8> {
|
||||
let queue = SCANCODE_QUEUE.try_get().expect("not initialised");
|
||||
if let Ok(c) = queue.pop() {
|
||||
return Some(c);
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for ScanCodeStream {
|
||||
|
||||
@@ -22,6 +22,11 @@ impl Stdin {
|
||||
let chr = KEYBOARD.lock().get_keystroke().await;
|
||||
chr
|
||||
}
|
||||
|
||||
pub fn try_keystroke() -> Option<char> {
|
||||
let chr = KEYBOARD.lock().try_keystroke();
|
||||
chr
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Screen {}
|
||||
|
||||
@@ -4,6 +4,7 @@ pub mod application;
|
||||
pub mod tasks;
|
||||
pub mod os;
|
||||
pub mod frame;
|
||||
pub mod time;
|
||||
|
||||
|
||||
// this is where the standard library for the operating system will be defined
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
use core::time::Duration;
|
||||
use embedded_time::{Clock, Timer};
|
||||
use cmos_rtc::{ReadRTC, Time};
|
||||
use crate::println;
|
||||
use super::super::kernel::interrupts::GLOBALTIMER;
|
||||
use x86_64::instructions::interrupts;
|
||||
pub fn wait(seconds: i64) {
|
||||
let mut start = 0;
|
||||
interrupts::without_interrupts(||{
|
||||
start = GLOBALTIMER.lock().val;
|
||||
});
|
||||
|
||||
loop {
|
||||
let mut new = 0;
|
||||
interrupts::without_interrupts(||{
|
||||
new = GLOBALTIMER.lock().val;
|
||||
});
|
||||
if new + seconds > start {
|
||||
return
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn timer() {
|
||||
interrupts::without_interrupts(||{
|
||||
println!("{}", GLOBALTIMER.lock().val);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user