SPMediaKeyTap.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <Cocoa/Cocoa.h>
  2. #import <IOKit/hidsystem/ev_keymap.h>
  3. #import <Carbon/Carbon.h>
  4. // http://overooped.com/post/2593597587/mediakeys
  5. #define SPSystemDefinedEventMediaKeys 8
  6. @interface SPMediaKeyTap : NSObject {
  7. EventHandlerRef _app_switching_ref;
  8. EventHandlerRef _app_terminating_ref;
  9. CFMachPortRef _eventPort;
  10. CFRunLoopSourceRef _eventPortSource;
  11. CFRunLoopRef _tapThreadRL;
  12. BOOL _shouldInterceptMediaKeyEvents;
  13. id _delegate;
  14. // The app that is frontmost in this list owns media keys
  15. NSMutableArray *_mediaKeyAppList;
  16. }
  17. + (NSArray*)defaultMediaKeyUserBundleIdentifiers;
  18. -(id)initWithDelegate:(id)delegate;
  19. +(BOOL)usesGlobalMediaKeyTap;
  20. -(void)startWatchingMediaKeys;
  21. -(void)stopWatchingMediaKeys;
  22. -(void)handleAndReleaseMediaKeyEvent:(NSEvent *)event;
  23. @end
  24. @interface NSObject (SPMediaKeyTapDelegate)
  25. -(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
  26. @end
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
  31. extern NSString *kIgnoreMediaKeysDefaultsKey;
  32. #ifdef __cplusplus
  33. }
  34. #endif