From 0bc757164fae9be1f44b88f12a29d61addc90e8f Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 17 Sep 2024 19:26:37 -0500 Subject: [PATCH] Input work --- sysdata/libraries/horizon_api/src/lib.hb | 7 ++++--- sysdata/libraries/intouch/README.md | 20 ++++++++++++++++++++ sysdata/libraries/intouch/key_maps/ps2.map | 2 ++ sysdata/libraries/intouch/src/keycodes.hb | 8 ++++++++ sysdata/libraries/intouch/src/lib.hb | 22 ++++++++++++++++++++++ sysdata/libraries/stn/src/buffer.hb | 8 ++++---- sysdata/libraries/stn/src/memory.hb | 6 +++--- sysdata/system_config.toml | 11 +++++++---- 8 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 sysdata/libraries/intouch/README.md create mode 100644 sysdata/libraries/intouch/key_maps/ps2.map create mode 100644 sysdata/libraries/intouch/src/keycodes.hb create mode 100644 sysdata/libraries/intouch/src/lib.hb diff --git a/sysdata/libraries/horizon_api/src/lib.hb b/sysdata/libraries/horizon_api/src/lib.hb index 543bd14a8..c4fde748d 100644 --- a/sysdata/libraries/horizon_api/src/lib.hb +++ b/sysdata/libraries/horizon_api/src/lib.hb @@ -1,6 +1,8 @@ stn := @use("rel:../../stn/src/lib.hb"); .{string, memory, buffer} := stn +input := @use("rel:../../intouch/src/lib.hb") + WindowID := struct { host_id: int, window_id: int, @@ -14,11 +16,10 @@ create_window := fn(channel: int): void { windowing_system_buffer := buffer.search("XHorizon\0") if windowing_system_buffer == 0 { + return } else { msg := "\{01}\0" msg_length := 2 - @eca(void, 3, windowing_system_buffer, msg, msg_length) + return @eca(3, windowing_system_buffer, msg, msg_length) } - - return } \ No newline at end of file diff --git a/sysdata/libraries/intouch/README.md b/sysdata/libraries/intouch/README.md new file mode 100644 index 000000000..a7967e80f --- /dev/null +++ b/sysdata/libraries/intouch/README.md @@ -0,0 +1,20 @@ +# intouch +This library is exclusively focused on allowing your to get input regardless of which devices you have. + +Partially modeled after SDL. + +Current goals include +- Interfaces + - PS/2 +- Device Types + - Keyboard + - Mouse + +Longer Term goals +- Interfaces + - USB + - USB-HID +- Device Types + - Gamepads/controllers + - Drawing Tablets + - Microphones diff --git a/sysdata/libraries/intouch/key_maps/ps2.map b/sysdata/libraries/intouch/key_maps/ps2.map new file mode 100644 index 000000000..684cae9e4 --- /dev/null +++ b/sysdata/libraries/intouch/key_maps/ps2.map @@ -0,0 +1,2 @@ +0x0D -> press Tab +0xF0 0x0D -> release Tab diff --git a/sysdata/libraries/intouch/src/keycodes.hb b/sysdata/libraries/intouch/src/keycodes.hb new file mode 100644 index 000000000..836a3dba3 --- /dev/null +++ b/sysdata/libraries/intouch/src/keycodes.hb @@ -0,0 +1,8 @@ +KeyCode := u32 + +// https://www.libsdl.org/release/SDL-1.2.15/include/SDL_keysym.h +Backspace := KeyCode.(8) +Tab := KeyCode.(9) +Clear := KeyCode.(12) +Return := KeyCode.(13) +Pause := KeyCode.(19) diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb new file mode 100644 index 000000000..faeb8a5db --- /dev/null +++ b/sysdata/libraries/intouch/src/lib.hb @@ -0,0 +1,22 @@ +keycodes := @use("rel:keycodes.hb"); +.{KeyCode} := keycodes + +MouseEvent := struct { + x_change: u8, + y_change: u8, + left: u8, + middle: u8, + right: u8, +} + +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 diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index aa7c43f81..266afb809 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -1,22 +1,22 @@ string := @use("rel:string.hb") receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 { - return @eca(^u8, 4, buffer_id, memory_map_location, length) + return @eca(4, buffer_id, memory_map_location, length) } send_message := fn(msg: ^u8, buffer_id: int, length: int): void { - return @eca(void, 3, buffer_id, msg, length) + return @eca(3, buffer_id, msg, length) } create := fn(msg: ^u8): int { msg_length := @inline(string.length, msg); *msg = 0 - return @eca(int, 3, 0, msg, msg_length) + return @eca(3, 0, msg, msg_length) } search := fn(msg: ^u8): int { msg_length := @inline(string.length, msg); *msg = 3 - return @eca(int, 3, 0, msg, msg_length) + return @eca(3, 0, msg, msg_length) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index 39d9468db..d1da701b2 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -2,7 +2,7 @@ request_page := fn(page_count: u8): ^u8 { msg := "\{00}\{01}xxxxxxxx\0" msg_page_count := msg + 1; *msg_page_count = page_count - return @eca(^u8, 3, 2, msg, 12) + return @eca(3, 2, msg, 12) } release_page := fn(ptr: ^u8, page_count: u8): void { @@ -14,7 +14,7 @@ release_page := fn(ptr: ^u8, page_count: u8): void { msg_ptr := @as(^^u8, @bitcast(msg + 2)); *msg_ptr = ptr - return @eca(void, 3, 2, msg, 12) + return @eca(3, 2, msg, 12) } OutbMsg := struct {a: u8, b: u8, addr: u16, value: u8} @@ -27,7 +27,7 @@ outb := fn(addr: u16, value: u8): void { } inb := fn(addr: u16): u8 { - return @eca(u8, 3, 3, &InbMsg.(0, 0, addr), @sizeof(InbMsg)) + return @eca(3, 3, &InbMsg.(0, 0, addr), @sizeof(InbMsg)) } outl := fn(addr: u16, value: u32): void { diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 8a4e85d5f..e8d6df016 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -32,11 +32,11 @@ 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" +[boot.limine.ableos.modules.horizon_testing_program] +path = "boot:///horizon_testing_program.hbf" # [boot.limine.ableos.modules.dt_buffer_test] # path = "boot:///dt_buffer_test.hbf" @@ -44,6 +44,9 @@ resolution = "1024x768x24" [boot.limine.ableos.modules.svga_driver] path = "boot:///svga_driver.hbf" +[boot.limine.ableos.modules.ps2_driver] +path = "boot:///ps2_driver.hbf" + # [boot.limine.ableos.modules.filesystem_fat32] # path = "boot:///filesystem_fat32.hbf" # [boot.limine.ableos.modules.pumpkin_print]