diff options
-rw-r--r-- | DomeKey/AppDelegate.m | 2 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.h | 2 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.m | 16 |
3 files changed, 15 insertions, 5 deletions
diff --git a/DomeKey/AppDelegate.m b/DomeKey/AppDelegate.m index bcd4dd0..30bd898 100644 --- a/DomeKey/AppDelegate.m +++ b/DomeKey/AppDelegate.m @@ -21,7 +21,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { - _headphone_key = [[HeadphoneKey alloc] initWithTimeout:_config->timeout]; + _headphone_key = [[HeadphoneKey alloc] initWithConfig:_config]; } @end diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index fc500cd..1d12e10 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -27,7 +27,7 @@ static const Milliseconds TIMEOUT_DEFAULT = 500; Milliseconds _timeout; } -- (instancetype)initWithTimeout:(Milliseconds)timeout; +- (instancetype)initWithConfig:(Config *)config; - (void)handleDeadKey:(HeadphoneButton)button; - (void)runAction; diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index a176cbf..11046e7 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -9,6 +9,7 @@ #import "HeadphoneKey.h" static const Sounds *sounds_inst; +static BOOL _play_audio; @implementation HeadphoneKey @@ -23,7 +24,7 @@ static const Sounds *sounds_inst; // default should always come from a `Config`, set in the Rust library. _timeout = TIMEOUT_DEFAULT; - sounds_inst = [[Sounds alloc] init]; + _play_audio = NO; // TODO: Think about moving this logger higher up dome_key_logger_init(); @@ -39,11 +40,16 @@ static const Sounds *sounds_inst; return self; } -- (instancetype)initWithTimeout:(Milliseconds)timeout +- (instancetype)initWithConfig:(Config *)config { self = [self init]; if (self) { - _timeout = timeout; + _timeout = config->timeout; + _play_audio = config->args.audio; + + if (_play_audio) { + sounds_inst = [[Sounds alloc] init]; + } } return self; } @@ -112,6 +118,10 @@ static const Sounds *sounds_inst; } void on_mode_change(ModeChange mode_change) { + if (!_play_audio) { + return; + } + switch (mode_change) { case ModeChange_Activated: [sounds_inst playModeActivated]; |