HID: hid-debug: more informative output for EV_KEY
authorThomas Kuehne <thomas.kuehne@gmx.li>
Sat, 13 Apr 2024 12:23:30 +0000 (12:23 +0000)
committerJiri Kosina <jkosina@suse.com>
Mon, 6 May 2024 21:16:41 +0000 (23:16 +0200)
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>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-debug.c

index a62e71a5ccef98bd63b7bbabf6c31fd0353b8f05..28b458fc69727f09920d3dbb95e734c06fe3d40a 100644 (file)
@@ -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)