From: Fredrik Hallenberg <megahallon@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>, linux-input@vger.kernel.org
Cc: Fredrik Hallenberg <megahallon@gmail.com>
Subject: [PATCH] Handle spurious backslash key repeats on some keyboards
Date: Sun, 10 Aug 2014 11:56:06 +0200 [thread overview]
Message-ID: <1407664566-5303-1-git-send-email-megahallon@gmail.com> (raw)
Here is my attempt on a fix for bug 70181, please review it. It is
tested on my nordic Corsair K70, if this solution is deemed acceptable
I can ask some people with other problematic keyboards to test it.
Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
---
drivers/hid/hid-input.c | 14 ++++++++++++++
include/linux/hid.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 2619f7f..56429c0 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1085,6 +1085,20 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return;
}
+ /*
+ * Some keyboards will report both HID keys 0x31 (\ and |) and
+ * 0x32 (Non-US # and ~) which are both mapped to
+ * KEY_BACKSLASH. This will cause spurious events causing
+ * repeated backslash key presses. Handle this by tracking the
+ * active HID code and ignoring the other one.
+ */
+ if (usage->type == EV_KEY && usage->code == KEY_BACKSLASH) {
+ if (value)
+ field->hidinput->backslash_usage = usage->hid;
+ else if (field->hidinput->backslash_usage != usage->hid)
+ return;
+ }
+
/* report the usage code as scancode if the key status has changed */
if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
input_event(input, EV_MSC, MSC_SCAN, usage->hid);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index f53c4a9..1c59f8f 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -448,6 +448,7 @@ struct hid_input {
struct list_head list;
struct hid_report *report;
struct input_dev *input;
+ unsigned backslash_usage;
};
enum hid_type {
--
2.1.0.rc1
next reply other threads:[~2014-08-10 9:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-10 9:56 Fredrik Hallenberg [this message]
2014-09-09 9:40 ` [PATCH] Handle spurious backslash key repeats on some keyboards Fredrik Hallenberg
2014-09-09 9:42 ` Jiri Kosina
2014-09-09 10:37 ` Fredrik Hallenberg
2014-09-10 8:26 ` Jiri Kosina
2014-09-10 10:09 ` David Herrmann
2014-09-10 11:13 ` Fredrik Hallenberg
2014-09-10 14:22 ` David Herrmann
2014-09-10 22:51 ` Dmitry Torokhov
2014-09-11 8:50 ` Fredrik Hallenberg
2014-09-11 12:41 ` David Herrmann
2014-09-11 20:35 ` Fredrik Hallenberg
2014-09-12 10:29 ` David Herrmann
2014-09-12 11:34 ` Fredrik Hallenberg
2014-09-12 11:47 ` David Herrmann
2014-09-12 17:36 ` Fredrik Hallenberg
2014-12-19 16:28 ` RH
2014-12-20 19:56 ` Fredrik Hallenberg
2014-09-14 16:45 ` David Herrmann
2014-09-14 17:03 ` David Herrmann
2014-09-14 22:53 ` Fredrik Hallenberg
2014-09-15 8:29 ` Fredrik Hallenberg
2014-09-15 14:39 ` Benjamin Tissoires
2014-09-15 14:47 ` Benjamin Tissoires
2014-09-15 14:52 ` David Herrmann
2014-09-15 15:14 ` Benjamin Tissoires
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=1407664566-5303-1-git-send-email-megahallon@gmail.com \
--to=megahallon@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@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).