[go: up one dir, main page]

File: svgakeymap

package info (click to toggle)
svgalib 1%3A1.4.3-33
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,012 kB
  • sloc: ansic: 60,381; makefile: 1,138; asm: 630; sh: 86; perl: 54; pascal: 49
file content (98 lines) | stat: -rwxr-xr-x 2,714 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/perl
#
# svgakeymap - by Brion Vibber (brion@pobox.com), 6/30 - 7/3/1998
# Generates a keymap conversion file for svgalib from two keytable definitions.
#
# Usage:
#   svgakeymap [physical_map [program_map]] > output.keymap
#
# The conversion map is output to stdout; you may wish to redirect it.
# Keymaps are searched for in /usr/share/keymaps and are automatically
# filtered through gzip if necessary.
#
# Read the file README.keymap from the svgalib distribution for more info.

$ktd = "/usr/share/keymaps/";
if(scalar(@ARGV) > 0) {
    $inmap = $ARGV[0];
} else {
    $inmap = "i386/qwerty/us";
}
if(scalar(@ARGV) > 1) {
    $outmap = $ARGV[1];
} else {
    $outmap = $inmap;
}
    

foreach $bob ($inmap, $outmap) {
    #print "$bob\n";
    unless(-e $bob) {
        # Tack the keytable dir on it
        $bob = $ktd . $bob;
        #print "$bob\n";

        unless(-e $bob) {
            # Tack a .gz on it
            $bob .= ".kmap";
            #print "$bob\n";
            
            unless(-e $bob) {
                # Tack a .gz on it
                $bob .= ".gz";
                #print "$bob\n";
                
                unless(-e $bob) {
                    die "Couldn't find $bob\n.";
                }
            }
        }
    }
}

if($inmap =~ m/\.gz$/) {
    # Filter thru gzip
    open INMAP, "gzip -dc $inmap |" or die "Could not open $inmap!\n";
} else {
    open INMAP, "<$inmap" or die "Could not open $inmap!\n";
}

if($outmap =~ m/\.gz$/) {
    # Filter thru gzip
    open OUTMAP, "gzip -dc $outmap |" or die "Could not open $outmap!\n";
} else {
    open OUTMAP, "<$outmap" or die "Could not open $outmap!\n";
}

print "# This is a svgalib scancode conversion map generated by svgakeymap.\n",
      "# Read the file README.keymap from the svgalib distribution for more info.\n#\n",
      "# Physical keyboard layout: $inmap\n",
      "# Program's expected keyboard layout: $outmap\n#\n",
      "# physical_scancode program_scancode key_name\n";


while($kc = <OUTMAP>) {
    if($kc =~ m/^keycode\s+([0-9]+)\s*\=\s*(\S+)/) {
        # Store scancodes and names for future reference
        #print stderr "- $1 - $2 -\n";
        $keys{$1} = $2;
        $keys{$2} = $1;
    } else {
        # We ignore anything else - including modifiers
    }
}

while($kc = <INMAP>) {
    if($kc =~ m/^keycode\s+([0-9]+)\s*\=\s*(\S+)/) {
        if($keys{$2}) {
            # Matching scancodes!
            #unless($keys{$1} eq $2) {
                # Find the other code with the same key...
                #print "$1 $keys{$2}\t# $keys{$1} <-> $2\n";
            #print "$1 $keys{$2}\t# $2\n";
            print "$1 $keys{$2} $2\n";
                #}
        }
    }
}