WIP keyboard syscall

This commit is contained in:
2025-08-31 22:41:09 -06:00
parent 1bbd988ef7
commit 5d0a3608d1
8 changed files with 210 additions and 113 deletions

View File

@@ -7,3 +7,6 @@ edition = "2024"
embedded-graphics = "0.8.1"
shared = { path = "../shared" }
abi_sys = { path = "../abi_sys" }
talc = "4.4.3"
spin = "0.10.0"
embassy-time = "0.5.0"

View File

@@ -1,20 +1,20 @@
#![no_std]
use abi_sys::{Syscall, call_abi};
use shared::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers};
use abi_sys::draw_iter;
pub use abi_sys::{get_key, print};
pub use embassy_time;
pub use shared::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers};
use talc::*;
pub fn print(msg: &str) {
let syscall = Syscall::Print {
msg: msg.as_ptr(),
len: msg.len(),
};
unsafe {
call_abi(&syscall);
}
}
static mut ARENA: [u8; 10000] = [0; 10000];
#[global_allocator]
static ALLOCATOR: Talck<spin::Mutex<()>, ClaimOnOom> =
Talc::new(unsafe { ClaimOnOom::new(Span::from_array(core::ptr::addr_of!(ARENA).cast_mut())) })
.lock();
pub mod display {
use crate::{Syscall, call_abi};
use crate::draw_iter;
use embedded_graphics::{
Pixel,
geometry::{Dimensions, Point},
@@ -30,18 +30,6 @@ pub mod display {
pub struct Display;
impl Display {
fn syscall_draw(&self, pixels: &[Pixel565]) {
let syscall = Syscall::DrawIter {
pixels: pixels.as_ptr(),
len: pixels.len(),
};
unsafe {
call_abi(&syscall);
}
}
}
impl Dimensions for Display {
fn bounding_box(&self) -> Rectangle {
Rectangle {
@@ -71,13 +59,13 @@ pub mod display {
count += 1;
if count == BUF_SIZE {
self.syscall_draw(&buf[..count]);
draw_iter(&buf[..count]);
count = 0;
}
}
if count > 0 {
self.syscall_draw(&buf[..count]);
draw_iter(&buf[..count]);
}
Ok(())