diff options
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r-- | drivers/hid/hid-input.c | 43 |
1 files 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); | |||
1858 | void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter, | 1858 | void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter, |
1859 | int hi_res_value) | 1859 | int hi_res_value) |
1860 | { | 1860 | { |
1861 | int low_res_value, remainder, multiplier; | 1861 | int low_res_scroll_amount; |
1862 | /* Some wheels will rest 7/8ths of a notch from the previous notch | ||
1863 | * after slow movement, so we want the threshold for low-res events to | ||
1864 | * be in the middle of the notches (e.g. after 4/8ths) as opposed to on | ||
1865 | * the notches themselves (8/8ths). | ||
1866 | */ | ||
1867 | int threshold = counter->resolution_multiplier / 2; | ||
1862 | 1868 | ||
1863 | input_report_rel(counter->dev, REL_WHEEL_HI_RES, | 1869 | input_report_rel(counter->dev, REL_WHEEL_HI_RES, |
1864 | hi_res_value * counter->microns_per_hi_res_unit); | 1870 | hi_res_value * counter->microns_per_hi_res_unit); |
1865 | 1871 | ||
1866 | /* | 1872 | counter->remainder += hi_res_value; |
1867 | * Update the low-res remainder with the high-res value, | 1873 | if (abs(counter->remainder) >= threshold) { |
1868 | * but reset if the direction has changed. | 1874 | /* Add (or subtract) 1 because we want to trigger when the wheel |
1869 | */ | 1875 | * is half-way to the next notch (i.e. scroll 1 notch after a |
1870 | remainder = counter->remainder; | 1876 | * 1/2 notch movement, 2 notches after a 1 1/2 notch movement, |
1871 | if ((remainder ^ hi_res_value) < 0) | 1877 | * etc.). |
1872 | remainder = 0; | 1878 | */ |
1873 | remainder += hi_res_value; | 1879 | low_res_scroll_amount = |
1874 | 1880 | counter->remainder / counter->resolution_multiplier | |
1875 | /* | 1881 | + (hi_res_value > 0 ? 1 : -1); |
1876 | * Then just use the resolution multiplier to see if | 1882 | input_report_rel(counter->dev, REL_WHEEL, |
1877 | * we should send a low-res (aka regular wheel) event. | 1883 | low_res_scroll_amount); |
1878 | */ | 1884 | counter->remainder -= |
1879 | multiplier = counter->resolution_multiplier; | 1885 | low_res_scroll_amount * counter->resolution_multiplier; |
1880 | low_res_value = remainder / multiplier; | 1886 | } |
1881 | remainder -= low_res_value * multiplier; | ||
1882 | counter->remainder = remainder; | ||
1883 | |||
1884 | if (low_res_value) | ||
1885 | input_report_rel(counter->dev, REL_WHEEL, low_res_value); | ||
1886 | } | 1887 | } |
1887 | EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll); | 1888 | EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll); |