From c49eb97397c4d77eae4466378b85af7c721916e4 Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 19 Feb 2022 09:07:33 -0600 Subject: [PATCH] patchup --- ableos/assets/key_event.txt | 17 ++++++++++++++ ableos/src/arch/x86_64/interrupts.rs | 3 ++- ableos/src/rhai_shell/mod.rs | 33 ++++++++++++++++------------ 3 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 ableos/assets/key_event.txt diff --git a/ableos/assets/key_event.txt b/ableos/assets/key_event.txt new file mode 100644 index 0000000..0617522 --- /dev/null +++ b/ableos/assets/key_event.txt @@ -0,0 +1,17 @@ +pub struct KeyEvent{ + lctrl 1 + rctrl 2 + lalt 3 + ralt 4 + lsup 5 + rsup 6 + lshift 7 + rshift 8 + caps 9 + + down 10 + # Keycodes + key 11-32 +} + + diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 1dca10a..1649093 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -1,7 +1,8 @@ use crate::{ arch::{drivers::vga::WRITER, gdt}, kernel_state::KERNEL_STATE, - print, println, KEYBUFF, + print, println, + rhai_shell::KEYBUFF, }; use lazy_static::lazy_static; diff --git a/ableos/src/rhai_shell/mod.rs b/ableos/src/rhai_shell/mod.rs index b14bf64..1fde8dc 100644 --- a/ableos/src/rhai_shell/mod.rs +++ b/ableos/src/rhai_shell/mod.rs @@ -1,20 +1,7 @@ use alloc::vec::Vec; pub fn rhai_shell() { - let mut engine = rhai::Engine::new(); - - engine.on_print(|x| println!("{}", x)); - - engine.on_debug(|x, src, pos| { - let src = src.unwrap_or("unknown"); - println!("DEBUG: {} at {:?}: {}", src, pos, x); - debug!("{} at {:?}: {}", src, pos, x); - }); - - engine.register_fn("afetch", afetch); - engine.register_fn("set_hostname", set_hostname); - engine.register_fn("shutdown", shutdown); - + let engine = engine_construction(); let mut scope = rhai::Scope::new(); let mut buf = String::new(); @@ -46,6 +33,7 @@ lazy_static::lazy_static!( ); use alloc::string::{String, ToString}; +use rhai::Engine; use x86_64::instructions::interrupts::{disable, enable}; use crate::{ @@ -74,3 +62,20 @@ pub fn set_hostname(name: String) { let mut kstate = KERNEL_STATE.lock(); kstate.hostname = name; } + +fn engine_construction() -> Engine { + let mut engine = rhai::Engine::new(); + + engine.on_print(|x| println!("{}", x)); + + engine.on_debug(|x, src, pos| { + let src = src.unwrap_or("unknown"); + println!("DEBUG: {} at {:?}: {}", src, pos, x); + debug!("{} at {:?}: {}", src, pos, x); + }); + + engine.register_fn("afetch", afetch); + engine.register_fn("set_hostname", set_hostname); + engine.register_fn("shutdown", shutdown); + engine +}