From e40a22fccdee7b9c1b0afce5031f0b4938f99c47 Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 11 Nov 2024 01:23:14 -0600 Subject: [PATCH] Commit --- sysdata/libraries/intouch/src/events.hb | 10 ++---- sysdata/libraries/intouch/src/lib.hb | 11 +++++++ sysdata/programs/horizon/src/main.hb | 31 ++++++++----------- .../programs/ps2_keyboard_driver/src/main.hb | 18 +++++++++-- sysdata/programs/render_example/src/main.hb | 2 +- sysdata/system_config.toml | 16 +++++----- 6 files changed, 51 insertions(+), 37 deletions(-) diff --git a/sysdata/libraries/intouch/src/events.hb b/sysdata/libraries/intouch/src/events.hb index c26fb95..546cb52 100644 --- a/sysdata/libraries/intouch/src/events.hb +++ b/sysdata/libraries/intouch/src/events.hb @@ -1,13 +1,9 @@ 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, +KeyEvent := packed struct { + up: bool, + just_triggered: bool, key: KeyCode, } diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index a6c5a91..14ac86e 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -6,6 +6,17 @@ events := @use("events.hb"); .{KeyEvent, MouseEvent} := events recieve_key_event := fn(): ?KeyEvent { + kevent := KeyEvent.(false, false, 0) + + buf_id := buffer.search("PS/2 Keyboard\0") + + // Read out of the Keyboard buffer here + buffer.recv(KeyEvent, buf_id, &kevent) + + if kevent.just_triggered { + return kevent + } + return null } diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 9ead559..114c492 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -56,23 +56,13 @@ main := fn(): int { loop { // Clear the screen render.clear(screen, render.black) + render.put_surface(screen, wallpaper, .(0, 0), false) // TODO: Read the window buffer here { - // buffer.recv([u8; 4096], win_buff, mem_buf) - // // for some reason this null check causes the compiler to spin forever - // if *mem_buf == 0 { - // 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"); - if false { // Scroll bar :ThumbsUp: render.put_rect(screen, .(100, 100), .(100, 10), render.white) @@ -83,6 +73,7 @@ main := fn(): int { } { + // Bottom Bar pos := Vec2(uint).(1, screen.height - 21) render_label_to_surface(screen, text_label, font, pos) render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white) @@ -91,6 +82,14 @@ main := fn(): int { // Screen border render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + // get input events from drivers via intouch + if false { + key_event := intouch.recieve_key_event() + if key_event != null { + log.info("Key event \0") + } + } + { mouse_event := intouch.recieve_mouse_event() // @@ -133,13 +132,9 @@ main := fn(): int { } } - // render mouse - lum := render.indexptr(screen, mouse_x, mouse_y) - if lum.r / 3 + lum.g / 3 + lum.b / 3 < 128 { - render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white) - } else { - render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black) - } + render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black) + render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white) + // Send events to focused window } diff --git a/sysdata/programs/ps2_keyboard_driver/src/main.hb b/sysdata/programs/ps2_keyboard_driver/src/main.hb index 150d3b0..41485ca 100644 --- a/sysdata/programs/ps2_keyboard_driver/src/main.hb +++ b/sysdata/programs/ps2_keyboard_driver/src/main.hb @@ -1,4 +1,8 @@ -.{memory, log, buffer} := @use("../../../libraries/stn/src/lib.hb") +stn := @use("../../../libraries/stn/src/lib.hb"); +.{memory, log, buffer} := stn + +intouch := @use("../../../libraries/intouch/src/lib.hb"); +.{KeyEvent} := intouch send_byte := fn(byte: u8): u8 { memory.outb(96, byte) @@ -6,23 +10,31 @@ send_byte := fn(byte: u8): u8 { } main := fn(): int { - buf := buffer.create("XKeyboard\0") + buf := buffer.create("PS/2 Keyboard\0") _ = send_byte(238) log.info("PS/2 Driver Loaded\0") + if send_byte(238) == 238 { log.info("PS/2 Keyboard Echoed\0") } + if send_byte(244) == 250 { log.info("Enabled scanning\0") } + prev_input := 250 loop { + loop if (memory.inb(0x64) & 0x20) == 0x20 break + input := memory.inb(96) + if input == prev_input { continue } prev_input = input - buffer.write(u8, &input, buf) + kevent := KeyEvent.(false, true, input) + + buffer.write(KeyEvent, &kevent, buf) } return 0 } \ No newline at end of file diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb index ab66cfa..77cb04c 100644 --- a/sysdata/programs/render_example/src/main.hb +++ b/sysdata/programs/render_example/src/main.hb @@ -1 +1 @@ -.{example: main} := @use("./examples/orbit.hb") \ No newline at end of file +.{example: main} := @use("./examples/text.hb") \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index da9cbd0..406a1ac 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -25,17 +25,17 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.render_example] # path = "boot:///render_example.hbf" -# [boot.limine.ableos.modules.horizon] -# path = "boot:///horizon.hbf" +[boot.limine.ableos.modules.horizon] +path = "boot:///horizon.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.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" -[boot.limine.ableos.modules.sunset_client] -path = "boot:///sunset_client.hbf" +# [boot.limine.ableos.modules.sunset_client] +# path = "boot:///sunset_client.hbf" -[boot.limine.ableos.modules.sunset_server] -path = "boot:///sunset_server.hbf" +# [boot.limine.ableos.modules.sunset_server] +# path = "boot:///sunset_server.hbf"