From patchwork Wed Mar 12 23:17:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clinton Sprain X-Patchwork-Id: 3821281 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6F7E7BF540 for ; Wed, 12 Mar 2014 23:18:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 815182028D for ; Wed, 12 Mar 2014 23:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9117F2021F for ; Wed, 12 Mar 2014 23:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751324AbaCLXSR (ORCPT ); Wed, 12 Mar 2014 19:18:17 -0400 Received: from mail-ie0-f177.google.com ([209.85.223.177]:63589 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162AbaCLXSR (ORCPT ); Wed, 12 Mar 2014 19:18:17 -0400 Received: by mail-ie0-f177.google.com with SMTP id rl12so198552iec.36 for ; Wed, 12 Mar 2014 16:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=+k14VcvUygqUdoegjcimMhOmH6fHMpmWoeAz9AaF2/c=; b=x2t7ir/vhtAV0GK9zSaWUcHZdeYwX1keW16kMUGY296itSACWOrRB98HFtPESdJ0rA NaRxKC9ITWq4t614PbL48D2d6BYztbD3pAEaVO1XG9+YysfZ4gm1n2nUQRHSu86DSvFN 3HQeTPyqTL3+2ig3dCX38jKuFKl3PXiril3s7mTMrTAGGFsPc1bMEjBWZVgwOXEOXkZp d1r/pdu9+Jss3a4RthImW0cssaUpxr0b+4fYsAE4uDt8HwpBDcuWKuUO8cXhVw/WsM6t vBnsmRvc7RJB25x+xsqS9frAOvFJ2lFJfJhTqbAJYTvB7i2rJSHA1sCC90z3l8sC96nU P6Ng== X-Received: by 10.43.163.200 with SMTP id mp8mr222246icc.18.1394666271994; Wed, 12 Mar 2014 16:17:51 -0700 (PDT) Received: from [10.105.134.127] (pat-wlanguest-e.epic.com. [199.204.56.144]) by mx.google.com with ESMTPSA id gd5sm2436793igd.5.2014.03.12.16.17.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 16:17:51 -0700 (PDT) Message-ID: <5320EB1E.3020302@gmail.com> Date: Wed, 12 Mar 2014 18:17:50 -0500 From: Clinton Sprain User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: linux-input@vger.kernel.org CC: Dmitry Torokhov , Henrik Rydberg Subject: [PATCH v4 3/3] input: appletouch: fix jumps when additional fingers are detected References: <52D9DE7A.7040509@gmail.com> <5320EA03.2040206@gmail.com> In-Reply-To: <5320EA03.2040206@gmail.com> 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 input: appletouch: fix jumps when additional fingers are detected Addresses issues related to when a second finger enters or leaves the field, causing the cursor to jump or the page to scroll unexpectedly; now, we discard any movement change that happens at the exact moment we detect a change in the number of fingers touching the trackpad. This doesn't completely resolve the issue but does greatly mitigate it. Signed-off-by: Clinton Sprain --- drivers/input/mouse/appletouch.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index e00f126..5140293 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c @@ -206,6 +206,7 @@ struct atp { bool valid; /* are the samples valid? */ bool size_detect_done; bool overflow_warned; + int fingers_old; /* last reported finger count */ int x_old; /* last reported x/y, */ int y_old; /* used for smoothing */ signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; @@ -508,7 +509,7 @@ static void atp_complete_geyser_1_2(struct urb *urb) { int x, y, x_z, y_z, x_f, y_f; int retval, i, j; - int key; + int key, fingers; struct atp *dev = urb->context; int status = atp_status_check(urb); @@ -591,7 +592,9 @@ static void atp_complete_geyser_1_2(struct urb *urb) dev->info->yfact, &y_z, &y_f); key = dev->data[dev->info->datalen - 1] & ATP_STATUS_BUTTON; - if (x && y) { + fingers = max(x_f, y_f); + + if (x && y && (fingers == dev->fingers_old)) { if (dev->x_old != -1) { x = (dev->x_old * 7 + x) >> 3; y = (dev->y_old * 7 + y) >> 3; @@ -608,7 +611,7 @@ static void atp_complete_geyser_1_2(struct urb *urb) input_report_abs(dev->input, ABS_Y, y); input_report_abs(dev->input, ABS_PRESSURE, min(ATP_PRESSURE, x_z + y_z)); - atp_report_fingers(dev->input, max(x_f, y_f)); + atp_report_fingers(dev->input, fingers); } dev->x_old = x; dev->y_old = y; @@ -616,6 +619,7 @@ static void atp_complete_geyser_1_2(struct urb *urb) } else if (!x && !y) { dev->x_old = dev->y_old = -1; + dev->fingers_old = 0; input_report_key(dev->input, BTN_TOUCH, 0); input_report_abs(dev->input, ABS_PRESSURE, 0); atp_report_fingers(dev->input, 0); @@ -624,6 +628,10 @@ static void atp_complete_geyser_1_2(struct urb *urb) memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); } + if (fingers != dev->fingers_old) + dev->x_old = dev->y_old = -1; + dev->fingers_old = fingers; + input_report_key(dev->input, BTN_LEFT, key); input_sync(dev->input); @@ -641,7 +649,7 @@ static void atp_complete_geyser_3_4(struct urb *urb) { int x, y, x_z, y_z, x_f, y_f; int retval, i, j; - int key; + int key, fingers; struct atp *dev = urb->context; int status = atp_status_check(urb); @@ -703,7 +711,9 @@ static void atp_complete_geyser_3_4(struct urb *urb) dev->info->yfact, &y_z, &y_f); key = dev->data[dev->info->datalen - 1] & ATP_STATUS_BUTTON; - if (x && y) { + fingers = max(x_f, y_f); + + if (x && y && (fingers == dev->fingers_old)) { if (dev->x_old != -1) { x = (dev->x_old * 7 + x) >> 3; y = (dev->y_old * 7 + y) >> 3; @@ -720,7 +730,7 @@ static void atp_complete_geyser_3_4(struct urb *urb) input_report_abs(dev->input, ABS_Y, y); input_report_abs(dev->input, ABS_PRESSURE, min(ATP_PRESSURE, x_z + y_z)); - atp_report_fingers(dev->input, max(x_f, y_f)); + atp_report_fingers(dev->input, fingers); } dev->x_old = x; dev->y_old = y; @@ -728,6 +738,7 @@ static void atp_complete_geyser_3_4(struct urb *urb) } else if (!x && !y) { dev->x_old = dev->y_old = -1; + dev->fingers_old = 0; input_report_key(dev->input, BTN_TOUCH, 0); input_report_abs(dev->input, ABS_PRESSURE, 0); atp_report_fingers(dev->input, 0); @@ -736,6 +747,10 @@ static void atp_complete_geyser_3_4(struct urb *urb) memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); } + if (fingers != dev->fingers_old) + dev->x_old = dev->y_old = -1; + dev->fingers_old = fingers; + input_report_key(dev->input, BTN_LEFT, key); input_sync(dev->input);