Wire real PS/2 scancodes through to input events and characters
Replace the keyboard driver's synthetic stream with the real path: - ps2-bus binds IRQ1 (interrupt bits set only after the bind), drains port 0x60 on each interrupt, and forwards every byte to the attached child driver over async ipc_send, routed by the status register's auxiliary-output bit. Children attach via the new well-known ps2_bus service, handing over their endpoint as a capability. - scancode.zig (new, pure, host-tested): scancode set 2 -> USB HID usage decoding (F0/E0/E1 prefix state machine) plus keyboard state — pressed-key bitmap, typematic-repeat classification, modifier and caps-lock tracking. - keyboard.zig decodes the forwarded stream and publishes real key_down/key_press/key_up events, filling key_press characters via xkeyboard-config (layout from argv[2], default us) and synthesizing ASCII control characters for Enter/Tab/Backspace/Escape. - protocol.zig names the full HID usage set in Keycode; build.zig threads the xkeyboard-config module into user binaries. Verified end to end in QEMU via monitor sendkey: shift, caps lock, and control-character synthesis all decode correctly. The mouse driver still publishes its synthetic stream; attaching it to the bus the same way is the follow-up.
This commit is contained in:
@@ -73,16 +73,125 @@ pub const modifier_shift: u32 = 1 << 0;
|
||||
pub const modifier_control: u32 = 1 << 1;
|
||||
pub const modifier_alt: u32 = 1 << 2;
|
||||
|
||||
/// A minimal danos-native keycode namespace — enough for the synthetic source and to show
|
||||
/// the shape. A real set (USB HID usage-style) fills in with the scancode decoder.
|
||||
/// The danos-native keycode namespace: USB HID keyboard-page usages (page 0x07), the
|
||||
/// numbering the PS/2 scancode decoder emits and the xkeyboard-config layout tables are
|
||||
/// indexed by. Non-exhaustive, so an unnamed usage still travels as a valid value.
|
||||
pub const Keycode = enum(u32) {
|
||||
unknown = 0,
|
||||
a = 4, // deliberately USB-HID-usage-aligned so a real decoder can extend this
|
||||
// letters
|
||||
a = 4,
|
||||
b = 5,
|
||||
c = 6,
|
||||
d = 7,
|
||||
e = 8,
|
||||
f = 9,
|
||||
g = 10,
|
||||
h = 11,
|
||||
i = 12,
|
||||
j = 13,
|
||||
k = 14,
|
||||
l = 15,
|
||||
m = 16,
|
||||
n = 17,
|
||||
o = 18,
|
||||
p = 19,
|
||||
q = 20,
|
||||
r = 21,
|
||||
s = 22,
|
||||
t = 23,
|
||||
u = 24,
|
||||
v = 25,
|
||||
w = 26,
|
||||
x = 27,
|
||||
y = 28,
|
||||
z = 29,
|
||||
// digit row
|
||||
one = 30,
|
||||
two = 31,
|
||||
three = 32,
|
||||
four = 33,
|
||||
five = 34,
|
||||
six = 35,
|
||||
seven = 36,
|
||||
eight = 37,
|
||||
nine = 38,
|
||||
zero = 39,
|
||||
// control and whitespace
|
||||
enter = 40,
|
||||
escape = 41,
|
||||
backspace = 42,
|
||||
tab = 43,
|
||||
spacebar = 44,
|
||||
// punctuation
|
||||
minus = 45,
|
||||
equal = 46,
|
||||
left_bracket = 47,
|
||||
right_bracket = 48,
|
||||
backslash = 49,
|
||||
non_us_hash = 50,
|
||||
semicolon = 51,
|
||||
apostrophe = 52,
|
||||
grave = 53,
|
||||
comma = 54,
|
||||
period = 55,
|
||||
slash = 56,
|
||||
caps_lock = 57,
|
||||
// function row
|
||||
f1 = 58,
|
||||
f2 = 59,
|
||||
f3 = 60,
|
||||
f4 = 61,
|
||||
f5 = 62,
|
||||
f6 = 63,
|
||||
f7 = 64,
|
||||
f8 = 65,
|
||||
f9 = 66,
|
||||
f10 = 67,
|
||||
f11 = 68,
|
||||
f12 = 69,
|
||||
print_screen = 70,
|
||||
scroll_lock = 71,
|
||||
pause = 72,
|
||||
// navigation
|
||||
insert = 73,
|
||||
home = 74,
|
||||
page_up = 75,
|
||||
delete = 76,
|
||||
end = 77,
|
||||
page_down = 78,
|
||||
right_arrow = 79,
|
||||
left_arrow = 80,
|
||||
down_arrow = 81,
|
||||
up_arrow = 82,
|
||||
// keypad
|
||||
num_lock = 83,
|
||||
keypad_slash = 84,
|
||||
keypad_asterisk = 85,
|
||||
keypad_minus = 86,
|
||||
keypad_plus = 87,
|
||||
keypad_enter = 88,
|
||||
keypad_one = 89,
|
||||
keypad_two = 90,
|
||||
keypad_three = 91,
|
||||
keypad_four = 92,
|
||||
keypad_five = 93,
|
||||
keypad_six = 94,
|
||||
keypad_seven = 95,
|
||||
keypad_eight = 96,
|
||||
keypad_nine = 97,
|
||||
keypad_zero = 98,
|
||||
keypad_period = 99,
|
||||
non_us_backslash = 100,
|
||||
application = 101,
|
||||
// modifiers
|
||||
left_control = 224,
|
||||
left_shift = 225,
|
||||
left_alt = 226,
|
||||
left_gui = 227,
|
||||
right_control = 228,
|
||||
right_shift = 229,
|
||||
right_alt = 230,
|
||||
right_gui = 231,
|
||||
_,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user