diff options
Diffstat (limited to 'src/evdev-wheel.c')
-rw-r--r-- | src/evdev-wheel.c | 156 |
1 files changed, 82 insertions, 74 deletions
diff --git a/src/evdev-wheel.c b/src/evdev-wheel.c index 5cbaf3b9..244e4eb0 100644 --- a/src/evdev-wheel.c +++ b/src/evdev-wheel.c @@ -30,6 +30,87 @@ #include "evdev-fallback.h" #include "util-input-event.h" +static void +wheel_flush_scroll(struct fallback_dispatch *dispatch, + struct evdev_device *device, + uint64_t time) +{ + struct normalized_coords wheel_degrees = { 0.0, 0.0 }; + struct discrete_coords discrete = { 0.0, 0.0 }; + struct wheel_v120 v120 = { 0.0, 0.0 }; + + if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) { + struct normalized_coords unaccel = { 0.0, 0.0 }; + + dispatch->wheel.hi_res.y *= -1; + fallback_normalize_delta(device, &dispatch->wheel.hi_res, &unaccel); + evdev_post_scroll(device, + time, + LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS, + &unaccel); + dispatch->wheel.hi_res.x = 0; + dispatch->wheel.hi_res.y = 0; + + return; + } + + if (dispatch->wheel.hi_res.y != 0) { + int value = dispatch->wheel.hi_res.y; + + v120.y = -1 * value; + wheel_degrees.y = -1 * value/120.0 * device->scroll.wheel_click_angle.y; + evdev_notify_axis_wheel( + device, + time, + bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL), + &wheel_degrees, + &v120); + dispatch->wheel.hi_res.y = 0; + } + + if (dispatch->wheel.lo_res.y != 0) { + int value = dispatch->wheel.lo_res.y; + + wheel_degrees.y = -1 * value * device->scroll.wheel_click_angle.y; + discrete.y = -1 * value; + evdev_notify_axis_legacy_wheel( + device, + time, + bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL), + &wheel_degrees, + &discrete); + dispatch->wheel.lo_res.y = 0; + } + + if (dispatch->wheel.hi_res.x != 0) { + int value = dispatch->wheel.hi_res.x; + + v120.x = value; + wheel_degrees.x = value/120.0 * device->scroll.wheel_click_angle.x; + evdev_notify_axis_wheel( + device, + time, + bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL), + &wheel_degrees, + &v120); + dispatch->wheel.hi_res.x = 0; + } + + if (dispatch->wheel.lo_res.x != 0) { + int value = dispatch->wheel.lo_res.x; + + wheel_degrees.x = value * device->scroll.wheel_click_angle.x; + discrete.x = value; + evdev_notify_axis_legacy_wheel( + device, + time, + bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL), + &wheel_degrees, + &discrete); + dispatch->wheel.lo_res.x = 0; + } +} + void fallback_wheel_process_relative(struct fallback_dispatch *dispatch, struct evdev_device *device, @@ -86,10 +167,6 @@ fallback_wheel_handle_state(struct fallback_dispatch *dispatch, struct evdev_device *device, uint64_t time) { - struct normalized_coords wheel_degrees = { 0.0, 0.0 }; - struct discrete_coords discrete = { 0.0, 0.0 }; - struct wheel_v120 v120 = { 0.0, 0.0 }; - if (!(device->seat_caps & EVDEV_DEVICE_POINTER)) return; @@ -113,76 +190,7 @@ fallback_wheel_handle_state(struct fallback_dispatch *dispatch, return; } - if (device->model_flags & EVDEV_MODEL_LENOVO_SCROLLPOINT) { - struct normalized_coords unaccel = { 0.0, 0.0 }; - - dispatch->wheel.hi_res.y *= -1; - fallback_normalize_delta(device, &dispatch->wheel.hi_res, &unaccel); - evdev_post_scroll(device, - time, - LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS, - &unaccel); - dispatch->wheel.hi_res.x = 0; - dispatch->wheel.hi_res.y = 0; - - return; - } - - if (dispatch->wheel.hi_res.y != 0) { - int value = dispatch->wheel.hi_res.y; - - v120.y = -1 * value; - wheel_degrees.y = -1 * value/120.0 * device->scroll.wheel_click_angle.y; - evdev_notify_axis_wheel( - device, - time, - bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL), - &wheel_degrees, - &v120); - dispatch->wheel.hi_res.y = 0; - } - - if (dispatch->wheel.lo_res.y != 0) { - int value = dispatch->wheel.lo_res.y; - - wheel_degrees.y = -1 * value * device->scroll.wheel_click_angle.y; - discrete.y = -1 * value; - evdev_notify_axis_legacy_wheel( - device, - time, - bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL), - &wheel_degrees, - &discrete); - dispatch->wheel.lo_res.y = 0; - } - - if (dispatch->wheel.hi_res.x != 0) { - int value = dispatch->wheel.hi_res.x; - - v120.x = value; - wheel_degrees.x = value/120.0 * device->scroll.wheel_click_angle.x; - evdev_notify_axis_wheel( - device, - time, - bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL), - &wheel_degrees, - &v120); - dispatch->wheel.hi_res.x = 0; - } - - if (dispatch->wheel.lo_res.x != 0) { - int value = dispatch->wheel.lo_res.x; - - wheel_degrees.x = value * device->scroll.wheel_click_angle.x; - discrete.x = value; - evdev_notify_axis_legacy_wheel( - device, - time, - bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL), - &wheel_degrees, - &discrete); - dispatch->wheel.lo_res.x = 0; - } + wheel_flush_scroll(dispatch, device, time); } void |