aboutsummaryrefslogtreecommitdiffstats
path: root/utils/keytable/gen_input_events.pl
blob: 01d6165eac54e1f28147e5b8d00f02b17ee0a81f (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
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
#!/usr/bin/perl
use strict;

my @ev;
my @msc;
my @key;
my @key;
my @rel;
my @abs;

my %key_hash;

while (<>) {
	if (m/^\#define\s+(EV_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) {
		next if ($1 eq "EV_VERSION");
		my @e = ($1, $2);
		push(@ev, \@e);
	}

	if (m/^\#define\s+(MSC_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) {
		my @e = ($1, $2);
		push(@msc, \@e);
	}

	if (m/^\#define\s+(KEY_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) {
		next if ($1 eq "KEY_MAX");
		$key_hash{$1} = $2;
		my @e = ($1, $2);
		push(@key, \@e);
	}

	if (m/^\#define\s+(KEY_[^\s]+)\s+(KEY_[^\s]+)/) {
		next if ($1 eq "KEY_MIN_INTERESTING");
		my @e = ($1, $key_hash{$2});
		push(@key, \@e);
	}

	if (m/^\#define\s+(BTN_[^\s]+)\s+(0x[\d\w]+|[\d]+)/)  {
		my @e = ($1, $2);
		push(@key, \@e);
	}

	if (m/^\#define\s+(REL_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) {
		my @e = ($1, $2);
		push(@rel, \@e);
	}

	if (m/^\#define\s+(ABS_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) {
		my @e = ($1, $2);
		push(@abs, \@e);
	}
}

print "struct parse_event {\n\tchar *name;\n\tunsigned int value;\n};\n";
print "struct parse_event events_type[] = {\n";
for my $e (@ev) {
	my $name = @$e[0];
	my $val = @$e[1];
	print "\t{\"$name\", $val},\n";
}
print "\t{ NULL, 0}\n};\n";

print "struct parse_event msc_events[] = {\n";
for my $e (@msc) {
	my $name = @$e[0];
	my $val = @$e[1];
	print "\t{\"$name\", $val},\n";
}
print "\t{ NULL, 0}\n};\n";

print "struct parse_event key_events[] = {\n";
for my $e (@key) {
	my $name = @$e[0];
	my $val = @$e[1];
	print "\t{\"$name\", $val},\n";
}
print "\t{ NULL, 0}\n};\n";

print "struct parse_event rel_events[] = {\n";
for my $e (@rel) {
	my $name = @$e[0];
	my $val = @$e[1];
	print "\t{\"$name\", $val},\n";
}
print "\t{ NULL, 0}\n};\n";

print "struct parse_event abs_events[] = {\n";
for my $e (@abs) {
	my $name = @$e[0];
	my $val = @$e[1];
	print "\t{\"$name\", $val},\n";
}
print "\t{ NULL, 0}\n};\n";

Privacy Policy