Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp155674pxv; Wed, 21 Jul 2021 18:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0Ha5VitUR8wZZj6i1PKd4am721L456gbeRAVWeO70BDlpnzGVGvupODvvbB4Xlo+z6uBE X-Received: by 2002:a05:6402:190c:: with SMTP id e12mr50428380edz.176.1626917533975; Wed, 21 Jul 2021 18:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626917533; cv=none; d=google.com; s=arc-20160816; b=0l4Ty78ZjQynLgDgby3P+OFTEkzCcRChbAiVYJdZhWhQtaNr36XGURPLZY6Par5zJT nalBjf1utwR87FtHUBo5lEgQebmoWkFaj2/WgxP90OaZKFuuf6MreSd6LBMP9Vbc7dkT 82m7o6uLEPxJYSrxKn5A5t36TNo1SidWkvG10p6BHd4VGUxb9gklSYQJUbv37NGzgbjj XzPVStgJM+rawoI9B+kdHBqnrBXUxSAykDH3z+wRwx6IUJpxK0npIZi1+FZG/IIrye3c 18CmdA9gFNpUnHVt5eTOVUL6dPL8FsQhryh41YfS+LaXjI62ctgYnHCAbL818A+6PJ1f GsLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MZABAg/+n9WQyXd6kpcysv47f5YUNyoN9MOsPW+8TWY=; b=ItWvAcwVd+NeToqvGmtJCsmOCjRJ7Uhd+v9Z9AdFXGN6smKVJzojYvLEnpx15gINWI XxrT58gKAtkGBFA/1HNDIvUiwy+rEtrerk3yPdL6Syxc8tkuPJ7SfD/chI9YqB7ocHkR 3frVsjpSkVd4bzsAy0emFk+6W+KMknuil8go2ZJmA6bytNSlSMXj3bWSiNZCGyDkBbzQ s4GKEFQNxi8CsDczjXxYGzFx6XtoDZ6X4XAlXdSQpMFler7fpkLXy8kJeUX7LGpGoamz 1d+9Zh/L2tIvgM/SLZwpwizrVw7gb6hdcjSa7LQu3y+5waA7GNWqpClsp3RSt1zP/KO9 /vGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si26912190edy.537.2021.07.21.18.31.50; Wed, 21 Jul 2021 18:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbhGVAt6 (ORCPT + 99 others); Wed, 21 Jul 2021 20:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbhGVAt5 (ORCPT ); Wed, 21 Jul 2021 20:49:57 -0400 X-Greylist: delayed 150 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 21 Jul 2021 18:30:33 PDT Received: from joooj.vinc17.net (joooj.vinc17.net [IPv6:2001:4b99:1:3:216:3eff:fe20:ac98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082D9C061575; Wed, 21 Jul 2021 18:30:32 -0700 (PDT) Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id BC419F6; Thu, 22 Jul 2021 03:27:59 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id 7577EC23053; Thu, 22 Jul 2021 03:27:59 +0200 (CEST) From: Vincent Lefevre To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Lefevre , Daniel Lin Subject: [PATCH] HID: apple: Add missing scan code event for keys handled by hid-apple Date: Thu, 22 Jul 2021 03:25:44 +0200 Message-Id: <20210722012544.78331-1-vincent@vinc17.net> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an EV_KEY event is generated by hid-apple due to special key mapping, the usual associated scan code event (EV_MSC) is missing. This issue can be seen with the evtest utility. Add the scan code event for these special keys. BugLink: https://bugs.debian.org/757356 Co-developed-by: Daniel Lin Signed-off-by: Daniel Lin Signed-off-by: Vincent Lefevre --- drivers/hid/hid-apple.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 6b8f0d004d34..cde92de7fca7 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -187,6 +187,15 @@ static const struct apple_key_translation *apple_find_translation( return NULL; } +static void input_event_with_scancode(struct input_dev *input, + __u8 type, __u16 code, unsigned int hid, __s32 value) +{ + if (type == EV_KEY && + (!test_bit(code, input->key)) == value) + input_event(input, EV_MSC, MSC_SCAN, hid); + input_event(input, type, code, value); +} + static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, struct hid_usage *usage, __s32 value) { @@ -199,7 +208,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, if (usage->code == fn_keycode) { asc->fn_on = !!value; - input_event(input, usage->type, KEY_FN, value); + input_event_with_scancode(input, usage->type, KEY_FN, + usage->hid, value); return 1; } @@ -240,7 +250,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, code = do_translate ? trans->to : trans->from; } - input_event(input, usage->type, code, value); + input_event_with_scancode(input, usage->type, code, + usage->hid, value); return 1; } @@ -258,8 +269,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, clear_bit(usage->code, asc->pressed_numlock); - input_event(input, usage->type, trans->to, - value); + input_event_with_scancode(input, usage->type, + trans->to, usage->hid, value); } return 1; @@ -270,7 +281,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) { trans = apple_find_translation(apple_iso_keyboard, usage->code); if (trans) { - input_event(input, usage->type, trans->to, value); + input_event_with_scancode(input, usage->type, + trans->to, usage->hid, value); return 1; } } @@ -279,7 +291,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, if (swap_opt_cmd) { trans = apple_find_translation(swapped_option_cmd_keys, usage->code); if (trans) { - input_event(input, usage->type, trans->to, value); + input_event_with_scancode(input, usage->type, + trans->to, usage->hid, value); return 1; } } @@ -287,7 +300,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, if (swap_fn_leftctrl) { trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code); if (trans) { - input_event(input, usage->type, trans->to, value); + input_event_with_scancode(input, usage->type, + trans->to, usage->hid, value); return 1; } } @@ -306,8 +320,8 @@ static int apple_event(struct hid_device *hdev, struct hid_field *field, if ((asc->quirks & APPLE_INVERT_HWHEEL) && usage->code == REL_HWHEEL) { - input_event(field->hidinput->input, usage->type, usage->code, - -value); + input_event_with_scancode(field->hidinput->input, usage->type, + usage->code, usage->hid, -value); return 1; } -- 2.32.0