LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jiri Kosina <jikos@kernel.org>
Cc: Harry Cutts <hcutts@chromium.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
peter.hutterer@who-t.net
Subject: Re: Logitech high-resolution scrolling..
Date: Mon, 29 Oct 2018 08:16:18 -0700 [thread overview]
Message-ID: <CAHk-=wgwgmcqxChVXQb66itd__qJOBc7LBsJ+nRAM86qJH-S2Q@mail.gmail.com> (raw)
In-Reply-To: <nycvar.YFH.7.76.1810291415570.23511@cbobk.fhfr.pm>
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
On Mon, Oct 29, 2018 at 6:18 AM Jiri Kosina <jikos@kernel.org> wrote:
>
> Benjamin indicated that Peter probably has found the issue in the code
> (failure to properly reset on direction change) that might be causing
> this.
So honestly, once I looked at that hid_scroll_counter_handle_scroll()
function, that's the first thing I tried - get rid of the "half-way
threshold" thing, and reset on direction changes.
It fixes the instability, and I don't see the "back-and-forth"
movements and I don't get the "move the mouse and it generates mouse
wheel events" any more.
It basically makes the wheel _work_ for me.
I'm not entirely convinced it's as good as it used to be, though. It
still feels like it might be a bit over-sensitive, but that may be
because now I'm just looking for it..
Patch I'm using attached. I'm inclined to just commit it, but if
somebody has a better idea, I can test alternatives too.
Linus
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 2208 bytes --]
drivers/hid/hid-input.c | 43 +++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 567c3bf64515..a2f74e6adc70 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1855,31 +1855,30 @@ EXPORT_SYMBOL_GPL(hidinput_disconnect);
void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter,
int hi_res_value)
{
- 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;
+ int low_res_value, remainder, multiplier;
input_report_rel(counter->dev, REL_WHEEL_HI_RES,
hi_res_value * counter->microns_per_hi_res_unit);
- 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;
- }
+ /*
+ * 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);
}
EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll);
next prev parent reply other threads:[~2018-10-29 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-28 19:13 Linus Torvalds
2018-10-28 21:08 ` Linus Torvalds
2018-10-30 15:53 ` Mauro Carvalho Chehab
2018-10-29 13:18 ` Jiri Kosina
2018-10-29 15:16 ` Linus Torvalds [this message]
2018-10-29 18:32 ` Linus Torvalds
2018-10-29 19:17 ` Harry Cutts
2018-10-29 21:11 ` Linus Torvalds
2018-10-29 21:42 ` Harry Cutts
2018-10-29 22:00 ` Linus Torvalds
2018-10-29 23:03 ` Harry Cutts
2018-10-30 6:26 ` Peter Hutterer
2018-10-30 16:29 ` Linus Torvalds
2018-10-30 17:48 ` Harry Cutts
2018-10-31 13:47 ` Nestor Lopez Casado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHk-=wgwgmcqxChVXQb66itd__qJOBc7LBsJ+nRAM86qJH-S2Q@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=benjamin.tissoires@redhat.com \
--cc=hcutts@chromium.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--subject='Re: Logitech high-resolution scrolling..' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).