Skip to content

Commit

Permalink
[console] Try to avoid problems caused by keycode 86
Browse files Browse the repository at this point in the history
The "us" keyboard layout contains a mapping for keycode 86 (which
seems not to correspond to any physical key on many US keyboards) to
the ASCII character '<'.  This mapping causes conflicts with the
mapping for keycode 51, which also maps (with shift) to '<'.

Change the keyboard mapping generator to choose the lowest keycode for
each ASCII character as indicating the relevant mapping to use, on the
basis that a lower keycode roughly indicates a "more normal" key.  On
a German keyboard, which has keys for both keycode 51 and keycode 86
present, this causes '<' to be remapped to ';', which is a closer
match to typical user expectations.

Reported-by: Sven Dreyer <sven@dreyer-net.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 16, 2011
1 parent dbb27c9 commit 48624cf
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_al.c
Expand Up @@ -16,6 +16,7 @@ struct key_mapping al_mapping[] __keymap = {
{ 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */
{ 0x22, 0x7b }, /* '"' => '{' */
{ 0x27, 0x5b }, /* '\'' => '[' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x40, 0x22 }, /* '@' => '"' */
{ 0x59, 0x5a }, /* 'Y' => 'Z' */
Expand Down
2 changes: 1 addition & 1 deletion src/hci/keymap/keymap_cz.c
Expand Up @@ -16,7 +16,7 @@ struct key_mapping cz_mapping[] __keymap = {
{ 0x2d, 0x3d }, /* '-' => '=' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x31, 0x2b }, /* '1' => '+' */
{ 0x3c, 0x5c }, /* '<' => '\\' */
{ 0x3c, 0x2c }, /* '<' => ',' */
{ 0x3e, 0x2e }, /* '>' => '.' */
{ 0x3f, 0x2d }, /* '?' => '-' */
{ 0x5d, 0x29 }, /* ']' => ')' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_de.c
Expand Up @@ -25,6 +25,7 @@ struct key_mapping de_mapping[] __keymap = {
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3a, 0x7b }, /* ':' => '{' */
{ 0x3b, 0x5b }, /* ';' => '[' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3d, 0x27 }, /* '=' => '\'' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_dk.c
Expand Up @@ -19,6 +19,7 @@ struct key_mapping dk_mapping[] __keymap = {
{ 0x2b, 0x60 }, /* '+' => '`' */
{ 0x2d, 0x2b }, /* '-' => '+' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
{ 0x40, 0x22 }, /* '@' => '"' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_es.c
Expand Up @@ -18,6 +18,7 @@ struct key_mapping es_mapping[] __keymap = {
{ 0x2a, 0x28 }, /* '*' => '(' */
{ 0x2d, 0x27 }, /* '-' => '\'' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
{ 0x40, 0x22 }, /* '@' => '"' */
Expand Down
2 changes: 2 additions & 0 deletions src/hci/keymap/keymap_et.c
Expand Up @@ -18,11 +18,13 @@ struct key_mapping et_mapping[] __keymap = {
{ 0x2a, 0x28 }, /* '*' => '(' */
{ 0x2d, 0x2b }, /* '-' => '+' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
{ 0x40, 0x22 }, /* '@' => '"' */
{ 0x5c, 0x27 }, /* '\\' => '\'' */
{ 0x5e, 0x26 }, /* '^' => '&' */
{ 0x5f, 0x3f }, /* '_' => '?' */
{ 0x7c, 0x2a }, /* '|' => '*' */
{ 0x7f, 0x1b }, /* 0x7f => 0x1b */
};
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_fi.c
Expand Up @@ -23,6 +23,7 @@ struct key_mapping fi_mapping[] __keymap = {
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3a, 0x5c }, /* ':' => '\\' */
{ 0x3b, 0x7c }, /* ';' => '|' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3d, 0x27 }, /* '=' => '\'' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_fr.c
Expand Up @@ -42,6 +42,7 @@ struct key_mapping fr_mapping[] __keymap = {
{ 0x39, 0x2f }, /* '9' => '/' */
{ 0x3a, 0x4d }, /* ':' => 'M' */
{ 0x3b, 0x6d }, /* ';' => 'm' */
{ 0x3c, 0x2e }, /* '<' => '.' */
{ 0x3e, 0x2f }, /* '>' => '/' */
{ 0x3f, 0x5c }, /* '?' => '\\' */
{ 0x40, 0x32 }, /* '@' => '2' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_it.c
Expand Up @@ -19,6 +19,7 @@ struct key_mapping it_mapping[] __keymap = {
{ 0x2b, 0x5e }, /* '+' => '^' */
{ 0x2d, 0x27 }, /* '-' => '\'' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
{ 0x40, 0x22 }, /* '@' => '"' */
Expand Down
1 change: 0 additions & 1 deletion src/hci/keymap/keymap_lt.c
Expand Up @@ -12,5 +12,4 @@ FILE_LICENCE ( PUBLIC_DOMAIN );

/** "lt" keyboard mapping */
struct key_mapping lt_mapping[] __keymap = {
{ 0x7f, 0x08 }, /* 0x7f => Ctrl-H */
};
1 change: 0 additions & 1 deletion src/hci/keymap/keymap_mt.c
Expand Up @@ -17,5 +17,4 @@ struct key_mapping mt_mapping[] __keymap = {
{ 0x40, 0x22 }, /* '@' => '"' */
{ 0x5c, 0x23 }, /* '\\' => '#' */
{ 0x7c, 0x7e }, /* '|' => '~' */
{ 0x7f, 0x08 }, /* 0x7f => Ctrl-H */
};
2 changes: 1 addition & 1 deletion src/hci/keymap/keymap_nl.c
Expand Up @@ -20,7 +20,7 @@ struct key_mapping nl_mapping[] __keymap = {
{ 0x2d, 0x2f }, /* '-' => '/' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3b, 0x2b }, /* ';' => '+' */
{ 0x3c, 0x5d }, /* '<' => ']' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x3d }, /* '?' => '=' */
{ 0x40, 0x22 }, /* '@' => '"' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_sg.c
Expand Up @@ -24,6 +24,7 @@ struct key_mapping sg_mapping[] __keymap = {
{ 0x2b, 0x60 }, /* '+' => '`' */
{ 0x2d, 0x27 }, /* '-' => '\'' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3d, 0x5e }, /* '=' => '^' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_sr.c
Expand Up @@ -21,6 +21,7 @@ struct key_mapping sr_mapping[] __keymap = {
{ 0x2b, 0x2a }, /* '+' => '*' */
{ 0x2d, 0x27 }, /* '-' => '\'' */
{ 0x2f, 0x2d }, /* '/' => '-' */
{ 0x3c, 0x3b }, /* '<' => ';' */
{ 0x3d, 0x2b }, /* '=' => '+' */
{ 0x3e, 0x3a }, /* '>' => ':' */
{ 0x3f, 0x5f }, /* '?' => '_' */
Expand Down
1 change: 0 additions & 1 deletion src/hci/keymap/keymap_th.c
Expand Up @@ -12,5 +12,4 @@ FILE_LICENCE ( PUBLIC_DOMAIN );

/** "th" keyboard mapping */
struct key_mapping th_mapping[] __keymap = {
{ 0x7f, 0x08 }, /* 0x7f => Ctrl-H */
};
1 change: 0 additions & 1 deletion src/hci/keymap/keymap_ua.c
Expand Up @@ -12,5 +12,4 @@ FILE_LICENCE ( PUBLIC_DOMAIN );

/** "ua" keyboard mapping */
struct key_mapping ua_mapping[] __keymap = {
{ 0x7f, 0x08 }, /* 0x7f => Ctrl-H */
};
1 change: 0 additions & 1 deletion src/hci/keymap/keymap_uk.c
Expand Up @@ -13,7 +13,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN );
/** "uk" keyboard mapping */
struct key_mapping uk_mapping[] __keymap = {
{ 0x22, 0x40 }, /* '"' => '@' */
{ 0x3c, 0x5c }, /* '<' => '\\' */
{ 0x40, 0x22 }, /* '@' => '"' */
{ 0x5c, 0x23 }, /* '\\' => '#' */
{ 0x7c, 0x7e }, /* '|' => '~' */
Expand Down
1 change: 1 addition & 0 deletions src/hci/keymap/keymap_wo.c
Expand Up @@ -36,6 +36,7 @@ struct key_mapping wo_mapping[] __keymap = {
{ 0x38, 0x5f }, /* '8' => '_' */
{ 0x3a, 0x4d }, /* ':' => 'M' */
{ 0x3b, 0x6d }, /* ';' => 'm' */
{ 0x3c, 0x2e }, /* '<' => '.' */
{ 0x3e, 0x2f }, /* '>' => '/' */
{ 0x40, 0x32 }, /* '@' => '2' */
{ 0x41, 0x51 }, /* 'A' => 'Q' */
Expand Down
19 changes: 15 additions & 4 deletions src/util/genkeymap.pl
Expand Up @@ -172,15 +172,26 @@ sub translate_keymaps {
or next;
my $to_ascii = keysym_to_ascii ( $to->[$keymap]->[$keycode] )
or next;
if ( ( $from_ascii != $to_ascii ) && $verbosity > 1 ) {
my $new_map = ( ! exists $map->{$from_ascii} );
my $update_map =
( $new_map || ( $keycode < $map->{$from_ascii}->{keycode} ) );
if ( ( $verbosity > 1 ) &&
( ( $from_ascii != $to_ascii ) ||
( $update_map && ! $new_map ) ) ) {
printf STDERR "In keymap %d: %s => %s%s\n", $keymap,
ascii_to_name ( $from_ascii ), ascii_to_name ( $to_ascii ),
( $map->{$from_ascii} ? " (ignored)" : "" );
( $update_map ? ( $new_map ? "" : " (override)" )
: " (ignored)" );
}
if ( $update_map ) {
$map->{$from_ascii} = {
to_ascii => $to_ascii,
keycode => $keycode,
};
}
$map->{$from_ascii} ||= $to_ascii;
}
}
return $map;
return { map { $_ => $map->{$_}->{to_ascii} } keys %$map };
}
# Parse command-line options
Expand Down

0 comments on commit 48624cf

Please sign in to comment.