* [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files
@ 2019-07-03 14:12 Sean Young
2019-07-03 14:12 ` [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap Sean Young
0 siblings, 1 reply; 2+ messages in thread
From: Sean Young @ 2019-07-03 14:12 UTC (permalink / raw)
To: linux-media; +Cc: Bastien Nocera
Some keymaps contain mappings in comments which should have not been
included.
Cc: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Sean Young <sean@mess.org>
---
utils/keytable/gen_keytables.pl | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl
index 4124e366..8f3a87e6 100755
--- a/utils/keytable/gen_keytables.pl
+++ b/utils/keytable/gen_keytables.pl
@@ -82,7 +82,17 @@ sub parse_file($$)
printf "processing file $filename\n" if ($debug);
open IN, "<$filename" or die "couldn't find $filename";
- while (<IN>) {
+ # read the entire file
+ my $file = do { local $/ = undef; <IN> };
+ close IN;
+
+ # remove comments
+ $file =~ s,/\*.*?\*/,,sg;
+ $file =~ s,//[^\n]*,,sg;
+
+ my @lines = split /\n/, $file;
+
+ foreach (@lines) {
if (m/struct\s+rc_map_table\s+(\w[\w\d_]+)/) {
flush($filename, $legacy);
@@ -140,7 +150,6 @@ sub parse_file($$)
}
}
}
- close IN;
flush($filename, $legacy);
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap
2019-07-03 14:12 [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files Sean Young
@ 2019-07-03 14:12 ` Sean Young
0 siblings, 0 replies; 2+ messages in thread
From: Sean Young @ 2019-07-03 14:12 UTC (permalink / raw)
To: linux-media; +Cc: Bastien Nocera
One scancode can only be mapped to one keycode. In addition, the
toml is invalid so the keymap cannot be loaded.
Cc: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Sean Young <sean@mess.org>
---
utils/keytable/gen_keytables.pl | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl
index 8f3a87e6..c14aded3 100755
--- a/utils/keytable/gen_keytables.pl
+++ b/utils/keytable/gen_keytables.pl
@@ -76,6 +76,7 @@ sub parse_file($$)
my $legacy = shift;
my $num_tables = 0;
+ my %scancodes = ();
$warn = 0;
next if ($filename =~ m/\.mod.c/);
@@ -101,6 +102,7 @@ sub parse_file($$)
$keyname =~ s/_table$//;
$read = 1;
$num_tables++;
+ %scancodes = ();
next;
}
if (m/struct\s+rc_map_list.*=\s+{/) {
@@ -142,7 +144,15 @@ sub parse_file($$)
if ($read) {
if (m/(0x[\dA-Fa-f]+)[\s\,]+(KEY|BTN)(\_[^\s\,\}]+)/) {
- $out .= "$1 = \"$2$3\"\n";
+ my $scancode = hex($1);
+ my $keycode = "$2$3";
+
+ if (exists($scancodes{$scancode})) {
+ printf STDERR "WARNING: duplicate scancode $1 in file $filename, set to $keycode and $scancodes{$scancode}\n";
+ } else {
+ $out .= "$1 = \"$keycode\"\n";
+ $scancodes{$scancode} = $keycode;
+ }
next;
}
if (m/\}/) {
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-03 14:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 14:12 [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files Sean Young
2019-07-03 14:12 ` [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap Sean Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).