Decode scancode into characters and write them to the screen
This commit is contained in:
parent
7b7f3e9a23
commit
1f30d20311
19
src/main.rs
19
src/main.rs
@ -1,9 +1,9 @@
|
||||
mod controller;
|
||||
|
||||
use std::{os::mikros::{ipc, syscalls}, sync::OnceLock};
|
||||
use std::{fs::File, io::Write, os::mikros::{ipc, syscalls}, sync::OnceLock};
|
||||
|
||||
use controller::Ps2Controller;
|
||||
use pc_keyboard::{ScancodeSet, ScancodeSet2};
|
||||
use pc_keyboard::{layouts::Us104Key, EventDecoder, HandleControl, KeyState, Modifiers, ScancodeSet, ScancodeSet2};
|
||||
|
||||
static CONTROLLER: OnceLock<Ps2Controller> = OnceLock::new();
|
||||
|
||||
@ -110,12 +110,23 @@ fn main() {
|
||||
syslog_client.send_text_message("ps2", "Set keyboard to scan code set 2").unwrap();
|
||||
|
||||
let mut scancode_decoder = ScancodeSet2::new();
|
||||
let mut event_decoder = EventDecoder::new(Us104Key, HandleControl::Ignore);
|
||||
|
||||
let mut display = File::open("/dev/bga0").unwrap();
|
||||
|
||||
loop {
|
||||
let byte = controller.read_port1();
|
||||
let event = scancode_decoder.advance_state(byte).unwrap();
|
||||
if let Some(event) = event {
|
||||
dbg!(event);
|
||||
let Some(event) = event else {
|
||||
continue;
|
||||
};
|
||||
let key = event_decoder.process_keyevent(event);
|
||||
let Some(key) = key else {
|
||||
continue;
|
||||
};
|
||||
match key {
|
||||
pc_keyboard::DecodedKey::RawKey(_) => (),
|
||||
pc_keyboard::DecodedKey::Unicode(ch) => write!(display, "{}", ch).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user