Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2355299imu; Wed, 21 Nov 2018 10:17:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/WRQce5jkR6/Z1AALR6PtXHEbNMGCAFxKxuV/sfhMiPgfyAyJqeTpKhQxtowDFpMkvlCyjj X-Received: by 2002:a63:554b:: with SMTP id f11mr7151439pgm.37.1542824240371; Wed, 21 Nov 2018 10:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542824240; cv=none; d=google.com; s=arc-20160816; b=PDNN7ODiFxNZX0rRz+uyOhZfIjQ7hvb3V/b1ARs7xdZC+52gqMGLHPq5zE/7t/YOa6 aULUSDFbW9/IF4lTldnUU5dCKbIRLx97iwvZq8qKDHbHmMNueb2thE69ENqb0meBDarF srVy8sJmJCuxEIBO8+nEUeo9BBLX/rP7a06BTxMApuhOWe9qhUo4/vRNGNJFWT8UHV5z lDip9mQqjP2WgDewXPsbner2x+OXuU89g7YNm9gqh5zd1XA9WBVIilTxSG+/yY9f48FM Dc42WQ7Zl12952BJByIXNm5s2zu+88CeaBwPAfJHS4E+QmFkRlHQuUO9iRke6UkRBiMj vt6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BZ8atEvHyiDNMwGDjXwDF8soK88/vNKv0AW6g4NmOHs=; b=wN+DHaRBOGbDGA27oovnbPCEjqyf+eyTSI34PQuzQt/LfDHNdyT3ck42rKYOmiEHkf Rvnu6bGnPQO9yfZ4Ba0vQHrY7GRGJTXn3yR2WIw0DUU++s59DPXYKkhs9uWeTJhhM+hF vG5wel06DPKU+TytMCvR8q249qb6lpMjDk+ZkdtRKaM7MX7LPQTd5zpUK+WZNpI9gAhc A3U2WaCZLgDsmkR29mPwSa94HMQNadrM6T2W/dswhlQd4xxB4qlejw+0RhJOv5H/6JrQ yDHj8NfUcrkQXbssb11Q8Ym9u+KLgu0IROBvbM4Tg/ZVAwXnuu0U7jojaezJJ7RmmjqO PXqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u9si20848298plk.61.2018.11.21.10.16.45; Wed, 21 Nov 2018 10:17:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731324AbeKVCCU (ORCPT + 99 others); Wed, 21 Nov 2018 21:02:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731213AbeKVCCT (ORCPT ); Wed, 21 Nov 2018 21:02:19 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64602307CDD6; Wed, 21 Nov 2018 15:27:26 +0000 (UTC) Received: from plouf.redhat.com (ovpn-204-124.brq.redhat.com [10.40.204.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 032DD103BAB7; Wed, 21 Nov 2018 15:27:23 +0000 (UTC) From: Benjamin Tissoires To: Dmitry Torokhov , Jiri Kosina , Harry Cutts , Peter Hutterer , torvalds@linux-foundation.org Cc: Nestor Lopez Casado , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 1/7] Revert "HID: input: simplify/fix high-res scroll event handling" Date: Wed, 21 Nov 2018 16:27:06 +0100 Message-Id: <20181121152712.6770-2-benjamin.tissoires@redhat.com> In-Reply-To: <20181121152712.6770-1-benjamin.tissoires@redhat.com> References: <20181121152712.6770-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 21 Nov 2018 15:27:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit 044ee890286153a1aefb40cb8b6659921aecb38b. It turns out the current API is not that compatible with some Microsoft mice, so better start again from scratch. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-input.c | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 44ea8e7c71a9..28ee2ed88a1a 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1858,30 +1858,31 @@ EXPORT_SYMBOL_GPL(hidinput_disconnect); void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter, int hi_res_value) { - int low_res_value, remainder, multiplier; + int low_res_scroll_amount; + /* Some wheels will rest 7/8ths of a notch from the previous notch + * after slow movement, so we want the threshold for low-res events to + * be in the middle of the notches (e.g. after 4/8ths) as opposed to on + * the notches themselves (8/8ths). + */ + int threshold = counter->resolution_multiplier / 2; input_report_rel(counter->dev, REL_WHEEL_HI_RES, hi_res_value * counter->microns_per_hi_res_unit); - /* - * Update the low-res remainder with the high-res value, - * but reset if the direction has changed. - */ - remainder = counter->remainder; - if ((remainder ^ hi_res_value) < 0) - remainder = 0; - remainder += hi_res_value; - - /* - * Then just use the resolution multiplier to see if - * we should send a low-res (aka regular wheel) event. - */ - multiplier = counter->resolution_multiplier; - low_res_value = remainder / multiplier; - remainder -= low_res_value * multiplier; - counter->remainder = remainder; - - if (low_res_value) - input_report_rel(counter->dev, REL_WHEEL, low_res_value); + counter->remainder += hi_res_value; + if (abs(counter->remainder) >= threshold) { + /* Add (or subtract) 1 because we want to trigger when the wheel + * is half-way to the next notch (i.e. scroll 1 notch after a + * 1/2 notch movement, 2 notches after a 1 1/2 notch movement, + * etc.). + */ + low_res_scroll_amount = + counter->remainder / counter->resolution_multiplier + + (hi_res_value > 0 ? 1 : -1); + input_report_rel(counter->dev, REL_WHEEL, + low_res_scroll_amount); + counter->remainder -= + low_res_scroll_amount * counter->resolution_multiplier; + } } EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll); -- 2.19.1