From patchwork Tue Nov 7 16:25:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gerecke X-Patchwork-Id: 10046975 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 B9C5C6031B for ; Tue, 7 Nov 2017 16:25:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACCCC2A182 for ; Tue, 7 Nov 2017 16:25:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A168E2A269; Tue, 7 Nov 2017 16:25:32 +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 ECF392A182 for ; Tue, 7 Nov 2017 16:25:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbdKGQZa (ORCPT ); Tue, 7 Nov 2017 11:25:30 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:49216 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965221AbdKGQZ1 (ORCPT ); Tue, 7 Nov 2017 11:25:27 -0500 Received: by mail-qk0-f195.google.com with SMTP id q83so15973769qke.6 for ; Tue, 07 Nov 2017 08:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=r7X3uq8sr/p1cino2xv52S6OOpMf+3Eosbt+SAyC0O0=; b=h4a/Fe9PQjJONrAMw77FCHWqRpfZX+R3VNaPYBrJ6275Mo8MFSzRdNf0BxNu7xXQmK QL4sZYkNJkx4PFyXhjTgsGPQHdXr2HXpMGq1H/0YxRg8r4iNAMPXFAArZ5sdz01ttsAH L/LyB92ruDJWi/ur5k9Q+y9kZmh7HHZ1ud7Se8RKf5Q3SOuBDAJ032EiUflATd7NKJwV 60UJkNEGW6mnzVDFdSWT4ZOPZ7Q4m2O/6MuUUoiaVqnegLJ2p83/u7Gxr1EQqJ/3GyUa S9S0t+8KG2en3R/LbYMWvYdAsth0fUNxFXOt00FRUvvbhm5yTLqt3OiVu0vtisZD2Naw PoSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r7X3uq8sr/p1cino2xv52S6OOpMf+3Eosbt+SAyC0O0=; b=JOO/oxTk3W1+PrPnHS10dH3xEaucJN4OcBYqzYDsP0ARtBTV5nnLWuP+uGDx7Q6i2N HKpQ59tFnqfWL1wSRpNiQXS8oOf+24zbe0+jol4Tq7NuRAlnfy+VMBNiDXguatRNrG5f nLH11E4EwQQfcPWENJHHBrB0fR7+AwkocssA4jTQ9J+cvZTagbyi2pFVn5dS6hxX2hjF 7fHAknqeA6V9TxdCnzCFcLmkip4NJIqmB8xy/0fxiIHd8YOaiFldy2kYNBmfm9E2cwqs 3IY2YsuVeS0iQzbDKa2NVEFuzeSBQYUpmjShmtBhiryqsGP0ocUTydZcm5/9pX1JcXBm QDHA== X-Gm-Message-State: AMCzsaWdF1IUvisxDdi9ae0WDRec5GIucYuluzGybMerBRA262HZbfX/ T2/KeEdv1/43IkH9Em97oLHPM8bx X-Google-Smtp-Source: ABhQp+SAEbowyp5ob+fbUTUJ0Mbx2+Avsd72NfJPdIplm/CurqBP8C5elDfZzWHwXEDLwXny2Z37Eg== X-Received: by 10.55.209.86 with SMTP id s83mr28926124qki.145.1510071926049; Tue, 07 Nov 2017 08:25:26 -0800 (PST) Received: from wacom-arch2.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id m39sm1127617qtk.30.2017.11.07.08.25.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 08:25:25 -0800 (PST) From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina Cc: Dmitry Torokhov , Peter Hutterer , Benjamin Tissoires , Ping Cheng , Jason Gerecke , Jason Gerecke Subject: [PATCH] HID: wacom: generic: Send BTN_STYLUS3 when both barrel switches are set Date: Tue, 7 Nov 2017 08:25:17 -0800 Message-Id: <20171107162517.1591-1-killertofu@gmail.com> X-Mailer: git-send-email 2.15.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 Wacom Pro Pen 3D includes a third barrel switch which is intended to be particularly useful in applications where one frequency uses pan, zoom, and rotate to navigate around a scene or model. The pen is compatible with the MobileStudio Pro, 2nd-gen Intuos Pro, and Cintiq Pro. When the third button is pressed, these devices set both the HID_DG_BARRELSWITCH and HID_DG_BARRELSWITCH2 usages since their HID descriptors do not include a usage specific to the button. Rather than send both BTN_STYLUS and BTN_STYLUS2 when the third button is pressed, userspace (libinput) has requested that we detect this condition and report a newly-defined BTN_STYLUS3 event instead. We could define a quirk specific to devices compatible with the Pro Pen 3D, but the liklihood of seeing both barrel switch bits set with other pens/devices is low enough to not worry about (pens mechanically prevent accidental activation of multiple switches). Signed-off-by: Jason Gerecke Acked-by: Dmitry Torokhov Acked-by: Peter Hutterer Acked-by: Benjamin Tissoires --- drivers/hid/wacom_wac.c | 18 ++++++++++++++++-- drivers/hid/wacom_wac.h | 2 ++ include/uapi/linux/input-event-codes.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index e3223b0c4f90..16af6886e828 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2140,6 +2140,12 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field case HID_DG_TIPSWITCH: wacom_wac->hid_data.tipswitch |= value; return; + case HID_DG_BARRELSWITCH: + wacom_wac->hid_data.barrelswitch = value; + return; + case HID_DG_BARRELSWITCH2: + wacom_wac->hid_data.barrelswitch2 = value; + return; case HID_DG_TOOLSERIALNUMBER: if (value) { wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); @@ -2254,6 +2260,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev, if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { int id = wacom_wac->id[0]; + int sw_state = wacom_wac->hid_data.barrelswitch | + (wacom_wac->hid_data.barrelswitch2 << 1); + + input_report_key(input, BTN_STYLUS, sw_state == 1); + input_report_key(input, BTN_STYLUS2, sw_state == 2); + input_report_key(input, BTN_STYLUS3, sw_state == 3); /* * Non-USI EMR tools should have their IDs mangled to @@ -3300,9 +3312,11 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, else __set_bit(INPUT_PROP_POINTER, input_dev->propbit); - if (features->type == HID_GENERIC) - /* setup has already been done */ + if (features->type == HID_GENERIC) { + /* setup has already been done; apply otherwise-undetectible quirks */ + input_set_capability(input_dev, EV_KEY, BTN_STYLUS3); return 0; + } __set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(ABS_MISC, input_dev->absbit); diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 8a03654048bf..69dda27e8dde 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -291,6 +291,8 @@ struct hid_data { bool inrange_state; bool invert_state; bool tipswitch; + bool barrelswitch; + bool barrelswitch2; int x; int y; int pressure; diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 179891074b3c..9b3a522f50d1 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -406,6 +406,7 @@ #define BTN_TOOL_MOUSE 0x146 #define BTN_TOOL_LENS 0x147 #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ +#define BTN_STYLUS3 0x149 #define BTN_TOUCH 0x14a #define BTN_STYLUS 0x14b #define BTN_STYLUS2 0x14c