aboutsummaryrefslogtreecommitdiffstats
path: root/utils/keytable/gen_keytables.pl
blob: 9d295beac698cc98938372e135e7fa59549fcc37 (plain)
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
#!/usr/bin/perl
use strict;

my $dir="rc_keymaps";
my $deftype = "UNKNOWN";

my $keyname="";
my $debug=0;
my $out;
my $read=0;
my $type = $deftype;
my $check_type = 0;

sub flush()
{
	return if (!$keyname || !$out);
	print "Creating $dir/$keyname\n";
	open OUT, ">$dir/$keyname";
	print OUT "# table $keyname, type: $type\n";
	print OUT $out;
	close OUT;

	$keyname = "";
	$out = "";
	$type = $deftype;
}

while (<>) {
	if (m/struct\s+ir_scancode\s+(\w[\w\d_]+)/) {
		flush();

		$keyname = $1;
		$keyname =~ s/^ir_codes_//;
		$keyname =~ s/_table$//;
		$read = 1;
		next;
	}
	if (m/struct\s+rc_keymap.*=\s+{/) {
		$check_type = 1;
		next;
	}
	if ($check_type) {
		if (m/^\s*}/) {
			$check_type = 0;
			next;
		}
		if (m/IR_TYPE_([\w\d_]+)/) {
			$type = $1;
		}
		next;
	}

	if ($read) {
		if (m/(0x[\dA-Fa-f]+).*(KEY_[^\s\,\}]+)/) {
			$out .= "$1 $2\n";
			next;
		}
		if (m/\}/) {
			$read = 0;
		}
	}
}

flush();

Privacy Policy