Add partial support for sending mouse position updates
This commit is contained in:
parent
85e63eb51c
commit
795f10986f
|
@ -1,15 +1,40 @@
|
|||
stn := @use("../../stn/src/lib.hb");
|
||||
.{log, buffer} := stn
|
||||
.{log, buffer, memory} := stn
|
||||
keycodes := @use("keycodes.hb")
|
||||
|
||||
events := @use("events.hb");
|
||||
.{KeyEvent, MouseEvent} := events
|
||||
|
||||
recieve_key_event := fn(): ?KeyEvent {
|
||||
buf := buffer.search("PS/2 Keyboard\0")
|
||||
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 {
|
||||
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("Haha\0")
|
||||
} else {
|
||||
log.info("Mouse event recieved in horizon.\0")
|
||||
dx := *mem_page
|
||||
dy := *mem_page + 1
|
||||
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
||||
return &mevent
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
|
@ -19,6 +19,13 @@ Window := struct {
|
|||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
main := fn(): int {
|
||||
I_LOOP := 10000
|
||||
loop {
|
||||
if I_LOOP >= 0 {
|
||||
break
|
||||
}
|
||||
I_LOOP += 1
|
||||
}
|
||||
win_buff := buffer.create("XHorizon\0")
|
||||
|
||||
screen := render.init(true)
|
||||
|
@ -60,9 +67,12 @@ main := fn(): int {
|
|||
|
||||
{
|
||||
// get input events from drivers via intouch
|
||||
key_event := intouch.recieve_key_event()
|
||||
// key_event := intouch.recieve_key_event()
|
||||
mouse_event := intouch.recieve_mouse_event()
|
||||
|
||||
if mouse_event != null {
|
||||
mouse_x += mouse_event.x_change
|
||||
mouse_y -= mouse_event.y_change
|
||||
}
|
||||
// render mouse
|
||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||
// Send events to focused window
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
.{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb")
|
||||
Vec2 := math.Vec2
|
||||
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb");
|
||||
.{MouseEvent} := intouch.events
|
||||
|
||||
i9 := packed struct {sign: bool, value: u8}
|
||||
Button := struct {id: u8}
|
||||
LeftButton := Button.(1)
|
||||
|
@ -91,10 +94,9 @@ set_up_mouse := fn(): void {
|
|||
button_states := @as(u8, 0)
|
||||
|
||||
main := fn(): int {
|
||||
mouse_buffer := buffer.create("PS/2 Mouse\0")
|
||||
format_page := memory.alloc(u8, 1024)
|
||||
|
||||
mouse_buffer := buffer.create("Mouse\0")
|
||||
|
||||
send_byte(0x64, 0xA8)
|
||||
log.info("Aux mouse device enabled.\0")
|
||||
|
||||
|
@ -142,7 +144,10 @@ main := fn(): int {
|
|||
dy.sign = (status & 0x20) == 0
|
||||
|
||||
if dy.value != 0 & dx.value != 0 {
|
||||
mouse_moved(.(dx, dy))
|
||||
event := MouseEvent.(dx.value, dy.value, 0, 0, 0)
|
||||
buffer.write(MouseEvent, &event, mouse_buffer)
|
||||
|
||||
// mouse_moved(.(dx, dy))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ resolution = "1024x768x24"
|
|||
# [boot.limine.ableos.modules.diskio_driver]
|
||||
# path = "boot:///diskio_driver.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.render_example]
|
||||
path = "boot:///render_example.hbf"
|
||||
# [boot.limine.ableos.modules.render_example]
|
||||
# path = "boot:///render_example.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.serial_driver]
|
||||
# path = "boot:///serial_driver.hbf"
|
||||
|
@ -37,8 +37,8 @@ path = "boot:///render_example.hbf"
|
|||
# [boot.limine.ableos.modules.serial_driver_test]
|
||||
# path = "boot:///serial_driver_test.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.horizon]
|
||||
# path = "boot:///horizon.hbf"
|
||||
[boot.limine.ableos.modules.horizon]
|
||||
path = "boot:///horizon.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.horizon_testing_program]
|
||||
# path = "boot:///horizon_testing_program.hbf"
|
||||
|
@ -58,8 +58,8 @@ path = "boot:///render_example.hbf"
|
|||
# [boot.limine.ableos.modules.pumpkin_print]
|
||||
# path = "boot:///pumpkin_print.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
# path = "boot:///ps2_mouse_driver.hbf"
|
||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
path = "boot:///ps2_mouse_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.app_bar]
|
||||
# path = "boot:///app_bar.hbf"
|
||||
|
|
Loading…
Reference in a new issue