5 die "Usage: genkeymap.pl <keysym-name> <dckeysyms.h> <keymap.txt> <output.h>\n";
9 my $dckeysymsfile = shift();
10 my $keymapfile = shift();
11 my $outputfile = shift();
17 open(DCKB, "<$dckeysymsfile") || die "Unable to open dckeysym file $dckeysymsfile";
19 if( /^#define\s+DCKB_([^ ]*)/ ) {
20 $dcsyms{$1} = "DCKB_$1";
25 open(KM, "<$keymapfile") || die "Unable to open keymap file $keymapfile";
27 my ($val, $sym) = split /\s+/;
28 $ival = POSIX::strtol($val,0);
34 open(OUT, ">$outputfile") || die "Unable to open output file $outputfile";
35 print OUT "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";
36 print OUT "const gchar *${name}_keysyms_by_keycode[128] = { ";
38 for( $i=0; $i < 128; $i++ ) {
42 if( defined($hash{$i}) ) {
43 print OUT "\"$hash{$i}\"";
50 print OUT "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";
51 for( $i=0; $i<128; $i++ ) {
55 if( defined($hash{$i}) && $dcsyms{$hash{$i}} ) {
56 print OUT $dcsyms{$hash{$i}};
58 print OUT "DCKB_NONE";
63 my @keys = sort {uc($a) cmp uc($b)} keys %rhash;
64 print OUT "#define ${name}_keysym_count " . ($#keys+1) . "\n";
65 print OUT "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";
66 print OUT "struct ${name}_keymap_struct ${name}_keysyms[] = { ";
67 foreach my $keysym (@keys) {
68 print OUT "{\"$keysym\", $rhash{$keysym} }, ";
70 print OUT "{NULL,-1} };\n\n";
.