2013-10-12 21:45:45 +00:00
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#import <IOKit/hidsystem/ev_keymap.h>
|
|
|
|
#import <Carbon/Carbon.h>
|
|
|
|
|
|
|
|
// http://overooped.com/post/2593597587/mediakeys
|
|
|
|
|
2018-06-10 02:22:04 +00:00
|
|
|
#define SPSystemDefinedEventMediaKeys 8
|
|
|
|
#define SPPassthroughEventData2Value -10
|
2013-10-12 21:45:45 +00:00
|
|
|
|
|
|
|
@interface SPMediaKeyTap : NSObject {
|
2018-06-10 02:22:04 +00:00
|
|
|
EventHandlerRef _app_switching_ref;
|
|
|
|
EventHandlerRef _app_terminating_ref;
|
|
|
|
CFMachPortRef _eventPort;
|
|
|
|
CFRunLoopSourceRef _eventPortSource;
|
|
|
|
CFRunLoopRef _tapThreadRL;
|
|
|
|
BOOL _shouldInterceptMediaKeyEvents;
|
|
|
|
id _delegate;
|
|
|
|
// The app that is frontmost in this list owns media keys
|
|
|
|
NSMutableArray *_mediaKeyAppList;
|
2013-10-12 21:45:45 +00:00
|
|
|
}
|
|
|
|
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
|
|
|
|
|
|
|
|
-(id)initWithDelegate:(id)delegate;
|
|
|
|
|
|
|
|
+(BOOL)usesGlobalMediaKeyTap;
|
2018-06-28 03:50:26 +00:00
|
|
|
-(BOOL)startWatchingMediaKeys;
|
2013-10-12 21:45:45 +00:00
|
|
|
-(void)stopWatchingMediaKeys;
|
|
|
|
-(void)handleAndReleaseMediaKeyEvent:(NSEvent *)event;
|
2018-06-10 02:22:04 +00:00
|
|
|
|
|
|
|
@property NSArray *blackListBundleIdentifiers;
|
|
|
|
|
2013-10-12 21:45:45 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSObject (SPMediaKeyTapDelegate)
|
|
|
|
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
|
|
|
@end
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
|
2018-06-10 02:22:04 +00:00
|
|
|
extern NSString *kMediaKeyUsingBlackListBundleIdentifiersDefaultsKey;
|
2013-10-12 21:45:45 +00:00
|
|
|
extern NSString *kIgnoreMediaKeysDefaultsKey;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2018-06-10 02:22:04 +00:00
|
|
|
#endif
|