generate_keymaps: Don't prepend Key_ to everything

If a key in the layout has parens, leave it there as-is. This makes it a
lot easier to have macros and whatnot in the layout: one can just use
M(0) and the like.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/66/head
Gergely Nagy 8 years ago
parent 373c89f95a
commit 728a8ac34f

@ -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