diff options
| author | Teddy Wing | 2018-09-18 13:36:34 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-09-18 13:36:34 +0200 | 
| commit | f6eb63bc9f55f76b5ad2d7496cbeb9afd0a5a0f4 (patch) | |
| tree | 3aacdc5c7c907a40dd9936231614aec413639129 | |
| parent | 0bb1ce741dad346d98e041986fa786a75c6c4836 (diff) | |
| download | DomeKey-f6eb63bc9f55f76b5ad2d7496cbeb9afd0a5a0f4.tar.bz2 | |
HeadphoneKey: Add a method to switch modes
This method will be used from `runAction` to switch to a different mode.
| -rw-r--r-- | DomeKey/HeadphoneKey.h | 2 | ||||
| -rw-r--r-- | DomeKey/HeadphoneKey.m | 13 | 
2 files changed, 15 insertions, 0 deletions
| 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 | 
