소스 검색

Fixed OS X scroll X-axis inversion.

When natural scrolling is disabled on OS X, the X-axis of the scroll
offsets is inverted compared to the direction on Windows.  The X11
scrolling directions are unspecified and so have been aligned with the
Windows port.  Natural scrolling inverts both axes on both OS X and X11,
so the issue remains when the feature is enabled.

This inverts the provided X-axis scroll offset, making "unnatural"
scroll data align with the Windows and X11 ports and "natual" scroll
data be fully inverted and aligned with its counterpart on X11.

Fixes #239.
Camilla Berglund 11 년 전
부모
커밋
f4a467a864
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 0
      README.md
  2. 6 1
      src/cocoa_window.m

+ 2 - 0
README.md

@@ -106,6 +106,8 @@ GLFW bundles a number of dependencies in the `deps/` directory.
                    bit field was unchanged
                    bit field was unchanged
  - [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems
  - [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems
  - [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window
  - [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window
+ - [Cocoa] Bugfix: The X-axis scroll offsets were inverted relative to the
+                   Windows and X11 ports
  - [Win32] Enabled generation of pkg-config file for MinGW
  - [Win32] Enabled generation of pkg-config file for MinGW
  - [Win32] Removed option to require explicitly linking against `winmm.dll`
  - [Win32] Removed option to require explicitly linking against `winmm.dll`
  - [Win32] Bugfix: Failure to load winmm or its functions was not reported to
  - [Win32] Bugfix: Failure to load winmm or its functions was not reported to

+ 6 - 1
src/cocoa_window.m

@@ -683,7 +683,12 @@ static int translateKey(unsigned int key)
     }
     }
 
 
     if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
     if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
-        _glfwInputScroll(window, deltaX, deltaY);
+    {
+        // NOTE: The X-axis is inverted for consistency with Windows and X11.
+        //       Natural scrolling inverts both axes, making it consistent with
+        //       the similarly named feature on modern X11 desktop systems.
+        _glfwInputScroll(window, -deltaX, deltaY);
+    }
 }
 }
 
 
 - (void)resetCursorRects
 - (void)resetCursorRects