diff --git a/.gitignore b/.gitignore index e132043b0..a36b33dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -110,4 +110,5 @@ fabric.properties # Resource Metadata *.meta -*.registry \ No newline at end of file +*.registry +.DS_Store diff --git a/fyrox-impl/src/utils/mod.rs b/fyrox-impl/src/utils/mod.rs index 4e10a3000..fd440c27d 100644 --- a/fyrox-impl/src/utils/mod.rs +++ b/fyrox-impl/src/utils/mod.rs @@ -529,7 +529,21 @@ pub fn translate_event(event: &WindowEvent) -> Option { WindowEvent::MouseWheel { delta, .. } => match delta { MouseScrollDelta::LineDelta(x, y) => Some(OsEvent::MouseWheel(*x, *y)), MouseScrollDelta::PixelDelta(pos) => { - Some(OsEvent::MouseWheel(pos.x as f32, pos.y as f32)) + #[cfg(target_os = "macos")] + { + // macOS trackpads emits pixel deltas; scale to line-like units to avoid excessive scroll speed. + const PIXELS_PER_LINE: f32 = 100.0; + + Some(OsEvent::MouseWheel( + pos.x as f32 / PIXELS_PER_LINE, + pos.y as f32 / PIXELS_PER_LINE, + )) + } + + #[cfg(not(target_os = "macos"))] + { + Some(OsEvent::MouseWheel(pos.x as f32, pos.y as f32)) + } } }, WindowEvent::MouseInput { state, button, .. } => Some(OsEvent::MouseInput {