From 977f1487c22b5d30051939b9572b99a31a9775ff Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 22 Mar 2024 09:41:10 +0400 Subject: input: Fix discrete axis value on winit --- src/input.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index a48a299a..80000efe 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1078,15 +1078,18 @@ impl State { fn on_pointer_axis(&mut self, event: I::PointerAxisEvent) { let source = event.source(); - let horizontal_amount = event - .amount(Axis::Horizontal) - .unwrap_or_else(|| event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.); - let vertical_amount = event - .amount(Axis::Vertical) - .unwrap_or_else(|| event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 3.0 / 120.); let horizontal_amount_v120 = event.amount_v120(Axis::Horizontal); let vertical_amount_v120 = event.amount_v120(Axis::Vertical); + let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| { + // Winit backend, discrete scrolling. + horizontal_amount_v120.unwrap_or(0.0) / 120. * 15. + }); + let vertical_amount = event.amount(Axis::Vertical).unwrap_or_else(|| { + // Winit backend, discrete scrolling. + vertical_amount_v120.unwrap_or(0.0) / 120. * 15. + }); + let mut frame = AxisFrame::new(event.time_msec()).source(source); if horizontal_amount != 0.0 { frame = frame -- cgit