diff options
-rw-r--r-- | DomeKey/HeadphoneKey.h | 2 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.m | 2 | ||||
-rw-r--r-- | DomeKey/HeadphoneKeyEventBluetooth.h | 9 | ||||
-rw-r--r-- | DomeKey/HeadphoneKeyEventBluetooth.m | 22 |
4 files changed, 34 insertions, 1 deletions
diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index 6670ff5..d5e9e76 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -51,6 +51,7 @@ #import "HeadphoneKeyEventDelegate.h" #import "HeadphoneKeyEventWired.h" +#import "HeadphoneKeyEventBluetooth.h" #import "Mappings.h" #import "Sounds.h" #import "dome_key_map.h" @@ -60,6 +61,7 @@ static const Milliseconds TIMEOUT_DEFAULT = 500; @interface HeadphoneKey : NSObject <HeadphoneKeyEventDelegate> { HeadphoneKeyEventWired *_wired_headphone_event; + HeadphoneKeyEventBluetooth *_bluetooth_headphone_event; NSMutableArray *_key_buffer; Mappings *_mappings; Milliseconds _timeout; diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 3aa79ce..beba94d 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -60,6 +60,8 @@ static BOOL _play_audio; if (self) { _wired_headphone_event = [[HeadphoneKeyEventWired alloc] initWithDelegate:self]; + _bluetooth_headphone_event = [[HeadphoneKeyEventBluetooth alloc] + initWithDelegate:self]; _key_buffer = [[NSMutableArray alloc] initWithCapacity:5]; diff --git a/DomeKey/HeadphoneKeyEventBluetooth.h b/DomeKey/HeadphoneKeyEventBluetooth.h index 00577c3..86e0ce7 100644 --- a/DomeKey/HeadphoneKeyEventBluetooth.h +++ b/DomeKey/HeadphoneKeyEventBluetooth.h @@ -8,6 +8,13 @@ #import <Foundation/Foundation.h> -@interface HeadphoneKeyEventBluetooth : NSObject +#import "HeadphoneKeyEventDelegate.h" +#import "dome_key_map.h" + +@interface HeadphoneKeyEventBluetooth : NSObject { + id <HeadphoneKeyEventDelegate> _delegate; +} + +- (instancetype)initWithDelegate:(id <HeadphoneKeyEventDelegate>)delegate; @end diff --git a/DomeKey/HeadphoneKeyEventBluetooth.m b/DomeKey/HeadphoneKeyEventBluetooth.m index 3c02486..52e22db 100644 --- a/DomeKey/HeadphoneKeyEventBluetooth.m +++ b/DomeKey/HeadphoneKeyEventBluetooth.m @@ -10,4 +10,26 @@ @implementation HeadphoneKeyEventBluetooth +- (instancetype)initWithDelegate:(id <HeadphoneKeyEventDelegate>)delegate +{ + self = [self init]; + if (self) { + _delegate = delegate; + + MPRemoteCommandCenter *cc = [MPRemoteCommandCenter sharedCommandCenter]; + [cc playCommand]; + [cc pauseCommand]; + [cc stopCommand]; + [cc togglePlayPauseCommand]; + // [cc nextTrackCommand]; + // [cc seekForwardCommand]; + // [cc previousTrackCommand]; + // [cc seekBackwardCommand]; + } + return self; +} + +MPRemoteCommandHandler key_pressed(HeadphoneButton button) { +} + @end |