Commit 39e14fc7 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Mac OS X gui: Send mouse wheel left/right event to vlc. This is a bit hackish and need some tuning.

parent fc4af29c
...@@ -468,19 +468,30 @@ ...@@ -468,19 +468,30 @@
- (void)scrollWheel:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY]; float f_yabsvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
int i, i_vlckey; float f_xabsvalue = [theEvent deltaX] > 0.0f ? [theEvent deltaX] : -[theEvent deltaX];
int i, i_yvlckey, i_xvlckey;
f_absvalue = f_absvalue/2.0f + 1.0f;
if ([theEvent deltaY] < 0.0f) 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 else
i_vlckey = KEY_MOUSEWHEELUP; i_xvlckey = KEY_MOUSEWHEELLEFT;
/* Send multiple key event, depending on the intensity of the event */ /* Send multiple key event, depending on the intensity of the event */
for (i = 0; i < (int)f_absvalue; i++) for (i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey ); 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 - (BOOL)keyEvent:(NSEvent *)o_event
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment