aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-10-09 14:31:36 +0200
committerTeddy Wing2018-10-09 14:31:36 +0200
commit2985bf318f4f367ae8a50a4a665ed0c765a1aa33 (patch)
tree2acd482cfc7fb99cfdf86152a8e35a37eea86c42
parenta4640221186905db82e3d9e71c5d28e6f6bf2b5e (diff)
downloadDomeKey-2985bf318f4f367ae8a50a4a665ed0c765a1aa33.tar.bz2
Try moving MPRemoteCommandCenter to AppDelegate
Wanted to see if moving this closer to the launch point of the application and also storing a reference to the command center in an ivar would change anything. It didn't, still doesn't appear to work for listening to Bluetooth button events.
-rw-r--r--DomeKey/AppDelegate.h3
-rw-r--r--DomeKey/AppDelegate.m24
-rw-r--r--DomeKey/HeadphoneKey.h1
-rw-r--r--DomeKey/HeadphoneKey.m21
4 files changed, 28 insertions, 21 deletions
diff --git a/DomeKey/AppDelegate.h b/DomeKey/AppDelegate.h
index 6b1d9a4..b343d6c 100644
--- a/DomeKey/AppDelegate.h
+++ b/DomeKey/AppDelegate.h
@@ -11,6 +11,9 @@
@interface AppDelegate : NSObject <NSApplicationDelegate> {
HeadphoneKey *_headphone_key;
+ MPRemoteCommandCenter *_blargh;
}
+- (void)mpmediaplayerBS;
+
@end
diff --git a/DomeKey/AppDelegate.m b/DomeKey/AppDelegate.m
index fab5171..32bbd47 100644
--- a/DomeKey/AppDelegate.m
+++ b/DomeKey/AppDelegate.m
@@ -14,7 +14,29 @@
{
_headphone_key = [[HeadphoneKey alloc] init];
[_headphone_key startMonitoringBluetoothEvents];
- [_headphone_key mpmediaplayerBS];
+
+ _blargh = [MPRemoteCommandCenter sharedCommandCenter];
+
+ [[_blargh togglePlayPauseCommand] addTarget:self action:@selector(mpmediaplayerplaypauesss:)];
+}
+
+- (void)mpmediaplayerBS
+{
+ MPRemoteCommandCenter *center = [MPRemoteCommandCenter sharedCommandCenter];
+
+ [[center togglePlayPauseCommand] addTarget:self action:@selector(mpmediaplayerplaypauesss:)];
+// pauseCommand
+// playCommand
+// togglePlayPauseCommand
+// nextTrackCommand
+// previousTrackCommand
+}
+
+- (MPRemoteCommandHandlerStatus) mpmediaplayerplaypauesss: (MPRemoteCommandEvent*) event
+{
+ NSLog(@"Played from MPMediaPlayer");
+
+ return MPRemoteCommandHandlerStatusSuccess;
}
@end
diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h
index 61c4864..4f048e0 100644
--- a/DomeKey/HeadphoneKey.h
+++ b/DomeKey/HeadphoneKey.h
@@ -31,6 +31,5 @@ static const unsigned int TIMEOUT_MILLISECONDS = 1000;
- (void)handleDeadKey:(HeadphoneButton)button;
- (void)runAction;
- (void)startMonitoringBluetoothEvents;
-- (void)mpmediaplayerBS;
@end
diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m
index e1588eb..e5ea7b0 100644
--- a/DomeKey/HeadphoneKey.m
+++ b/DomeKey/HeadphoneKey.m
@@ -67,6 +67,8 @@
int key_flags = ([theEvent data1] & 0x0000FFFF);
int key_state = (((key_flags & 0xFF00) >> 8)) == 0xA;
+ NSLog(@"Key from global monitor pressed");
+
// TODO: Fix magic numbers
if (key_code == 10 && key_flags == 6972) {
switch ([theEvent data2]) {
@@ -96,25 +98,6 @@
}];
}
-- (void)mpmediaplayerBS
-{
- MPRemoteCommandCenter *center = [MPRemoteCommandCenter sharedCommandCenter];
-
- [[center togglePlayPauseCommand] addTarget:self action:@selector(mpmediaplayerplaypauesss:)];
-// pauseCommand
-// playCommand
-// togglePlayPauseCommand
-// nextTrackCommand
-// previousTrackCommand
-}
-
-- (MPRemoteCommandHandlerStatus) mpmediaplayerplaypauesss: (MPRemoteCommandEvent*) event
-{
- NSLog(@"Played from MPMediaPlayer");
-
- return MPRemoteCommandHandlerStatusSuccess;
-}
-
- (void)handleDeadKey:(HeadphoneButton)button
{
NSNumber *storable_button = [NSNumber numberWithUnsignedInteger:button];