3 $DEFAULT_EXT = ".kmap";
8 "usage: $0 [ -p old_code=new_code ] ...\n".
9 (" "x(8+length $0))."[path]default_layout[.map] ] ".
10 "[path]kbd_layout[.map]\n";
15 while ($ARGV[0] eq "-p") {
17 &usage unless $ARGV[0] =~ /=/;
18 $table[eval($`)] = eval($');
21 &usage unless defined $ARGV[0];
22 load_map("def",defined $ARGV[1] ? $ARGV[0] : undef);
23 load_map("kbd",defined $ARGV[1] ? $ARGV[1] : $ARGV[0]);
24 &build_table("plain","shift","ctrl","altgr","shift_ctrl",
25 "altgr_ctrl","alt","shift_alt","ctrl_alt");
26 for ($i = 0; $i < 256; $i++) {
27 printf("%c",$table[$i] ? $table[$i] : $i) || die "print: $!";
29 close STDOUT || die "close: $!";
34 local ($pfx,$map) = @_;
35 local ($empty,$current);
37 $map = $DEFAULT_MAP unless defined $map;
38 $map .= $DEFAULT_EXT unless $map =~ m|/[^/]+\.[^/]+$|;
39 if (!open(FILE,"loadkeys -m $map |")) {
40 print STDERR "loadkeys -m $map: $!\n";
47 if (/^(static\s+)?u_short\s+(\S+)_map\[\S*\]\s+=\s+{\s*$/) {
48 die "active at beginning of map" if defined $current;
49 $current = $pfx.":".$2;
52 undef $current if /^};\s*$/;
53 next unless defined $current;
60 print STDERR "Keymap is empty\n";
73 for (split(",",$map{"def:".$map})) {
74 die "bad map entry $_ (def, map $map)" unless /^0x\S\S(\S\S)$/;
75 $tmp[$code] = hex $1 unless $tmp[$code];
83 for (split(",",$map{"kbd:".$map})) {
84 die "bad map entry $_ (kbd, map $map)" unless /^0x\S\S(\S\S)$/;
85 $table[$tmp[$code]] = hex $1 unless $table[$tmp[$code]];