Commit 9929cc94 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: replace all 'key-action' calls with their proper counter-parts

This excludes 'ACTIONID_POSITION' for which there doesn't seem to be a replacement.
parent 606a09d2
/***************************************************************************** /*****************************************************************************
* CoreInteraction.m: MacOS X interface module * CoreInteraction.m: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2011-2012 Felix Paul Kühne * Copyright (C) 2011-2013 Felix Paul Kühne
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#import <vlc_strings.h> #import <vlc_strings.h>
#import <vlc_url.h> #import <vlc_url.h>
@interface VLCMainWindow (Internal)
- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value;
@end
@implementation VLCCoreInteraction @implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil; static VLCCoreInteraction *_o_sharedInstance = nil;
...@@ -78,11 +82,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -78,11 +82,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
{ {
input_thread_t * p_input; input_thread_t * p_input;
p_input = pl_CurrentInput(VLCIntf); p_input = pl_CurrentInput(VLCIntf);
playlist_t * p_playlist = pl_Get(VLCIntf);
if (p_input) { if (p_input) {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE); playlist_Play(p_playlist);
vlc_object_release(p_input); vlc_object_release(p_input);
} else { } else {
playlist_t * p_playlist = pl_Get(VLCIntf);
bool empty; bool empty;
PL_LOCK; PL_LOCK;
...@@ -98,27 +103,27 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -98,27 +103,27 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)pause - (void)pause
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PAUSE); playlist_Pause(pl_Get(VLCIntf));
} }
- (void)stop - (void)stop
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_STOP); playlist_Stop(pl_Get(VLCIntf));
} }
- (void)faster - (void)faster
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_FASTER); var_TriggerCallback(pl_Get(VLCIntf), "rate-faster");
} }
- (void)slower - (void)slower
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_SLOWER); var_TriggerCallback(pl_Get(VLCIntf), "rate-slower");
} }
- (void)normalSpeed - (void)normalSpeed
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_RATE_NORMAL); var_SetFloat(pl_Get(VLCIntf), "rate", 1.);
} }
- (void)toggleRecord - (void)toggleRecord
...@@ -180,12 +185,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -180,12 +185,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)previous - (void)previous
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PREV); playlist_Prev(pl_Get(VLCIntf));
} }
- (void)next - (void)next
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT); playlist_Next(pl_Get(VLCIntf));
} }
- (int)durationOfCurrentPlaylistItem - (int)durationOfCurrentPlaylistItem
...@@ -288,44 +293,60 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -288,44 +293,60 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
[self backwardShort]; [self backwardShort];
} }
- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value
{
input_thread_t *p_input = pl_CurrentInput(VLCIntf);
if (!p_input)
return;
int i_interval = var_InheritInteger( p_input, p_value );
if (i_interval > 0) {
mtime_t val = CLOCK_FREQ * i_interval;
if (!b_value)
val = val * -1;
var_SetTime( p_input, "time-offset", val );
}
vlc_object_release(p_input);
}
- (void)forwardExtraShort - (void)forwardExtraShort
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_EXTRASHORT); [self jumpWithValue:"extrashort-jump-size" forward:YES];
} }
- (void)backwardExtraShort - (void)backwardExtraShort
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_EXTRASHORT); [self jumpWithValue:"extrashort-jump-size" forward:NO];
} }
- (void)forwardShort - (void)forwardShort
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT); [self jumpWithValue:"short-jump-size" forward:YES];
} }
- (void)backwardShort - (void)backwardShort
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT); [self jumpWithValue:"short-jump-size" forward:NO];
} }
- (void)forwardMedium - (void)forwardMedium
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_MEDIUM); [self jumpWithValue:"medium-jump-size" forward:YES];
} }
- (void)backwardMedium - (void)backwardMedium
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_MEDIUM); [self jumpWithValue:"medium-jump-size" forward:NO];
} }
- (void)forwardLong - (void)forwardLong
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_LONG); [self jumpWithValue:"long-jump-size" forward:YES];
} }
- (void)backwardLong - (void)backwardLong
{ {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_LONG); [self jumpWithValue:"long-jump-size" forward:NO];
} }
- (void)shuffle - (void)shuffle
......
/***************************************************************************** /*****************************************************************************
* controls.m: MacOS X interface module * controls.m: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN * Copyright (C) 2002-2013 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......
...@@ -1053,12 +1053,10 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1053,12 +1053,10 @@ static VLCMain *_o_sharedMainInstance = nil;
[[VLCCoreInteraction sharedInstance] backward]; [[VLCCoreInteraction sharedInstance] backward];
break; break;
case kRemoteButtonVolume_Plus_Hold: case kRemoteButtonVolume_Plus_Hold:
if (p_intf) [[VLCCoreInteraction sharedInstance] volumeUp];
var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_UP);
break; break;
case kRemoteButtonVolume_Minus_Hold: case kRemoteButtonVolume_Minus_Hold:
if (p_intf) [[VLCCoreInteraction sharedInstance] volumeDown];
var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_DOWN);
break; break;
} }
if (b_remote_button_hold) { if (b_remote_button_hold) {
......
/***************************************************************************** /*****************************************************************************
* misc.m: code not specific to vlc * misc.m: code not specific to vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2012 VLC authors and VideoLAN * Copyright (C) 2003-2013 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -397,6 +397,7 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -397,6 +397,7 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event - (void)scrollWheel:(NSEvent *)o_event
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
BOOL b_forward = NO;
CGFloat f_deltaY = [o_event deltaY]; CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX]; CGFloat f_deltaX = [o_event deltaX];
...@@ -410,17 +411,19 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -410,17 +411,19 @@ void _drawFrameInRect(NSRect frameRect)
CGFloat f_abs; CGFloat f_abs;
int i_vlckey; int i_vlckey;
if (f_delta > 0.0f) { if (f_delta > 0.0f)
i_vlckey = ACTIONID_JUMP_BACKWARD_EXTRASHORT;
f_abs = f_delta; f_abs = f_delta;
}
else { else {
i_vlckey = ACTIONID_JUMP_FORWARD_EXTRASHORT; b_forward = YES;
f_abs = -f_delta; f_abs = -f_delta;
} }
for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
var_SetInteger( p_intf->p_libvlc, "key-action", i_vlckey ); if (b_forward)
[[VLCCoreInteraction sharedInstance] forwardExtraShort];
else
[[VLCCoreInteraction sharedInstance] backwardExtraShort];
}
} }
- (BOOL)acceptsFirstResponder - (BOOL)acceptsFirstResponder
...@@ -500,6 +503,7 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -500,6 +503,7 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event - (void)scrollWheel:(NSEvent *)o_event
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
BOOL b_up = NO;
CGFloat f_deltaY = [o_event deltaY]; CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX]; CGFloat f_deltaX = [o_event deltaX];
...@@ -513,17 +517,19 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -513,17 +517,19 @@ void _drawFrameInRect(NSRect frameRect)
CGFloat f_abs; CGFloat f_abs;
int i_vlckey; int i_vlckey;
if (f_delta > 0.0f) { if (f_delta > 0.0f)
i_vlckey = ACTIONID_VOL_DOWN;
f_abs = f_delta; f_abs = f_delta;
}
else { else {
i_vlckey = ACTIONID_VOL_UP; b_up = YES;
f_abs = -f_delta; f_abs = -f_delta;
} }
for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
var_SetInteger(p_intf->p_libvlc, "key-action", i_vlckey); if (b_up)
[[VLCCoreInteraction sharedInstance] volumeUp];
else
[[VLCCoreInteraction sharedInstance] volumeDown];
}
} }
@end @end
......
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