1
0
Fork 0
forked from AbleOS/ableos

Simple mouse driver commands

This commit is contained in:
peony 2024-11-02 14:20:44 +01:00
parent 376a5213ac
commit e670a0ef53
3 changed files with 83 additions and 11 deletions

View file

@ -407,7 +407,10 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
"-parallel", "none", "-parallel", "none",
"-monitor", "none", "-monitor", "none",
"-machine", accel, "-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", "-audiodev", "pa,id=speaker",
"-machine", "pcspk-audiodev=speaker", "-machine", "pcspk-audiodev=speaker",
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",

View file

@ -3,6 +3,62 @@ render := @use("../../../libraries/render/src/lib.hb")
ACK := 250 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 { wait_for := fn(for: u8): void {
log.info("Start waiting\0") log.info("Start waiting\0")
loop { loop {
@ -44,8 +100,8 @@ main := fn(): int {
send_command(0xF4) send_command(0xF4)
b := get_response() b := get_response()
x := -0 x := @as(int, 0)
y := -0 y := @as(int, 0)
loop { loop {
// render.clear(screen, render.black) // render.clear(screen, render.black)
@ -55,17 +111,30 @@ main := fn(): int {
log.info("Yeah\0") log.info("Yeah\0")
break break
} else {
} }
} }
status := memory.inb(0x60) status := memory.inb(0x60)
log.info(string.display_int(status, format_page, 10)) log.info(string.display_int(status, format_page, 10))
d_x := memory.inb(0x60) d_x := @as(i32, @bitcast(@as(u32, @intcast(memory.inb(0x60)))))
log.info(string.display_int(d_x, format_page, 10)) if (status & 0x10) > 0 {
d_x = d_x | 0xFFFFFF00
}
x = x + d_x 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 y = y + d_y
if y < 0 {
y = 0
}
log.info(string.display_int(d_y, format_page, 10)) log.info(string.display_int(d_y, format_page, 10))
// render.put_rect(screen, .(x, y), .(x + 10, y + 10), render.white) // render.put_rect(screen, .(x, y), .(x + 10, y + 10), render.white)

View file

@ -3,8 +3,8 @@
default_entry = 1 default_entry = 1
timeout = 0 timeout = 0
verbose = false verbose = false
interface_resolution = "1600x900x24" # interface_resolution = "1600x900x24"
# interface_resolution = "640x480x32" interface_resolution = "640x480x32"
# Terminal related settings # Terminal related settings
# term_wallpaper = "boot:///background.bmp" # term_wallpaper = "boot:///background.bmp"
term_wallpaper = "boot:///empty-background.bmp" term_wallpaper = "boot:///empty-background.bmp"
@ -15,8 +15,8 @@ comment = "Default AbleOS boot entry."
protocol = "limine" protocol = "limine"
kernel_path = "boot:///kernel_${ARCH}" kernel_path = "boot:///kernel_${ARCH}"
kernel_cmdline = "" kernel_cmdline = ""
# resolution = "640x480x32" resolution = "640x480x32"
resolution = "1600x900x24" # resolution = "1600x900x24"
[boot.limine.ableos.modules] [boot.limine.ableos.modules]