Commit
This commit is contained in:
parent
cf917927a5
commit
e40a22fccd
|
@ -1,13 +1,9 @@
|
||||||
keycodes := @use("keycodes.hb");
|
keycodes := @use("keycodes.hb");
|
||||||
.{KeyCode} := keycodes
|
.{KeyCode} := keycodes
|
||||||
|
|
||||||
KeyEvent := struct {
|
KeyEvent := packed struct {
|
||||||
// 0 if down
|
up: bool,
|
||||||
// 1 if up
|
just_triggered: bool,
|
||||||
up: u8,
|
|
||||||
// 0 if not just triggered
|
|
||||||
// 1 if just triggered
|
|
||||||
just_triggered: u8,
|
|
||||||
key: KeyCode,
|
key: KeyCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,17 @@ events := @use("events.hb");
|
||||||
.{KeyEvent, MouseEvent} := events
|
.{KeyEvent, MouseEvent} := events
|
||||||
|
|
||||||
recieve_key_event := fn(): ?KeyEvent {
|
recieve_key_event := fn(): ?KeyEvent {
|
||||||
|
kevent := KeyEvent.(false, false, 0)
|
||||||
|
|
||||||
|
buf_id := buffer.search("PS/2 Keyboard\0")
|
||||||
|
|
||||||
|
// Read out of the Keyboard buffer here
|
||||||
|
buffer.recv(KeyEvent, buf_id, &kevent)
|
||||||
|
|
||||||
|
if kevent.just_triggered {
|
||||||
|
return kevent
|
||||||
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,23 +56,13 @@ main := fn(): int {
|
||||||
loop {
|
loop {
|
||||||
// Clear the screen
|
// Clear the screen
|
||||||
render.clear(screen, render.black)
|
render.clear(screen, render.black)
|
||||||
|
|
||||||
render.put_surface(screen, wallpaper, .(0, 0), false)
|
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||||
|
|
||||||
// TODO: Read the window buffer here
|
// TODO: Read the window buffer here
|
||||||
{
|
{
|
||||||
// buffer.recv([u8; 4096], win_buff, mem_buf)
|
|
||||||
// // for some reason this null check causes the compiler to spin forever
|
|
||||||
// if *mem_buf == 0 {
|
|
||||||
// log.info("No messages\0")
|
|
||||||
// } else {
|
|
||||||
// log.info("Handle Messages\0")
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get input events from drivers via intouch
|
|
||||||
// key_event := intouch.recieve_key_event();
|
|
||||||
// log.info("before mouse event check\0");
|
|
||||||
|
|
||||||
if false {
|
if false {
|
||||||
// Scroll bar :ThumbsUp:
|
// Scroll bar :ThumbsUp:
|
||||||
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
||||||
|
@ -83,6 +73,7 @@ main := fn(): int {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// Bottom Bar
|
||||||
pos := Vec2(uint).(1, screen.height - 21)
|
pos := Vec2(uint).(1, screen.height - 21)
|
||||||
render_label_to_surface(screen, text_label, font, pos)
|
render_label_to_surface(screen, text_label, font, pos)
|
||||||
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
||||||
|
@ -91,6 +82,14 @@ main := fn(): int {
|
||||||
// Screen border
|
// Screen border
|
||||||
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)
|
||||||
|
|
||||||
|
// get input events from drivers via intouch
|
||||||
|
if false {
|
||||||
|
key_event := intouch.recieve_key_event()
|
||||||
|
if key_event != null {
|
||||||
|
log.info("Key event \0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
mouse_event := intouch.recieve_mouse_event()
|
mouse_event := intouch.recieve_mouse_event()
|
||||||
//
|
//
|
||||||
|
@ -133,13 +132,9 @@ main := fn(): int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// render mouse
|
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
||||||
lum := render.indexptr(screen, mouse_x, mouse_y)
|
|
||||||
if lum.r / 3 + lum.g / 3 + lum.b / 3 < 128 {
|
|
||||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||||
} else {
|
|
||||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
|
||||||
}
|
|
||||||
// Send events to focused window
|
// Send events to focused window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
.{memory, log, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
|
.{memory, log, buffer} := stn
|
||||||
|
|
||||||
|
intouch := @use("../../../libraries/intouch/src/lib.hb");
|
||||||
|
.{KeyEvent} := intouch
|
||||||
|
|
||||||
send_byte := fn(byte: u8): u8 {
|
send_byte := fn(byte: u8): u8 {
|
||||||
memory.outb(96, byte)
|
memory.outb(96, byte)
|
||||||
|
@ -6,23 +10,31 @@ send_byte := fn(byte: u8): u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
buf := buffer.create("XKeyboard\0")
|
buf := buffer.create("PS/2 Keyboard\0")
|
||||||
_ = send_byte(238)
|
_ = send_byte(238)
|
||||||
log.info("PS/2 Driver Loaded\0")
|
log.info("PS/2 Driver Loaded\0")
|
||||||
|
|
||||||
if send_byte(238) == 238 {
|
if send_byte(238) == 238 {
|
||||||
log.info("PS/2 Keyboard Echoed\0")
|
log.info("PS/2 Keyboard Echoed\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if send_byte(244) == 250 {
|
if send_byte(244) == 250 {
|
||||||
log.info("Enabled scanning\0")
|
log.info("Enabled scanning\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_input := 250
|
prev_input := 250
|
||||||
loop {
|
loop {
|
||||||
|
loop if (memory.inb(0x64) & 0x20) == 0x20 break
|
||||||
|
|
||||||
input := memory.inb(96)
|
input := memory.inb(96)
|
||||||
|
|
||||||
if input == prev_input {
|
if input == prev_input {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
prev_input = input
|
prev_input = input
|
||||||
buffer.write(u8, &input, buf)
|
kevent := KeyEvent.(false, true, input)
|
||||||
|
|
||||||
|
buffer.write(KeyEvent, &kevent, buf)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -1 +1 @@
|
||||||
.{example: main} := @use("./examples/orbit.hb")
|
.{example: main} := @use("./examples/text.hb")
|
|
@ -25,17 +25,17 @@ resolution = "1024x768x24"
|
||||||
# [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"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.sunset_client]
|
# [boot.limine.ableos.modules.sunset_client]
|
||||||
path = "boot:///sunset_client.hbf"
|
# path = "boot:///sunset_client.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.sunset_server]
|
# [boot.limine.ableos.modules.sunset_server]
|
||||||
path = "boot:///sunset_server.hbf"
|
# path = "boot:///sunset_server.hbf"
|
||||||
|
|
Loading…
Reference in a new issue