diff options
author | Okke Formsma <okke@formsma.nl> | 2020-12-16 19:41:53 +0100 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-01-01 23:07:54 -0500 |
commit | caa285852adc2d18ebd925171d11d0fd20d88dc8 (patch) | |
tree | 2acb444dde54c1493574d6a03b50eab4e394b71e | |
parent | 5a7266289879c429982e33b80a33a11f4485c0da (diff) |
refactor(events): return 'ZMK_EV_EVENT_BUBBLE' instead of magic number 0
-rw-r--r-- | app/include/zmk/event_manager.h | 1 | ||||
-rw-r--r-- | app/src/behaviors/behavior_hold_tap.c | 14 | ||||
-rw-r--r-- | app/src/behaviors/behavior_sticky_key.c | 4 | ||||
-rw-r--r-- | app/src/display/widgets/battery_status.c | 2 | ||||
-rw-r--r-- | app/src/display/widgets/output_status.c | 2 | ||||
-rw-r--r-- | app/src/split_listener.c | 2 |
6 files changed, 13 insertions, 12 deletions
diff --git a/app/include/zmk/event_manager.h b/app/include/zmk/event_manager.h index 31c5322..e5b6ed5 100644 --- a/app/include/zmk/event_manager.h +++ b/app/include/zmk/event_manager.h @@ -19,6 +19,7 @@ struct zmk_event_header { uint8_t last_listener_index; }; +#define ZMK_EV_EVENT_BUBBLE 0 #define ZMK_EV_EVENT_HANDLED 1 #define ZMK_EV_EVENT_CAPTURED 2 diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index d303960..7ad1d32 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -392,16 +392,16 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) { if (undecided_hold_tap == NULL) { LOG_DBG("%d bubble (no undecided hold_tap active)", ev->position); - return 0; + return ZMK_EV_EVENT_BUBBLE; } if (undecided_hold_tap->position == ev->position) { if (ev->state) { // keydown LOG_ERR("hold-tap listener should be called before before most other listeners!"); - return 0; + return ZMK_EV_EVENT_BUBBLE; } else { // keyup LOG_DBG("%d bubble undecided hold-tap keyrelease event", undecided_hold_tap->position); - return 0; + return ZMK_EV_EVENT_BUBBLE; } } @@ -418,7 +418,7 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) { // we'll catch modifiers later in modifier_state_changed_listener LOG_DBG("%d bubbling %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); - return 0; + return ZMK_EV_EVENT_BUBBLE; } LOG_DBG("%d capturing %d %s event", undecided_hold_tap->position, ev->position, @@ -439,12 +439,12 @@ static int keycode_state_changed_listener(const struct zmk_event_header *eh) { if (undecided_hold_tap == NULL) { // LOG_DBG("0x%02X bubble (no undecided hold_tap active)", ev->keycode); - return 0; + return ZMK_EV_EVENT_BUBBLE; } if (!only_mods(ev)) { // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); - return 0; + return ZMK_EV_EVENT_BUBBLE; } // only key-up events will bubble through position_state_changed_listener @@ -461,7 +461,7 @@ int behavior_hold_tap_listener(const struct zmk_event_header *eh) { } else if (is_keycode_state_changed(eh)) { return keycode_state_changed_listener(eh); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(behavior_hold_tap, behavior_hold_tap_listener); diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 643ae48..271b168 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -177,7 +177,7 @@ static const struct behavior_driver_api behavior_sticky_key_driver_api = { static int sticky_key_keycode_state_changed_listener(const struct zmk_event_header *eh) { if (!is_keycode_state_changed(eh)) { - return 0; + return ZMK_EV_EVENT_BUBBLE; } struct keycode_state_changed *ev = cast_keycode_state_changed(eh); for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { @@ -222,7 +222,7 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head } } } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(behavior_sticky_key, sticky_key_keycode_state_changed_listener); diff --git a/app/src/display/widgets/battery_status.c b/app/src/display/widgets/battery_status.c index 346c519..f1f1c9f 100644 --- a/app/src/display/widgets/battery_status.c +++ b/app/src/display/widgets/battery_status.c @@ -78,7 +78,7 @@ lv_obj_t *zmk_widget_battery_status_obj(struct zmk_widget_battery_status *widget int battery_status_listener(const struct zmk_event_header *eh) { struct zmk_widget_battery_status *widget; SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_battery_symbol(widget->obj); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(widget_battery_status, battery_status_listener) diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c index 9a72511..716228b 100644 --- a/app/src/display/widgets/output_status.c +++ b/app/src/display/widgets/output_status.c @@ -82,7 +82,7 @@ lv_obj_t *zmk_widget_output_status_obj(struct zmk_widget_output_status *widget) int output_status_listener(const struct zmk_event_header *eh) { struct zmk_widget_output_status *widget; SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(widget_output_status, output_status_listener) diff --git a/app/src/split_listener.c b/app/src/split_listener.c index 153ed99..f475002 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -29,7 +29,7 @@ int split_listener(const struct zmk_event_header *eh) { return zmk_split_bt_position_released(ev->position); } } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(split_listener, split_listener); |