refactor(core): Move to stack allocated events.

* Move to local/stack allocated event API that doesn't require
  dynamic allocation/freeing.
* Disable heap, we no longer use alloc/free unless using LVGL.
* Tons of refactors all over to account for the new event approach.
This commit is contained in:
Peter Johanson
2023-03-23 08:56:02 +00:00
committed by Pete Johanson
parent 50e473276f
commit 33209dee1d
24 changed files with 172 additions and 147 deletions

View File

@@ -76,6 +76,7 @@ static struct zmk_behavior_binding
#endif /* ZMK_KEYMAP_HAS_SENSORS */
static inline int set_layer_state(uint8_t layer, bool state) {
int ret = 0;
if (layer >= ZMK_KEYMAP_LAYERS_LEN) {
return -EINVAL;
}
@@ -90,10 +91,13 @@ static inline int set_layer_state(uint8_t layer, bool state) {
// Don't send state changes unless there was an actual change
if (old_state != _zmk_keymap_layer_state) {
LOG_DBG("layer_changed: layer %d state %d", layer, state);
ZMK_EVENT_RAISE(create_layer_state_changed(layer, state));
ret = raise_layer_state_changed(layer, state);
if (ret < 0) {
LOG_WRN("Failed to raise layer state changed (%d)", ret);
}
}
return 0;
return ret;
}
uint8_t zmk_keymap_layer_default(void) { return _zmk_keymap_layer_default; }