Detecting keypresses

This commit is contained in:
Talha Qamar 2024-08-30 18:03:12 +05:00
parent 0d3641e199
commit 1615297536
4 changed files with 44 additions and 4 deletions

View file

@ -4,9 +4,7 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u
return @eca(^u8, 4, buffer_id, memory_map_location, length)
}
send_message := fn(buffer_id: int): void {
message := "Hello there\0"
message_length := string.length(message)
send_message := fn(buffer_id: int, message: ^u8, message_length: int): void {
@eca(i32, 3, buffer_id, message, message_length)
return
}

View file

@ -0,0 +1,11 @@
[package]
name = "ps2_driver"
authors = ["Talha Qamar"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -1,2 +1,31 @@
main:= fn(): int {
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
send_byte := fn(byte: u8): u8 {
memory.outb(0, 96, byte)
input := memory.inb(0, 96)
return input
}
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()
ptr := memory.request_page(1)
prev_input := 250
loop {
input := memory.inb(0, 96)
if input == prev_input {
continue
}
prev_input = input
keycode_str := string.display_int(input, ptr)
log.info(string.display_int(buf))
buffer.send_message(buf, keycode_str, string.length(keycode_str))
}
return 0
}

View file

@ -22,6 +22,8 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules.a_serial_driver]
path = "boot:///a_serial_driver.hbf"
[boot.limine.ableos.modules.ps2_driver]
path = "boot:///ps2_driver.hbf"
[boot.limine.ableos.modules.diskio_driver]
path = "boot:///diskio_driver.hbf"