forked from AbleOS/ableos
Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos
This commit is contained in:
commit
d0f078cf10
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -253,12 +253,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#44fc9c3e2e0aa32b92a4a9a20e4eadbf354d7b6c"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#44fc9c3e2e0aa32b92a4a9a20e4eadbf354d7b6c"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.0",
|
||||
"hbbytecode",
|
||||
|
@ -270,7 +270,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#44fc9c3e2e0aa32b92a4a9a20e4eadbf354d7b6c"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
|
|
@ -35,7 +35,7 @@ create_window := fn(channel: int): ^render.Surface {
|
|||
loop if x > 1000 break else x += 1
|
||||
|
||||
ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf)
|
||||
if ret == 0 {
|
||||
if ret == null {
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
||||
|
|
22
sysdata/libraries/intouch/src/events.hb
Normal file
22
sysdata/libraries/intouch/src/events.hb
Normal file
|
@ -0,0 +1,22 @@
|
|||
keycodes := @use("keycodes.hb");
|
||||
.{KeyCode} := keycodes
|
||||
|
||||
KeyEvent := struct {
|
||||
// 0 if down
|
||||
// 1 if up
|
||||
up: u8,
|
||||
// 0 if not just triggered
|
||||
// 1 if just triggered
|
||||
just_triggered: u8,
|
||||
key: KeyCode,
|
||||
}
|
||||
|
||||
MouseEvent := struct {
|
||||
x_change: u8,
|
||||
y_change: u8,
|
||||
left: u8,
|
||||
middle: u8,
|
||||
right: u8,
|
||||
}
|
||||
|
||||
GamepadEvent := struct {}
|
|
@ -1,67 +1,121 @@
|
|||
/*
|
||||
Originally I was modelling this after the following(1). I have since changed my mind.
|
||||
I am now modelling it as I see fit. This is likely not the final version.
|
||||
|
||||
1) https://www.libsdl.org/release/SDL-1.2.15/include/SDL_keysym.h
|
||||
*/
|
||||
|
||||
KeyCode := u32
|
||||
|
||||
// https://www.libsdl.org/release/SDL-1.2.15/include/SDL_keysym.h
|
||||
Backspace := KeyCode.(8)
|
||||
Tab := KeyCode.(9)
|
||||
Clear := KeyCode.(12)
|
||||
Return := KeyCode.(13)
|
||||
Pause := KeyCode.(19)
|
||||
Escape := KeyCode.(27)
|
||||
Space := KeyCode.(32)
|
||||
// Typically this is not a keycode you will ever recieve.
|
||||
None := KeyCode.(0)
|
||||
|
||||
A := KeyCode.(97)
|
||||
/*
|
||||
ETC
|
||||
*/
|
||||
Z := KeyCode.(122)
|
||||
Escape := KeyCode.(1)
|
||||
/* Alphabet keycodes */
|
||||
|
||||
Delete := KeyCode.(127)
|
||||
A := KeyCode.(2)
|
||||
B := KeyCode.(3)
|
||||
C := KeyCode.(4)
|
||||
D := KeyCode.(5)
|
||||
E := KeyCode.(6)
|
||||
F := KeyCode.(7)
|
||||
G := KeyCode.(8)
|
||||
H := KeyCode.(9)
|
||||
I := KeyCode.(10)
|
||||
J := KeyCode.(11)
|
||||
K := KeyCode.(12)
|
||||
L := KeyCode.(13)
|
||||
M := KeyCode.(14)
|
||||
N := KeyCode.(15)
|
||||
O := KeyCode.(16)
|
||||
P := KeyCode.(17)
|
||||
Q := KeyCode.(18)
|
||||
R := KeyCode.(19)
|
||||
S := KeyCode.(20)
|
||||
T := KeyCode.(21)
|
||||
U := KeyCode.(22)
|
||||
V := KeyCode.(23)
|
||||
W := KeyCode.(24)
|
||||
X := KeyCode.(25)
|
||||
Y := KeyCode.(26)
|
||||
Z := KeyCode.(27)
|
||||
|
||||
/*
|
||||
ETC
|
||||
*/
|
||||
/* Numeric keycodes*/
|
||||
|
||||
KeypadNumber0 := KeyCode.(256)
|
||||
KeypadNumber1 := KeyCode.(257)
|
||||
KeypadNumber2 := KeyCode.(258)
|
||||
KeypadNumber3 := KeyCode.(259)
|
||||
KeypadNumber4 := KeyCode.(260)
|
||||
KeypadNumber5 := KeyCode.(261)
|
||||
KeypadNumber6 := KeyCode.(262)
|
||||
KeypadNumber7 := KeyCode.(263)
|
||||
KeypadNumber8 := KeyCode.(264)
|
||||
KeypadNumber9 := KeyCode.(265)
|
||||
Number0 := KeyCode.(28)
|
||||
Number1 := KeyCode.(29)
|
||||
Number2 := KeyCode.(30)
|
||||
Number3 := KeyCode.(31)
|
||||
Number4 := KeyCode.(32)
|
||||
Number5 := KeyCode.(33)
|
||||
Number6 := KeyCode.(34)
|
||||
Number7 := KeyCode.(35)
|
||||
Number8 := KeyCode.(36)
|
||||
Number9 := KeyCode.(37)
|
||||
|
||||
KeypadPeriod := KeyCode.(266)
|
||||
KeypadDivide := KeyCode.(267)
|
||||
KeypadMultiply := KeyCode.(268)
|
||||
KeypadMinus := KeyCode.(269)
|
||||
KeypadPlus := KeyCode.(270)
|
||||
KeypadEnter := KeyCode.(271)
|
||||
KeypadEquals := KeyCode.(272)
|
||||
KeypadNumber0 := KeyCode.(38)
|
||||
KeypadNumber1 := KeyCode.(39)
|
||||
KeypadNumber2 := KeyCode.(40)
|
||||
KeypadNumber3 := KeyCode.(41)
|
||||
KeypadNumber4 := KeyCode.(42)
|
||||
KeypadNumber5 := KeyCode.(43)
|
||||
KeypadNumber6 := KeyCode.(44)
|
||||
KeypadNumber7 := KeyCode.(45)
|
||||
KeypadNumber8 := KeyCode.(46)
|
||||
KeypadNumber9 := KeyCode.(47)
|
||||
|
||||
NumLock := KeyCode.(300)
|
||||
CapsLock := KeyCode.(301)
|
||||
ScrollLock := KeyCode.(302)
|
||||
KeypadPeriod := KeyCode.(48)
|
||||
KeypadDivide := KeyCode.(49)
|
||||
KeypadMultiply := KeyCode.(50)
|
||||
KeypadMinus := KeyCode.(51)
|
||||
KeypadPlus := KeyCode.(52)
|
||||
KeypadEnter := KeyCode.(53)
|
||||
KeypadEquals := KeyCode.(54)
|
||||
|
||||
RightShift := KeyCode.(303)
|
||||
LeftShift := KeyCode.(304)
|
||||
|
||||
RightControl := KeyCode.(305)
|
||||
LeftControl := KeyCode.(306)
|
||||
RightAlt := KeyCode.(307)
|
||||
LeftAlt := KeyCode.(308)
|
||||
RightMeta := KeyCode.(309)
|
||||
LeftMeta := KeyCode.(310)
|
||||
|
||||
/* Left "Windows" key */
|
||||
LeftSuper := KeyCode.(311)
|
||||
|
||||
/* Right "Windows" key */
|
||||
RightSuper := KeyCode.(312)
|
||||
Delete := KeyCode.(55)
|
||||
/* Locking Keys */
|
||||
NumLock := KeyCode.(56)
|
||||
CapsLock := KeyCode.(57)
|
||||
ScrollLock := KeyCode.(58)
|
||||
|
||||
/* "Alt Gr" key */
|
||||
Mode := KeyCode.(313)
|
||||
Mode := KeyCode.(59)
|
||||
|
||||
/* Multi-key compose key */
|
||||
Compose := KeyCode.(314)
|
||||
Compose := KeyCode.(60)
|
||||
|
||||
LeftAlt := KeyCode.(61)
|
||||
LeftControl := KeyCode.(62)
|
||||
LeftMeta := KeyCode.(63)
|
||||
LeftShift := KeyCode.(64)
|
||||
/* Left "Windows" key */
|
||||
LeftSuper := KeyCode.(65)
|
||||
|
||||
RightAlt := KeyCode.(66)
|
||||
RightControl := KeyCode.(67)
|
||||
RightMeta := KeyCode.(68)
|
||||
RightShift := KeyCode.(69)
|
||||
/* Right "Windows" key */
|
||||
RightSuper := KeyCode.(70)
|
||||
|
||||
/*
|
||||
This block of any triggers on any press of any of the keys.
|
||||
Typically this is the event to care about.
|
||||
*/
|
||||
AnyNumber0 := KeyCode.(71)
|
||||
AnyNumber1 := KeyCode.(72)
|
||||
AnyNumber2 := KeyCode.(73)
|
||||
AnyNumber3 := KeyCode.(74)
|
||||
AnyNumber4 := KeyCode.(75)
|
||||
AnyNumber5 := KeyCode.(76)
|
||||
AnyNumber6 := KeyCode.(77)
|
||||
AnyNumber7 := KeyCode.(78)
|
||||
AnyNumber8 := KeyCode.(79)
|
||||
AnyNumber9 := KeyCode.(80)
|
||||
|
||||
AnyAlt := KeyCode.(81)
|
||||
AnyControl := KeyCode.(82)
|
||||
AnyMeta := KeyCode.(83)
|
||||
AnyShift := KeyCode.(84)
|
||||
/* Any "Windows" key */
|
||||
AnySuper := KeyCode.(85)
|
|
@ -1,22 +1,15 @@
|
|||
keycodes := @use("keycodes.hb");
|
||||
.{KeyCode} := keycodes
|
||||
stn := @use("../../stn/src/lib.hb");
|
||||
.{log, buffer} := stn
|
||||
events := @use("events.hb");
|
||||
.{KeyEvent, MouseEvent} := events
|
||||
|
||||
MouseEvent := struct {
|
||||
x_change: u8,
|
||||
y_change: u8,
|
||||
left: u8,
|
||||
middle: u8,
|
||||
right: u8,
|
||||
recieve_key_event := fn(): ?KeyEvent {
|
||||
buf := buffer.search("PS/2 Keyboard\0")
|
||||
// Read out of the keyboard buffer here
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
KeyEvent := struct {
|
||||
// 0 if down
|
||||
// 1 if up
|
||||
up: u8,
|
||||
// 0 if not just triggered
|
||||
// 1 if just triggered
|
||||
just_triggered: u8,
|
||||
key: KeyCode,
|
||||
}
|
||||
|
||||
GamepadEvent := struct {}
|
||||
recieve_mouse_event := fn(): ?MouseEvent {
|
||||
return null
|
||||
}
|
|
@ -32,11 +32,11 @@ BitmapColorHeader := packed struct {
|
|||
unused: u32,
|
||||
}
|
||||
|
||||
surface_from_bmp := fn(bmp: ^u8): Surface {
|
||||
surface_from_bmp := fn(bmp: ^u8): ?Surface {
|
||||
file_header := @as(^BitmapFileHeader, @bitcast(bmp))
|
||||
if file_header.img_type != 0x4D42 {
|
||||
log.error("failed to load bmp image: not a bmp image, idiot\0")
|
||||
return idk
|
||||
return null
|
||||
}
|
||||
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
||||
bmp += file_header.offset
|
||||
|
@ -64,11 +64,11 @@ surface_from_bmp := fn(bmp: ^u8): Surface {
|
|||
return .(@bitcast(bmp), info_header.width, info_header.height)
|
||||
}
|
||||
|
||||
new_surface_from_bmp := fn(bmp: ^u8): Surface {
|
||||
new_surface_from_bmp := fn(bmp: ^u8): ?Surface {
|
||||
file_header := @as(^BitmapFileHeader, @bitcast(bmp))
|
||||
if file_header.img_type != 0x4D42 {
|
||||
log.error("failed to load bmp image: not a bmp image, idiot\0")
|
||||
return idk
|
||||
return null
|
||||
}
|
||||
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
||||
bmp += file_header.offset
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
.{get_glyph, Font} := text;
|
||||
.{Vec2} := math
|
||||
|
||||
// safety: don't use before init() or you will get a memory access violation
|
||||
framebuffer := memory.dangling(^Color)
|
||||
|
||||
Surface := struct {
|
||||
buf: ^Color,
|
||||
width: uint,
|
||||
|
@ -100,8 +103,9 @@ put_filled_rect := fn(surface: Surface, pos: Vec2(uint), tr: Vec2(uint), color:
|
|||
rows_to_fill := tr.y
|
||||
|
||||
loop if rows_to_fill <= 1 break else {
|
||||
@inline(memory.set, Color, &color, top_start_idx, @bitcast(tr.x))
|
||||
@inline(memory.set, Color, &color, bottom_start_idx, @bitcast(tr.x))
|
||||
// inline is broked
|
||||
memory.set(Color, &color, top_start_idx, @bitcast(tr.x))
|
||||
memory.set(Color, &color, bottom_start_idx, @bitcast(tr.x))
|
||||
|
||||
top_start_idx += surface.width
|
||||
bottom_start_idx -= surface.width
|
||||
|
@ -446,10 +450,12 @@ put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str:
|
|||
}
|
||||
|
||||
glyph_data := @inline(get_glyph, font, @intcast(*current_char))
|
||||
if glyph_data == idk {
|
||||
current_char += 1
|
||||
continue
|
||||
}
|
||||
// ! cool null check don't disable :dead:
|
||||
// !! i disabled the cool null check because compiler
|
||||
// if glyph_data == null {
|
||||
// current_char += 1
|
||||
// continue
|
||||
// }
|
||||
|
||||
if cursor.x % surface.width + font.width >= surface.width {
|
||||
cursor.x = pos.x
|
||||
|
|
|
@ -28,11 +28,11 @@ Font := struct {
|
|||
char_gap: uint,
|
||||
}
|
||||
|
||||
font_from_psf1 := fn(psf: ^u8): Font {
|
||||
font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||
header := @as(^PSF1Header, @bitcast(psf))
|
||||
if header.magic != 0x436 {
|
||||
log.error("failed to load psf font: not a psf1 font, idiot\0")
|
||||
return idk
|
||||
return null
|
||||
}
|
||||
|
||||
psf += @sizeof(PSF1Header)
|
||||
|
@ -40,30 +40,30 @@ font_from_psf1 := fn(psf: ^u8): Font {
|
|||
return .(
|
||||
psf,
|
||||
8,
|
||||
@intcast(header.character_size),
|
||||
header.character_size,
|
||||
256,
|
||||
@intcast(header.character_size),
|
||||
header.character_size,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
font_from_psf2 := fn(psf: ^u8): Font {
|
||||
font_from_psf2 := fn(psf: ^u8): ?Font {
|
||||
header := @as(^PSF2Header, @bitcast(psf))
|
||||
if header.magic != 0x864AB572 {
|
||||
log.error("failed to load psf font: not a psf2 font, idiot\0")
|
||||
return idk
|
||||
return null
|
||||
}
|
||||
|
||||
psf += header.header_size
|
||||
|
||||
return .(
|
||||
psf,
|
||||
@intcast(header.width),
|
||||
@intcast(header.height),
|
||||
@intcast(header.num_glyph),
|
||||
@intcast(header.bytes_per_glyph),
|
||||
header.width,
|
||||
header.height,
|
||||
header.num_glyph,
|
||||
header.bytes_per_glyph,
|
||||
(header.flags & 1) != 0,
|
||||
0,
|
||||
0,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
string := @use("string.hb")
|
||||
|
||||
recv := fn($Expr: type, buffer_id: int, memory_map_location: ^u8): ^Expr {
|
||||
recv := fn($Expr: type, buffer_id: int, memory_map_location: ^u8): ?^Expr {
|
||||
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
|
||||
}
|
||||
|
||||
|
|
|
@ -6,4 +6,14 @@ buffer := @use("buffer.hb")
|
|||
math := @use("math.hb")
|
||||
random := @use("random.hb")
|
||||
file := @use("file_io.hb")
|
||||
dt := @use("dt.hb")
|
||||
dt := @use("dt.hb")
|
||||
|
||||
panic := fn(message: ?^u8): never {
|
||||
log.error("Error: Panic Called, Message:\0")
|
||||
if message == null {
|
||||
log.error("None\0")
|
||||
} else {
|
||||
log.error(message)
|
||||
}
|
||||
die
|
||||
}
|
|
@ -2,6 +2,10 @@ PAGE_SIZE := 4096
|
|||
MAX_ALLOC := 0xFF
|
||||
MAX_FREE := 0xFF
|
||||
|
||||
dangling := fn($Expr: type): Expr {
|
||||
return @bitcast(@sizeof(Expr))
|
||||
}
|
||||
|
||||
calc_pages := fn($Expr: type, num: uint): uint {
|
||||
return 1 + @sizeof(Expr) * num / PAGE_SIZE
|
||||
}
|
||||
|
@ -14,10 +18,10 @@ alloc := fn($Expr: type, num: uint): ^Expr {
|
|||
ptr := request_page(0xFF)
|
||||
remaining := pages - MAX_ALLOC
|
||||
loop if remaining < MAX_ALLOC break else {
|
||||
_ := request_page(@intcast(MAX_ALLOC))
|
||||
_ = request_page(@intcast(MAX_ALLOC))
|
||||
remaining -= MAX_ALLOC
|
||||
}
|
||||
_ := request_page(@intcast(remaining))
|
||||
_ = request_page(@intcast(remaining))
|
||||
return @bitcast(ptr)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
panic := fn(message: ?^u8): void {
|
||||
if message != null {
|
||||
log.error(message)
|
||||
}
|
||||
// TODO: replace with die keyword when it gets pushed
|
||||
loop {
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
length := fn(ptr: ^u8): uint {
|
||||
len := @as(uint, 0)
|
||||
// loop if *(ptr + len) == 0 return len else len += 1
|
||||
loop if *(ptr + len) == 0 break else len += 1
|
||||
return len
|
||||
len := 0
|
||||
loop if *(ptr + len) == 0 return len else len += 1
|
||||
}
|
||||
|
||||
display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
|
||||
|
@ -58,7 +57,7 @@ display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
|
|||
}
|
||||
|
||||
reverse := fn(s: ^u8): void {
|
||||
i := @as(uint, 0)
|
||||
i := 0
|
||||
j := @inline(length, s) - 1
|
||||
temp := @as(u8, 0)
|
||||
loop if i >= j break else {
|
||||
|
|
2
sysdata/programs/app_bar/README.md
Normal file
2
sysdata/programs/app_bar/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# app bar
|
||||
The app bar is a mini-bar meant to launch applications.
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mouse_driver"
|
||||
authors = ["peony"]
|
||||
name = "app_bar"
|
||||
authors = ["able"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
35
sysdata/programs/app_bar/src/main.hb
Normal file
35
sysdata/programs/app_bar/src/main.hb
Normal file
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
}
|
|
@ -9,8 +9,7 @@ OemIdent := struct {
|
|||
}
|
||||
|
||||
new_oem_ident := fn(major: int, minor: int): OemIdent {
|
||||
ver := [u8].(0, 0, 0, 0, 0, 0, 0, 0)
|
||||
return OemIdent.(ver, ver)
|
||||
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
|
||||
}
|
||||
|
||||
BiosParameterBlock := struct {
|
||||
|
@ -38,9 +37,7 @@ bpb_sanity_check := fn(bpb: BiosParameterBlock): int {
|
|||
}
|
||||
|
||||
new_bpb := fn(): BiosParameterBlock {
|
||||
oem := new_oem_ident(0, 0)
|
||||
|
||||
return BiosParameterBlock.(VALID_JUMP_BYTES, oem, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
return .(VALID_JUMP_BYTES, new_oem_ident(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
sector_count := fn(bpb: BiosParameterBlock): u32 {
|
||||
|
|
|
@ -5,6 +5,7 @@ stn := @use("../../../libraries/stn/src/lib.hb");
|
|||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
||||
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||
|
||||
Window := struct {
|
||||
// TODO: Replace this with widgets
|
||||
|
@ -36,7 +37,11 @@ main := fn(): int {
|
|||
vel_inner := Vec2(int).(1, 1)
|
||||
pos_inner := Vec2(uint).((window.width - side) / 2, (window.height - side) / 2)
|
||||
str := "Window Title Bar\0"
|
||||
font := render.text.font_from_psf2(@bitcast(&psf))
|
||||
// really we should null check but it is a bit broked
|
||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf)))
|
||||
|
||||
mouse_x := 0
|
||||
mouse_y := 0
|
||||
|
||||
loop {
|
||||
// Clear the screen
|
||||
|
@ -45,11 +50,22 @@ main := fn(): int {
|
|||
// TODO: Read the window buffer here
|
||||
{
|
||||
ret := buffer.recv([u8; 4096], win_buff, mem_buf)
|
||||
if ret == 0 {
|
||||
log.info("No messages\0")
|
||||
} else {
|
||||
log.info("Handle Messages\0")
|
||||
}
|
||||
// for some reason this null check causes the compiler to spin forever
|
||||
// if ret == null {
|
||||
// log.info("No messages\0")
|
||||
// } else {
|
||||
// log.info("Handle Messages\0")
|
||||
// }
|
||||
}
|
||||
|
||||
{
|
||||
// get input events from drivers via intouch
|
||||
key_event := intouch.recieve_key_event()
|
||||
mouse_event := intouch.recieve_mouse_event()
|
||||
|
||||
// render mouse
|
||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||
// Send events to focused window
|
||||
}
|
||||
|
||||
if pos_inner.x == 0 | pos_inner.x == window.width - side {
|
||||
|
@ -63,29 +79,29 @@ main := fn(): int {
|
|||
|
||||
// TODO: Get windows out of a collection and iter through
|
||||
window_count := 0
|
||||
loop {
|
||||
render.clear(window, render.black)
|
||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||
// loop {
|
||||
// render.clear(window, render.black)
|
||||
|
||||
// Draw the decorators
|
||||
{
|
||||
render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white)
|
||||
render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white)
|
||||
render.put_text(window, font, .(window.width / 2, 1), render.white, str)
|
||||
}
|
||||
render.put_filled_rect(window, pos_inner, .(side, side), color)
|
||||
// // Draw the decorators
|
||||
// {
|
||||
// render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white)
|
||||
// render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white)
|
||||
// render.put_text(window, font, .(window.width / 2, 1), render.white, str)
|
||||
// }
|
||||
// render.put_filled_rect(window, pos_inner, .(side, side), color)
|
||||
|
||||
// Apply the image to the screen
|
||||
pos := Vec2(uint).(x, 100)
|
||||
// // Apply the image to the screen
|
||||
// pos := Vec2(uint).(x, 100)
|
||||
|
||||
render.put_surface(screen, window, pos, false)
|
||||
if window_count >= 1 {
|
||||
x = 0
|
||||
break
|
||||
}
|
||||
window_count += 1
|
||||
x += screen.width / 2
|
||||
}
|
||||
// render.put_surface(screen, window, pos, false)
|
||||
// if window_count >= 1 {
|
||||
// x = 0
|
||||
// break
|
||||
// }
|
||||
// window_count += 1
|
||||
// x += screen.width / 2
|
||||
// }
|
||||
pos_inner += @bitcast(vel_inner)
|
||||
|
||||
// Sync the screen
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
# mouse_driver
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "ps2_driver"
|
||||
name = "ps2_keyboard_driver"
|
||||
authors = ["Talha Qamar"]
|
||||
|
||||
[dependants.libraries]
|
|
@ -7,7 +7,7 @@ send_byte := fn(byte: u8): u8 {
|
|||
|
||||
main := fn(): int {
|
||||
buf := buffer.create("XKeyboard\0")
|
||||
_ := send_byte(238)
|
||||
_ = send_byte(238)
|
||||
log.info("PS/2 Driver Loaded\0")
|
||||
if send_byte(238) == 238 {
|
||||
log.info("PS/2 Keyboard Echoed\0")
|
2
sysdata/programs/ps2_mouse_driver/README.md
Normal file
2
sysdata/programs/ps2_mouse_driver/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# ps2_mouse_driver
|
||||
A small PS/2 mouse driver. This driver pushes changes to the input service in ableOS.
|
11
sysdata/programs/ps2_mouse_driver/meta.toml
Normal file
11
sysdata/programs/ps2_mouse_driver/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "ps2_mouse_driver"
|
||||
authors = ["able", "peony"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
150
sysdata/programs/ps2_mouse_driver/src/main.hb
Normal file
150
sysdata/programs/ps2_mouse_driver/src/main.hb
Normal file
|
@ -0,0 +1,150 @@
|
|||
.{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb")
|
||||
Vec2 := math.Vec2
|
||||
|
||||
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)
|
||||
|
||||
mouse_buffer := buffer.create("Mouse\0")
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
|
@ -8,9 +8,10 @@ bmp_1 := @embed("./assets/able.bmp")
|
|||
bmp_2 := @embed("./assets/mini.bmp")
|
||||
|
||||
example := fn(): void {
|
||||
// strictly we should be null checking here but i am lazy
|
||||
images := [render.Surface].(
|
||||
render.image.surface_from_bmp(@bitcast(&bmp_1)),
|
||||
render.image.surface_from_bmp(@bitcast(&bmp_2)),
|
||||
@unwrap(render.image.surface_from_bmp(@bitcast(&bmp_1))),
|
||||
@unwrap(render.image.surface_from_bmp(@bitcast(&bmp_2))),
|
||||
)
|
||||
screen := render.init(true)
|
||||
vel := Vec2(int).(1, 1)
|
||||
|
|
|
@ -1,22 +1,37 @@
|
|||
.{Vec2, sin, cos} := @use("../../../../libraries/stn/src/lib.hb").math
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
/* expected result:
|
||||
words */
|
||||
extended unicode test */
|
||||
|
||||
psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
screen := render.init(false)
|
||||
font := render.text.font_from_psf2(@bitcast(&psf))
|
||||
t := 0
|
||||
str := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX\0"
|
||||
|
||||
loop {
|
||||
render.clear(screen, render.black)
|
||||
render.put_text(screen, font, .(t, t % screen.height), render.red, str)
|
||||
render.sync(screen)
|
||||
// t += 1
|
||||
}
|
||||
str := "Extended unicode test:
|
||||
|
||||
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
0123456789
|
||||
!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~
|
||||
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞß
|
||||
àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ
|
||||
ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğ
|
||||
ĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿ
|
||||
„‟†‡•‣․‥…‧
|
||||
₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿
|
||||
∀∁∂∃∄∅∆∇∈∉∊∋∌∍∎∏∐∑−∓∔∕∖∗∘∙√∛∜∝∞∟
|
||||
─│┌┐└┘├┤┬┴┼╋╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿
|
||||
▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
|
||||
■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿◀◁◂◃◄◅◆◇◈◉◊○
|
||||
←↑→↓↔↕↖↗↘↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻
|
||||
、。〃〄々〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟
|
||||
✀✁✂✃✄✅✆✇✈✉✊✋✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟
|
||||
✠✡✢✣✤✥✦✧✨✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿\0"
|
||||
|
||||
render.clear(screen, render.black)
|
||||
render.put_text(screen, @unwrap(font), .(0, 0), render.white, str)
|
||||
render.sync(screen)
|
||||
return
|
||||
}
|
|
@ -5,7 +5,9 @@ log_info := fn(): void {
|
|||
if a == 0 {
|
||||
} else {
|
||||
msg := "XABC\0"
|
||||
msg_length := @inline(string.length, msg)
|
||||
// inline is broked
|
||||
// msg_length := @inline(string.length, msg)
|
||||
msg_length := 5
|
||||
@as(void, @eca(3, a, msg, msg_length))
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ path = "boot:///mouse_driver.hbf"
|
|||
# [boot.limine.ableos.modules.serial_driver_test]
|
||||
# path = "boot:///serial_driver_test.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.horizon]
|
||||
# path = "boot:///horizon.hbf"
|
||||
[boot.limine.ableos.modules.horizon]
|
||||
path = "boot:///horizon.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.horizon_testing_program]
|
||||
# path = "boot:///horizon_testing_program.hbf"
|
||||
|
@ -50,8 +50,8 @@ path = "boot:///mouse_driver.hbf"
|
|||
# [boot.limine.ableos.modules.svga_driver]
|
||||
# path = "boot:///svga_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_driver]
|
||||
# path = "boot:///ps2_driver.hbf"
|
||||
[boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||
path = "boot:///ps2_keyboard_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.filesystem_fat32]
|
||||
# path = "boot:///filesystem_fat32.hbf"
|
||||
|
|
Loading…
Reference in a new issue