forked from AbleOS/ableos
mouse cursor functional
This commit is contained in:
parent
d2152537ad
commit
eea23d967b
|
@ -1,3 +1,3 @@
|
||||||
[alias]
|
[alias]
|
||||||
repbuild = "run --manifest-path ./repbuild/Cargo.toml -r --"
|
repbuild = "run --manifest-path ./repbuild/Cargo.toml -r -- "
|
||||||
dev = "run --manifest-path ./dev/Cargo.toml -r --"
|
dev = "run --manifest-path ./dev/Cargo.toml -r --"
|
||||||
|
|
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -228,12 +228,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.15.1",
|
"hashbrown 0.15.1",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
|
@ -245,7 +245,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
]
|
]
|
||||||
|
|
|
@ -421,6 +421,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
"-drive", "file=target/disk.img,format=raw",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-device", "vmware-svga",
|
"-device", "vmware-svga",
|
||||||
|
// "-serial", "stdio",
|
||||||
"-m", "2G",
|
"-m", "2G",
|
||||||
"-smp", "1",
|
"-smp", "1",
|
||||||
"-parallel", "none",
|
"-parallel", "none",
|
||||||
|
|
|
@ -29,7 +29,7 @@ recieve_mouse_event := fn(): ?MouseEvent {
|
||||||
if *mem_page != 0 {
|
if *mem_page != 0 {
|
||||||
log.info("Mouse events\0")
|
log.info("Mouse events\0")
|
||||||
dx := @as(i8, @bitcast(*mem_page))
|
dx := @as(i8, @bitcast(*mem_page))
|
||||||
dy := @as(i8, @bitcast(*mem_page + 1))
|
dy := @as(i8, @bitcast(*(mem_page + 1)))
|
||||||
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
||||||
return mevent
|
return mevent
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ main := fn(): int {
|
||||||
// really we should null check but it is a bit broked
|
// really we should null check but it is a bit broked
|
||||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
||||||
|
|
||||||
mouse_x := 0
|
mouse_x := @as(i16, 0)
|
||||||
mouse_y := 0
|
mouse_y := @as(i16, 0)
|
||||||
text_label := new_label("Hi\0")
|
text_label := new_label("Hi\0")
|
||||||
// widgets := "()\0"
|
// widgets := "()\0"
|
||||||
// ui := sexpr_parser(widgets)
|
// ui := sexpr_parser(widgets)
|
||||||
|
@ -52,7 +52,7 @@ main := fn(): int {
|
||||||
|
|
||||||
// TODO: Read the window buffer here
|
// TODO: Read the window buffer here
|
||||||
{
|
{
|
||||||
ret := buffer.recv([u8; 4096], win_buff, mem_buf)
|
// ret := buffer.recv([u8; 4096], win_buff, mem_buf)
|
||||||
// for some reason this null check causes the compiler to spin forever
|
// for some reason this null check causes the compiler to spin forever
|
||||||
// if ret == null {
|
// if ret == null {
|
||||||
// log.info("No messages\0")
|
// log.info("No messages\0")
|
||||||
|
@ -64,6 +64,22 @@ main := fn(): int {
|
||||||
// get input events from drivers via intouch
|
// get input events from drivers via intouch
|
||||||
// key_event := intouch.recieve_key_event();
|
// key_event := intouch.recieve_key_event();
|
||||||
// log.info("before mouse event check\0");
|
// log.info("before mouse event check\0");
|
||||||
|
|
||||||
|
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||||
|
{
|
||||||
|
// Scroll bar :ThumbsUp:
|
||||||
|
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
||||||
|
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
||||||
|
|
||||||
|
render.put_rect(screen, .(90, 110), .(10, 100), render.white)
|
||||||
|
render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
pos := Vec2(uint).(1, screen.height - 21)
|
||||||
|
render_label_to_surface(screen, text_label, font, pos)
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
mouse_event := intouch.recieve_mouse_event()
|
mouse_event := intouch.recieve_mouse_event()
|
||||||
//
|
//
|
||||||
|
@ -71,8 +87,30 @@ main := fn(): int {
|
||||||
if mouse_event != null {
|
if mouse_event != null {
|
||||||
// log.warn("Mouse event recieved\0")
|
// log.warn("Mouse event recieved\0")
|
||||||
|
|
||||||
mouse_x += mouse_event.x_change
|
change_x := @as(i16, mouse_event.x_change)
|
||||||
mouse_y += mouse_event.y_change
|
change_x = change_x << 8
|
||||||
|
change_x = change_x >> 8
|
||||||
|
|
||||||
|
mouse_x += change_x
|
||||||
|
if mouse_x < 0 {
|
||||||
|
mouse_x = 0
|
||||||
|
}
|
||||||
|
if mouse_x >= screen.width - 20 {
|
||||||
|
mouse_x = @intcast(screen.width - 21)
|
||||||
|
}
|
||||||
|
|
||||||
|
change_y := @as(i16, mouse_event.y_change)
|
||||||
|
change_y = change_y << 8
|
||||||
|
change_y = change_y >> 8
|
||||||
|
|
||||||
|
if mouse_y < 0 {
|
||||||
|
mouse_y = 0
|
||||||
|
}
|
||||||
|
if mouse_y >= screen.height - 20 {
|
||||||
|
mouse_y = @intcast(screen.height - 21)
|
||||||
|
}
|
||||||
|
mouse_y -= change_y
|
||||||
|
|
||||||
set_label_text(text_label, "Mouse Moved\0")
|
set_label_text(text_label, "Mouse Moved\0")
|
||||||
}
|
}
|
||||||
// render mouse
|
// render mouse
|
||||||
|
@ -82,20 +120,6 @@ main := fn(): int {
|
||||||
|
|
||||||
// TODO: Get windows out of a collection and iter through
|
// TODO: Get windows out of a collection and iter through
|
||||||
|
|
||||||
// render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
|
||||||
// {
|
|
||||||
// // Scroll bar :ThumbsUp:
|
|
||||||
// render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
|
||||||
// render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
|
||||||
|
|
||||||
// render.put_rect(screen, .(90, 110), .(10, 100), render.white)
|
|
||||||
// render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// {
|
|
||||||
// pos := Vec2(uint).(1, screen.height - 21)
|
|
||||||
// render_label_to_surface(screen, text_label, font, pos)
|
|
||||||
// }
|
|
||||||
// Sync the screen
|
// Sync the screen
|
||||||
render.sync(screen)
|
render.sync(screen)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ main := fn(): int {
|
||||||
loop if (memory.inb(0x64) & 0x20) == 0x20 break
|
loop if (memory.inb(0x64) & 0x20) == 0x20 break
|
||||||
|
|
||||||
status := memory.inb(0x60)
|
status := memory.inb(0x60)
|
||||||
|
|
||||||
if status == 0xAA {
|
if status == 0xAA {
|
||||||
loop if memory.inb(0x60) == 0 break
|
loop if memory.inb(0x60) == 0 break
|
||||||
log.info("Mouse plugged in!\0")
|
log.info("Mouse plugged in!\0")
|
||||||
|
@ -132,24 +133,24 @@ main := fn(): int {
|
||||||
|
|
||||||
button_states ^= changes
|
button_states ^= changes
|
||||||
|
|
||||||
// log.info(string.display_int(status, format_page, 10))
|
|
||||||
|
|
||||||
dx := i9.(false, 0)
|
dx := i9.(false, 0)
|
||||||
dy := i9.(false, 0)
|
dy := i9.(false, 0)
|
||||||
|
|
||||||
dx.value = memory.inb(0x60)
|
dx.value = memory.inb(0x60)
|
||||||
dx.sign = (status & 0x10) > 0
|
dx.sign = (status & 0x10) > 0
|
||||||
|
|
||||||
dy.value = -memory.inb(0x60)
|
dy.value = memory.inb(0x60)
|
||||||
dy.sign = (status & 0x20) == 0
|
dy.sign = (status & 0x20) != 0
|
||||||
|
|
||||||
if dy.value != 0 & dx.value != 0 {
|
|
||||||
y_change := @as(i8, @bitcast(dy.value))
|
y_change := @as(i8, @bitcast(dy.value))
|
||||||
x_change := @as(i8, @bitcast(dx.value))
|
x_change := @as(i8, @bitcast(dx.value))
|
||||||
event := MouseEvent.(x_change, y_change, 0, 0, 0)
|
|
||||||
|
event := MouseEvent.(0, 0, 0, 0, 0)
|
||||||
|
event.x_change = x_change
|
||||||
|
event.y_change = y_change
|
||||||
|
|
||||||
buffer.write(MouseEvent, &event, mouse_buffer)
|
buffer.write(MouseEvent, &event, mouse_buffer)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -22,11 +22,11 @@ resolution = "1024x768x24"
|
||||||
|
|
||||||
[boot.limine.ableos.modules]
|
[boot.limine.ableos.modules]
|
||||||
|
|
||||||
[boot.limine.ableos.modules.render_example]
|
# [boot.limine.ableos.modules.render_example]
|
||||||
path = "boot:///render_example.hbf"
|
# path = "boot:///render_example.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.horizon]
|
[boot.limine.ableos.modules.horizon]
|
||||||
# path = "boot:///horizon.hbf"
|
path = "boot:///horizon.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
[boot.limine.ableos.modules.ps2_mouse_driver]
|
||||||
path = "boot:///ps2_mouse_driver.hbf"
|
path = "boot:///ps2_mouse_driver.hbf"
|
||||||
|
|
Loading…
Reference in a new issue