linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seth Forshee <seth.forshee@canonical.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
Date: Wed, 23 Mar 2011 16:13:43 -0500	[thread overview]
Message-ID: <1300914823-9440-3-git-send-email-seth.forshee@canonical.com> (raw)
In-Reply-To: <1300914823-9440-1-git-send-email-seth.forshee@canonical.com>

This allows for debugging non-functional keys easily from
userspace.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/input/sparse-keymap.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 74bca5d..744980e 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -209,6 +209,7 @@ int sparse_keymap_setup(struct input_dev *dev,
 	}
 
 	if (test_bit(EV_KEY, dev->evbit)) {
+		__set_bit(KEY_UNKNOWN, dev->keybit);
 		__set_bit(EV_MSC, dev->evbit);
 		__set_bit(MSC_SCAN, dev->mscbit);
 	}
@@ -311,12 +312,19 @@ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
 {
 	const struct key_entry *ke =
 		sparse_keymap_entry_from_scancode(dev, code);
+	struct key_entry unknown_ke;
 
 	if (ke) {
 		sparse_keymap_report_entry(dev, ke, value, autorelease);
 		return true;
 	}
 
+	/* Report an unknown key event as a debugging aid */
+	unknown_ke.type = KE_KEY;
+	unknown_ke.code = code;
+	unknown_ke.keycode = KEY_UNKNOWN;
+	sparse_keymap_report_entry(dev, &unknown_ke, value, autorelease);
+
 	return false;
 }
 EXPORT_SYMBOL(sparse_keymap_report_event);
-- 
1.7.4.1


  parent reply	other threads:[~2011-03-23 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 21:13 [PATCH 0/2] sparse-keymap: Emit events useful for key debugging Seth Forshee
2011-03-23 21:13 ` [PATCH 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
2011-03-23 21:13 ` Seth Forshee [this message]
2011-03-25  7:35   ` [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Dmitry Torokhov
2011-03-25 13:40     ` Seth Forshee
2011-03-25 13:40       ` [PATCH v2 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
2011-03-25 13:40       ` [PATCH v2 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee

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=1300914823-9440-3-git-send-email-seth.forshee@canonical.com \
    --to=seth.forshee@canonical.com \
    --cc=dmitry.torokhov@gmail.com \
    --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 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).