Browse Source

refactor(core): make the event manager a bit easier to read

xmkb
Okke Formsma 4 years ago committed by Pete Johanson
parent
commit
8ebe0cd0c8
  1. 15
      app/src/event_manager.c

15
app/src/event_manager.c

@ -22,13 +22,13 @@ int zmk_event_manager_handle_from(zmk_event_t *event, uint8_t start_index) {
uint8_t len = __event_subscriptions_end - __event_subscriptions_start; uint8_t len = __event_subscriptions_end - __event_subscriptions_start;
for (int i = start_index; i < len; i++) { for (int i = start_index; i < len; i++) {
struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i;
if (ev_sub->event_type == event->event) { if (ev_sub->event_type != event->event) {
continue;
}
ret = ev_sub->listener->callback(event); ret = ev_sub->listener->callback(event);
if (ret < 0) {
LOG_DBG("Listener returned an error: %d", ret);
goto release;
} else if (ret > 0) {
switch (ret) { switch (ret) {
case ZMK_EV_EVENT_BUBBLE:
continue;
case ZMK_EV_EVENT_HANDLED: case ZMK_EV_EVENT_HANDLED:
LOG_DBG("Listener handled the event"); LOG_DBG("Listener handled the event");
ret = 0; ret = 0;
@ -38,8 +38,9 @@ int zmk_event_manager_handle_from(zmk_event_t *event, uint8_t start_index) {
event->last_listener_index = i; event->last_listener_index = i;
// Listeners are expected to free events they capture // Listeners are expected to free events they capture
return 0; return 0;
} default:
} LOG_DBG("Listener returned an error: %d", ret);
goto release;
} }
} }

Loading…
Cancel
Save