From patchwork Fri Sep 8 00:51:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 9943029 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 95D7E600CB for ; Fri, 8 Sep 2017 00:51:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81F8427C0B for ; Fri, 8 Sep 2017 00:51:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7669827F8F; Fri, 8 Sep 2017 00:51:18 +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 04A5C27C0B for ; Fri, 8 Sep 2017 00:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752874AbdIHAvR (ORCPT ); Thu, 7 Sep 2017 20:51:17 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36772 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752454AbdIHAvQ (ORCPT ); Thu, 7 Sep 2017 20:51:16 -0400 Received: by mail-pf0-f193.google.com with SMTP id f84so631349pfj.3 for ; Thu, 07 Sep 2017 17:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GEhRQm5GgZgEJh7ObIQNgP9eU4C80Dw/cpwPpgc5KI4=; b=t3U6yDBhnv1SgdQuFFWIwI2gk5pBoZj8J70GYL3VuRORUAs2ePbgiRTMR3RHtLJEjM qFnosMwyGf0HUldzD5ySmIAg+F5pO4+SdKTmlOyDuB0O1h3DUKOEMsFGFCLCxE4gULyX iz6ATY7bfXTQPgwmOuR7BtETTlQZN9hAyxibqaifWzX67qRm4vNt+C2ddNOPIlN6POrb LGpeUK+F+4HBRnC6UTgHD0Hx42zpe/R/k1QhN/qFcRK1FDQe2J6zYUiW40Ho7gLW4Vqb 7O3DqPo0H//ArwJu5szGMsl2aXnJDQcsUZ/BfzmcZdlG+jyUy8EFBCdBQd2zaMH01rFr 73oA== 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=GEhRQm5GgZgEJh7ObIQNgP9eU4C80Dw/cpwPpgc5KI4=; b=tpwgAi+rqg3zfABxhJKCsfsXTwHtVw4hdnBghhWXecMQdlFvNktfuJCAmryeMBHBe7 rH4RixPoSfxqczr/LfFBNRvto0YTHb1EJxg4xID2l6xy0KjJmdGWL8baApgNxe/o43yi x4ziUwefWxgNDHwZqDmgg+ZVmeaJ1o52xbGByss87el2N2KxO1gPemgatlDX+gle2kv0 q5OU7J3SodD6cCN5rvWX0InOt+DYDYwbXHhFstEYodNTkUotfIFzHFkObfMUSNf5kawM NURIpjOXNcQExc5/qcBSInLa0Y3Kca73lj15OFRucosUkhEDcb3rnCL574AKIdUwFBCw llcg== X-Gm-Message-State: AHPjjUgaCNEpGvHStMMJhw7ydNXQBhZrrJ4gvuElo0gD59T0H9IAWxwy HoHTsj0eVJidfw== X-Google-Smtp-Source: ADKCNb4bwYawgpHPGQpASq3j3YGIvmqi2NskTV7SX1J5gKj2cvGApN9GzkON61WtSPuNFS/uH20tVQ== X-Received: by 10.84.129.193 with SMTP id b59mr1431971plb.200.1504831876542; Thu, 07 Sep 2017 17:51:16 -0700 (PDT) Received: from localhost.localdomain (mobile-166-176-185-67.mycingular.net. [166.176.185.67]) by smtp.gmail.com with ESMTPSA id q13sm971702pfd.100.2017.09.07.17.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2017 17:51:16 -0700 (PDT) From: Ping Cheng X-Google-Original-From: Ping Cheng To: jikos@kernel.org Cc: linux-input@vger.kernel.org, Jason Gerecke , Ping Cheng , Jason Gerecke Subject: [PATCH 5/6] HID: wacom: generic: Send BTN_TOOL_PEN in prox once the pen enters range Date: Thu, 7 Sep 2017 17:51:06 -0700 Message-Id: <20170908005106.3116-1-ping.cheng@wacom.com> X-Mailer: git-send-email 2.9.5 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 From: Jason Gerecke When a pen is first able to to be sensed by the tablet, we would like to inform userspace that a tool is nearby so that it can attempt to perform palm rejection. Unfortunately, we don't know any information about the tool that is nearby, so the best we can do is send a prox event for a generic BTN_TOOL_PEN. If the pen later comes closer and enters proximity, we can determine the actual tool type and send BTN_TOOL_PEN out of prox if necessary. Signed-off-by: Ping Cheng Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 9b3a247..929a1ce 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2247,6 +2247,17 @@ static void wacom_wac_pen_report(struct hid_device *hdev, wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); else wacom_wac->tool[0] = BTN_TOOL_PEN; + + if (wacom_wac->shared->stylus_in_proximity && + wacom_wac->tool[0] != BTN_TOOL_PEN) { + input_report_key(input, BTN_TOOL_PEN, 0); + input_sync(input); + } + } + else if (!wacom_wac->tool[0] && !range) { /* entering in sense */ + input_report_key(input, BTN_TOOL_PEN, sense); + input_report_key(input, BTN_TOUCH, 0); + input_sync(input); } /* keep pen state for touch events */