Commit 47649fbf authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: backported the new options to disable Apple Remote and Media Keys support

parent d7bd6ae3
...@@ -353,6 +353,7 @@ struct intf_sys_t ...@@ -353,6 +353,7 @@ struct intf_sys_t
- (id)controllerWindow; - (id)controllerWindow;
- (id)voutMenu; - (id)voutMenu;
- (id)eyeTVController; - (id)eyeTVController;
- (id)appleRemoteController;
- (void)applicationWillTerminate:(NSNotification *)notification; - (void)applicationWillTerminate:(NSNotification *)notification;
- (NSString *)localizedString:(const char *)psz; - (NSString *)localizedString:(const char *)psz;
- (char *)delocalizeString:(NSString *)psz; - (char *)delocalizeString:(NSString *)psz;
...@@ -424,9 +425,11 @@ struct intf_sys_t ...@@ -424,9 +425,11 @@ struct intf_sys_t
@interface VLCApplication : NSApplication @interface VLCApplication : NSApplication
{ {
BOOL b_justJumped; BOOL b_justJumped;
BOOL b_mediaKeySupport;
} }
- (void)sendEvent: (NSEvent*)event; - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
//- (void)sendEvent: (NSEvent*)event;
- (void)resetJump; - (void)resetJump;
@end @end
...@@ -1479,6 +1479,11 @@ static unsigned int VLCModifiersToCocoa( unsigned int i_key ) ...@@ -1479,6 +1479,11 @@ static unsigned int VLCModifiersToCocoa( unsigned int i_key )
return nil; return nil;
} }
- (id)appleRemoteController
{
return o_remote;
}
#pragma mark - #pragma mark -
#pragma mark Polling #pragma mark Polling
...@@ -2818,52 +2823,73 @@ end: ...@@ -2818,52 +2823,73 @@ end:
@implementation VLCApplication @implementation VLCApplication
- (void)awakeFromNib
{
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
{
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
}
/*
- (void)sendEvent: (NSEvent*)event - (void)sendEvent: (NSEvent*)event
{ {
if( [event type] == NSSystemDefined && [event subtype] == 8 ) if( b_mediaKeySupport )
{ {
int keyCode = (([event data1] & 0xFFFF0000) >> 16); if( [event type] == NSSystemDefined && [event subtype] == 8 )
int keyFlags = ([event data1] & 0x0000FFFF); {
int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA; int keyCode = (([event data1] & 0xFFFF0000) >> 16);
int keyRepeat = (keyFlags & 0x1); int keyFlags = ([event data1] & 0x0000FFFF);
int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
int keyRepeat = (keyFlags & 0x1);
if( keyCode == NX_KEYTYPE_PLAY && keyState == 0 ) if( keyCode == NX_KEYTYPE_PLAY && keyState == 0 )
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE ); var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
if( keyCode == NX_KEYTYPE_FAST && !b_justJumped ) if( keyCode == NX_KEYTYPE_FAST && !b_justJumped )
{
if( keyState == 0 && keyRepeat == 0 )
{ {
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT ); if( keyState == 0 && keyRepeat == 0 )
} {
else if( keyRepeat == 1 ) var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT );
{ }
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT ); else if( keyRepeat == 1 )
b_justJumped = YES; {
[self performSelector:@selector(resetJump) var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
withObject: NULL b_justJumped = YES;
afterDelay:0.25]; [self performSelector:@selector(resetJump)
withObject: NULL
afterDelay:0.25];
}
} }
}
if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped ) if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
{
if( keyState == 0 && keyRepeat == 0 )
{ {
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV ); if( keyState == 0 && keyRepeat == 0 )
} {
else if( keyRepeat == 1 ) var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
{ }
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT ); else if( keyRepeat == 1 )
b_justJumped = YES; {
[self performSelector:@selector(resetJump) var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
withObject: NULL b_justJumped = YES;
afterDelay:0.25]; [self performSelector:@selector(resetJump)
withObject: NULL
afterDelay:0.25];
}
} }
} }
} }
[super sendEvent: event]; [super sendEvent: event];
} }*/
- (void)resetJump - (void)resetJump
{ {
......
...@@ -87,6 +87,13 @@ void CloseVideoGL ( vlc_object_t * ); ...@@ -87,6 +87,13 @@ void CloseVideoGL ( vlc_object_t * );
#define EQ_KEEP_LONGTEXT N_("By default, VLC keeps the last equalizer settings before " \ #define EQ_KEEP_LONGTEXT N_("By default, VLC keeps the last equalizer settings before " \
"termination. This feature can be disabled here.") "termination. This feature can be disabled here.")
#define USE_APPLE_REMOTE_TEXT N_("Allow playback control with the Apple Remote")
#define USE_APPLE_REMOTE_LONGTEXT N_("By default, VLC can be remotely controlled with the Apple Remote.")
#define USE_MEDIAKEYS_TEXT N_("Allow playback control with the media keys")
#define USE_MEDIAKEYS_LONGTEXT N_("By default, VLC can be controlled using the media keys on modern Apple " \
"keyboards.")
vlc_module_begin () vlc_module_begin ()
set_description( N_("Mac OS X interface") ) set_description( N_("Mac OS X interface") )
set_capability( "interface", 200 ) set_capability( "interface", 200 )
...@@ -101,6 +108,10 @@ vlc_module_begin () ...@@ -101,6 +108,10 @@ vlc_module_begin ()
false ) false )
add_bool( "macosx-fspanel", 1, NULL, FSPANEL_TEXT, FSPANEL_LONGTEXT, add_bool( "macosx-fspanel", 1, NULL, FSPANEL_TEXT, FSPANEL_LONGTEXT,
false ) false )
add_bool( "macosx-appleremote", 1, NULL, USE_APPLE_REMOTE_TEXT, USE_APPLE_REMOTE_LONGTEXT,
false )
add_bool( "macosx-mediakeys", 1, NULL, USE_MEDIAKEYS_TEXT, USE_MEDIAKEYS_LONGTEXT,
false )
add_submodule () add_submodule ()
set_description( "Mac OS X OpenGL" ) set_description( "Mac OS X OpenGL" )
......
/***************************************************************************** /*****************************************************************************
* simple_prefs.h: Simple Preferences for Mac OS X * simple_prefs.h: Simple Preferences for Mac OS X
***************************************************************************** *****************************************************************************
* Copyright (C) 2008 the VideoLAN team * Copyright (C) 2008-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne at videolan dot org> * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
IBOutlet id o_intf_art_txt; IBOutlet id o_intf_art_txt;
IBOutlet id o_intf_embedded_ckb; IBOutlet id o_intf_embedded_ckb;
IBOutlet id o_intf_fspanel_ckb; IBOutlet id o_intf_fspanel_ckb;
IBOutlet id o_intf_appleremote_ckb;
IBOutlet id o_intf_mediakeys_ckb;
IBOutlet id o_intf_lang_pop; IBOutlet id o_intf_lang_pop;
IBOutlet id o_intf_lang_txt; IBOutlet id o_intf_lang_txt;
IBOutlet id o_intf_network_box; IBOutlet id o_intf_network_box;
......
/***************************************************************************** /*****************************************************************************
* simple_prefs.m: Simple Preferences for Mac OS X * simple_prefs.m: Simple Preferences for Mac OS X
***************************************************************************** *****************************************************************************
* Copyright (C) 2008 the VideoLAN team * Copyright (C) 2008-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne at videolan dot org> * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import <vlc_interface.h> #import <vlc_interface.h>
#import <vlc_dialog.h> #import <vlc_dialog.h>
#import "misc.h" #import "misc.h"
#import "AppleRemote.h"
static NSString* VLCSPrefsToolbarIdentifier = @"Our Simple Preferences Toolbar Identifier"; static NSString* VLCSPrefsToolbarIdentifier = @"Our Simple Preferences Toolbar Identifier";
static NSString* VLCIntfSettingToolbarIdentifier = @"Intf Settings Item Identifier"; static NSString* VLCIntfSettingToolbarIdentifier = @"Intf Settings Item Identifier";
...@@ -262,7 +263,9 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -262,7 +263,9 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")]; [o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")];
[o_intf_lang_txt setStringValue: _NS("Language")]; [o_intf_lang_txt setStringValue: _NS("Language")];
[o_intf_network_box setTitle: _NS("Privacy / Network Interaction")]; [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
[o_intf_appleremote_ckb setTitle: _NS("Control playback with the Apple Remote")];
[o_intf_mediakeys_ckb setTitle: _NS("Control playback with media keys")];
/* Subtitles and OSD */ /* Subtitles and OSD */
[o_osd_encoding_txt setStringValue: _NS("Default Encoding")]; [o_osd_encoding_txt setStringValue: _NS("Default Encoding")];
[o_osd_font_box setTitle: _NS("Display Settings")]; [o_osd_font_box setTitle: _NS("Display Settings")];
...@@ -413,6 +416,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -413,6 +416,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_intf_fspanel_ckb setState: config_GetInt( p_intf, "macosx-fspanel" )]; [o_intf_fspanel_ckb setState: config_GetInt( p_intf, "macosx-fspanel" )];
[o_intf_embedded_ckb setState: config_GetInt( p_intf, "embedded-video" )]; [o_intf_embedded_ckb setState: config_GetInt( p_intf, "embedded-video" )];
[o_intf_appleremote_ckb setState: config_GetInt( p_intf, "macosx-appleremote" )];
[o_intf_mediakeys_ckb setState: config_GetInt( p_intf, "macosx-mediakeys" )];
/****************** /******************
* audio settings * * audio settings *
...@@ -610,6 +615,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -610,6 +615,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
- (void)showSimplePrefs - (void)showSimplePrefs
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
/* we want to show the interface settings, if no category was chosen */ /* we want to show the interface settings, if no category was chosen */
if( [[o_sprefs_win toolbar] selectedItemIdentifier] == nil ) if( [[o_sprefs_win toolbar] selectedItemIdentifier] == nil )
{ {
...@@ -621,6 +627,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des ...@@ -621,6 +627,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
[o_sprefs_win center]; [o_sprefs_win center];
[o_sprefs_win makeKeyAndOrderFront: self]; [o_sprefs_win makeKeyAndOrderFront: self];
[o_pool release];
} }
- (IBAction)buttonAction:(id)sender - (IBAction)buttonAction:(id)sender
...@@ -732,6 +739,17 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -732,6 +739,17 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
config_PutInt( p_intf, "macosx-fspanel", [o_intf_fspanel_ckb state] ); config_PutInt( p_intf, "macosx-fspanel", [o_intf_fspanel_ckb state] );
config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] ); config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] );
config_PutInt( p_intf, "macosx-appleremote", [o_intf_appleremote_ckb state] );
config_PutInt( p_intf, "macosx-mediakeys", [o_intf_mediakeys_ckb state] );
/* activate stuff without restart */
if( [o_intf_appleremote_ckb state] == YES )
[[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
else
[[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
//[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
// object: nil
// userInfo: nil];
/* okay, let's save our changes to vlcrc */ /* okay, let's save our changes to vlcrc */
i = config_SaveConfigFile( p_intf, "main" ); i = config_SaveConfigFile( p_intf, "main" );
......
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