Skip to content

Commit b03c7d8

Browse files
committed
macsos: use ScrollEventUnit::LINE for mousewheel
1 parent 0dd413e commit b03c7d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

input-emulation/src/macos.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,18 @@ impl Emulation for MacOSEmulation {
343343
event.post(CGEventTapLocation::HID);
344344
}
345345
PointerEvent::AxisDiscrete120 { axis, value } => {
346+
const LINES_PER_STEP: i32 = 3;
346347
let (count, wheel1, wheel2, wheel3) = match axis {
347-
0 => (1, value, 0, 0), // 0 = vertical => 1 scroll wheel device (y axis)
348-
1 => (2, 0, value, 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x)
348+
0 => (1, value / (120 / LINES_PER_STEP), 0, 0), // 0 = vertical => 1 scroll wheel device (y axis)
349+
1 => (2, 0, value / (120 / LINES_PER_STEP), 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x)
349350
_ => {
350351
log::warn!("invalid scroll event: {axis}, {value}");
351352
return Ok(());
352353
}
353354
};
354355
let event = match CGEvent::new_scroll_event(
355356
self.event_source.clone(),
356-
ScrollEventUnit::PIXEL,
357+
ScrollEventUnit::LINE,
357358
count,
358359
wheel1,
359360
wheel2,

0 commit comments

Comments
 (0)