Import 2.3.25pre1
[davej-history.git] / drivers / usb / mkmap
blob35808f227cca0fa26e0ec5ac0092d21e018afa3e
1 #!/usr/bin/perl
3 ($ME = $0) =~ s|.*/||;
5 $file = "maps/serial.map";
6 $line = 1;
7 open(PC, $file) || die("$!");
8 while(<PC>)
10 if(/^\s*keycode\s+(\d+)\s*=\s*(\S+)/)
12 my($idx) = int($1);
13 my($sym) = $2;
14 if(defined($map{uc($sym)}))
16 # print STDERR "$file:$line: warning: `$sym' redefined\n";
18 $map{uc($sym)} = $idx;
20 $line++;
22 close(PC);
24 $file = "maps/fixup.map";
25 $line = 1;
26 open(FIXUP, $file) || die("$!");
27 while(<FIXUP>)
29 if(/^\s*keycode\s+(\d+)\s*=\s*/)
31 my($idx) = int($1);
32 for $sym (split(/\s+/, $'))
34 $map{uc($sym)} = $idx;
37 $line++;
39 close(FIXUP);
41 $file = "maps/usb.map";
42 $line = 1;
43 open(USB, $file) || die("$!");
44 while(<USB>)
46 if(/^\s*keycode\s+(\d+)\s*=\s*/)
48 my($idx) = int($1);
49 for $sym (split(/\s+/, $'))
51 my($val) = $map{uc($sym)};
52 $map[$idx] = $val;
53 if(!defined($val))
55 print STDERR "$file:$line: warning: `$sym' undefined\n";
57 else
59 last;
63 $line++;
65 close(USB);
67 print "unsigned char usb_kbd_map[256] = \n{\n";
68 for($x = 0; $x < 32; $x++)
70 if($x && !($x % 2))
72 print "\n";
74 print " ";
75 for($y = 0; $y < 8; $y++)
77 my($idx) = $x * 8 + $y;
78 print sprintf(" 0x%02x,",
79 int(defined($map[$idx]) ? $map[$idx]:0));
81 print "\n";
83 print "};\n";