~ubuntu-branches/debian/sid/v4l-utils/sid

« back to all changes in this revision

Viewing changes to utils/keytable/gen_keytables.pl

  • Committer: Bazaar Package Importer
  • Author(s): Gregor Jasny
  • Date: 2010-10-03 16:26:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101003162640-88djisgfegdp020e
Tags: 0.8.1-1
* New upstream version (Closes: #598969)
* Bumped standards to version 3.9.1 (no changes needed)
* Updated copyright file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
use strict;
3
3
 
 
4
my $dir="rc_keymaps";
 
5
my $deftype = "UNKNOWN";
 
6
 
4
7
my $keyname="";
5
8
my $debug=0;
6
9
my $out;
7
10
my $read=0;
 
11
my $type = $deftype;
 
12
my $check_type = 0;
8
13
 
9
14
sub flush()
10
15
{
11
16
        return if (!$keyname || !$out);
12
 
        open OUT, ">keycodes/$keyname";
 
17
        print "Creating $dir/$keyname\n";
 
18
        open OUT, ">$dir/$keyname";
 
19
        print OUT "# table $keyname, type: $type\n";
13
20
        print OUT $out;
14
21
        close OUT;
15
22
 
16
23
        $keyname = "";
17
24
        $out = "";
 
25
        $type = $deftype;
18
26
}
19
27
 
20
28
while (<>) {
21
 
        if (m/struct\s+(dvb_usb_rc_key|ir_scancode)\s+(\w[\w\d_]+)/) {
 
29
        if (m/struct\s+ir_scancode\s+(\w[\w\d_]+)/) {
22
30
                flush();
23
31
 
24
 
                $keyname = $2;
 
32
                $keyname = $1;
25
33
                $keyname =~ s/^ir_codes_//;
 
34
                $keyname =~ s/_table$//;
26
35
                $read = 1;
27
36
                next;
28
37
        }
29
 
        if (m/IR_TABLE\(\s*([^\,\s]+)\s*,\s*([^\,\s]+)\s*,\s*([^\,\s]+)\s*\)/) {
30
 
                my $name = $1;
31
 
                my $type = $2;
32
 
                $type =~ s/IR_TYPE_//;
33
 
                $out = "# table $name, type: $type\n$out";
34
 
                $read = 0;
 
38
        if (m/struct\s+rc_keymap.*=\s+{/) {
 
39
                $check_type = 1;
 
40
                next;
 
41
        }
 
42
        if ($check_type) {
 
43
                if (m/^\s*}/) {
 
44
                        $check_type = 0;
 
45
                        next;
 
46
                }
 
47
                if (m/IR_TYPE_([\w\d_]+)/) {
 
48
                        $type = $1;
 
49
                }
 
50
                next;
 
51
        }
35
52
 
36
 
                flush();
37
 
        }
38
53
        if ($read) {
39
54
                if (m/(0x[\dA-Fa-f]+).*(KEY_[^\s\,\}]+)/) {
40
55
                        $out .= "$1 $2\n";