Skip to content

feat(kbd): layouts desde XKB (sin .klc) + tests + migración - #705

Merged
alexis900 merged 5 commits into
developfrom
fix/kbd-layouts-394
Oct 14, 2026
Merged

alexis900 merged 5 commits into
developfrom
fix/kbd-layouts-394

Conversation

@alexis900

@alexis900 alexis900 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Consolida el pipeline de layouts de teclado.

Qué

  • XKB como fuente (tools/xkbcompile): resuelve include, EVDEV→scancode set-1, niveles 1-3, keysyms Latin-1/U<hex>/Latin-2, dead keys + compose desde el Compose de X11.
  • Elimina los .klc (en-US.klc, es-ES.klc); los .kbd se generan de XKB.
  • Genera 15 locales: en-US, es-ES (es(deadtilde), dead tilde en AltGr+4), ca-ES (es(cat)), fr-FR, de-DE, it-IT, pt-PT, pt-BR, nl-NL, sv-SE, da-DK, nb-NO, fi-FI, pl-PL, cs-CZ.
  • scripts/gen-keyboard-layouts.sh / check-keyboard-layouts.sh + job de CI.
  • Kernel: load_kbd dimensiona el buffer por inodo (antes cap fijo 8 KiB); migración/persistencia de Layout en Registry; tests extra (KBD-TESTS: Tests de integración de NeoKBD #394).

Limitación conocida

Solo en-US/es-ES se cargan al boot por ahora: habilitar los 15 llena la page cache y destapa #709 (eviction de páginas dirty por dev_tag/LBA). Para activar el resto, una vez arreglado #709, basta ampliar LAYOUT_TAGS (kernel) y kbd_layouts (NeoDev, PR #42).

Verificación

neodev build --image + neodev test → 968/968. check-keyboard-layouts.sh OK. check-i18n, check-skills, markdownlint OK.

kbdcompile never parsed the real KLC layout table, so US.kbd/Spanish.kbd
shipped with 256 empty entries. Only the kernel's built-in US fallback
worked; switching to Spanish changed the index but typed nothing.

- rewrite the KLC parser: shift-state columns, `@` dead keys and the
  DEADKEY/COMPOSE tables; regenerate the layouts from the sources.
- rename the layouts to locale tags `en-US`/`es-ES` (files
  `en-US.kbd`/`es-ES.kbd`) and migrate legacy `US`/`Spanish` Registry
  values on load.
- add kernel tests for switching by name (case-insensitive) and typing
  with the Spanish layout (ñ/Ñ/ç, dead keys, composition).
The Registry value was only normalised in memory at load, so a legacy
`Layout = "Spanish"`/`"US"` stayed on disk until the next write.

Resolve the persisted name against the layouts actually loaded (by name,
language tag, then legacy `US`/`Spanish` aliases) in `kbd_init()`, and
persist the canonical name when it differs — the Registry now converges
to `en-US`/`es-ES` instead of keeping a stale value. Drops the static
`normalize_layout_name` table from `kbd_load_config`.
Extend the NeoKBD tests toward the §7 plan: a missing `.kbd` is rejected,
repeat delay/rate bounds are enforced, the LED mask is clamped to 0x07 and
Shift make/break toggles the modifier bit.
Sourcing layouts from Microsoft `.klc` is awkward (MSKLC GUI) and the
files are Microsoft-licensed. Add a host tool that reads the open, offline
XKB data (`/usr/share/X11/xkb/symbols/*`) and emits the NeoDOS `.kbd`
format directly.

- resolves `include "file(section)"` chains, maps EVDEV -> set-1
  scancodes, maps levels 1-3 to normal/shift/altgr, translates Latin-1 /
  `U<hex>` / common keysym names, marks dead keys and builds the compose
  table from the X11 `Compose` file.
- verified `us`, `es`, `fr`, `de`: the `es` output matches the
  `.klc`-derived `es-ES` (ñ/Ñ, ´/¨, ç/Ç, dead keys, ¡/¿).

Related: #390 (dynamic .kbd discovery) — new layouts still need wiring
into the image allowlist and the kernel load list.
Make the open, offline XKB data the source of truth for keyboard layouts
and remove the intermediate `.klc` files.

- xkbcompile: strip `//` comments before splitting statements (an
  `include` preceded by a comment was being dropped — broke no/pl/br),
  add Latin-2 keysyms, and use it to generate 15 locales
  (en-US … cs-CZ; es-ES via `es(deadtilde)` so dead tilde is AltGr+4).
- data/keyboard: remove en-US.klc/es-ES.klc; add the generated .kbd.
- scripts/gen + check for all locales, wired into a CI job.
- kernel: load_kbd sizes the buffer from the inode instead of a fixed
  8 KiB cap; only en-US/es-ES are enabled at boot for now — loading all
  fifteen stresses the page cache and triggers #709.
@alexis900 alexis900 changed the title fix(kbd): real .kbd layouts and locale-tag names (en-US/es-ES) feat(kbd): layouts desde XKB (sin .klc) + tests + migración Oct 13, 2026
@alexis900
alexis900 merged commit a11b924 into develop Oct 14, 2026
4 checks passed
@alexis900
alexis900 deleted the fix/kbd-layouts-394 branch October 14, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant