Generating Busybox Binary Keymaps

Busybox is considered as the Swiss Army's Knife for embedded Linux: this package offers in a very compact footprint most of all the Linux command-line utilities.

However, as an international developper, I am concerned about using the right keyboard on my computer ;-). Unfortunately, This is not a trivial task in Busybox, as it uses a special binary keymap file format for specifying the keymap to use.

The standard Linux way of handling keymaps is using the kbd utility package. This package contains most of the worldwide keyboard definitions in a keymap format. The two most usefull commands are the loadkeys and dumpkeys, which respectively loads an ASCII keymap file into the kernel's internal translation table and dumps this table to the standard output.

Unfortunately, the keymaps file format (see Linux manual (5) for keymaps) is difficult to parse ,as it requires a full lex/yacc parser to handle it :-(.

However, such a parser is included into loadkeys... And this utility also provides a -m option that generates a C-style output of the file...

After studying Busybox's binary keymap format in details, it appears to be no more than just a file dump of all key translation tables for each state (ie. plain, shifted, controlled, etc.), preceeded by a binary map of translation tables.

So, I decided to write a patch to the kbd package to add a -b option that provides a binary keymap dump capability to loadkeys. Here it is!