From 795f10986f2ae55ad9d0c109059ac9d393254ae6 Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 5 Nov 2024 22:58:52 -0600 Subject: [PATCH] Add partial support for sending mouse position updates --- sysdata/libraries/intouch/src/lib.hb | 31 +++++++++++++++++-- sysdata/programs/horizon/src/main.hb | 14 +++++++-- sysdata/programs/ps2_mouse_driver/src/main.hb | 11 +++++-- sysdata/system_config.toml | 12 +++---- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index e592a7b..a8d3e36 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -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 } \ No newline at end of file diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 5c79dfc..e78a4b3 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -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 diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 62920d1..82c849e 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -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)) } } diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index e9e920c..b1d8a65 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -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"