From d2b5f0951125aee1ff063eb07cad6781023c3bb9 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 8 Nov 2024 10:16:24 -0600 Subject: [PATCH] changes + lui examples --- repbuild/src/main.rs | 2 +- .../libraries/horizon_api/examples/label.lui | 1 + .../horizon_api/examples/vertical.lui | 3 ++ sysdata/libraries/horizon_api/src/ui.hb | 7 +-- .../horizon_api/src/widgets/widgets.hb | 1 + sysdata/libraries/intouch/src/lib.hb | 5 +- sysdata/programs/horizon/src/main.hb | 46 +++++++++++++------ sysdata/programs/ps2_mouse_driver/src/main.hb | 12 +++-- sysdata/system_config.toml | 12 ++--- 9 files changed, 55 insertions(+), 34 deletions(-) create mode 100644 sysdata/libraries/horizon_api/examples/label.lui create mode 100644 sysdata/libraries/horizon_api/examples/vertical.lui diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 898d1f74..05522e20 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -237,7 +237,7 @@ TERM_BACKDROP={} .for_each(drop); if !errors.is_empty() { - writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!"); + let _ = writeln!(errors, "!!! STOPPING DUE TO PREVIOUS ERRORS !!!"); std::eprint!("{errors}"); continue; } diff --git a/sysdata/libraries/horizon_api/examples/label.lui b/sysdata/libraries/horizon_api/examples/label.lui new file mode 100644 index 00000000..6db625c9 --- /dev/null +++ b/sysdata/libraries/horizon_api/examples/label.lui @@ -0,0 +1 @@ +(label "hello") diff --git a/sysdata/libraries/horizon_api/examples/vertical.lui b/sysdata/libraries/horizon_api/examples/vertical.lui new file mode 100644 index 00000000..ee6a4013 --- /dev/null +++ b/sysdata/libraries/horizon_api/examples/vertical.lui @@ -0,0 +1,3 @@ +(vertical + (label "hello") + (label "hello" color:red)) \ No newline at end of file diff --git a/sysdata/libraries/horizon_api/src/ui.hb b/sysdata/libraries/horizon_api/src/ui.hb index 93fae2d8..e6512a1d 100644 --- a/sysdata/libraries/horizon_api/src/ui.hb +++ b/sysdata/libraries/horizon_api/src/ui.hb @@ -6,11 +6,8 @@ render := @use("../../../libraries/render/src/lib.hb"); .{Surface} := render; .{Font} := render.text -UI := struct { - raw: ^u8, - raw_length: uint, - is_dirty: bool, - surface: Surface, +UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte +// children: ^^u8, } render_ui := fn(surface: Surface, ui: UI): void { diff --git a/sysdata/libraries/horizon_api/src/widgets/widgets.hb b/sysdata/libraries/horizon_api/src/widgets/widgets.hb index 2cda29ab..360b9943 100644 --- a/sysdata/libraries/horizon_api/src/widgets/widgets.hb +++ b/sysdata/libraries/horizon_api/src/widgets/widgets.hb @@ -23,6 +23,7 @@ Vertical := packed struct { magic: uint, // array of children, idk // use a vec or linked list or whatever + children: ^^u8, } diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index b6d751ca..ebfde1bf 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -27,12 +27,13 @@ recieve_mouse_event := fn(): ?MouseEvent { // 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.warn("No mouse events\0") - return null + // log.error("No mouse events\0") + return MouseEvent.(0, 0, 0, 0, 0) } \ No newline at end of file diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 8afd4f6b..33d3185b 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -9,6 +9,7 @@ horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); render := @use("../../../libraries/render/src/lib.hb"); .{Surface} := render; .{Font} := render.text + intouch := @use("../../../libraries/intouch/src/lib.hb") Window := struct { @@ -42,30 +43,45 @@ main := fn(): int { mouse_x := 0 mouse_y := 0 text_label := new_label("Hi\0") - widgets := "()\0" - ui := sexpr_parser(widgets) + // widgets := "()\0" + // ui := sexpr_parser(widgets) + + mouse_event := intouch.recieve_mouse_event() + + if mouse_event == null { + log.warn("null\0") + } else { + log.warn("not null\0") + } loop { // Clear the screen render.clear(screen, render.black) // TODO: Read the window buffer here - // { - // ret := buffer.recv([u8; 4096], win_buff, mem_buf) - // // for some reason this null check causes the compiler to spin forever - // // if ret == null { - // // log.info("No messages\0") - // // } else { - // // log.info("Handle Messages\0") - // // } - // } - { - // get input events from drivers via intouch - // key_event := intouch.recieve_key_event() + ret := buffer.recv([u8; 4096], win_buff, mem_buf) + // for some reason this null check causes the compiler to spin forever + // if ret == null { + // log.info("No messages\0") + // } else { + // log.info("Handle Messages\0") + // } + } + + // get input events from drivers via intouch + // key_event := intouch.recieve_key_event(); + // log.info("before mouse event check\0"); + { + // Note: MLokis, this inline halts the compiler forever + // mouse_event := @inline(intouch.recieve_mouse_event) + // Note: MLokis, this function returns null unless the mouse is moving mouse_event := intouch.recieve_mouse_event() + // + if mouse_event != null { - log.info("Mouse event") + log.warn("Mouse event recieved\0") + mouse_x += mouse_event.x_change mouse_y += mouse_event.y_change set_label_text(text_label, "Mouse Moved\0") diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 82c849ee..1f66adad 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -13,13 +13,13 @@ Button4 := Button.(8) Button5 := Button.(16) mouse_moved := fn(delta: Vec2(i9)): void { - log.info("Mouse movement.\0") + // log.info("Mouse movement.\0") } button_event := fn(button: Button, pressed: bool): void { if pressed { - log.info("Mouse-button pressed.\0") + // log.info("Mouse-button pressed.\0") } else { - log.info("Mouse-button released.\0") + // log.info("Mouse-button released.\0") } } @@ -132,7 +132,7 @@ main := fn(): int { button_states ^= changes - log.info(string.display_int(status, format_page, 10)) + // log.info(string.display_int(status, format_page, 10)) dx := i9.(false, 0) dy := i9.(false, 0) @@ -144,7 +144,9 @@ main := fn(): int { dy.sign = (status & 0x20) == 0 if dy.value != 0 & dx.value != 0 { - event := MouseEvent.(dx.value, dy.value, 0, 0, 0) + y_change := dy.value + x_change := dx.value + event := MouseEvent.(x_change, y_change, 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 34b3a7ba..dfe4619d 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"