From 7d6c546b435634b71de337c1e65b58c22404099d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 27 Oct 2018 06:08:38 +0200 Subject: HeadphoneKey: Delete `startMonitoringBluetoothEvents` method From what I could tell, this didn't work for handling Bluetooth button press events. Delete it since it's not being used. We'll have to come back to Bluetooth again later. --- DomeKey/AppDelegate.m | 1 - DomeKey/HeadphoneKey.h | 1 - DomeKey/HeadphoneKey.m | 41 ----------------------------------------- 3 files changed, 43 deletions(-) diff --git a/DomeKey/AppDelegate.m b/DomeKey/AppDelegate.m index a1e6563..bcd4dd0 100644 --- a/DomeKey/AppDelegate.m +++ b/DomeKey/AppDelegate.m @@ -22,7 +22,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { _headphone_key = [[HeadphoneKey alloc] initWithTimeout:_config->timeout]; - [_headphone_key startMonitoringBluetoothEvents]; } @end diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index ad6f8dd..be0e62c 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -30,6 +30,5 @@ static const Milliseconds TIMEOUT_DEFAULT = 500; - (instancetype)initWithTimeout:(Milliseconds)timeout; - (void)handleDeadKey:(HeadphoneButton)button; - (void)runAction; -- (void)startMonitoringBluetoothEvents; @end diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 5a83ad0..5cf0806 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -71,47 +71,6 @@ } } -- (void)startMonitoringBluetoothEvents -{ - // https://github.com/jguice/mac-bt-headset-fix/blob/master/Spotify%20Bluetooth%20Headset%20Listener/KDMAppDelegate.m - [NSEvent - addGlobalMonitorForEventsMatchingMask:(NSKeyDownMask | NSSystemDefinedMask) - handler:^(NSEvent *theEvent) { - int key_code = (([theEvent data1] & 0xFFFF0000) >> 16); - 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]) { - case 786608: - case 786637: - NSLog(@"Play"); - - break; - case 786611: - NSLog(@"Next"); - - break; - case 786612: - NSLog(@"Previous"); - - break; - case 786613: - NSLog(@"Fast-forward"); - - break; - case 786614: - NSLog(@"Rewind"); - - break; - } - } - }]; -} - - (void)handleDeadKey:(HeadphoneButton)button { NSNumber *storable_button = [NSNumber numberWithUnsignedInteger:button]; -- cgit v1.2.3