feat(userspace): programs in /bin w/o .elf; bin manifests (needs = display) so shell runs snake; Ctrl+C kills foreground via terminal interrupt notification; ctrl keys; sleep

This commit is contained in:
2026-10-27 21:16:00 +01:00
parent 1fc5a54f06
commit 83809bbe94
33 changed files with 608 additions and 121 deletions

View File

@@ -4,6 +4,17 @@ use port_input_device::Key;
pub const LEFT_SHIFT: u16 = 42;
pub const RIGHT_SHIFT: u16 = 54;
pub const LEFT_CTRL: u16 = 29;
pub const RIGHT_CTRL: u16 = 97;
/// A letter typed with Ctrl held is its control character, as on a
/// terminal: Ctrl+C is 3. Anything else is itself.
pub fn with_ctrl(key: Key) -> Key {
match key {
Key::Char(c) if c.is_ascii_alphabetic() => Key::Char(c.to_ascii_lowercase() & 0x1f),
k => k,
}
}
/// Rows of the main block: the first key's code, then each key unshifted
/// and shifted.
@@ -41,6 +52,14 @@ pub fn key(code: u16, shift: bool) -> Option<Key> {
mod tests {
use super::*;
#[test]
fn ctrl_letters_are_control_characters() {
assert_eq!(with_ctrl(Key::Char(b'c')), Key::Char(3));
assert_eq!(with_ctrl(Key::Char(b'C')), Key::Char(3));
assert_eq!(with_ctrl(Key::Char(b'1')), Key::Char(b'1'));
assert_eq!(with_ctrl(Key::Enter), Key::Enter);
}
#[test]
fn letters_digits_and_shift() {
assert_eq!(key(35, false), Some(Key::Char(b'h')));