From patchwork Wed Apr 4 21:24:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 10323429 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 7F32460390 for ; Wed, 4 Apr 2018 21:25:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7019F29026 for ; Wed, 4 Apr 2018 21:25:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6452129029; Wed, 4 Apr 2018 21:25: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.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 4B95329026 for ; Wed, 4 Apr 2018 21:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753097AbeDDVZP (ORCPT ); Wed, 4 Apr 2018 17:25:15 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44894 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753053AbeDDVZM (ORCPT ); Wed, 4 Apr 2018 17:25:12 -0400 Received: by mail-pl0-f67.google.com with SMTP id b6-v6so13978229pla.11; Wed, 04 Apr 2018 14:25:12 -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=LBBeiBp4M3kCPf/oTeJPQOVs31rc+3wS7T4muD6Ecb0=; b=DHXV3K6+GEUJ/gWiZ9w/UMcy3KvcwD43nJqpyvomEz1WPh8xR1IiiftPKARpTqhEdd cy6PQUwfvyrxogh1iEQGhLqUuFsbhVbkd7CuiWk1te1iBgFcIYiz8jfLoKg3yQlrUqq4 0/5ROVDz5cA6rSxkMS1LfpCupoHWkjzINmi3iY9GtzdBgHsyrLIykz5ZRv5Zv/UKLQGA U6cepnENIkivnPyVmoSEEZsssCgZ6Z77ibsZ+ns/qnpbhfi4ihFnPCILQOu0cTQql5FU Sv7Ss2R4ebZDWAXU5Ciq2aimQkXVbH2n/R9xCpHAFa5K+xkzfabS4hz/4FOl2whbSLqF Q46g== 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=LBBeiBp4M3kCPf/oTeJPQOVs31rc+3wS7T4muD6Ecb0=; b=XV2ZcDqOh8zrO71LoSMOd7IztXiED7T9a+C9SGVbmW4SqRqWYyMaXTiXrSHOo0uBHb /U0LCDxFx2OJLQ6zgAiVSaSIBv6sM1qgxxWb4GBT9F1eT6XkBEMDdPewQWG594dqYv2e taeupJdZ5sVOXR9kLP8vsG0ZSE92BYF/y2y12Q56lDy9y+FG2vWc9KiRtcboMAQhtyAd rxAzwDNVzr5wWG4yOELaseJ9SfRKtXLc+eF8wWMAjGPauFjj3d13N3IGKJVZ5NTzNuf/ Asb8PiZY3QW5mF+mwrSF1WWfDiqfTn7BLqtm3g3vija97Zt24mOqW8sdwCHUkmW9I6+M rmvw== X-Gm-Message-State: AElRT7ESnIK3Oy91i42oNx1OHB+kpWa96svd/5qZ0hOGP2hg2ax46qHG V+G8CvaLdazgD72mv2Mo5KAfWPHC X-Google-Smtp-Source: AIpwx49iUCIz8mb+0eBtYTSrGlJ1T9PZTgRXrsSYLttBKzTkElKlq9703VgNDpyKJq4+4/kKIUB/9A== X-Received: by 10.98.70.8 with SMTP id t8mr15147201pfa.185.1522877111452; Wed, 04 Apr 2018 14:25:11 -0700 (PDT) Received: from juhua.Home (184-100-226-242.ptld.qwest.net. [184.100.226.242]) by smtp.googlemail.com with ESMTPSA id a12sm2551440pfe.78.2018.04.04.14.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Apr 2018 14:25:09 -0700 (PDT) From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, pinglinux@gmail.com, killertofu@gmail.com, jkosina@suse.cz Cc: Aaron Armstrong Skomra , "# 4 . 11" , Aaron Armstrong Skomra Subject: [PATCH] HID: wacom: bluetooth: send exit report for recent Bluetooth devices Date: Wed, 4 Apr 2018 14:24:11 -0700 Message-Id: <1522877051-3943-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 The code path for recent Bluetooth devices omits an exit report which resets all the values of the device. Fixes: 4922cd26f0 ("HID: wacom: Support 2nd-gen Intuos Pro's Bluetooth classic interface") Cc: # 4.11 Signed-off-by: Aaron Armstrong Skomra Reviewed-by: Ping Cheng --- drivers/hid/wacom_wac.c | 76 ++++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 6da16a879c9f..5f947ec20dcb 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -689,6 +689,45 @@ static int wacom_intuos_get_tool_type(int tool_id) return tool_type; } +static void wacom_exit_report(struct wacom_wac *wacom) +{ + struct input_dev *input = wacom->pen_input; + struct wacom_features *features = &wacom->features; + unsigned char *data = wacom->data; + int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; + + /* + * Reset all states otherwise we lose the initial states + * when in-prox next time + */ + input_report_abs(input, ABS_X, 0); + input_report_abs(input, ABS_Y, 0); + input_report_abs(input, ABS_DISTANCE, 0); + input_report_abs(input, ABS_TILT_X, 0); + input_report_abs(input, ABS_TILT_Y, 0); + if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { + input_report_key(input, BTN_LEFT, 0); + input_report_key(input, BTN_MIDDLE, 0); + input_report_key(input, BTN_RIGHT, 0); + input_report_key(input, BTN_SIDE, 0); + input_report_key(input, BTN_EXTRA, 0); + input_report_abs(input, ABS_THROTTLE, 0); + input_report_abs(input, ABS_RZ, 0); + } else { + input_report_abs(input, ABS_PRESSURE, 0); + input_report_key(input, BTN_STYLUS, 0); + input_report_key(input, BTN_STYLUS2, 0); + input_report_key(input, BTN_TOUCH, 0); + input_report_abs(input, ABS_WHEEL, 0); + if (features->type >= INTUOS3S) + input_report_abs(input, ABS_Z, 0); + } + input_report_key(input, wacom->tool[idx], 0); + input_report_abs(input, ABS_MISC, 0); /* reset tool id */ + input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); + wacom->id[idx] = 0; +} + static int wacom_intuos_inout(struct wacom_wac *wacom) { struct wacom_features *features = &wacom->features; @@ -741,36 +780,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) if (!wacom->id[idx]) return 1; - /* - * Reset all states otherwise we lose the initial states - * when in-prox next time - */ - input_report_abs(input, ABS_X, 0); - input_report_abs(input, ABS_Y, 0); - input_report_abs(input, ABS_DISTANCE, 0); - input_report_abs(input, ABS_TILT_X, 0); - input_report_abs(input, ABS_TILT_Y, 0); - if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { - input_report_key(input, BTN_LEFT, 0); - input_report_key(input, BTN_MIDDLE, 0); - input_report_key(input, BTN_RIGHT, 0); - input_report_key(input, BTN_SIDE, 0); - input_report_key(input, BTN_EXTRA, 0); - input_report_abs(input, ABS_THROTTLE, 0); - input_report_abs(input, ABS_RZ, 0); - } else { - input_report_abs(input, ABS_PRESSURE, 0); - input_report_key(input, BTN_STYLUS, 0); - input_report_key(input, BTN_STYLUS2, 0); - input_report_key(input, BTN_TOUCH, 0); - input_report_abs(input, ABS_WHEEL, 0); - if (features->type >= INTUOS3S) - input_report_abs(input, ABS_Z, 0); - } - input_report_key(input, wacom->tool[idx], 0); - input_report_abs(input, ABS_MISC, 0); /* reset tool id */ - input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); - wacom->id[idx] = 0; + wacom_exit_report(wacom); return 2; } @@ -1235,6 +1245,12 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) if (!valid) continue; + if (!prox) { + wacom->shared->stylus_in_proximity = false; + wacom_exit_report(wacom); + input_sync(pen_input); + return; + } 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]));