Commit 40ad28f7 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: optimize scrollwheel code by saving 3 objc selector calls per run

no functional change
(cherry picked from commit d9fb60be)
parent 5de326ba
......@@ -258,49 +258,54 @@
{
intf_thread_t * p_intf = VLCIntf;
BOOL b_invertedEventFromDevice = NO;
CGFloat f_deltaY, f_deltaX = .0;
if (OSX_LION)
{
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;
f_deltaY = [theEvent deltaY];
f_deltaX = [theEvent deltaX];
CGFloat f_yabsvalue = f_deltaY > 0.0f ? f_deltaY : -f_deltaY;
CGFloat f_xabsvalue = f_deltaX > 0.0f ? f_deltaX : -f_deltaX;
int i_yvlckey, i_xvlckey;
if (b_invertedEventFromDevice)
{
if ([theEvent deltaY] > 0.0f)
if (f_deltaY > 0.0f)
i_yvlckey = KEY_MOUSEWHEELDOWN;
else
i_yvlckey = KEY_MOUSEWHEELUP;
if ([theEvent deltaX] > 0.0f)
if (f_deltaX > 0.0f)
i_xvlckey = KEY_MOUSEWHEELRIGHT;
else
i_xvlckey = KEY_MOUSEWHEELLEFT;
}
else
{
if ([theEvent deltaY] < 0.0f)
if (f_deltaY < 0.0f)
i_yvlckey = KEY_MOUSEWHEELDOWN;
else
i_yvlckey = KEY_MOUSEWHEELUP;
if ([theEvent deltaX] < 0.0f)
if (f_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++)
for (NSUInteger 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++)
for (NSUInteger i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++)
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_xvlckey );
}
}
......
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