From patchwork Fri Oct 20 12:41:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Strobach X-Patchwork-Id: 10020195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 238B0602CB for ; Fri, 20 Oct 2017 12:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D32628EBC for ; Fri, 20 Oct 2017 12:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00B2E28ED6; Fri, 20 Oct 2017 12:41:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DFFD28EBC for ; Fri, 20 Oct 2017 12:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751410AbdJTMlg (ORCPT ); Fri, 20 Oct 2017 08:41:36 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:45535 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244AbdJTMlg (ORCPT ); Fri, 20 Oct 2017 08:41:36 -0400 Received: by mail-wr0-f194.google.com with SMTP id k7so11255208wre.2 for ; Fri, 20 Oct 2017 05:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/ayTlcDfwg9kBP1d0sgmCuiHtFcGK1gKAvhJsxRe4Lk=; b=Lq3z64APCO9zVYWZ7VzHrx0dQeS4uplVy31geWrjiQ6edTMNDiPLpLClpryay6AL6p N4GZkkYarNBoOoN/Dgi5Zs4QvfCIVLuWlZvXSvVsbktKJWfktSMwXIQ+QJHRVphmX1pj LVLQGPTfw/sgMcv5r5utCmtEm67C20kQ8cm4qSQR9/z0PnQ2v4xhkocRkbbor2SA/XTn W1nmUUPMrgb1WoC1T/uzFeQS1JgXwSmoddJSJrN1dq1A2jNqT02W4YFidrLe8deDGP4p 9KwkWkka5EccAJcqN9hPnlUGHoEHH6gRxF9DKCByCTW9hCkZdvc3yoZSt1D3qGn6WGoT uBzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/ayTlcDfwg9kBP1d0sgmCuiHtFcGK1gKAvhJsxRe4Lk=; b=XGobdfdyC1sPKAHbTe/y6ofqI0DsMX8OgmchLhX4AI6hwiHPvTeHIkO+zzRJev4teQ 3TsnSHplGSu8+BzbBAbeNuhtNuzgw5lmQJODR5tT5kd+hzfd4CBc++uxW7ZvVBG+rZwv l4duEtOM33mYc+hSkx3dIEW70ajQgvfvOB59qinoWewCRbY3vQqkCuIYyZUmrdsCQ3ua hy1z24Eg4O5vwj3fqmYqpPQqCPJ/4bDu5S179/oziwsUDMvOT2+V3d5T9LT2TBgznHem QpC4okcstVlQ76GHdBUyCbCco0RBBwlIiu09Nh/cPYYVLV2rypYqsaoaitYAMckmlib7 XIiA== X-Gm-Message-State: AMCzsaX0rF2UfwbbuijS53LSxm9ek/asI4r05uwpxT7Azh60/3MEHMum zJcujYtgdu4oQZQ3AiGzKIOvcg== X-Google-Smtp-Source: ABhQp+SFrhbBp0Ok7yX4DBvOHgJN91LifUG6+oA8zcHKtAck2EjRM9Fb+Ci7DSSWkJ+hF7d5qgZHsw== X-Received: by 10.223.161.210 with SMTP id v18mr1100404wrv.211.1508503294554; Fri, 20 Oct 2017 05:41:34 -0700 (PDT) Received: from str.localnet (a155.dkm.cz. [62.24.65.155]) by smtp.gmail.com with ESMTPSA id w126sm1030821wme.25.2017.10.20.05.41.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2017 05:41:33 -0700 (PDT) From: David Strobach To: linux-input@vger.kernel.org Subject: [PATCH] HID: hid-kensington: add alternative button mapping Date: Fri, 20 Oct 2017 14:41:33 +0200 Message-ID: <2082258.qPnAmo2zZ4@str> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current mapping of the proprietary Kensington Slimblade buttons is as follows: +---+---+ | 2 | 8 | +---X---+ | 1 | 3 | +---+---+ This modification adds an alternative button mapping for users, who prefer to use middle mouse button emulation (buttons 1+3) in order to get one extra button at the top right. The alternative button mapping is: +---+---+ | 9 | 8 | +---X---+ | 1 | 3 | +---+---+ The desired behavior should ideally be achievable in userland, but in reality only recent evdev Xorg driver since v2.10.5 is able to handle middle mouse button remapping together with middle button emulation. --- drivers/hid/hid-kensington.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) } diff --git a/drivers/hid/hid-kensington.c b/drivers/hid/hid-kensington.c index fe9a99dd8d08..1673e461338f 100644 --- a/drivers/hid/hid-kensington.c +++ b/drivers/hid/hid-kensington.c @@ -20,6 +20,11 @@ #define ks_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c)) +static bool use_alt_mapping; +module_param(use_alt_mapping, bool, S_IRUGO); +MODULE_PARM_DESC(use_alt_mapping, + "Use alternative button mapping (default = false)"); + static int ks_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) @@ -28,8 +33,18 @@ static int ks_input_mapping(struct hid_device *hdev, struct hid_input *hi, return 0; switch (usage->hid & HID_USAGE) { - case 0x01: ks_map_key(BTN_MIDDLE); break; - case 0x02: ks_map_key(BTN_SIDE); break; + case 0x01: + if (use_alt_mapping) + ks_map_key(BTN_SIDE); + else + ks_map_key(BTN_MIDDLE); + break; + case 0x02: + if (use_alt_mapping) + ks_map_key(BTN_EXTRA); + else + ks_map_key(BTN_SIDE); + break; default: return 0;