fix(core): Address review comments from Joel.

* Fix up some lingering events API tweaks for heap-less event manager.
This commit is contained in:
Peter Johanson
2024-01-13 21:17:35 +00:00
committed by Pete Johanson
parent 33209dee1d
commit 644feeb40d
6 changed files with 26 additions and 19 deletions

View File

@@ -21,15 +21,13 @@ static int behavior_key_press_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1);
return raise_zmk_keycode_state_changed(
zmk_keycode_state_changed_from_encoded(binding->param1, true, event.timestamp));
return raise_zmk_keycode_state_changed_from_encoded(binding->param1, true, event.timestamp);
}
static int on_keymap_binding_released(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1);
return raise_zmk_keycode_state_changed(
zmk_keycode_state_changed_from_encoded(binding->param1, false, event.timestamp));
return raise_zmk_keycode_state_changed_from_encoded(binding->param1, false, event.timestamp);
}
static const struct behavior_driver_api behavior_key_press_driver_api = {

View File

@@ -23,8 +23,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1);
bool pressed = zmk_hid_is_pressed(binding->param1);
return raise_zmk_keycode_state_changed(
zmk_keycode_state_changed_from_encoded(binding->param1, !pressed, event.timestamp));
return raise_zmk_keycode_state_changed_from_encoded(binding->param1, !pressed, event.timestamp);
}
static int on_keymap_binding_released(struct zmk_behavior_binding *binding,

View File

@@ -236,8 +236,8 @@ static int sticky_key_keycode_state_changed_listener(const zmk_event_t *eh) {
if (sticky_key->config->quick_release) {
// immediately release the sticky key after the key press is handled.
if (!event_reraised) {
struct zmk_keycode_state_changed_event dupe_ev;
memcpy(&dupe_ev, eh, sizeof(struct zmk_keycode_state_changed_event));
struct zmk_keycode_state_changed_event dupe_ev =
copy_raised_zmk_keycode_state_changed(ev);
ZMK_EVENT_RAISE_AFTER(dupe_ev, behavior_sticky_key);
event_reraised = true;
}

View File

@@ -274,14 +274,14 @@ static int release_pressed_keys() {
uint32_t count = pressed_keys_count;
pressed_keys_count = 0;
for (int i = 0; i < count; i++) {
struct zmk_position_state_changed_event ev = pressed_keys[i];
struct zmk_position_state_changed_event *ev = &pressed_keys[i];
if (i == 0) {
LOG_DBG("combo: releasing position event %d", ev.data.position);
ZMK_EVENT_RELEASE(ev)
LOG_DBG("combo: releasing position event %d", ev->data.position);
ZMK_EVENT_RELEASE(*ev);
} else {
// reprocess events (see tests/combo/fully-overlapping-combos-3 for why this is needed)
LOG_DBG("combo: reraising position event %d", ev.data.position);
ZMK_EVENT_RAISE(ev);
LOG_DBG("combo: reraising position event %d", ev->data.position);
ZMK_EVENT_RAISE(*ev);
}
}