[syslinux] proper keymap format ?

Michael Brown mcb30 at ipxe.org
Mon Apr 4 02:09:27 PDT 2011


On Monday 04 Apr 2011 00:14:01 H. Peter Anvin wrote:
> OK, let me rephrase that then:
> 
> 1. I'd like to have the maps in some kind of human-readable text format
> as the source material.
> 
> 2. I don't have time to maintain this... if someone is willing to do a
> git tree that I can pull I'm willing to include it.
> 
> I'm curious about what model Michael Brown has for iPXE.  It might be
> close enough that we could even use that format.

iPXE uses a method inspired by keytab-lilo, but with some additional sanity 
checks.  Essentially it comes down to:

1. Parse keymap generated by "loadkeys -b", for both the source ("us") and the 
target layout.

2. Find the ASCII equivalent for each {modifier,keycode} pair in each keymap.  
Special keys (i.e. anything other than KT_LATIN, KT_ASCII or KT_LETTER) are 
ignored.

3. Where an ASCII equivalent exists for a given {modifier,keycode} in both 
keymaps, create a mapping from the source ASCII character to the target ASCII 
character.

4. In cases where there are multiple possible ASCII mappings, choose the one 
generated from the numerically lower keycode.  This resolves the problem of 
keycode 86 (the "<"/">" key that doesn't seem to physically exist on most "us" 
keyboards).

5. Generate a table in C source code form consisting of byte pairs 
representing ASCII characters that need to be mapped.  For example:

  /** "uk" keyboard mapping */
  struct key_mapping uk_mapping[] __keymap = {
        { 0x22, 0x40 }, /* '"' => '@' */
        { 0x40, 0x22 }, /* '@' => '"' */
        { 0x5c, 0x23 }, /* '\\' => '#' */
        { 0x7c, 0x7e }, /* '|' => '~' */
  };

I use a byte pair array rather than a lookup table (as used in LILO/Syslinux) 
because it works out smaller for most keyboard maps, but the two forms are 
obviously equivalent.

This method is still subject to the limitations of mapping ASCII characters 
from the "us" layout used by the BIOS, but does produce human-readable 
annotated source files for the keyboard maps rather than binary blobs.

If it's useful, I'm happy to extend iPXE's genkeymap.pl to produce whatever 
source format works best for Syslinux.

Michael

PS - please avoid using the old mcb30 at etherboot.org address.  A test message 
sent to that address produces no delivery error, but doesn't turn up in my 
inbox.  I assume this is the result of incompetence rather than malice on the 
part of the domain owner, but there's no way of knowing.




More information about the Syslinux mailing list