OSDN Git Service

HID: input: use the Resolution Multiplier for high-resolution scrolling
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 5 Dec 2018 00:42:24 +0000 (10:42 +1000)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Fri, 7 Dec 2018 15:27:13 +0000 (16:27 +0100)
commit2dc702c991e3774af9d7ce410eef410ca9e2357e
tree227cb95401e7b53c2f60edd52bee40e0b683f3da
parent5a4abb36f312cf83206b1b7d1308ba47cba0b3cc
HID: input: use the Resolution Multiplier for high-resolution scrolling

Windows uses a magic number of 120 for a wheel click. High-resolution
scroll wheels are supposed to use a fraction of 120 to signal smaller
scroll steps. This is implemented by the Resolution Multiplier in the
device itself.

If the multiplier is present in the report descriptor, set it to the
logical max and then use the resolution multiplier to calculate the
high-resolution events. This is the recommendation by Microsoft, see
http://msdn.microsoft.com/en-us/windows/hardware/gg487477.aspx

Note that all mice encountered so far have a logical min/max of 0/1, so
it's a binary "yes or no" to high-res scrolling anyway.

To make userspace simpler, always enable the REL_WHEEL_HI_RES bit. Where
the device doesn't support high-resolution scrolling, the value for the
high-res data will simply be a multiple of 120 every time. For userspace,
if REL_WHEEL_HI_RES is available that is the one to be used.

Potential side-effect: a device with a Resolution Multiplier applying to
other Input items will have those items set to the logical max as well.
This cannot easily be worked around but it is doubtful such devices exist.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Verified-by: Harry Cutts <hcutts@chromium.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
drivers/hid/hid-input.c
include/linux/hid.h