From patchwork Wed Feb 15 05:27:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 9573387 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 4217160209 for ; Wed, 15 Feb 2017 05:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 351AD283F4 for ; Wed, 15 Feb 2017 05:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29BB62842B; Wed, 15 Feb 2017 05:27:57 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 705E4283F4 for ; Wed, 15 Feb 2017 05:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750810AbdBOF1z (ORCPT ); Wed, 15 Feb 2017 00:27:55 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34531 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732AbdBOF1z (ORCPT ); Wed, 15 Feb 2017 00:27:55 -0500 Received: by mail-pf0-f193.google.com with SMTP id o64so6894024pfb.1 for ; Tue, 14 Feb 2017 21:27:55 -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=vKf7NqqVB9NGFB3d9Woc4N6EJ8kFH8dmr2QX4xmaKm0=; b=ZBerT1FASaAWSIvjERymF5p2F8QjxiERv+VxucjANp8XLlR2sOOMxggbmJJswteeJw hXBN26GBLhjWX2Di0ysce200rAFOP8OEAi4bBXxAYnRjZf36h0fYzg/AIBtnvYlIrQZ8 C/RyvEMxHKijLEVO5ka/sBIIqc3mm331Tr1wynU6Gj81djwWEYLZgHpeHgXPmCRaWUzs FmgGZpkmjnrzNWZD3Eez0dyK3d51o4GCC8FE5/WFtxhHKfRTjmOGbA1VeoSDOsMRGOPT zJrrlYP426Qoqz7vOEkWM7fXYqgyza7gXNjy9s4YHNNju9/aJMpy42IFuHCNIixLxTC9 BPyw== 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=vKf7NqqVB9NGFB3d9Woc4N6EJ8kFH8dmr2QX4xmaKm0=; b=abX4KUGpEkfs5ZoTn+AUNWgAG5hLxOW7OOAr2hFyRbedN0ku/y3ibrrtd078nfpVr+ 9oi/HSSEGm2y9ij5WI3QWfyM21X8pp0Iqs42wXueRcWVgbbM5Ofmzt9oOx1fPHqEKtG1 mEV1HQAJSEt0eHcRHqQ/wAmnjN09BKTzCFr9MJL9L9J5eY0KM6HLIyThWQ0Jtl2tMd/n GxRgnS+7DTi8ifdkgky5+bYkvpPX/Ms95u1vl1N/Jze87SHM8VgARcBk+6tdESrrqKJ2 O4A/nJx1xz6tMFZxaWi2/0x0+qh3bupB4qfq0yD5uvKmkUYXVsG7GKTvNrENZpZC1on9 PLXw== X-Gm-Message-State: AMke39n8WCqV08N8GULeiiPCsuZQWaLBp2sbo601tU0sftFm+pu/IYWYmc9A6OTyeTFscg== X-Received: by 10.84.138.165 with SMTP id 34mr41142206plp.37.1487136474658; Tue, 14 Feb 2017 21:27:54 -0800 (PST) Received: from localhost.net (c-24-21-228-48.hsd1.wa.comcast.net. [24.21.228.48]) by smtp.gmail.com with ESMTPSA id f3sm4376483pfd.10.2017.02.14.21.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 21:27:54 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: linux-input@vger.kernel.org Cc: jikos@kernel.org, benjamin.tissoires@gmail.com, dmitry.torokhov@gmail.com, Ping Cheng , Ping Cheng Subject: [PATCH 3/3] HID: wacom: generic: support touch on/off softkey Date: Tue, 14 Feb 2017 21:27:45 -0800 Message-Id: <1487136465-5255-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.8.3.1 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 Wacom Cintiq Pro has a softkey to turn touch on/off. Since it is a softkey, hardware/firmware still reports touch events no matter what state the softkey is. We need to ignore touch events when the key is in off mode. Signed-off-by: Ping Cheng --- drivers/hid/wacom_sys.c | 4 +++- drivers/hid/wacom_wac.c | 18 +++++++++++++++++- drivers/hid/wacom_wac.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index b3272c6..953e690 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2100,8 +2100,10 @@ static void wacom_set_shared_values(struct wacom_wac *wacom_wac) wacom_wac->shared->touch_input = wacom_wac->touch_input; } - if (wacom_wac->has_mute_touch_switch) + if (wacom_wac->has_mute_touch_switch) { wacom_wac->shared->has_mute_touch_switch = true; + wacom_wac->shared->is_touch_on = true; + } if (wacom_wac->shared->has_mute_touch_switch && wacom_wac->shared->touch_input) { diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 0c544e7..5276dbe 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1732,6 +1732,7 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHONOFF: + case WACOM_HID_WD_MUTE_DEVICE: /* * This usage, which is used to mute touch events, comes * from the pad packet, but is reported on the touch @@ -1824,6 +1825,7 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field struct wacom_features *features = &wacom_wac->features; unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); int i; + bool is_touch_on = value; /* * Avoid reporting this event and setting inrange_state if this usage @@ -1843,10 +1845,17 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field input_event(input, usage->type, usage->code, 0); break; + case WACOM_HID_WD_MUTE_DEVICE: + if (wacom_wac->shared->touch_input && value) { + wacom_wac->shared->is_touch_on = !wacom_wac->shared->is_touch_on; + is_touch_on = wacom_wac->shared->is_touch_on; + } + + /* fall through*/ case WACOM_HID_WD_TOUCHONOFF: if (wacom_wac->shared->touch_input) { input_report_switch(wacom_wac->shared->touch_input, - SW_MUTE_DEVICE, !value); + SW_MUTE_DEVICE, !is_touch_on); input_sync(wacom_wac->shared->touch_input); } break; @@ -2205,6 +2214,13 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, bool prox = hid_data->tipswitch && report_touch_events(wacom_wac); + if (wacom_wac->shared->has_mute_touch_switch && + !wacom_wac->shared->is_touch_on) { + if (!wacom_wac->shared->touch_down) + return; + prox = 0; + } + wacom_wac->hid_data.num_received++; if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) return; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index d9669c6..839bd4b 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -121,6 +121,7 @@ #define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910) #define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950) #define WACOM_HID_WD_MODE_CHANGE (WACOM_HID_UP_WACOMDIGITIZER | 0x0980) +#define WACOM_HID_WD_MUTE_DEVICE (WACOM_HID_UP_WACOMDIGITIZER | 0x0981) #define WACOM_HID_WD_CONTROLPANEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0982) #define WACOM_HID_WD_ONSCREEN_KEYBOARD (WACOM_HID_UP_WACOMDIGITIZER | 0x0983) #define WACOM_HID_WD_BUTTONCONFIG (WACOM_HID_UP_WACOMDIGITIZER | 0x0986) @@ -274,6 +275,7 @@ struct wacom_shared { struct hid_device *pen; struct hid_device *touch; bool has_mute_touch_switch; + bool is_touch_on; }; struct hid_data {