feat: VirtIO keyboard input for QEMU GUI

- Add VirtIO input device driver (device ID 18) reading from eventq
- Translate Linux keycodes (WASD, arrows) to InputEvent
- Kernel probes for VirtIO input device, falls back to UART
- Add -device virtio-keyboard-device to run-gui Makefile target
- input-qemu tries VirtIO first, falls back to UART
This commit is contained in:
2026-10-19 00:30:20 +02:00
parent 68849f698b
commit 0a47b5489a
9 changed files with 259 additions and 12 deletions

View File

@@ -3,14 +3,30 @@
extern crate userspace_rt;
use driver_input_uart::UartInputDevice;
use types::bounded::CapSlot;
#[unsafe(no_mangle)]
extern "C" fn main() {
let device = UartInputDevice::new();
let mut srv = input_server::server::InputServer::new(device);
let ep = CapSlot::new(0).unwrap();
server_framework::serve(&mut srv, ep);
if let Some(dev) = driver_input_virtio::VirtioInputDevice::try_new() {
run_input(dev, ep);
} else {
run_uart(ep);
}
loop { userspace::syscall::yield_now(); }
}
#[inline(never)]
fn run_input(device: driver_input_virtio::VirtioInputDevice, ep: CapSlot) {
let mut srv = input_server::server::InputServer::new(device);
server_framework::serve(&mut srv, ep);
}
#[inline(never)]
fn run_uart(ep: CapSlot) {
let device = driver_input_uart::UartInputDevice::new();
let mut srv = input_server::server::InputServer::new(device);
server_framework::serve(&mut srv, ep);
}