From: Joao Moreno <mail@joaomoreno.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Joao Moreno <mail@joaomoreno.com>, Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] HID: apple: Fix stuck function keys when using FN
Date: Mon, 10 Jun 2019 23:31:06 +0200 [thread overview]
Message-ID: <20190610213106.19342-1-mail@joaomoreno.com> (raw)
This fixes an issue in which key down events for function keys would be
repeatedly emitted even after the user has raised the physical key. For
example, the driver fails to emit the F5 key up event when going through
the following steps:
- fnmode=1: hold FN, hold F5, release FN, release F5
- fnmode=2: hold F5, hold FN, release F5, release FN
The repeated F5 key down events can be easily verified using xev.
Signed-off-by: Joao Moreno <mail@joaomoreno.com>
---
drivers/hid/hid-apple.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 1cb41992aaa1..81867a6fa047 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -205,20 +205,21 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
trans = apple_find_translation (table, usage->code);
if (trans) {
- if (test_bit(usage->code, asc->pressed_fn))
- do_translate = 1;
- else if (trans->flags & APPLE_FLAG_FKEY)
- do_translate = (fnmode == 2 && asc->fn_on) ||
- (fnmode == 1 && !asc->fn_on);
+ int fn_on = value ? asc->fn_on :
+ test_bit(usage->code, asc->pressed_fn);
+
+ if (!value)
+ clear_bit(usage->code, asc->pressed_fn);
+ else if (asc->fn_on)
+ set_bit(usage->code, asc->pressed_fn);
+
+ if (trans->flags & APPLE_FLAG_FKEY)
+ do_translate = (fnmode == 2 && fn_on) ||
+ (fnmode == 1 && !fn_on);
else
do_translate = asc->fn_on;
if (do_translate) {
- if (value)
- set_bit(usage->code, asc->pressed_fn);
- else
- clear_bit(usage->code, asc->pressed_fn);
-
input_event(input, usage->type, trans->to,
value);
--
2.19.1
next reply other threads:[~2019-06-10 21:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 21:31 Joao Moreno [this message]
2019-06-30 20:15 ` João Moreno
2019-07-01 8:32 ` Benjamin Tissoires
2019-07-08 20:35 ` João Moreno
2019-08-08 20:10 ` João Moreno
2019-08-12 16:57 ` Benjamin Tissoires
2019-08-27 16:57 ` Benjamin Tissoires
2019-09-02 14:44 ` João Moreno
2019-09-02 15:23 ` Benjamin Tissoires
2019-09-02 16:11 ` João Moreno
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=20190610213106.19342-1-mail@joaomoreno.com \
--to=mail@joaomoreno.com \
--cc=benjamin.tissoires@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®