Revert "HID: input: simplify/fix high-res scroll event handling"
This reverts commit 044ee89028
.
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 <benjamin.tissoires@redhat.com>
Acked-by: Harry Cutts <hcutts@chromium.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
Родитель
fb862c3b19
Коммит
e2b95b2719
|
@ -1858,30 +1858,31 @@ EXPORT_SYMBOL_GPL(hidinput_disconnect);
|
||||||
void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter,
|
void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter,
|
||||||
int hi_res_value)
|
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,
|
input_report_rel(counter->dev, REL_WHEEL_HI_RES,
|
||||||
hi_res_value * counter->microns_per_hi_res_unit);
|
hi_res_value * counter->microns_per_hi_res_unit);
|
||||||
|
|
||||||
/*
|
counter->remainder += hi_res_value;
|
||||||
* Update the low-res remainder with the high-res value,
|
if (abs(counter->remainder) >= threshold) {
|
||||||
* but reset if the direction has changed.
|
/* 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
|
||||||
remainder = counter->remainder;
|
* 1/2 notch movement, 2 notches after a 1 1/2 notch movement,
|
||||||
if ((remainder ^ hi_res_value) < 0)
|
* etc.).
|
||||||
remainder = 0;
|
*/
|
||||||
remainder += hi_res_value;
|
low_res_scroll_amount =
|
||||||
|
counter->remainder / counter->resolution_multiplier
|
||||||
/*
|
+ (hi_res_value > 0 ? 1 : -1);
|
||||||
* Then just use the resolution multiplier to see if
|
input_report_rel(counter->dev, REL_WHEEL,
|
||||||
* we should send a low-res (aka regular wheel) event.
|
low_res_scroll_amount);
|
||||||
*/
|
counter->remainder -=
|
||||||
multiplier = counter->resolution_multiplier;
|
low_res_scroll_amount * 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);
|
EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче