Search
lxdream.org :: lxdream/src/drivers/genkeymap.pl :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/genkeymap.pl
changeset 1183:425d9de21c78
prev917:2146dd5529fd
author nkeynes
date Tue Feb 28 17:25:26 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change Implement display output for the GLES2 case (no fixed function
rendering)
file annotate diff log raw
1.1 --- a/src/drivers/genkeymap.pl Fri Nov 07 07:53:31 2008 +0000
1.2 +++ b/src/drivers/genkeymap.pl Tue Feb 28 17:25:26 2012 +1000
1.3 @@ -1,56 +1,71 @@
1.4 #!/usr/bin/perl
1.5 -
1.6 use POSIX;
1.7
1.8 -my $dckeysymsfile = "dckeysyms.h";
1.9 +if( $#ARGV != 3 ) {
1.10 + die "Usage: genkeymap.pl <keysym-name> <dckeysyms.h> <keymap.txt> <output.h>\n";
1.11 +}
1.12 +
1.13 +my $name = shift();
1.14 +my $dckeysymsfile = shift();
1.15 +my $keymapfile = shift();
1.16 +my $outputfile = shift();
1.17 my %dcsyms = ();
1.18
1.19 -open DCKB, "<$dckeysymsfile" || die "Unable to open keysym file $dckeysymsfile";
1.20 +my %hash = ();
1.21 +my %rhash = ();
1.22 +
1.23 +open(DCKB, "<$dckeysymsfile") || die "Unable to open dckeysym file $dckeysymsfile";
1.24 while(<DCKB>) {
1.25 if( /^#define\s+DCKB_([^ ]*)/ ) {
1.26 $dcsyms{$1} = "DCKB_$1";
1.27 }
1.28 }
1.29 +close DCKB;
1.30
1.31 -my %hash = ();
1.32 -my %rhash = ();
1.33 -my $name = shift();
1.34 -while(<ARGV>) {
1.35 +open(KM, "<$keymapfile") || die "Unable to open keymap file $keymapfile";
1.36 +while(<KM>) {
1.37 my ($val, $sym) = split /\s+/;
1.38 $ival = POSIX::strtol($val,0);
1.39 $hash{$ival} = $sym;
1.40 $rhash{$sym} = $ival;
1.41 }
1.42 +close KM;
1.43
1.44 -print "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";
1.45 +open(OUT, ">$outputfile") || die "Unable to open output file $outputfile";
1.46 +print OUT "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";
1.47 +print OUT "const gchar *${name}_keysyms_by_keycode[128] = { ";
1.48
1.49 -print "const gchar *${name}_keysyms_by_keycode[128] = { ";
1.50 for( $i=0; $i < 128; $i++ ) {
1.51 - if( $i != 0 ) { print ", "; }
1.52 + if( $i != 0 ) {
1.53 + print OUT ", ";
1.54 + }
1.55 if( defined($hash{$i}) ) {
1.56 - print "\"$hash{$i}\"";
1.57 + print OUT "\"$hash{$i}\"";
1.58 } else {
1.59 - print "NULL";
1.60 + print OUT "NULL";
1.61 }
1.62 }
1.63 -print "};\n\n";
1.64 +print OUT "};\n\n";
1.65
1.66 -print "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";
1.67 +print OUT "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";
1.68 for( $i=0; $i<128; $i++ ) {
1.69 - if( $i != 0 ) { print ", "; }
1.70 + if( $i != 0 ) {
1.71 + print OUT ", ";
1.72 + }
1.73 if( defined($hash{$i}) && $dcsyms{$hash{$i}} ) {
1.74 - print $dcsyms{$hash{$i}};
1.75 + print OUT $dcsyms{$hash{$i}};
1.76 } else {
1.77 - print "DCKB_NONE";
1.78 + print OUT "DCKB_NONE";
1.79 }
1.80 }
1.81 -print "};\n\n";
1.82 +print OUT "};\n\n";
1.83
1.84 my @keys = sort {uc($a) cmp uc($b)} keys %rhash;
1.85 -print "#define ${name}_keysym_count " . ($#keys+1) . "\n";
1.86 -print "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";
1.87 -print "struct ${name}_keymap_struct ${name}_keysyms[] = { ";
1.88 +print OUT "#define ${name}_keysym_count " . ($#keys+1) . "\n";
1.89 +print OUT "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";
1.90 +print OUT "struct ${name}_keymap_struct ${name}_keysyms[] = { ";
1.91 foreach my $keysym (@keys) {
1.92 - print "{\"$keysym\", $rhash{$keysym} }, ";
1.93 + print OUT "{\"$keysym\", $rhash{$keysym} }, ";
1.94 }
1.95 -print "{NULL,-1} };\n\n";
1.96 +print OUT "{NULL,-1} };\n\n";
1.97 +close OUT;
.