All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Kuehne <thomas.kuehne@gmx.li>
To: jikos@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] HID: hid-debug: more informative output for EV_KEY
Date: Sat, 13 Apr 2024 12:23:30 +0000	[thread overview]
Message-ID: <Zhp5QlMGazcW+RV5@black> (raw)

Currently hid-debug's hid_resolv_event prints questions marks for
all entries without explicit mapping information. This makes
debugging unnecessarily complicated as multiple different
keys may simply result in the same uninformative output.

Some common event codes are deliberately not defined in
input-event-codes.h. For example the 16th gamepad key.

Instead, print the hexadecimal codes for all events without symbolic
names.

Signed-off-by: Thomas Kuehne <thomas.kuehne@gmx.li>
---
 drivers/hid/hid-debug.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index add353a17853..0a0c435a1284 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -3582,8 +3582,15 @@ static const char **names[EV_MAX + 1] = {

 static void hid_resolv_event(__u8 type, __u16 code, struct seq_file *f)
 {
-	seq_printf(f, "%s.%s", events[type] ? events[type] : "?",
-		names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
+	if (events[type])
+		seq_printf(f, "%s.", events[type]);
+	else
+		seq_printf(f, "%02x.", type);
+
+	if (names[type] && names[type][code])
+		seq_printf(f, "%s", names[type][code]);
+	else
+		seq_printf(f, "%04x", code);
 }

 static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)

base-commit: 9ed46da14b9b9b2ad4edb3b0c545b6dbe5c00d39
--
2.40.1


             reply	other threads:[~2024-04-13 11:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13 12:23 Thomas Kuehne [this message]
2024-05-06 21:17 ` [PATCH] HID: hid-debug: more informative output for EV_KEY Jiri Kosina

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=Zhp5QlMGazcW+RV5@black \
    --to=thomas.kuehne@gmx.li \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.