[vlc-commits] macosx: invert scrolling direction if the devices inverts its event

Felix Paul Kühne git at videolan.org
Sun Jul 3 20:29:43 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Jul  3 20:29:32 2011 +0200| [1a95c088f6431cb76d62343f8b96f9318c5ca5ac] | committer: Felix Paul Kühne

macosx: invert scrolling direction if the devices inverts its event

aka if you scroll to the right, you want the movie to skip to the right, etc.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a95c088f6431cb76d62343f8b96f9318c5ca5ac
---

 modules/gui/macosx/controls.m |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index 3c55d07..d331bb1 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -393,19 +393,41 @@
 - (void)scrollWheel:(NSEvent *)theEvent
 {
     intf_thread_t * p_intf = VLCIntf;
+    BOOL b_invertedEventFromDevice = NO;
+    if ([theEvent respondsToSelector:@selector(isDirectionInvertedFromDevice)])
+    {
+        if ([theEvent isDirectionInvertedFromDevice])
+            b_invertedEventFromDevice = YES;
+    }
+
     float f_yabsvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
     float f_xabsvalue = [theEvent deltaX] > 0.0f ? [theEvent deltaX] : -[theEvent deltaX];
     int i, i_yvlckey, i_xvlckey;
 
-    if ([theEvent deltaY] < 0.0f)
-        i_yvlckey = KEY_MOUSEWHEELDOWN;
-    else
-        i_yvlckey = KEY_MOUSEWHEELUP;
+    if (b_invertedEventFromDevice)
+    {
+        if ([theEvent deltaY] > 0.0f)
+            i_yvlckey = KEY_MOUSEWHEELDOWN;
+        else
+            i_yvlckey = KEY_MOUSEWHEELUP;
 
-    if ([theEvent deltaX] < 0.0f)
-        i_xvlckey = KEY_MOUSEWHEELRIGHT;
+        if ([theEvent deltaX] > 0.0f)
+            i_xvlckey = KEY_MOUSEWHEELRIGHT;
+        else
+            i_xvlckey = KEY_MOUSEWHEELLEFT;
+    }
     else
-        i_xvlckey = KEY_MOUSEWHEELLEFT;
+    {
+        if ([theEvent deltaY] < 0.0f)
+            i_yvlckey = KEY_MOUSEWHEELDOWN;
+        else
+            i_yvlckey = KEY_MOUSEWHEELUP;
+
+        if ([theEvent deltaX] < 0.0f)
+            i_xvlckey = KEY_MOUSEWHEELRIGHT;
+        else
+            i_xvlckey = KEY_MOUSEWHEELLEFT;
+    }
 
     /* Send multiple key event, depending on the intensity of the event */
     for (i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)



More information about the vlc-commits mailing list