/thirdparty/SPMediaKeyTap/SPMediaKeyTap.h

http://github.com/tomahawk-player/tomahawk · C Header · 43 lines · 32 code · 9 blank · 2 comment · 0 complexity · 72f03fb79a3e4cb6ef92ff4a68cd6c05 MD5 · raw file

  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