From 728a8ac34f0ff6099f67b80d4241f893b0be1544 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 5 Dec 2016 10:19:54 +0100 Subject: [PATCH] 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 --- tools/generate_keymaps.pl | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tools/generate_keymaps.pl b/tools/generate_keymaps.pl index 81ff38cc..9907f596 100644 --- a/tools/generate_keymaps.pl +++ b/tools/generate_keymaps.pl @@ -15,7 +15,7 @@ for my $line (@data) { } 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 */ "; @@ -27,23 +27,24 @@ print "},\n"; sub lookup { my %table = ( -'{' => 'LCurlyBracket', -'}' => 'RCurlyBracket', -'['=> 'LSquareBracket', -']'=> 'RSquareBracket', -'|'=> 'Pipe', -'\\' => 'Backslash', - - ';' => 'Semicolon', - ',' => 'Comma', - '.' => 'Period', - '/' => 'Slash', - "'" => 'Quote', - '`' => 'Backtick', - '-' => 'Minus', - '=' => 'Equals'); - - my $x = shift; - return $x unless defined $table{$x}; +'{' => 'Key_LCurlyBracket', +'}' => 'Key_RCurlyBracket', +'['=> 'Key_LSquareBracket', +']'=> 'Key_RSquareBracket', +'|'=> 'Key_Pipe', +'\\' => 'Key_Backslash', + + ';' => 'Key_Semicolon', + ',' => 'Key_Comma', + '.' => 'Key_Period', + '/' => 'Key_Slash', + "'" => 'Key_Quote', + '`' => 'Key_Backtick', + '-' => 'Key_Minus', + '=' => 'Key_Equals'); + + my $x = shift; + return $x if $x =~ /\(.*\)/; + return 'Key_'.$x unless defined $table{$x}; return $table{$x}; }