2024-11-03 19:38:40 -06:00
|
|
|
stn := @use("../../stn/src/lib.hb");
|
2024-11-05 22:58:52 -06:00
|
|
|
.{log, buffer, memory} := stn
|
|
|
|
keycodes := @use("keycodes.hb")
|
|
|
|
|
2024-11-03 19:38:40 -06:00
|
|
|
events := @use("events.hb");
|
|
|
|
.{KeyEvent, MouseEvent} := events
|
2024-09-17 19:26:37 -05:00
|
|
|
|
2024-11-03 19:38:40 -06:00
|
|
|
recieve_key_event := fn(): ?KeyEvent {
|
2024-11-05 22:58:52 -06:00
|
|
|
mem_page := memory.request_page(1)
|
|
|
|
|
|
|
|
buf_id := buffer.search("PS/2 Keyboard\0")
|
|
|
|
|
2024-11-03 19:53:09 -06:00
|
|
|
// Read out of the keyboard buffer here
|
2024-11-05 22:58:52 -06:00
|
|
|
buffer.recv(KeyEvent, buf_id, mem_page)
|
|
|
|
|
|
|
|
key_event := KeyEvent.(0, 0, 2)
|
|
|
|
// return key_event
|
2024-11-03 19:53:09 -06:00
|
|
|
|
2024-11-09 20:44:08 -06:00
|
|
|
// return null
|
2024-09-17 19:26:37 -05:00
|
|
|
}
|
|
|
|
|
2024-11-07 09:57:39 -06:00
|
|
|
recieve_mouse_event := fn(): ?MouseEvent {
|
2024-11-05 22:58:52 -06:00
|
|
|
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)
|
2024-11-05 23:01:06 -06:00
|
|
|
if *mem_page != 0 {
|
2024-11-08 10:16:24 -06:00
|
|
|
log.info("Mouse events\0")
|
2024-11-09 20:44:08 -06:00
|
|
|
dx := @as(i8, @bitcast(*mem_page))
|
|
|
|
dy := @as(i8, @bitcast(*mem_page + 1))
|
2024-11-05 22:58:52 -06:00
|
|
|
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
2024-11-07 09:57:39 -06:00
|
|
|
return mevent
|
2024-11-05 22:58:52 -06:00
|
|
|
}
|
|
|
|
|
2024-11-08 10:16:24 -06:00
|
|
|
// log.error("No mouse events\0")
|
|
|
|
return MouseEvent.(0, 0, 0, 0, 0)
|
2024-11-03 19:38:40 -06:00
|
|
|
}
|