@ -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') ;
'{' = > ' 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 unless defined $ table { $ x } ;
return $ x if $ x =~ /\(.*\)/ ;
return 'Key_' . $ x unless defined $ table { $ x } ;
return $ table { $ x } ;
}