diff --git a/src/linux/wayland/listen.rs b/src/linux/wayland/listen.rs index 761e161f..dd77ac9f 100644 --- a/src/linux/wayland/listen.rs +++ b/src/linux/wayland/listen.rs @@ -5,7 +5,7 @@ use crate::rdev::{Event, KeyboardState, ListenError}; use crate::{Button, EventType}; use input::event::PointerEvent; use input::event::keyboard::{KeyState, KeyboardEventTrait}; -use input::event::pointer::{Axis, ButtonState}; +use input::event::pointer::{Axis, ButtonState, PointerScrollEvent}; use input::{Event as LibEvent, Libinput, LibinputInterface}; use libc::{O_RDONLY, O_RDWR, O_WRONLY}; use std::fs::{File, OpenOptions}; @@ -51,10 +51,21 @@ fn convert_type(libevent: LibEvent) -> Option { x: btn.absolute_x(), y: btn.absolute_y(), }), - LibEvent::Pointer(PointerEvent::ScrollWheel(btn)) => Some(EventType::Wheel { - delta_x: -(btn.scroll_value_v120(Axis::Horizontal) / 120.0) as i64, - delta_y: -(btn.scroll_value_v120(Axis::Vertical) / 120.0) as i64, - }), + LibEvent::Pointer(PointerEvent::ScrollWheel(btn)) => { + let delta_x = if btn.has_axis(Axis::Horizontal) { + -(btn.scroll_value_v120(Axis::Horizontal) / 120.0) as i64 + } else { + 0 + }; + + let delta_y = if btn.has_axis(Axis::Vertical) { + -(btn.scroll_value_v120(Axis::Vertical) / 120.0) as i64 + } else { + 0 + }; + + Some(EventType::Wheel { delta_x, delta_y }) + } _ => { // dbg!(format!("Received unhandlded event {lib:?}")); None