]> git.sesse.net Git - vlc/commitdiff
Mac OS X gui: Send mouse wheel left/right event to vlc. This is a bit hackish and...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 8 May 2007 11:25:39 +0000 (11:25 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 8 May 2007 11:25:39 +0000 (11:25 +0000)
modules/gui/macosx/controls.m

index 862e54bb3e82392365c283c12d08d420613025a6..0441bcf0baa2cc2a25be1e58dad494134243ab7a 100644 (file)
 - (void)scrollWheel:(NSEvent *)theEvent
 {
     intf_thread_t * p_intf = VLCIntf;
-    float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
-    int i, i_vlckey;
-
-    f_absvalue = f_absvalue/2.0f + 1.0f;
+    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_vlckey = KEY_MOUSEWHEELDOWN;
+        i_yvlckey = KEY_MOUSEWHEELDOWN;
+    else
+        i_yvlckey = KEY_MOUSEWHEELUP;
+
+    if ([theEvent deltaX] < 0.0f)
+        i_xvlckey = KEY_MOUSEWHEELRIGHT;
     else
-        i_vlckey = KEY_MOUSEWHEELUP;
+        i_xvlckey = KEY_MOUSEWHEELLEFT;
 
     /* Send multiple key event, depending on the intensity of the event */
-    for (i = 0; i < (int)f_absvalue; i++)
-        var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
+    for (i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)
+        var_SetInteger( p_intf->p_libvlc, "key-pressed", i_yvlckey );
+
+       /* Prioritize Y event (sound volume) over X event */
+       if (f_yabsvalue < 0.05)
+       {
+               for (i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++)
+                var_SetInteger( p_intf->p_libvlc, "key-pressed", i_xvlckey );
+       }
 }
 
 - (BOOL)keyEvent:(NSEvent *)o_event