feat(keymap): extract pure HID decode into host-testable crate

The Key type, US-QWERTY translate, and the edge-detecting boot-report
parser lived in usb_kbd.rs, unreachable by cargo test (the firmware
crate is pinned to the xtensa target). Move them to a dependency-free
#![no_std] + #![forbid(unsafe_code)] crate so the one path that parses
untrusted device bytes can be exercised on the host.

14 tests, including an ASCII-invariant sweep over all 256 usage IDs
(pins the guarantee the editor's byte==char indexing relies on) and a
never-panics fuzz over arbitrary-length/content reports.
This commit is contained in:
Julien Calixte
2026-07-10 10:36:37 +01:00
parent f373892870
commit 2cd3bba98d
3 changed files with 367 additions and 0 deletions

10
keymap/Cargo.toml Normal file
View File

@@ -0,0 +1,10 @@
[package]
name = "keymap"
version = "0.1.0"
edition = "2021"
description = "Pure HID boot-keyboard decode: the Key event type, a US-QWERTY translate, and an edge-detecting Decoder. No esp/std deps, so it is host-testable and fuzzable off-device (see MEMORY_AUDIT.md)."
# Deliberately dependency-free and #![no_std] (except under test) so the decode
# path — the one place untrusted device bytes are parsed — can be exercised on
# the host without the ESP toolchain. The firmware crate depends on this by path.
[dependencies]