keyboard input is now in irq compliant mode
This commit is contained in:
parent
d382b623a4
commit
1c606561a1
2 changed files with 35 additions and 26 deletions
|
|
@ -7,3 +7,4 @@ $(grub-iso): $(kernel) $(grub-cfg) Makefile
|
||||||
@cp $(grub-cfg) $(isodir)/boot/grub
|
@cp $(grub-cfg) $(isodir)/boot/grub
|
||||||
@cp $(kernel) $(isodir)/boot/$(OS)
|
@cp $(kernel) $(isodir)/boot/$(OS)
|
||||||
@grub-mkrescue -o $@ $(isodir) 2>/dev/null
|
@grub-mkrescue -o $@ $(isodir) 2>/dev/null
|
||||||
|
@printf "\r\033[38;5;117m✓ GRUB ==> $(grub-iso)\033[0m\033[K\n"
|
||||||
|
|
|
||||||
|
|
@ -76,33 +76,41 @@ fn check_key_state(key: u8) -> (bool, usize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kbd_callback() {
|
fn get_scancode() -> u8 {
|
||||||
static mut SHIFT: bool = false;
|
let mut scancode = 0;
|
||||||
static mut CTRL: bool = false;
|
loop {
|
||||||
static mut ALT: bool = false;
|
if cpuio::inb(0x60) != scancode {
|
||||||
let control = cpuio::inb(0x64);
|
scancode = cpuio::inb(0x60);
|
||||||
if (control & 1) == 1 {
|
if scancode > 0 {
|
||||||
let scancode = cpuio::inb(0x60);
|
return scancode;
|
||||||
let (is_release, scancode) = check_key_state(scancode);
|
|
||||||
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,
|
|
||||||
0x1D => CTRL = !is_release,
|
|
||||||
0x0E if !is_release => {
|
|
||||||
vga::VGA.backspace();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
Some(ascii) if !is_release => {
|
|
||||||
let sym = if SHIFT { ascii[1] } else { ascii[0] };
|
|
||||||
vga::VGA.keypress(sym);
|
|
||||||
}
|
|
||||||
Some(_) => {}
|
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn kbd_callback() {
|
||||||
|
static mut SHIFT: bool = false;
|
||||||
|
static mut CTRL: bool = false;
|
||||||
|
static mut ALT: bool = false;
|
||||||
|
let scancode = get_scancode();
|
||||||
|
let (is_release, scancode) = check_key_state(scancode);
|
||||||
|
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,
|
||||||
|
0x1D => CTRL = !is_release,
|
||||||
|
0x0E if !is_release => {
|
||||||
|
vga::VGA.backspace();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
Some(ascii) if !is_release => {
|
||||||
|
let sym = if SHIFT { ascii[1] } else { ascii[0] };
|
||||||
|
vga::VGA.keypress(sym);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue