aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-09-24 11:48:20 +0200
committerTeddy Wing2018-09-24 11:48:20 +0200
commit319f40e0c999e936d982bda2b900d8eb5a8ec91b (patch)
treeef5535eb81a67cad50650145054ddeaddbecf9ad
parent342a2bebed69e57be8a827ff977d636ae9392924 (diff)
downloadDomeKey-319f40e0c999e936d982bda2b900d8eb5a8ec91b.tar.bz2
HeadphoneKey: Get switching to mode working
* Update to latest dome-key-map, which handles in-mode internally using a `State` struct * Make a `State *` ivar to store the current dome-key-map state, and let it do the work of mode handling Currently doesn't handle exiting a mode, only entering one. But that last part actually does finally work now, yay! Still requires cleanup to get rid of the old `in_mode` handling.
-rw-r--r--DomeKey/HeadphoneKey.h1
-rw-r--r--DomeKey/HeadphoneKey.m7
m---------lib/dome-key-map0
3 files changed, 5 insertions, 3 deletions
diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h
index 9a8bab1..3be7148 100644
--- a/DomeKey/HeadphoneKey.h
+++ b/DomeKey/HeadphoneKey.h
@@ -24,6 +24,7 @@ static const unsigned int TIMEOUT_MILLISECONDS = 1000;
NSMutableArray *_key_buffer;
// const Trigger *_in_mode;
Trigger *_in_mode;
+ State *_state;
}
- (void)handleDeadKey:(HeadphoneButton)button;
diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m
index 47583a7..44fd4e6 100644
--- a/DomeKey/HeadphoneKey.m
+++ b/DomeKey/HeadphoneKey.m
@@ -16,6 +16,7 @@
if (self) {
_key_buffer = [[NSMutableArray alloc] initWithCapacity:5];
_in_mode = NULL;
+ _state = state_new();
_mikeys = [DDHidAppleMikey allMikeys];
[_mikeys makeObjectsPerformSelector:@selector(setDelegate:)
@@ -80,7 +81,7 @@
.length = count
};
- const CKeyActionResult *result = c_run_key_action(trigger, _in_mode);
+ const CKeyActionResult *result = c_run_key_action(_state, trigger, _in_mode);
// if ([self maybeSwitchToMode:result]) {
// goto cleanup;
@@ -98,8 +99,8 @@
}
else if (*result->kind == ActionKind_Mode) {
// [self maybeSwitchToMode:result];
- _in_mode = malloc(sizeof(Trigger))
- *_in_mode = *result->in_mode;
+ // _in_mode = malloc(sizeof(Trigger))
+ // *_in_mode = *result->in_mode;
// memcpy(_in_mode, result->in_mode, sizeof(const Trigger));
}
}
diff --git a/lib/dome-key-map b/lib/dome-key-map
-Subproject ce1eca32e2249a72692c6eb01052361d98af29c
+Subproject 882dfbe6f0aad091613839841d2f54334e37b32