ableos/sysdata/programs/ps2_driver/src/main.hb

30 lines
683 B
Plaintext
Raw Normal View History

2024-08-30 08:03:12 -05:00
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
send_byte := fn(byte: u8): u8 {
memory.outb(24576, byte)
return memory.inb(24576)
2024-07-26 08:29:12 -05:00
}
2024-08-30 08:03:12 -05:00
main := fn(): int {
log.info("PS/2 Driver Loaded\0")
if send_byte(238) == 238 {
log.info("PS/2 Keyboard Echoed\0")
}
if send_byte(244) == 250 {
log.info("Enabled scanning\0")
}
buf := buffer.create("XKeyboard\0")
2024-08-30 08:03:12 -05:00
ptr := memory.request_page(1)
prev_input := 250
loop {
input := memory.inb(24576)
2024-08-30 08:03:12 -05:00
if input == prev_input {
continue
}
prev_input = input
keycode_str := string.display_int(input, ptr)
log.info(string.display_int(input, ptr))
buffer.send_message(keycode_str, buf)
2024-08-30 08:03:12 -05:00
}
return 0
}