forked from AbleOS/ableos
enable horizon and ps2 driver
This commit is contained in:
parent
16135ae536
commit
b795215b62
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,22 +1,13 @@
|
|||
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 {
|
||||
log.info("hi\0")
|
||||
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,
|
||||
recieve_mouse_event := fn(): ?MouseEvent {
|
||||
return null
|
||||
}
|
||||
|
||||
GamepadEvent := struct {}
|
|
@ -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
|
||||
|
@ -39,6 +40,9 @@ main := fn(): int {
|
|||
// 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
|
||||
render.clear(screen, render.black)
|
||||
|
@ -54,6 +58,16 @@ main := fn(): int {
|
|||
// }
|
||||
}
|
||||
|
||||
{
|
||||
// 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 {
|
||||
vel_inner.x = -vel_inner.x
|
||||
color = random.any(render.Color)
|
||||
|
@ -65,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,8 +1,6 @@
|
|||
.{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)
|
||||
|
@ -95,10 +93,7 @@ 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)
|
||||
mouse_buffer := buffer.create("Mouse\0")
|
||||
|
||||
send_byte(0x64, 0xA8)
|
||||
log.info("Aux mouse device enabled.\0")
|
||||
|
@ -148,15 +143,7 @@ main := fn(): int {
|
|||
|
||||
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]
|
||||
# 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"
|
||||
|
|
Loading…
Reference in a new issue