forked from AbleOS/ableos
39 lines
864 B
Plaintext
39 lines
864 B
Plaintext
stn := @use("../../stn/src/lib.hb");
|
|
.{log, buffer, memory} := stn
|
|
keycodes := @use("keycodes.hb")
|
|
|
|
events := @use("events.hb");
|
|
.{KeyEvent, MouseEvent} := events
|
|
|
|
recieve_key_event := fn(): ?KeyEvent {
|
|
mem_page := memory.request_page(1)
|
|
|
|
buf_id := buffer.search("PS/2 Keyboard\0")
|
|
|
|
// Read out of the keyboard buffer here
|
|
buffer.recv(KeyEvent, buf_id, mem_page)
|
|
|
|
key_event := KeyEvent.(0, 0, 2)
|
|
// return key_event
|
|
|
|
return null
|
|
}
|
|
|
|
recieve_mouse_event := fn(): ?MouseEvent {
|
|
mem_page := memory.request_page(1)
|
|
|
|
buf_id := buffer.search("PS/2 Mouse\0")
|
|
|
|
// Read out of the Mouse buffer here
|
|
buffer.recv(MouseEvent, buf_id, mem_page)
|
|
if *mem_page != 0 {
|
|
log.info("Mouse events\0")
|
|
dx := *mem_page
|
|
dy := *mem_page + 1
|
|
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
|
return mevent
|
|
}
|
|
|
|
// log.error("No mouse events\0")
|
|
return MouseEvent.(0, 0, 0, 0, 0)
|
|
} |