summaryrefslogtreecommitdiff
path: root/app/src/combo.c
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2021-01-19 14:21:00 -0500
committerPete Johanson <peter@peterjohanson.com>2021-01-20 07:06:11 -0500
commit3368a81057d4981aa259c5548050d95739d99d51 (patch)
treea2feaed6f49eb25949a64c9c3cafe574f43fe23d /app/src/combo.c
parent3fe2acc2d191006fa6309191ee99b2e4e249ed08 (diff)
refactor(core): Combine `is_` and `cast_` event functions.
* Use a single `as_foo` generated function to conditionally return a certain event type from a generic `zmk_event_t*` pointer.
Diffstat (limited to 'app/src/combo.c')
-rw-r--r--app/src/combo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/src/combo.c b/app/src/combo.c
index a08a2f5..82f6538 100644
--- a/app/src/combo.c
+++ b/app/src/combo.c
@@ -291,7 +291,7 @@ static void activate_combo(struct combo_cfg *combo) {
}
move_pressed_keys_to_active_combo(active_combo);
press_combo_behavior(
- combo, cast_zmk_position_state_changed(active_combo->key_positions_pressed[0])->timestamp);
+ combo, as_zmk_position_state_changed(active_combo->key_positions_pressed[0])->timestamp);
}
static void deactivate_combo(int active_combo_index) {
@@ -315,7 +315,7 @@ static bool release_combo_key(int32_t position, int64_t timestamp) {
for (int i = 0; i < active_combo->combo->key_position_len; i++) {
if (active_combo->key_positions_pressed[i] == NULL) {
all_keys_pressed = false;
- } else if (cast_zmk_position_state_changed(active_combo->key_positions_pressed[i])
+ } else if (as_zmk_position_state_changed(active_combo->key_positions_pressed[i])
->position != position) {
all_keys_released = false;
} else { // not null and position matches
@@ -418,11 +418,11 @@ static void combo_timeout_handler(struct k_work *item) {
}
static int position_state_changed_listener(const zmk_event_t *ev) {
- if (!is_zmk_position_state_changed(ev)) {
+ struct zmk_position_state_changed *data = as_zmk_position_state_changed(ev);
+ if (data == NULL) {
return 0;
}
- struct zmk_position_state_changed *data = cast_zmk_position_state_changed(ev);
if (data->state) { // keydown
return position_state_down(ev, data);
} else { // keyup