cleanup
This commit is contained in:
parent
37d51d2afe
commit
864d2dca4e
2 changed files with 40 additions and 56 deletions
|
|
@ -82,48 +82,45 @@ pub fn kbd_callback() {
|
|||
static mut CTRL: bool = false;
|
||||
static mut ALT: bool = false;
|
||||
// let terminal_two: vga::terminal::Terminal = vga::Screen::new();
|
||||
let control = unsafe { cpuio::inb(0x64) };
|
||||
let control = cpuio::inb(0x64);
|
||||
if (control & 1) == 1 {
|
||||
let scancode = unsafe { cpuio::inb(0x60) };
|
||||
let scancode = cpuio::inb(0x60);
|
||||
let (is_release, scancode) = check_key_state(scancode);
|
||||
//TODO implement logic to translate scancode->ascii
|
||||
unsafe {//TODO remove unsafe
|
||||
match self::KEYMAP_US.get(scancode as usize) {
|
||||
Some(b"\0\0") => {
|
||||
match scancode {
|
||||
0x2A | 0x36 => {SHIFT = !is_release},
|
||||
0x38 => {ALT = !is_release; println!("atl")},
|
||||
0x1D => {CTRL = !is_release; println!("ctrl")},
|
||||
0x0F if !is_release => {
|
||||
CONTEXT.switch_term();
|
||||
CONTEXT.current_term().flush();
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
},
|
||||
// Some(b"2@") if ALT => {
|
||||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
// Some(b"1!") if CTRL && !is_release => {
|
||||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().keypress('>' as u8);
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
Some(ascii) if !is_release => {
|
||||
let mut terminal = CONTEXT.current_term();
|
||||
if SHIFT {
|
||||
terminal.keypress(ascii[1]);
|
||||
}
|
||||
else {
|
||||
terminal.keypress(ascii[0]);
|
||||
}
|
||||
},
|
||||
Some(_) => {},
|
||||
None =>{},
|
||||
// None => println!("nokey ctrl {:x}", control),
|
||||
match self::KEYMAP_US.get(scancode as usize) {
|
||||
Some(b"\0\0") => {
|
||||
match scancode {
|
||||
0x2A | 0x36 => {SHIFT = !is_release},
|
||||
0x38 => {ALT = !is_release; println!("atl")},
|
||||
0x1D => {CTRL = !is_release; println!("ctrl")},
|
||||
0x0F if !is_release => {
|
||||
CONTEXT.switch_term();
|
||||
CONTEXT.current_term().flush();
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
},
|
||||
// Some(b"2@") if ALT => {
|
||||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
// Some(b"1!") if CTRL && !is_release => {
|
||||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().keypress('>' as u8);
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
Some(ascii) if !is_release => {
|
||||
let mut terminal = CONTEXT.current_term();
|
||||
if SHIFT {
|
||||
terminal.keypress(ascii[1]);
|
||||
}
|
||||
else {
|
||||
terminal.keypress(ascii[0]);
|
||||
}
|
||||
},
|
||||
Some(_) => {},
|
||||
None =>{},
|
||||
}
|
||||
}
|
||||
}
|
||||
// current_screen.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,6 @@ fn shutdown() -> ! {
|
|||
}
|
||||
#[no_mangle]
|
||||
pub extern fn kmain() -> ! {
|
||||
// use vga::VgaScreen;
|
||||
// use vga::color::Color;
|
||||
// use vga::color::ColorCode;
|
||||
|
||||
println!(r#" ,--, "#);
|
||||
println!(r#" ,--.'| ,----, "#);
|
||||
println!(r#" ,--, | : .' .' \ "#);
|
||||
|
|
@ -78,15 +74,6 @@ pub extern fn kmain() -> ! {
|
|||
loop {
|
||||
keyboard::kbd_callback();
|
||||
}
|
||||
// let control = unsafe { cpuio::inb(0x64) };
|
||||
// if (control & 1) == 1 {
|
||||
// let keycode = unsafe { cpuio::inb(0x60) };
|
||||
// match keyboard::KEY_CODE_TO_ASCII.get(keycode as usize) {
|
||||
// Some(ascii) => print!("{}", *ascii as char),
|
||||
// None =>{},
|
||||
// // None => println!("nokey ctrl {:x}", control),
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"] #[no_mangle]
|
||||
|
|
@ -96,12 +83,12 @@ pub extern fn eh_personality() {
|
|||
|
||||
#[lang = "panic_fmt"] #[no_mangle]
|
||||
pub extern fn panic_fmt(
|
||||
// fmt: core::fmt::Arguments, file: &'static str, line: u32
|
||||
fmt: core::fmt::Arguments, file: &'static str, line: u32
|
||||
)
|
||||
-> ! {
|
||||
// println!("PANIC: {}", fmt);
|
||||
// println!("FILE: {}", file);
|
||||
// println!("LINE: {}", line);
|
||||
println!("PANIC: {}", fmt);
|
||||
println!("FILE: {}", file);
|
||||
println!("LINE: {}", line);
|
||||
loop {}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue