zmk/app/src/events/position_state_changed.c
Okke Formsma 25fd5b2402 feat(events): Add trace_id to position, behavior and key events
With the trace_id it's possible for behaviors to keep track of which events were caused by which trigger.
2021-02-16 21:58:34 +01:00

21 lines
540 B
C

/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <kernel.h>
#include <zmk/events/position_state_changed.h>
ZMK_EVENT_IMPL(zmk_position_state_changed);
static uint32_t zmk_last_event_trace_id = 0;
static uint32_t zmk_event_trace_ids[ZMK_KEYMAP_LEN] = {0};
uint32_t zmk_get_event_trace_id(uint32_t position, bool pressed) {
if (pressed) {
zmk_last_event_trace_id++;
zmk_event_trace_ids[position] = zmk_last_event_trace_id;
}
return zmk_event_trace_ids[position];
}