Skip to content

Commit

Permalink
Fix mouse-wheel handling for evdev devices with extended values
Browse files Browse the repository at this point in the history
Newer mouse devices support a so-called "free-scroll" mode, which
unlocks the wheel and allows for faster scrolling. For such input
devices, evdev will report an event value greater than 1, when free
scrolling is active. Examples for such devices would be the Logitech
G700 or MX Master series.

However QEvdevMouseHandler interpreted such an event's data incorrectly
and triggered wheel events for the opposite scrolling direction. This
also often resulted in jittery & jumpy scrolling, when the events'
values alternated between 1 and 2.

Change-Id: Ibb23ed4419d647fff9b90d371d5bb4037cf2bd9b
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
  • Loading branch information
muesli committed Jun 22, 2018
1 parent 95b4177 commit 9e15a93
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,12 @@ void QEvdevMouseHandler::readMouseData()
m_y += data->value;
posChanged = true;
} else if (data->code == ABS_WHEEL) { // vertical scroll
// data->value: 1 == up, -1 == down
if (data->value == 1)
delta.setY(120);
else
delta.setY(-120);
// data->value: positive == up, negative == down
delta.setY(120 * data->value);
emit handleWheelEvent(delta);
} else if (data->code == ABS_THROTTLE) { // horizontal scroll
// data->value: 1 == right, -1 == left
if (data->value == 1)
delta.setX(-120);
else
delta.setX(120);
// data->value: positive == right, negative == left
delta.setX(-120 * data->value);
emit handleWheelEvent(delta);
}
} else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
Expand Down

0 comments on commit 9e15a93

Please sign in to comment.