From patchwork Sun Aug 10 09:56:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Hallenberg X-Patchwork-Id: 4704111 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4B5B1C0338 for ; Sun, 10 Aug 2014 09:56:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55AD820145 for ; Sun, 10 Aug 2014 09:56:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B92520136 for ; Sun, 10 Aug 2014 09:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751307AbaHJJ4R (ORCPT ); Sun, 10 Aug 2014 05:56:17 -0400 Received: from mail-lb0-f178.google.com ([209.85.217.178]:48097 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbaHJJ4R (ORCPT ); Sun, 10 Aug 2014 05:56:17 -0400 Received: by mail-lb0-f178.google.com with SMTP id c11so4987898lbj.37 for ; Sun, 10 Aug 2014 02:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ia91Nqww2usBv/efDNIVY0vBZ/I2B6Nff9oyRx2Y98g=; b=Yuh6Y859HVId72FQTQFikwTuX4dq12ATB8afatQYUgJvQkmTmJFf63roT6m1AZZkgr rTa+H2oBFWzbBFKw5MXPxSCqoLdDIkEr1+RX4Y3fG+dIkQbxMGMqRJQkrBKD1ozWgT7J qYSOa3PgAqmWCE1oGGzXQ2Qb3np+ivVf4YvlRDdw/reHDDCkz5Tg9NoP7x/HOwG77hQh H4OZAXPD65GGZxdGmw5h1MtQ59pq6ulmobK/1a/P0FF9nW0k7YVhv4T3GeZWInf+1RIC XPYTjPMBxCDVsDpmtyFm45aMw42WGuOuNC+EK5T7ozBkPYddLrjnWUb4fZahA2PfZLLd uyVw== X-Received: by 10.152.22.199 with SMTP id g7mr2107006laf.6.1407664574910; Sun, 10 Aug 2014 02:56:14 -0700 (PDT) Received: from localhost.localdomain (c193-14-12-40.cust.tele2.se. [193.14.12.40]) by mx.google.com with ESMTPSA id kw10sm4383771lac.22.2014.08.10.02.56.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Aug 2014 02:56:13 -0700 (PDT) From: Fredrik Hallenberg To: Jiri Kosina , linux-input@vger.kernel.org Cc: Fredrik Hallenberg Subject: [PATCH] Handle spurious backslash key repeats on some keyboards Date: Sun, 10 Aug 2014 11:56:06 +0200 Message-Id: <1407664566-5303-1-git-send-email-megahallon@gmail.com> X-Mailer: git-send-email 2.1.0.rc1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 {