From patchwork Fri Jan 9 19:05:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 5602261 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BABF4C058D for ; Fri, 9 Jan 2015 19:05:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCC9F2060E for ; Fri, 9 Jan 2015 19:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3CCA205FA for ; Fri, 9 Jan 2015 19:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbbAITFK (ORCPT ); Fri, 9 Jan 2015 14:05:10 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:46560 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbbAITFK (ORCPT ); Fri, 9 Jan 2015 14:05:10 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so18950155pdb.8 for ; Fri, 09 Jan 2015 11:05:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=m74tthtbaWq3sw6f1n2kKWr1hX+EiJ/K2JHYEq12mvc=; b=moCWw3KnyxdB2Ed7Dcl9GRbAJpcYWyMsgdh9CuUUrNJGFPZCo0UD/E1sM1BO5PvxKN gDEiX3luDHD+Wbcnh5KDN8E/QCi+kiaZTd9+mEaX4SghccbxqrPX5S4RXYf7x1liO3e8 qwsvyYU2QZtV0D3MgrlvjZO+OjvfRH+Yv13gOoXy+g+hEtGfIfKNgbVCF3CWvsa2WpFr b2Qdt8rCadXahfVqmwOWrNNoy4pY49vmWGBLxdcX5zuRHcxosweYLiQV9e3HC0JxSXYn R9kwFmTBkHhNDk9FjMdDsB/NBWHdWK+sxcftmGF/7AvvVUfTO2bszkrwBe3oY0gNOWBP kwAA== X-Received: by 10.70.63.99 with SMTP id f3mr15444741pds.149.1420830309561; Fri, 09 Jan 2015 11:05:09 -0800 (PST) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id ob4sm7773026pdb.48.2015.01.09.11.05.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Jan 2015 11:05:09 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: jkosina@suse.cz Cc: linux-input@vger.kernel.org, Ping Cheng Subject: [PATCH 2/2] Report In Range event according to the spec Date: Fri, 9 Jan 2015 11:05:13 -0800 Message-Id: <1420830313-5092-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Some Cintiq and Intuos tablets report In Range event. This event is sent before valid data is reported when tool enters proximity; or before out of proximity event is reported when tool exits. While entering proximity, In Range means a pen is detected. This information can be used for palm/touch rejection on both pen and touch enabled devices. While exiting, it means the tool has reached its maximum detectable distance. Signed-off-by: Ping Cheng --- v2: Updated typos in commit comments as pointed out by Bastien Nocera. --- drivers/hid/wacom_wac.c | 15 ++++++++------- drivers/hid/wacom_wac.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 5276689..a4ba8ca 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -443,9 +443,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) /* Enter report */ if ((data[1] & 0xfc) == 0xc0) { - if (features->quirks & WACOM_QUIRK_MULTI_INPUT) - wacom->shared->stylus_in_proximity = true; - /* serial number of the tool */ wacom->serial[idx] = ((data[3] & 0x0f) << 28) + (data[4] << 20) + (data[5] << 12) + @@ -554,19 +551,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) (features->type == CINTIQ && !(data[1] & 0x40))) return 1; - /* Range Report */ - if ((data[1] & 0xfe) == 0x20) { + if (features->quirks & WACOM_QUIRK_MULTI_INPUT) + wacom->shared->stylus_in_proximity = true; + + /* in Range while exiting */ + if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) { input_report_key(input, BTN_TOUCH, 0); input_report_abs(input, ABS_PRESSURE, 0); input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); - if (features->quirks & WACOM_QUIRK_MULTI_INPUT) - wacom->shared->stylus_in_proximity = true; + return 2; } /* Exit report */ if ((data[1] & 0xfe) == 0x80) { if (features->quirks & WACOM_QUIRK_MULTI_INPUT) wacom->shared->stylus_in_proximity = false; + wacom->reporting_data = false; /* don't report exit if we don't know the ID */ if (!wacom->id[idx]) @@ -952,6 +952,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */ input_report_key(input, wacom->tool[idx], 1); input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); + wacom->reporting_data = true; return 1; } diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 7afd929..72e78cc 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -189,6 +189,7 @@ struct wacom_wac { int tool[2]; int id[2]; __u32 serial[2]; + bool reporting_data; struct wacom_features features; struct wacom_shared *shared; struct input_dev *input;