Compare commits
No commits in common. "16135ae536a513f2219a57c91de8a79b2b1906da" and "9e83707a28f8c279e90bac9acff93c3ae15ee361" have entirely different histories.
16135ae536
...
9e83707a28
|
@ -1,2 +0,0 @@
|
||||||
# app bar
|
|
||||||
The app bar is a mini-bar meant to launch applications.
|
|
|
@ -1,35 +0,0 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
|
||||||
.{string, memory, buffer, random, log} := stn;
|
|
||||||
.{Vec2} := stn.math
|
|
||||||
|
|
||||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
|
||||||
|
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
|
||||||
|
|
||||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
screen := render.init(true)
|
|
||||||
|
|
||||||
// Clear the screen to black.
|
|
||||||
render.clear(screen, render.black)
|
|
||||||
|
|
||||||
x := 0
|
|
||||||
|
|
||||||
mem_buf := memory.request_page(1)
|
|
||||||
color := random.any(render.Color)
|
|
||||||
|
|
||||||
str := "Window Title Bar\0"
|
|
||||||
font := render.text.font_from_psf2(@bitcast(&psf))
|
|
||||||
|
|
||||||
loop {
|
|
||||||
// Clear the screen
|
|
||||||
render.clear(screen, render.black)
|
|
||||||
|
|
||||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, 26), render.white)
|
|
||||||
// Sync the screen
|
|
||||||
render.sync(screen)
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
1
sysdata/programs/mouse_driver/README.md
Normal file
1
sysdata/programs/mouse_driver/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# mouse_driver
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "app_bar"
|
name = "mouse_driver"
|
||||||
authors = ["able"]
|
authors = [""]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
||||||
|
|
79
sysdata/programs/mouse_driver/src/main.hb
Normal file
79
sysdata/programs/mouse_driver/src/main.hb
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
.{memory, buffer, log, string} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
render := @use("../../../libraries/render/src/lib.hb")
|
||||||
|
|
||||||
|
ACK := 250
|
||||||
|
|
||||||
|
wait_for := fn(for: u8): void {
|
||||||
|
log.info("Start waiting\0")
|
||||||
|
loop {
|
||||||
|
if (memory.inb(0x64) & 2 >> for) == for {
|
||||||
|
log.info("End waiting\0")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
send_info := fn(info: u8): void {
|
||||||
|
wait_for(1)
|
||||||
|
memory.outb(0x64, info)
|
||||||
|
}
|
||||||
|
|
||||||
|
send_command := fn(command: u8): void {
|
||||||
|
send_info(0xD4)
|
||||||
|
wait_for(1)
|
||||||
|
memory.outb(0x60, command)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_response := fn(): u8 {
|
||||||
|
wait_for(1)
|
||||||
|
return memory.inb(0x60)
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
// screen := render.init(true)
|
||||||
|
|
||||||
|
format_page := memory.alloc(u8, 1024)
|
||||||
|
|
||||||
|
wait_for(0)
|
||||||
|
memory.outb(0x64, 0xA8)
|
||||||
|
log.info("Aux mouse device enabled.\0")
|
||||||
|
|
||||||
|
send_command(0xF6)
|
||||||
|
a := get_response()
|
||||||
|
|
||||||
|
send_command(0xF4)
|
||||||
|
b := get_response()
|
||||||
|
|
||||||
|
x := -0
|
||||||
|
y := -0
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// render.clear(screen, render.black)
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if (memory.inb(0x64) & 0x20) == 0x20 {
|
||||||
|
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))
|
||||||
|
x = x + d_x
|
||||||
|
d_y := memory.inb(0x60)
|
||||||
|
y = y + d_y
|
||||||
|
log.info(string.display_int(d_y, format_page, 10))
|
||||||
|
// render.put_rect(screen, .(x, y), .(x + 10, y + 10), render.white)
|
||||||
|
|
||||||
|
log.info("XY\0")
|
||||||
|
|
||||||
|
log.info(string.display_int(x, format_page, 10))
|
||||||
|
log.info(string.display_int(y, format_page, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -1,2 +0,0 @@
|
||||||
# ps2_mouse_driver
|
|
||||||
A small PS/2 mouse driver. This driver pushes changes to the input service in ableOS.
|
|
|
@ -1,11 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "ps2_mouse_driver"
|
|
||||||
authors = ["able", "peony"]
|
|
||||||
|
|
||||||
[dependants.libraries]
|
|
||||||
|
|
||||||
[dependants.binaries]
|
|
||||||
hblang.version = "1.0.0"
|
|
||||||
|
|
||||||
[build]
|
|
||||||
command = "hblang src/main.hb"
|
|
|
@ -1,163 +0,0 @@
|
||||||
.{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb")
|
|
||||||
Vec2 := math.Vec2
|
|
||||||
|
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
|
||||||
|
|
||||||
i9 := packed struct {sign: bool, value: u8}
|
|
||||||
Button := struct {id: u8}
|
|
||||||
LeftButton := Button.(1)
|
|
||||||
RightButton := Button.(2)
|
|
||||||
MiddleButton := Button.(4)
|
|
||||||
Button4 := Button.(8)
|
|
||||||
Button5 := Button.(16)
|
|
||||||
|
|
||||||
mouse_moved := fn(delta: Vec2(i9)): void {
|
|
||||||
log.info("Mouse movement.\0")
|
|
||||||
}
|
|
||||||
button_event := fn(button: Button, pressed: bool): void {
|
|
||||||
if pressed {
|
|
||||||
log.info("Mouse-button pressed.\0")
|
|
||||||
} else {
|
|
||||||
log.info("Mouse-button released.\0")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
log.info("Self check passed.\0")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
send_command_byte := fn(byte: u8): void {
|
|
||||||
@inline(send_byte, 0x64, 0xD4)
|
|
||||||
@inline(send_byte, 0x60, byte)
|
|
||||||
loop if memory.inb(0x60) == 0xFA {
|
|
||||||
log.info("ACK\0")
|
|
||||||
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)
|
|
||||||
|
|
||||||
resend_packet := fn(): void @inline(send_command_byte, 0xFE)
|
|
||||||
|
|
||||||
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.(1)
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
set_up_mouse := fn(): void {
|
|
||||||
@inline(reset_mouse)
|
|
||||||
@inline(set_resolution, res_8count_per_mm)
|
|
||||||
@inline(enable_streaming)
|
|
||||||
}
|
|
||||||
|
|
||||||
button_states := @as(u8, 0)
|
|
||||||
|
|
||||||
main := fn(): int {
|
|
||||||
format_page := memory.alloc(u8, 1024)
|
|
||||||
|
|
||||||
screen := render.init(true)
|
|
||||||
|
|
||||||
// Clear the screen to black.
|
|
||||||
render.clear(screen, render.black)
|
|
||||||
|
|
||||||
send_byte(0x64, 0xA8)
|
|
||||||
log.info("Aux mouse device enabled.\0")
|
|
||||||
|
|
||||||
set_up_mouse()
|
|
||||||
|
|
||||||
set_resolution(res_8count_per_mm)
|
|
||||||
|
|
||||||
x := @as(u8, 0)
|
|
||||||
y := @as(u8, 0)
|
|
||||||
|
|
||||||
loop {
|
|
||||||
loop if (memory.inb(0x64) & 0x20) == 0x20 break
|
|
||||||
|
|
||||||
status := memory.inb(0x60)
|
|
||||||
if status == 0xAA {
|
|
||||||
loop if memory.inb(0x60) == 0 break
|
|
||||||
log.info("Mouse plugged in!\0")
|
|
||||||
set_up_mouse()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
changes := button_states ^ status & 7
|
|
||||||
|
|
||||||
if (changes & LeftButton.id) != 0 {
|
|
||||||
button_event(LeftButton, (status & LeftButton.id) != 0)
|
|
||||||
}
|
|
||||||
if (changes & RightButton.id) != 0 {
|
|
||||||
button_event(RightButton, (status & RightButton.id) != 0)
|
|
||||||
}
|
|
||||||
if (changes & MiddleButton.id) != 0 {
|
|
||||||
button_event(MiddleButton, (status & MiddleButton.id) != 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
button_states ^= changes
|
|
||||||
|
|
||||||
log.info(string.display_int(status, format_page, 10))
|
|
||||||
|
|
||||||
dx := i9.(false, 0)
|
|
||||||
dy := i9.(false, 0)
|
|
||||||
|
|
||||||
dx.value = memory.inb(0x60)
|
|
||||||
dx.sign = (status & 0x10) > 0
|
|
||||||
|
|
||||||
dy.value = -memory.inb(0x60)
|
|
||||||
dy.sign = (status & 0x20) == 0
|
|
||||||
|
|
||||||
if dy.value != 0 & dx.value != 0 {
|
|
||||||
mouse_moved(.(dx, dy))
|
|
||||||
x += dx.value
|
|
||||||
y += dy.value
|
|
||||||
}
|
|
||||||
|
|
||||||
render.clear(screen, render.black)
|
|
||||||
|
|
||||||
render.put_rect(screen, .(x, y), .(10, 10), render.white)
|
|
||||||
// Sync the screen
|
|
||||||
render.sync(screen)
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -37,8 +37,8 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.serial_driver_test]
|
# [boot.limine.ableos.modules.serial_driver_test]
|
||||||
# path = "boot:///serial_driver_test.hbf"
|
# path = "boot:///serial_driver_test.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.horizon]
|
[boot.limine.ableos.modules.horizon]
|
||||||
# path = "boot:///horizon.hbf"
|
path = "boot:///horizon.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.horizon_testing_program]
|
# [boot.limine.ableos.modules.horizon_testing_program]
|
||||||
# path = "boot:///horizon_testing_program.hbf"
|
# path = "boot:///horizon_testing_program.hbf"
|
||||||
|
@ -58,8 +58,5 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.pumpkin_print]
|
# [boot.limine.ableos.modules.pumpkin_print]
|
||||||
# path = "boot:///pumpkin_print.hbf"
|
# path = "boot:///pumpkin_print.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
# [boot.limine.ableos.modules.mouse_driver]
|
||||||
path = "boot:///ps2_mouse_driver.hbf"
|
# path = "boot:///mouse_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.app_bar]
|
|
||||||
# path = "boot:///app_bar.hbf"
|
|
||||||
|
|
Loading…
Reference in a new issue