summaryrefslogtreecommitdiff
path: root/app/src/behaviors/behavior_sticky_key.c
diff options
context:
space:
mode:
authorOkke Formsma <okke@formsma.nl>2020-11-30 22:18:03 +0100
committerPete Johanson <peter@peterjohanson.com>2020-12-15 13:59:03 -0500
commit1c2796d1c9055fc4fb214aa8004a01133918ed62 (patch)
tree76c9c60b7b68f5b927e2d5a9fb089b6b61ec8ea7 /app/src/behaviors/behavior_sticky_key.c
parentbc8803ba5079fb81babe6d7e328eac1904234fbf (diff)
refactor(sticky keys): use pointer to avoid repetition in store_sticky_key
Diffstat (limited to 'app/src/behaviors/behavior_sticky_key.c')
-rw-r--r--app/src/behaviors/behavior_sticky_key.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c
index 295d243..776d3e2 100644
--- a/app/src/behaviors/behavior_sticky_key.c
+++ b/app/src/behaviors/behavior_sticky_key.c
@@ -53,21 +53,21 @@ static struct active_sticky_key *store_sticky_key(uint32_t position, uint32_t pa
uint32_t param2,
const struct behavior_sticky_key_config *config) {
for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) {
- if (active_sticky_keys[i].position != ZMK_BHV_STICKY_KEY_POSITION_NOT_USED ||
- if (active_sticky_keys[i].position != ZMK_BHV_STICKY_KEY_POSITION_FREE ||
- active_sticky_keys[i].timer_cancelled) {
+ struct active_sticky_key *const sticky_key = &active_sticky_keys[i];
+ if (sticky_key->position != ZMK_BHV_STICKY_KEY_POSITION_FREE ||
+ sticky_key->timer_cancelled) {
continue;
}
- active_sticky_keys[i].position = position;
- active_sticky_keys[i].param1 = param1;
- active_sticky_keys[i].param2 = param2;
- active_sticky_keys[i].config = config;
- active_sticky_keys[i].release_at = 0;
- active_sticky_keys[i].timer_cancelled = false;
- active_sticky_keys[i].timer_started = false;
- active_sticky_keys[i].modified_key_usage_page = 0;
- active_sticky_keys[i].modified_key_keycode = 0;
- return &active_sticky_keys[i];
+ sticky_key->position = position;
+ sticky_key->param1 = param1;
+ sticky_key->param2 = param2;
+ sticky_key->config = config;
+ sticky_key->release_at = 0;
+ sticky_key->timer_cancelled = false;
+ sticky_key->timer_started = false;
+ sticky_key->modified_key_usage_page = 0;
+ sticky_key->modified_key_keycode = 0;
+ return sticky_key;
}
return NULL;
}