diff --git a/sysdata/programs/mouse_driver/src/main.hb b/sysdata/programs/mouse_driver/src/main.hb index 571aba0..90d39dc 100644 --- a/sysdata/programs/mouse_driver/src/main.hb +++ b/sysdata/programs/mouse_driver/src/main.hb @@ -55,8 +55,6 @@ 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) -resend_packet := fn(): void @inline(send_command_byte, 0xFE) - SampleRate := struct {value: u8} sr10 := SampleRate.(10) sr20 := SampleRate.(20) @@ -82,10 +80,14 @@ set_resolution := fn(resolution: Resolution): void { @inline(send_command_byte, resolution.value) } -set_up_mouse := fn(): void { - @inline(reset_mouse) - @inline(set_resolution, res_8count_per_mm) - @inline(enable_streaming) +MouseID := struct {data: u8} +id0 := MouseID.(0) +id3 := MouseID.(3) +id4 := MouseID.(4) + +get_mouse_id := fn(): MouseID { + @inline(send_command_byte, 0xF2) + return MouseID.(memory.inb(0x60)) } button_states := @as(u8, 0) @@ -96,7 +98,24 @@ main := fn(): int { send_byte(0x64, 0xA8) log.info("Aux mouse device enabled.\0") - set_up_mouse() + reset_mouse() + + mouse_id := get_mouse_id() + log.info("Mouse ID:\0") + log.info(string.display_int(mouse_id.data, format_page, 10)) + + if mouse_id.data == 0 { + set_sample_rate(sr200) + set_sample_rate(sr100) + set_sample_rate(sr80) + mouse_id = get_mouse_id() //Returns 0 ;~; + set_sample_rate(sr100) + } + + log.info("Mouse ID:\0") + log.info(string.display_int(mouse_id.data, format_page, 10)) + + enable_streaming() loop { info := memory.inb(0x64) @@ -110,7 +129,6 @@ main := fn(): int { if status == 0xAA { loop if memory.inb(0x60) == 0 break log.info("Mouse plugged in!\0") - set_up_mouse() continue } @@ -128,8 +146,6 @@ main := fn(): int { button_states ^= changes - log.info(string.display_int(status, format_page, 10)) - dx := i9.(false, 0) dy := i9.(false, 0)