summaryrefslogtreecommitdiff
path: root/app/src/keymap.c
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-06-30 00:31:09 -0400
committerPete Johanson <peter@peterjohanson.com>2020-06-30 00:31:09 -0400
commit9a991bf019d6f723bc4230822852efa78a05be49 (patch)
tree5c6604f146502a9f4886231bb0c3b39d7646888f /app/src/keymap.c
parent22238d24de3a25cb9242330eba568294c7937c63 (diff)
Initial event manager work, and two first events.
* Add initial event manager implementation, roughly mimicking Nordic's API. * Add `position_state_changed` and `keycode_state_changed` events. * Hook up HID and keymap to new events instead of using behaviour global event crazy.
Diffstat (limited to 'app/src/keymap.c')
-rw-r--r--app/src/keymap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/src/keymap.c b/app/src/keymap.c
index f951dd7..25bcf80 100644
--- a/app/src/keymap.c
+++ b/app/src/keymap.c
@@ -9,6 +9,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <drivers/behavior.h>
#include <zmk/behavior.h>
+#include <zmk/event-manager.h>
+#include <zmk/events/position-state-changed.h>
+
static u32_t zmk_keymap_layer_state = 0;
static u8_t zmk_keymap_layer_default = 0;
@@ -116,3 +119,16 @@ int zmk_keymap_position_state_changed(u32_t position, bool pressed)
return -ENOTSUP;
}
+
+int keymap_listener(const struct zmk_event_header *eh)
+{
+ if (is_position_state_changed(eh)) {
+ const struct position_state_changed *ev = cast_position_state_changed(eh);
+ zmk_keymap_position_state_changed(ev->position, ev->state);
+ }
+ return 0;
+}
+
+ZMK_LISTENER(keymap, keymap_listener);
+ZMK_SUBSCRIPTION(keymap, position_state_changed);
+