misc
This commit is contained in:
parent
68d3236cc0
commit
8808ed5bfe
|
@ -1,3 +1,3 @@
|
||||||
[alias]
|
[alias]
|
||||||
repbuild = "run --manifest-path ./repbuild/Cargo.toml -r -- "
|
repbuild = "run --manifest-path ./repbuild/Cargo.toml -- "
|
||||||
dev = "run --manifest-path ./dev/Cargo.toml -r --"
|
dev = "run --manifest-path ./dev/Cargo.toml -r --"
|
||||||
|
|
|
@ -31,7 +31,7 @@ render_label_to_surface := fn(surface: Surface, label: Label, font: Font, pos: V
|
||||||
}
|
}
|
||||||
|
|
||||||
new_label := fn(text: ^u8): Label {
|
new_label := fn(text: ^u8): Label {
|
||||||
text_surface := render.new_surface(1000, 20)
|
text_surface := render.new_surface(1024, 20)
|
||||||
text_length := string.length(text)
|
text_length := string.length(text)
|
||||||
label := Label.(3, true, text_surface, text, text_length)
|
label := Label.(3, true, text_surface, text, text_length)
|
||||||
return label
|
return label
|
||||||
|
|
|
@ -11,12 +11,12 @@ KeyEvent := struct {
|
||||||
key: KeyCode,
|
key: KeyCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseEvent := struct {
|
MouseEvent := packed struct {
|
||||||
x_change: i8,
|
x_change: i8,
|
||||||
y_change: i8,
|
y_change: i8,
|
||||||
left: u8,
|
left: bool,
|
||||||
middle: u8,
|
middle: bool,
|
||||||
right: u8,
|
right: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
GamepadEvent := struct {}
|
GamepadEvent := struct {}
|
|
@ -6,34 +6,20 @@ events := @use("events.hb");
|
||||||
.{KeyEvent, MouseEvent} := events
|
.{KeyEvent, MouseEvent} := events
|
||||||
|
|
||||||
recieve_key_event := fn(): ?KeyEvent {
|
recieve_key_event := fn(): ?KeyEvent {
|
||||||
mem_page := memory.request_page(1)
|
return null
|
||||||
|
|
||||||
buf_id := buffer.search("PS/2 Keyboard\0")
|
|
||||||
|
|
||||||
// Read out of the keyboard buffer here
|
|
||||||
buffer.recv(KeyEvent, buf_id, mem_page)
|
|
||||||
|
|
||||||
key_event := KeyEvent.(0, 0, 2)
|
|
||||||
// return key_event
|
|
||||||
|
|
||||||
// return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recieve_mouse_event := fn(): ?MouseEvent {
|
recieve_mouse_event := fn(): ?MouseEvent {
|
||||||
mem_page := memory.request_page(1)
|
mevent := MouseEvent.(0, 0, false, false, false)
|
||||||
|
|
||||||
buf_id := buffer.search("PS/2 Mouse\0")
|
buf_id := buffer.search("PS/2 Mouse\0")
|
||||||
|
|
||||||
// Read out of the Mouse buffer here
|
// Read out of the Mouse buffer here
|
||||||
buffer.recv(MouseEvent, buf_id, mem_page)
|
buffer.recv(MouseEvent, buf_id, @bitcast(&mevent))
|
||||||
if *mem_page != 0 {
|
|
||||||
log.info("Mouse events\0")
|
if mevent.x_change != 0 | mevent.y_change != 0 | mevent.left | mevent.middle | mevent.right {
|
||||||
dx := @as(i8, @bitcast(*mem_page))
|
|
||||||
dy := @as(i8, @bitcast(*(mem_page + 1)))
|
|
||||||
mevent := MouseEvent.(dx, dy, 0, 0, 0)
|
|
||||||
return mevent
|
return mevent
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.error("No mouse events\0")
|
return null
|
||||||
return MouseEvent.(0, 0, 0, 0, 0)
|
|
||||||
}
|
}
|
|
@ -65,8 +65,7 @@ main := fn(): int {
|
||||||
// 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)
|
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)
|
||||||
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
||||||
|
@ -78,6 +77,7 @@ main := fn(): int {
|
||||||
{
|
{
|
||||||
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, screen.height - 1), render.white)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -111,8 +111,17 @@ main := fn(): int {
|
||||||
}
|
}
|
||||||
mouse_y -= change_y
|
mouse_y -= change_y
|
||||||
|
|
||||||
set_label_text(text_label, "Mouse Moved\0")
|
if mouse_event.left {
|
||||||
|
set_label_text(text_label, "LEFT CLICK\0")
|
||||||
|
} else if mouse_event.middle {
|
||||||
|
set_label_text(text_label, "MIDDLE CLICK\0")
|
||||||
|
} else if mouse_event.right {
|
||||||
|
set_label_text(text_label, "RIGHT CLICK\0")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||||
|
|
||||||
// render mouse
|
// render mouse
|
||||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||||
// Send events to focused window
|
// Send events to focused window
|
||||||
|
|
|
@ -118,17 +118,32 @@ main := fn(): int {
|
||||||
set_up_mouse()
|
set_up_mouse()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
event := MouseEvent.(0, 0, false, false, false)
|
||||||
|
|
||||||
changes := button_states ^ status & 7
|
changes := button_states ^ status & 7
|
||||||
|
|
||||||
if (changes & LeftButton.id) != 0 {
|
if (changes & LeftButton.id) != 0 {
|
||||||
button_event(LeftButton, (status & LeftButton.id) != 0)
|
if (status & LeftButton.id) != 0 {
|
||||||
|
event.left = true
|
||||||
|
} else {
|
||||||
|
event.left = false
|
||||||
}
|
}
|
||||||
if (changes & RightButton.id) != 0 {
|
|
||||||
button_event(RightButton, (status & RightButton.id) != 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes & MiddleButton.id) != 0 {
|
if (changes & MiddleButton.id) != 0 {
|
||||||
button_event(MiddleButton, (status & MiddleButton.id) != 0)
|
if (status & MiddleButton.id) != 0 {
|
||||||
|
event.middle = true
|
||||||
|
} else {
|
||||||
|
event.middle = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes & RightButton.id) != 0 {
|
||||||
|
if (status & RightButton.id) != 0 {
|
||||||
|
event.right = true
|
||||||
|
} else {
|
||||||
|
event.right = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button_states ^= changes
|
button_states ^= changes
|
||||||
|
@ -145,7 +160,6 @@ main := fn(): int {
|
||||||
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.(0, 0, 0, 0, 0)
|
|
||||||
event.x_change = x_change
|
event.x_change = x_change
|
||||||
event.y_change = y_change
|
event.y_change = y_change
|
||||||
|
|
||||||
|
|
|
@ -30,3 +30,6 @@ 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]
|
||||||
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
Loading…
Reference in a new issue