mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-07 20:09:59 +03:00
macsos: use ScrollEventUnit::LINE for mousewheel (#337)
This commit is contained in:
committed by
GitHub
parent
0dd413e989
commit
99c8bc5567
@@ -343,9 +343,10 @@ impl Emulation for MacOSEmulation {
|
|||||||
event.post(CGEventTapLocation::HID);
|
event.post(CGEventTapLocation::HID);
|
||||||
}
|
}
|
||||||
PointerEvent::AxisDiscrete120 { axis, value } => {
|
PointerEvent::AxisDiscrete120 { axis, value } => {
|
||||||
|
const LINES_PER_STEP: i32 = 3;
|
||||||
let (count, wheel1, wheel2, wheel3) = match axis {
|
let (count, wheel1, wheel2, wheel3) = match axis {
|
||||||
0 => (1, value, 0, 0), // 0 = vertical => 1 scroll wheel device (y axis)
|
0 => (1, value / (120 / LINES_PER_STEP), 0, 0), // 0 = vertical => 1 scroll wheel device (y axis)
|
||||||
1 => (2, 0, value, 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x)
|
1 => (2, 0, value / (120 / LINES_PER_STEP), 0), // 1 = horizontal => 2 scroll wheel devices (y, x) -> (0, x)
|
||||||
_ => {
|
_ => {
|
||||||
log::warn!("invalid scroll event: {axis}, {value}");
|
log::warn!("invalid scroll event: {axis}, {value}");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -353,7 +354,7 @@ impl Emulation for MacOSEmulation {
|
|||||||
};
|
};
|
||||||
let event = match CGEvent::new_scroll_event(
|
let event = match CGEvent::new_scroll_event(
|
||||||
self.event_source.clone(),
|
self.event_source.clone(),
|
||||||
ScrollEventUnit::PIXEL,
|
ScrollEventUnit::LINE,
|
||||||
count,
|
count,
|
||||||
wheel1,
|
wheel1,
|
||||||
wheel2,
|
wheel2,
|
||||||
|
|||||||
Reference in New Issue
Block a user