refactor(core): Extra event payloads to own types, refactor API.

* Make it easier to use *just* event payloads by defining the data,
  and then having event manager macros generate "wrapper structs"
* Improve is_*/cast_* APIs to hide details of full event struct.
* Create `zmk_event_t` typedef to pass to event handlers.
* Bring event names inline w/ consistent `zmk_` prefix.
This commit is contained in:
Pete Johanson
2021-01-18 00:35:56 -05:00
parent 003db892ad
commit 3fe2acc2d1
40 changed files with 190 additions and 239 deletions

View File

@@ -79,7 +79,7 @@ lv_obj_t *zmk_widget_output_status_obj(struct zmk_widget_output_status *widget)
return widget->obj;
}
int output_status_listener(const struct zmk_event_header *eh) {
int output_status_listener(const zmk_event_t *eh) {
struct zmk_widget_output_status *widget;
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj); }
return ZMK_EV_EVENT_BUBBLE;
@@ -87,8 +87,8 @@ int output_status_listener(const struct zmk_event_header *eh) {
ZMK_LISTENER(widget_output_status, output_status_listener)
#if defined(CONFIG_USB)
ZMK_SUBSCRIPTION(widget_output_status, usb_conn_state_changed);
ZMK_SUBSCRIPTION(widget_output_status, zmk_usb_conn_state_changed);
#endif
#if defined(CONFIG_ZMK_BLE)
ZMK_SUBSCRIPTION(widget_output_status, ble_active_profile_changed);
ZMK_SUBSCRIPTION(widget_output_status, zmk_ble_active_profile_changed);
#endif