From f6eb63bc9f55f76b5ad2d7496cbeb9afd0a5a0f4 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 18 Sep 2018 13:36:34 +0200 Subject: HeadphoneKey: Add a method to switch modes This method will be used from `runAction` to switch to a different mode. --- DomeKey/HeadphoneKey.h | 2 ++ DomeKey/HeadphoneKey.m | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index 22e7238..cad78ab 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -22,9 +22,11 @@ static const unsigned int TIMEOUT_MILLISECONDS = 1000; @interface HeadphoneKey : NSObject { NSArray *_mikeys; NSMutableArray *_key_buffer; + const Trigger *_in_mode; } - (void)handleDeadKey:(HeadphoneButton)button; - (void)runAction; +- (const Trigger *)maybeSwitchToMode:(const CKeyActionResult *)result; @end diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index b6d783e..b55c171 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -95,4 +95,17 @@ [_key_buffer removeAllObjects]; } +- (const Trigger *)maybeSwitchToMode:(const CKeyActionResult *)result +{ + // if _in_mode is not null, nullify it + // TODO: rename this method + + if (result->kind && + *result->kind == ActionKind_Mode) { + _in_mode = result->in_mode; + } + + return _in_mode; +} + @end -- cgit v1.2.3