diff options
author | Teddy Wing | 2018-10-27 06:19:28 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-27 06:19:28 +0200 |
commit | 031a0af4993e8fad33d49d9c3cfa936a205b7c79 (patch) | |
tree | d95baa14d08638cbd9e17b7408d7df5155f7c1ce | |
parent | 7d6c546b435634b71de337c1e65b58c22404099d (diff) | |
download | DomeKey-031a0af4993e8fad33d49d9c3cfa936a205b7c79.tar.bz2 |
HeadphoneKey: Only print `NSLog`s in a debug mode
Add a new `LogDebug` macro that `NSLog`s when a `DOME_KEY_DEBUG`
environment variable is set to "1".
This gets rid of the verbose output every time a headphone key is
pressed. But it enables you to see it if needed for debugging purposes.
-rw-r--r-- | DomeKey/HeadphoneKey.h | 1 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.m | 8 | ||||
-rw-r--r-- | DomeKey/log.h | 10 |
3 files changed, 15 insertions, 4 deletions
diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index be0e62c..618bdd2 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -10,6 +10,7 @@ #import <DDHidLib/DDHidAppleMikey.h> #import "dome_key_map.h" +#import "log.h" typedef enum KeyPress : BOOL { KeyPressDown = YES, diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 5cf0806..df31fec 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -56,15 +56,15 @@ if (upOrDown == KeyPressUp) { switch (usageId) { case kHIDUsage_Csmr_PlayOrPause: - NSLog(@"Middle"); + LogDebug(@"Middle"); [self handleDeadKey:HeadphoneButton_Play]; break; case kHIDUsage_Csmr_VolumeIncrement: - NSLog(@"Top"); + LogDebug(@"Top"); [self handleDeadKey:HeadphoneButton_Up]; break; case kHIDUsage_Csmr_VolumeDecrement: - NSLog(@"Bottom"); + LogDebug(@"Bottom"); [self handleDeadKey:HeadphoneButton_Down]; break; } @@ -88,7 +88,7 @@ - (void)runAction { - NSLog(@"%@", _key_buffer); + LogDebug(@"%@", _key_buffer); NSUInteger count = [_key_buffer count]; HeadphoneButton buttons[count]; diff --git a/DomeKey/log.h b/DomeKey/log.h new file mode 100644 index 0000000..7684143 --- /dev/null +++ b/DomeKey/log.h @@ -0,0 +1,10 @@ +#ifndef LOG_H +#define LOG_H + +#define LogDebug(...) \ + if ([[[[NSProcessInfo processInfo] environment] \ + objectForKey:@"DOME_KEY_DEBUG"] isEqualToString:@"1"]) { \ + NSLog(__VA_ARGS__); \ + } + +#endif /* LOG_H */ |