Merge pull request #66 from algernon/f/gen-keymap/macro-support

generate_keymaps: Don't prepend Key_ to everything
pull/72/head
Jesse Vincent 8 years ago committed by GitHub
commit 15e9be25bb

@ -15,7 +15,7 @@ for my $line (@data) {
} }
my @keys = split(/\s+/, $line); my @keys = split(/\s+/, $line);
push @map, join(', ', map{ 'Key_'.lookup($_).'' } @keys); push @map, join(', ', map{ ''.lookup($_).'' } @keys);
} }
print "#define KEYMAP_$name { /* Generated keymap for $name */ "; print "#define KEYMAP_$name { /* Generated keymap for $name */ ";
@ -27,23 +27,24 @@ print "},\n";
sub lookup { sub lookup {
my %table = ( my %table = (
'{' => 'LCurlyBracket', '{' => 'Key_LCurlyBracket',
'}' => 'RCurlyBracket', '}' => 'Key_RCurlyBracket',
'['=> 'LSquareBracket', '['=> 'Key_LSquareBracket',
']'=> 'RSquareBracket', ']'=> 'Key_RSquareBracket',
'|'=> 'Pipe', '|'=> 'Key_Pipe',
'\\' => 'Backslash', '\\' => 'Key_Backslash',
';' => 'Semicolon', ';' => 'Key_Semicolon',
',' => 'Comma', ',' => 'Key_Comma',
'.' => 'Period', '.' => 'Key_Period',
'/' => 'Slash', '/' => 'Key_Slash',
"'" => 'Quote', "'" => 'Key_Quote',
'`' => 'Backtick', '`' => 'Key_Backtick',
'-' => 'Minus', '-' => 'Key_Minus',
'=' => 'Equals'); '=' => 'Key_Equals');
my $x = shift; my $x = shift;
return $x unless defined $table{$x}; return $x if $x =~ /\(.*\)/;
return 'Key_'.$x unless defined $table{$x};
return $table{$x}; return $table{$x};
} }

Loading…
Cancel
Save