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.
This commit is contained in:
Pete Johanson
2021-01-19 14:21:00 -05:00
parent 3fe2acc2d1
commit 3368a81057
8 changed files with 43 additions and 36 deletions

View File

@@ -76,7 +76,11 @@ int zmk_display_init() {
}
int display_event_handler(const zmk_event_t *eh) {
struct zmk_activity_state_changed *ev = cast_zmk_activity_state_changed(eh);
struct zmk_activity_state_changed *ev = as_zmk_activity_state_changed(eh);
if (ev == NULL) {
return -ENOTSUP;
}
switch (ev->state) {
case ZMK_ACTIVITY_ACTIVE:
start_display_updates();