diff options
-rw-r--r-- | DomeKey/HeadphoneKeyEventBluetooth.h | 3 | ||||
-rw-r--r-- | DomeKey/HeadphoneKeyEventBluetooth.m | 27 |
2 files changed, 19 insertions, 11 deletions
diff --git a/DomeKey/HeadphoneKeyEventBluetooth.h b/DomeKey/HeadphoneKeyEventBluetooth.h index 86e0ce7..a55a539 100644 --- a/DomeKey/HeadphoneKeyEventBluetooth.h +++ b/DomeKey/HeadphoneKeyEventBluetooth.h @@ -7,11 +7,12 @@ // #import <Foundation/Foundation.h> +#import <IOBluetooth/IOBluetooth.h> #import "HeadphoneKeyEventDelegate.h" #import "dome_key_map.h" -@interface HeadphoneKeyEventBluetooth : NSObject { +@interface HeadphoneKeyEventBluetooth : NSObject <IOBluetoothDevicePairDelegate> { id <HeadphoneKeyEventDelegate> _delegate; } diff --git a/DomeKey/HeadphoneKeyEventBluetooth.m b/DomeKey/HeadphoneKeyEventBluetooth.m index 52e22db..839a4ba 100644 --- a/DomeKey/HeadphoneKeyEventBluetooth.m +++ b/DomeKey/HeadphoneKeyEventBluetooth.m @@ -16,20 +16,27 @@ if (self) { _delegate = delegate; - MPRemoteCommandCenter *cc = [MPRemoteCommandCenter sharedCommandCenter]; - [cc playCommand]; - [cc pauseCommand]; - [cc stopCommand]; - [cc togglePlayPauseCommand]; - // [cc nextTrackCommand]; - // [cc seekForwardCommand]; - // [cc previousTrackCommand]; - // [cc seekBackwardCommand]; + IOBluetoothUserNotification *notification = [IOBluetoothDevice + registerForConnectNotifications:self + selector:@selector(connectNotification:forDevice:)]; + if (!notification) { + // TODO: error + NSLog(@"Connection notification error"); + } } return self; } -MPRemoteCommandHandler key_pressed(HeadphoneButton button) { +- (void)devicePairingFinished:(id)sender + error:(IOReturn)error +{ + NSLog(@"Paired: %@", sender); +} + +- (void)connectNotification:(IOBluetoothUserNotification *)notification + forDevice:(IOBluetoothDevice *)device +{ + NSLog(@"Paired notification: %@ ; Device: %@", notification, device); } @end |