From b795215b62cf4e5212b4e5fb4dfd0b5ff8b2d2f5 Mon Sep 17 00:00:00 2001 From: Able Date: Sun, 3 Nov 2024 19:38:40 -0600 Subject: [PATCH] enable horizon and ps2 driver --- sysdata/libraries/intouch/src/events.hb | 22 ++++++++ sysdata/libraries/intouch/src/lib.hb | 29 ++++------ sysdata/programs/horizon/src/main.hb | 54 ++++++++++++------- sysdata/programs/ps2_mouse_driver/src/main.hb | 15 +----- sysdata/system_config.toml | 4 +- 5 files changed, 69 insertions(+), 55 deletions(-) create mode 100644 sysdata/libraries/intouch/src/events.hb diff --git a/sysdata/libraries/intouch/src/events.hb b/sysdata/libraries/intouch/src/events.hb new file mode 100644 index 000000000..1d5442385 --- /dev/null +++ b/sysdata/libraries/intouch/src/events.hb @@ -0,0 +1,22 @@ +keycodes := @use("keycodes.hb"); +.{KeyCode} := keycodes + +KeyEvent := struct { + // 0 if down + // 1 if up + up: u8, + // 0 if not just triggered + // 1 if just triggered + just_triggered: u8, + key: KeyCode, +} + +MouseEvent := struct { + x_change: u8, + y_change: u8, + left: u8, + middle: u8, + right: u8, +} + +GamepadEvent := struct {} \ No newline at end of file diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index 86175a6c0..2cfde5557 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -1,22 +1,13 @@ -keycodes := @use("keycodes.hb"); -.{KeyCode} := keycodes +stn := @use("../../stn/src/lib.hb"); +.{log, buffer} := stn +events := @use("events.hb"); +.{KeyEvent, MouseEvent} := events -MouseEvent := struct { - x_change: u8, - y_change: u8, - left: u8, - middle: u8, - right: u8, +recieve_key_event := fn(): ?KeyEvent { + log.info("hi\0") + return null } -KeyEvent := struct { - // 0 if down - // 1 if up - up: u8, - // 0 if not just triggered - // 1 if just triggered - just_triggered: u8, - key: KeyCode, -} - -GamepadEvent := struct {} \ No newline at end of file +recieve_mouse_event := fn(): ?MouseEvent { + 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 2ab0368c5..be9f9248f 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -5,6 +5,7 @@ stn := @use("../../../libraries/stn/src/lib.hb"); horizon_api := @use("../../../libraries/horizon_api/src/lib.hb") render := @use("../../../libraries/render/src/lib.hb") +intouch := @use("../../../libraries/intouch/src/lib.hb") Window := struct { // TODO: Replace this with widgets @@ -39,6 +40,9 @@ main := fn(): int { // really we should null check but it is a bit broked font := @unwrap(render.text.font_from_psf2(@bitcast(&psf))) + mouse_x := 0 + mouse_y := 0 + loop { // Clear the screen render.clear(screen, render.black) @@ -54,6 +58,16 @@ main := fn(): int { // } } + { + // get input events from drivers via intouch + key_event := intouch.recieve_key_event() + mouse_event := intouch.recieve_mouse_event() + + // render mouse + render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white) + // Send events to focused window + } + if pos_inner.x == 0 | pos_inner.x == window.width - side { vel_inner.x = -vel_inner.x color = random.any(render.Color) @@ -65,29 +79,29 @@ main := fn(): int { // TODO: Get windows out of a collection and iter through window_count := 0 - loop { - render.clear(window, render.black) - render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + // loop { + // render.clear(window, render.black) - // Draw the decorators - { - render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white) - render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white) - render.put_text(window, font, .(window.width / 2, 1), render.white, str) - } - render.put_filled_rect(window, pos_inner, .(side, side), color) + // // Draw the decorators + // { + // render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white) + // render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white) + // render.put_text(window, font, .(window.width / 2, 1), render.white, str) + // } + // render.put_filled_rect(window, pos_inner, .(side, side), color) - // Apply the image to the screen - pos := Vec2(uint).(x, 100) + // // Apply the image to the screen + // pos := Vec2(uint).(x, 100) - render.put_surface(screen, window, pos, false) - if window_count >= 1 { - x = 0 - break - } - window_count += 1 - x += screen.width / 2 - } + // render.put_surface(screen, window, pos, false) + // if window_count >= 1 { + // x = 0 + // break + // } + // window_count += 1 + // x += screen.width / 2 + // } pos_inner += @bitcast(vel_inner) // Sync the screen diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 98b360a2b..62920d1c6 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -1,8 +1,6 @@ .{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb") Vec2 := math.Vec2 -render := @use("../../../libraries/render/src/lib.hb") - i9 := packed struct {sign: bool, value: u8} Button := struct {id: u8} LeftButton := Button.(1) @@ -95,10 +93,7 @@ button_states := @as(u8, 0) main := fn(): int { format_page := memory.alloc(u8, 1024) - screen := render.init(true) - - // Clear the screen to black. - render.clear(screen, render.black) + mouse_buffer := buffer.create("Mouse\0") send_byte(0x64, 0xA8) log.info("Aux mouse device enabled.\0") @@ -148,15 +143,7 @@ main := fn(): int { if dy.value != 0 & dx.value != 0 { mouse_moved(.(dx, dy)) - x += dx.value - y += dy.value } - - render.clear(screen, render.black) - - render.put_rect(screen, .(x, y), .(10, 10), render.white) - // Sync the screen - render.sync(screen) } return 0 diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 8f8b17913..e4000d463 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -37,8 +37,8 @@ resolution = "1024x768x24" # [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"