Search
lxdream.org :: lxdream :: r1183:425d9de21c78
lxdream 0.9.1
released Jun 29
Download Now
changeset1183:425d9de21c78
parent1182:b38a327ad8fa
child1184:0a306d645e2c
authornkeynes
dateTue Nov 29 16:15:38 2011 +1000 (7 years ago)
Fix out-of-tree builds of the mac keymaps
src/Makefile.am
src/Makefile.in
src/drivers/genkeymap.pl
1.1 --- a/src/Makefile.am Sun Nov 27 18:20:21 2011 +1000
1.2 +++ b/src/Makefile.am Tue Nov 29 16:15:38 2011 +1000
1.3 @@ -257,7 +257,7 @@
1.4 $(mkdir_p) `dirname $@`
1.5 ./genglsl $(srcdir)/pvr2/shaders.glsl $@
1.6 pvr2/shaders.h: pvr2/shaders.def
1.7 -drivers/mac_keymap.h: drivers/mac_keymap.txt drivers/genkeymap.pl
1.8 +drivers/mac_keymap.h: dckeysyms.h drivers/mac_keymap.txt drivers/genkeymap.pl
1.9 $(mkdir_p) `dirname $@`
1.10 - $(srcdir)/drivers/genkeymap.pl mac $(srcdir)/drivers/mac_keymap.txt > $@
1.11 + $(srcdir)/drivers/genkeymap.pl mac $(srcdir)/dckeysyms.h $(srcdir)/drivers/mac_keymap.txt $@
1.12
1.13 \ No newline at end of file
2.1 --- a/src/Makefile.in Sun Nov 27 18:20:21 2011 +1000
2.2 +++ b/src/Makefile.in Tue Nov 29 16:15:38 2011 +1000
2.3 @@ -3217,9 +3217,9 @@
2.4 $(mkdir_p) `dirname $@`
2.5 ./genglsl $(srcdir)/pvr2/shaders.glsl $@
2.6 pvr2/shaders.h: pvr2/shaders.def
2.7 -drivers/mac_keymap.h: drivers/mac_keymap.txt drivers/genkeymap.pl
2.8 +drivers/mac_keymap.h: dckeysyms.h drivers/mac_keymap.txt drivers/genkeymap.pl
2.9 $(mkdir_p) `dirname $@`
2.10 - $(srcdir)/drivers/genkeymap.pl mac $(srcdir)/drivers/mac_keymap.txt > $@
2.11 + $(srcdir)/drivers/genkeymap.pl mac $(srcdir)/dckeysyms.h $(srcdir)/drivers/mac_keymap.txt $@
2.12 # Tell versions [3.59,3.63) of GNU make to not export all variables.
2.13 # Otherwise a system limit (for SysV at least) may be exceeded.
2.14 .NOEXPORT:
3.1 --- a/src/drivers/genkeymap.pl Sun Nov 27 18:20:21 2011 +1000
3.2 +++ b/src/drivers/genkeymap.pl Tue Nov 29 16:15:38 2011 +1000
3.3 @@ -1,56 +1,71 @@
3.4 #!/usr/bin/perl
3.5 -
3.6 use POSIX;
3.7
3.8 -my $dckeysymsfile = "dckeysyms.h";
3.9 +if( $#ARGV != 3 ) {
3.10 + die "Usage: genkeymap.pl <keysym-name> <dckeysyms.h> <keymap.txt> <output.h>\n";
3.11 +}
3.12 +
3.13 +my $name = shift();
3.14 +my $dckeysymsfile = shift();
3.15 +my $keymapfile = shift();
3.16 +my $outputfile = shift();
3.17 my %dcsyms = ();
3.18
3.19 -open DCKB, "<$dckeysymsfile" || die "Unable to open keysym file $dckeysymsfile";
3.20 +my %hash = ();
3.21 +my %rhash = ();
3.22 +
3.23 +open(DCKB, "<$dckeysymsfile") || die "Unable to open dckeysym file $dckeysymsfile";
3.24 while(<DCKB>) {
3.25 if( /^#define\s+DCKB_([^ ]*)/ ) {
3.26 $dcsyms{$1} = "DCKB_$1";
3.27 }
3.28 }
3.29 +close DCKB;
3.30
3.31 -my %hash = ();
3.32 -my %rhash = ();
3.33 -my $name = shift();
3.34 -while(<ARGV>) {
3.35 +open(KM, "<$keymapfile") || die "Unable to open keymap file $keymapfile";
3.36 +while(<KM>) {
3.37 my ($val, $sym) = split /\s+/;
3.38 $ival = POSIX::strtol($val,0);
3.39 $hash{$ival} = $sym;
3.40 $rhash{$sym} = $ival;
3.41 }
3.42 +close KM;
3.43
3.44 -print "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";
3.45 +open(OUT, ">$outputfile") || die "Unable to open output file $outputfile";
3.46 +print OUT "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";
3.47 +print OUT "const gchar *${name}_keysyms_by_keycode[128] = { ";
3.48
3.49 -print "const gchar *${name}_keysyms_by_keycode[128] = { ";
3.50 for( $i=0; $i < 128; $i++ ) {
3.51 - if( $i != 0 ) { print ", "; }
3.52 + if( $i != 0 ) {
3.53 + print OUT ", ";
3.54 + }
3.55 if( defined($hash{$i}) ) {
3.56 - print "\"$hash{$i}\"";
3.57 + print OUT "\"$hash{$i}\"";
3.58 } else {
3.59 - print "NULL";
3.60 + print OUT "NULL";
3.61 }
3.62 }
3.63 -print "};\n\n";
3.64 +print OUT "};\n\n";
3.65
3.66 -print "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";
3.67 +print OUT "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";
3.68 for( $i=0; $i<128; $i++ ) {
3.69 - if( $i != 0 ) { print ", "; }
3.70 + if( $i != 0 ) {
3.71 + print OUT ", ";
3.72 + }
3.73 if( defined($hash{$i}) && $dcsyms{$hash{$i}} ) {
3.74 - print $dcsyms{$hash{$i}};
3.75 + print OUT $dcsyms{$hash{$i}};
3.76 } else {
3.77 - print "DCKB_NONE";
3.78 + print OUT "DCKB_NONE";
3.79 }
3.80 }
3.81 -print "};\n\n";
3.82 +print OUT "};\n\n";
3.83
3.84 my @keys = sort {uc($a) cmp uc($b)} keys %rhash;
3.85 -print "#define ${name}_keysym_count " . ($#keys+1) . "\n";
3.86 -print "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";
3.87 -print "struct ${name}_keymap_struct ${name}_keysyms[] = { ";
3.88 +print OUT "#define ${name}_keysym_count " . ($#keys+1) . "\n";
3.89 +print OUT "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";
3.90 +print OUT "struct ${name}_keymap_struct ${name}_keysyms[] = { ";
3.91 foreach my $keysym (@keys) {
3.92 - print "{\"$keysym\", $rhash{$keysym} }, ";
3.93 + print OUT "{\"$keysym\", $rhash{$keysym} }, ";
3.94 }
3.95 -print "{NULL,-1} };\n\n";
3.96 +print OUT "{NULL,-1} };\n\n";
3.97 +close OUT;
.