From patchwork Sat Feb 11 00:14:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 9567657 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 7719D60572 for ; Sat, 11 Feb 2017 00:14:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60A4C285E3 for ; Sat, 11 Feb 2017 00:14:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53B2A285F4; Sat, 11 Feb 2017 00:14:35 +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 46688285E3 for ; Sat, 11 Feb 2017 00:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbdBKAOd (ORCPT ); Fri, 10 Feb 2017 19:14:33 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36728 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbdBKAOc (ORCPT ); Fri, 10 Feb 2017 19:14:32 -0500 Received: by mail-pg0-f68.google.com with SMTP id 75so4138928pgf.3 for ; Fri, 10 Feb 2017 16:14:32 -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=NerraoJbAdbkydNYb0XANUsNpMnsZhDA5AEgPAKv66w=; b=NMZk23rDvRCKp7WBxRvLcdUD69lz48pYgYwWyB2q4VQfap2MV+Ce3UPvtiY1fdDVGo W6+tnCodOxgZg64pFSv56h2MG43yY/ZoWQLH91YZpTvB2aCCNQf0sz1hBTPMadSaEj5I 18Qr/npHJiwym/+KzvIuCE0LqZj+7FTQzp4crFf8crPuuBI3Z8O7aRNGE3MzoODGqxHZ JIheBLIEP2n248rphOIVqT6/jBTkUmzwcsQBr5zLQKBTXKyLveQ+6/qO1UNDag+ieRCS E5z0n714Wt21VQs0p5rMJqwyGwAp17DWS06wRICI4TsdlAwU8pZYOkGkaPW3e0TCV5WC GPHg== 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=NerraoJbAdbkydNYb0XANUsNpMnsZhDA5AEgPAKv66w=; b=Ju76z9BNz3fjLkTDB1+olcZH5G+lM6lO+RGYRAX7K3rKIfhCRLPk8AcQdsKf2wBQ7q fUqAlmUnA3W6qqtFn6tzL0OtFeknNK9gDiKJI8iItbnIKCcsrPV4z6l9HPOXFQLYhkQe EChTG7WCSyPG7H0yHySZL8cwo5oofsy0lyCLKtwS5iK+DTCPC2Isd5MaCJ5SgTD9OCLW GTbRpvdOMUMGkdAGUkHa5EDBEhoXyBG/fJLdXJ1hRS/RR0E1+PI7ol4RivWJioBeO+zQ Rn4h2QFH5mRU7FV3C5JlCkw/QskEpQX2cJ55rgJ6TxybaLQGZKBwN43Hakh2VvvB330S hcHg== X-Gm-Message-State: AMke39kyI6aVmvY085h01b3S49E8rAzMPh28BinHmq32ncIFoiDjiaN+ToYOTkul3/vovg== X-Received: by 10.99.126.27 with SMTP id z27mr13918818pgc.177.1486772071549; Fri, 10 Feb 2017 16:14:31 -0800 (PST) Received: from localhost.localdomain (97-120-4-215.ptld.qwest.net. [97.120.4.215]) by smtp.googlemail.com with ESMTPSA id m136sm7662152pga.22.2017.02.10.16.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 16:14:30 -0800 (PST) From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jkosina@suse.cz, pinglinux@gmail.com, killertofu@gmail.com Cc: Jason Gerecke Subject: [PATCH input-wacom] HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range Date: Fri, 10 Feb 2017 16:14:07 -0800 Message-Id: <1486772047-7903-1-git-send-email-skomra@gmail.com> X-Mailer: git-send-email 2.7.4 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 The prox/range bits included in the Bluetooth reports from the Intuos Pro were being ignored, leading to two issues. Firstly, the pen would never announce a BTN_TOOL_PEN event with value 0, leaving userspace to believe the pen was always active. Secondly, the driver would continue to send events for data while the packet's "prox" bit was clear. This can lead to sudden incorrect pointer jumps if the pen is slowly moved away from the tablet surface. Signed-off-by: Jason Gerecke Reviewed-by: Ping Cheng --- drivers/hid/wacom_wac.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index bb98ca8..63b2485 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1213,29 +1213,34 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) for (i = 0; i < pen_frames; i++) { unsigned char *frame = &data[i*pen_frame_len + 1]; + bool valid = frame[0] & 0x80; + bool prox = frame[0] & 0x40; + bool range = frame[0] & 0x20; - if (!(frame[0] & 0x80)) + if (!valid) continue; - input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); - input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); + if (range) { + input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); + input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); + input_report_abs(pen_input, ABS_TILT_X, frame[7]); + input_report_abs(pen_input, ABS_TILT_Y, frame[8]); + input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9])); + input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11])); + } input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); - input_report_abs(pen_input, ABS_TILT_X, frame[7]); - input_report_abs(pen_input, ABS_TILT_Y, frame[8]); - input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9])); - input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11])); - input_report_abs(pen_input, ABS_DISTANCE, frame[13]); + input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max); input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); - input_report_key(pen_input, wacom->tool[0], 1); + input_report_key(pen_input, wacom->tool[0], prox); input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); input_report_abs(pen_input, ABS_MISC, wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ - wacom->shared->stylus_in_proximity = frame[0] & 0x40; + wacom->shared->stylus_in_proximity = prox; input_sync(pen_input); }