Generalize input module to mouse and joystick/gamepad events
Extend the input service beyond the keyboard so mouse and joystick/gamepad drivers can broadcast too, with per-device publish and subscribe methods. - protocol: KeyEvent joins MouseEvent (motion/buttons/scroll) and JoystickEvent (axes/buttons), all carried in a common InputEvent envelope tagged with a DeviceKind. A subscribe request carries a device_mask, so a subscriber names the classes it wants and the service routes each event only to interested subscribers (a mouse-only listener never wakes for keystrokes). - runtime: per-device publish methods (publishKeyboardEvent/publishMouseEvent/ publishJoystickEvent) and subscribe helpers (subscribeKeyboard/Mouse/Joystick, each typed, plus subscribe(mask)/subscribeAll returning the tagged envelope). - service: subscriber table gains a device_mask; broadcast routes by the event's device class. - mouse driver now publishes (synthetic) mouse events like the keyboard driver; input-source cycles all three classes; input-test subscribes to all and only emits its "ok" marker once it has received one of each class — so the passing test proves per-device routing, not just delivery. Real HID decoding stays a follow-up. No kernel changes: ipc_send is generic and the 36-byte InputEvent fits its 64-byte payload. Full QEMU suite 48/48; serial log confirms keyboard, mouse, and joystick all reach one subscription.
This commit is contained in:
@@ -1587,13 +1587,14 @@ fn vfsTest(boot_information: *const BootInformation) void {
|
||||
result();
|
||||
}
|
||||
|
||||
/// The full input path: spawn the input service, a synthetic keyboard source, and a
|
||||
/// subscriber from the initial_ramdisk. The source publishes key events; the service
|
||||
/// broadcasts them (with the asynchronous ipc_send); the subscriber receives them and —
|
||||
/// only once it has — heartbeats "input-test: ok". Seeing that marker proves an event
|
||||
/// travelled source -> service -> subscriber over IPC, exercising the async buffered-send
|
||||
/// primitive and capability-passing subscription. The source and service stay silent
|
||||
/// after startup so the subscriber's line is the one left in the shared evidence buffer.
|
||||
/// The full input path: spawn the input service, a synthetic source, and a subscriber from
|
||||
/// the initial_ramdisk. The source publishes keyboard, mouse, and joystick events in turn;
|
||||
/// the service routes them (with the asynchronous ipc_send) to the subscriber, which took
|
||||
/// all three classes and — only once it has received one — heartbeats "input-test: ok".
|
||||
/// Seeing that marker proves an event travelled source -> service -> subscriber over IPC,
|
||||
/// exercising the async buffered-send primitive, capability-passing subscription, and
|
||||
/// per-device routing. The source and service stay silent after startup so the subscriber's
|
||||
/// line is the one left in the shared evidence buffer.
|
||||
fn inputTest(boot_information: *const BootInformation) void {
|
||||
log("DANOS-TEST-BEGIN: input\n", .{});
|
||||
if (boot_information.initial_ramdisk_len == 0) {
|
||||
|
||||
Reference in New Issue
Block a user