Skip to contentSkip to conversation

HID: hid-debug: more informative output for EV_KEY

PATCH Applied Thomas Kuehne 2 participants 2 messages Apr 13, 2024 – May 6, 2024 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hid-debug: more informative output for EV_KEY

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.

---
 drivers/hid/hid-debug.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/hid/hid-debug.c +9 -2
index add353a17853..0a0c435a1284 100644
@@ -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

maintainer Applied
#1 lore raw
Quoted 10 lines · Thomas Kuehne

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.

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs