feat(display): input routed via display server to focused app; input Subscribe; uses caps badged + Delegate

This commit is contained in:
2026-10-27 16:38:16 +01:00
parent 64ec5df379
commit 2845d190f0
18 changed files with 286 additions and 26 deletions

View File

@@ -12,8 +12,8 @@ use libkos::syscall;
use server_framework::Encode;
use display_server::protocol::DisplayRequest;
const INPUT_EP: CapSlot = CapSlot::const_new(0);
const DISPLAY_EP: CapSlot = CapSlot::const_new(1);
/// Input comes through the display server too, while this app has focus.
const DISPLAY_EP: CapSlot = CapSlot::const_new(0);
const TICK_DELAY: u64 = 5_000_000;
const MAX_RENDER_CMDS: usize = 140;
@@ -37,6 +37,8 @@ fn flush() {
#[unsafe(no_mangle)]
extern "C" fn main() {
// Takes focus; the game polls every tick, so it never waits on the signal.
let _ = libkos::display::subscribe_input(DISPLAY_EP);
let mut snake = Snake::new();
let mut commands = [RenderCommand { x: 0, y: 0, w: 0, h: 0, color: 0 }; MAX_RENDER_CMDS];
@@ -65,7 +67,7 @@ extern "C" fn main() {
fn handle_input(snake: &mut Snake) {
// Drain all pending events, apply the latest direction
loop {
let Ok([tag, kind, _, _]) = syscall::request(INPUT_EP, [0; 4]) else {
let Ok([tag, kind, _, _]) = syscall::request(DISPLAY_EP, [types::display::input::POLL, 0, 0, 0]) else {
break;
};
if tag == 0 { break; } // NoEvent — queue drained