diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 4ec8dfc..8b1e770 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -407,7 +407,10 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> { "-parallel", "none", "-monitor", "none", "-machine", accel, - "-cpu", "max", "-serial", "stdio", + "-cpu", "max", + "-serial", "stdio", + "-d", "trace:ps2_mouse_send_packet", + //"-d", "trace:ps2_mouse_event_disabled", "-audiodev", "pa,id=speaker", "-machine", "pcspk-audiodev=speaker", "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", diff --git a/sysdata/programs/mouse_driver/src/main.hb b/sysdata/programs/mouse_driver/src/main.hb index f1c24f3..40d1076 100644 --- a/sysdata/programs/mouse_driver/src/main.hb +++ b/sysdata/programs/mouse_driver/src/main.hb @@ -3,6 +3,62 @@ render := @use("../../../libraries/render/src/lib.hb") ACK := 250 +send_byte := fn(target: u8, data: u8): void { + loop if (memory.inb(0x64) & 2) == 0 break + memory.outb(target, data) +} + +reset_mouse := fn(): void { + @inline(send_byte, 0x64, 0xD4) + @inline(send_byte, 0x60, 0xFF) + loop if memory.inb(0x60) == 0xAA return +} + +send_command_byte := fn(byte: u8): void { + @inline(send_byte, 0x64, 0xD4) + @inline(send_byte, 0x60, byte) + loop if memory.inb(0x60) == 0xFA return +} + +set_defaults := fn(): void @inline(send_command_byte, 0xF6) +disable_streaming := fn(): void @inline(send_command_byte, 0xF5) +enable_streaming := fn(): void @inline(send_command_byte, 0xF4) + +set_remote_mode := fn(): void @inline(send_command_byte, 0xF0) +set_warp_mode := fn(): void @inline(send_command_byte, 0xEE) +reset_warp_mode := fn(): void @inline(send_command_byte, 0xEC) +set_stream_mode := fn(): void @inline(send_command_byte, 0xEA) + +set_non_linear_scaling := fn(): void @inline(send_command_byte, 0xE7) +set_linear_scaling := fn(): void @inline(send_command_byte, 0xE6) + +SampleRate := struct { value: u8 } +sr10 := SampleRate.(10) +sr20 := SampleRate.(20) +sr40 := SampleRate.(40) +sr60 := SampleRate.(60) +sr80 := SampleRate.(80) +sr100 := SampleRate.(100) +sr200 := SampleRate.(200) + +set_sample_rate := fn(sample_rate: SampleRate): void { + @inline(send_command_byte, 0xE6) + @inline(send_command_byte, sample_rate.value) +} + +Resolution := struct { value: u8 } +res_1count_per_mm := Resolution.(0) +res_2count_per_mm := Resolution.(01) +res_4count_per_mm := Resolution.(2) +res_8count_per_mm := Resolution.(3) + +set_resolution := fn(resolution: Resolution): void { + @inline(send_command_byte, 0xE6) + @inline(send_command_byte, resolution.value) +} + + + wait_for := fn(for: u8): void { log.info("Start waiting\0") loop { @@ -44,8 +100,8 @@ main := fn(): int { send_command(0xF4) b := get_response() - x := -0 - y := -0 + x := @as(int, 0) + y := @as(int, 0) loop { // render.clear(screen, render.black) @@ -55,17 +111,30 @@ main := fn(): int { log.info("Yeah\0") break - } else { } } status := memory.inb(0x60) log.info(string.display_int(status, format_page, 10)) - d_x := memory.inb(0x60) - log.info(string.display_int(d_x, format_page, 10)) + d_x := @as(i32, @bitcast(@as(u32, @intcast(memory.inb(0x60))))) + if (status & 0x10) > 0 { + d_x = d_x | 0xFFFFFF00 + } x = x + d_x - d_y := memory.inb(0x60) + if x < 0 { + x = 0 + } + log.info(string.display_int(d_x, format_page, 10)) + + d_y := @as(i32, @bitcast(@as(u32, @intcast(memory.inb(0x60))))) + if (status & 0x20) > 0 { + d_y = d_y | 0xFFFFFF00 + } y = y + d_y + if y < 0 { + y = 0 + } + log.info(string.display_int(d_y, format_page, 10)) // render.put_rect(screen, .(x, y), .(x + 10, y + 10), render.white) diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 6f4aa2f..3ea0ea9 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -3,8 +3,8 @@ default_entry = 1 timeout = 0 verbose = false -interface_resolution = "1600x900x24" -# interface_resolution = "640x480x32" +# interface_resolution = "1600x900x24" +interface_resolution = "640x480x32" # Terminal related settings # term_wallpaper = "boot:///background.bmp" term_wallpaper = "boot:///empty-background.bmp" @@ -15,8 +15,8 @@ comment = "Default AbleOS boot entry." protocol = "limine" kernel_path = "boot:///kernel_${ARCH}" kernel_cmdline = "" -# resolution = "640x480x32" -resolution = "1600x900x24" +resolution = "640x480x32" +# resolution = "1600x900x24" [boot.limine.ableos.modules]