filename | src/drivers/genkeymap.pl |
changeset | 681:1755a126b109 |
next | 917:2146dd5529fd |
author | nkeynes |
date | Sun Aug 03 02:55:27 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Check the MAX_COLOR_ATTACHMENTS value rather than assuming it's at least 4, since it may in fact be less. |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/drivers/genkeymap.pl Sun Aug 03 02:55:27 2008 +00001.3 @@ -0,0 +1,56 @@1.4 +#!/usr/bin/perl1.5 +1.6 +use POSIX;1.7 +1.8 +my $dckeysymsfile = "dckeysyms.h";1.9 +my %dcsyms = ();1.10 +1.11 +open DCKB, "<$dckeysymsfile" || die "Unable to open keysym file $dckeysymsfile";1.12 +while(<DCKB>) {1.13 + if( /^#define\s+DCKB_([^ ]*)/ ) {1.14 + $dcsyms{$1} = "DCKB_$1";1.15 + }1.16 +}1.17 +1.18 +my %hash = ();1.19 +my %rhash = ();1.20 +my $name = shift();1.21 +while(<ARGV>) {1.22 + my ($val, $sym) = split /\s+/;1.23 + $ival = POSIX::strtol($val,0);1.24 + $hash{$ival} = $sym;1.25 + $rhash{$sym} = $ival;1.26 +}1.27 +1.28 +print "/**\n * $name keyboard map autogenerated by genkeymap.pl\n */\n\n";1.29 +1.30 +print "const gchar *${name}_keysyms_by_keycode[128] = { ";1.31 +for( $i=0; $i < 128; $i++ ) {1.32 + if( $i != 0 ) { print ", "; }1.33 + if( $hash{$i} ) {1.34 + print "\"$hash{$i}\"";1.35 + } else {1.36 + print "NULL";1.37 + }1.38 +}1.39 +print "};\n\n";1.40 +1.41 +print "const uint16_t ${name}_keycode_to_dckeysym[128] = { ";1.42 +for( $i=0; $i<128; $i++ ) {1.43 + if( $i != 0 ) { print ", "; }1.44 + if( $hash{$i} && $dcsyms{$hash{$i}} ) {1.45 + print $dcsyms{$hash{$i}};1.46 + } else {1.47 + print "DCKB_NONE";1.48 + }1.49 +}1.50 +print "};\n\n";1.51 +1.52 +my @keys = sort {uc($a) cmp uc($b)} keys %rhash;1.53 +print "#define ${name}_keysym_count " . ($#keys+1) . "\n";1.54 +print "struct ${name}_keymap_struct {\n const gchar *name;\n uint16_t keycode;\n};\n\n";1.55 +print "struct ${name}_keymap_struct ${name}_keysyms[] = { ";1.56 +foreach my $keysym (@keys) {1.57 + print "{\"$keysym\", $rhash{$keysym} }, ";1.58 +}1.59 +print "{NULL,-1} };\n\n";
.