Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
276e7227
Commit
276e7227
authored
Oct 23, 2018
by
Jiri Kosina
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-4.20/logitech-highres' into for-linus
High-resolution support for hid-logitech
parents
4e7be68e
d9ca1c99
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
383 additions
and
28 deletions
+383
-28
Documentation/input/event-codes.rst
Documentation/input/event-codes.rst
+10
-1
drivers/hid/hid-input.c
drivers/hid/hid-input.c
+45
-0
drivers/hid/hid-logitech-hidpp.c
drivers/hid/hid-logitech-hidpp.c
+282
-27
include/linux/hid.h
include/linux/hid.h
+28
-0
include/uapi/linux/input-event-codes.h
include/uapi/linux/input-event-codes.h
+18
-0
No files found.
Documentation/input/event-codes.rst
View file @
276e7227
...
...
@@ -190,7 +190,16 @@ A few EV_REL codes have special meanings:
* REL_WHEEL, REL_HWHEEL:
- These codes are used for vertical and horizontal scroll wheels,
respectively.
respectively. The value is the number of "notches" moved on the wheel, the
physical size of which varies by device. For high-resolution wheels (which
report multiple events for each notch of movement, or do not have notches)
this may be an approximation based on the high-resolution scroll events.
* REL_WHEEL_HI_RES:
- If a vertical scroll wheel supports high-resolution scrolling, this code
will be emitted in addition to REL_WHEEL. The value is the (approximate)
distance travelled by the user's finger, in microns.
EV_ABS
------
...
...
drivers/hid/hid-input.c
View file @
276e7227
...
...
@@ -1838,3 +1838,48 @@ void hidinput_disconnect(struct hid_device *hid)
}
EXPORT_SYMBOL_GPL
(
hidinput_disconnect
);
/**
* hid_scroll_counter_handle_scroll() - Send high- and low-resolution scroll
* events given a high-resolution wheel
* movement.
* @counter: a hid_scroll_counter struct describing the wheel.
* @hi_res_value: the movement of the wheel, in the mouse's high-resolution
* units.
*
* Given a high-resolution movement, this function converts the movement into
* microns and emits high-resolution scroll events for the input device. It also
* uses the multiplier from &struct hid_scroll_counter to emit low-resolution
* scroll events when appropriate for backwards-compatibility with userspace
* input libraries.
*/
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
;
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
;
}
}
EXPORT_SYMBOL_GPL
(
hid_scroll_counter_handle_scroll
);
drivers/hid/hid-logitech-hidpp.c
View file @
276e7227
This diff is collapsed.
Click to expand it.
include/linux/hid.h
View file @
276e7227
...
...
@@ -1139,6 +1139,34 @@ static inline u32 hid_report_len(struct hid_report *report)
int
hid_report_raw_event
(
struct
hid_device
*
hid
,
int
type
,
u8
*
data
,
u32
size
,
int
interrupt
);
/**
* struct hid_scroll_counter - Utility class for processing high-resolution
* scroll events.
* @dev: the input device for which events should be reported.
* @microns_per_hi_res_unit: the amount moved by the user's finger for each
* high-resolution unit reported by the mouse, in
* microns.
* @resolution_multiplier: the wheel's resolution in high-resolution mode as a
* multiple of its lower resolution. For example, if
* moving the wheel by one "notch" would result in a
* value of 1 in low-resolution mode but 8 in
* high-resolution, the multiplier is 8.
* @remainder: counts the number of high-resolution units moved since the last
* low-resolution event (REL_WHEEL or REL_HWHEEL) was sent. Should
* only be used by class methods.
*/
struct
hid_scroll_counter
{
struct
input_dev
*
dev
;
int
microns_per_hi_res_unit
;
int
resolution_multiplier
;
int
remainder
;
};
void
hid_scroll_counter_handle_scroll
(
struct
hid_scroll_counter
*
counter
,
int
hi_res_value
);
/* HID quirks API */
unsigned
long
hid_lookup_quirk
(
const
struct
hid_device
*
hdev
);
int
hid_quirks_init
(
char
**
quirks_param
,
__u16
bus
,
int
count
);
...
...
include/uapi/linux/input-event-codes.h
View file @
276e7227
...
...
@@ -708,6 +708,15 @@
#define REL_DIAL 0x07
#define REL_WHEEL 0x08
#define REL_MISC 0x09
/*
* 0x0a is reserved and should not be used in input drivers.
* It was used by HID as REL_MISC+1 and userspace needs to detect if
* the next REL_* event is correct or is just REL_MISC + n.
* We define here REL_RESERVED so userspace can rely on it and detect
* the situation described above.
*/
#define REL_RESERVED 0x0a
#define REL_WHEEL_HI_RES 0x0b
#define REL_MAX 0x0f
#define REL_CNT (REL_MAX+1)
...
...
@@ -744,6 +753,15 @@
#define ABS_MISC 0x28
/*
* 0x2e is reserved and should not be used in input drivers.
* It was used by HID as ABS_MISC+6 and userspace needs to detect if
* the next ABS_* event is correct or is just ABS_MISC + n.
* We define here ABS_RESERVED so userspace can rely on it and detect
* the situation described above.
*/
#define ABS_RESERVED 0x2e
#define ABS_MT_SLOT 0x2f
/* MT slot being modified */
#define ABS_MT_TOUCH_MAJOR 0x30
/* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31
/* Minor axis (omit if circular) */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment