linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org
Cc: Bastien Nocera <hadess@hadess.net>
Subject: [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap
Date: Wed,  3 Jul 2019 15:12:12 +0100	[thread overview]
Message-ID: <20190703141212.31719-2-sean@mess.org> (raw)
In-Reply-To: <20190703141212.31719-1-sean@mess.org>

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


      reply	other threads:[~2019-07-03 14:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190703141212.31719-2-sean@mess.org \
    --to=sean@mess.org \
    --cc=hadess@hadess.net \
    --cc=linux-media@vger.kernel.org \
    --subject='Re: [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).