summaryrefslogtreecommitdiff
path: root/app/include/zmk/event-manager.h
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-07-30 00:20:41 -0400
committerGitHub <noreply@github.com>2020-07-30 00:20:41 -0400
commitf269b26ea1cdd61e39f13c6e11cbdfcdc6a0bd5c (patch)
tree7d1f813939bc19fbdabc2e0c891508a11d76b2be /app/include/zmk/event-manager.h
parent2f1c3dd538257eb1405ea52908db4b758ff12835 (diff)
parentcf8c7856ff4251c72b53d29f1b48cc266badab98 (diff)
Merge pull request #68 from petejohanson/core/ev-manager-capture-release-events
Add the ability to capture event and release later
Diffstat (limited to 'app/include/zmk/event-manager.h')
-rw-r--r--app/include/zmk/event-manager.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h
index 2ef55e9..3938171 100644
--- a/app/include/zmk/event-manager.h
+++ b/app/include/zmk/event-manager.h
@@ -17,8 +17,12 @@ struct zmk_event_type
struct zmk_event_header {
const struct zmk_event_type* event;
+ u8_t last_listener_index;
};
+#define ZMK_EV_EVENT_HANDLED 1
+#define ZMK_EV_EVENT_CAPTURED 2
+
typedef int (*zmk_listener_callback_t)(const struct zmk_event_header *eh);
struct zmk_listener
{
@@ -33,7 +37,7 @@ struct zmk_event_subscription {
#define ZMK_EVENT_DECLARE(event_type) \
struct event_type* new_##event_type(); \
bool is_##event_type(const struct zmk_event_header *eh); \
- const struct event_type* cast_##event_type(const struct zmk_event_header *eh); \
+ struct event_type* cast_##event_type(const struct zmk_event_header *eh); \
extern const struct zmk_event_type zmk_event_##event_type;
#define ZMK_EVENT_IMPL(event_type) \
@@ -49,8 +53,8 @@ struct zmk_event_subscription {
bool is_##event_type(const struct zmk_event_header *eh) { \
return eh->event == &zmk_event_##event_type; \
}; \
- const struct event_type* cast_##event_type(const struct zmk_event_header *eh) {\
- return (const struct event_type*)eh; \
+ struct event_type* cast_##event_type(const struct zmk_event_header *eh) {\
+ return (struct event_type*)eh; \
};
@@ -68,4 +72,8 @@ struct zmk_event_subscription {
#define ZMK_EVENT_RAISE(ev) \
zmk_event_manager_raise((struct zmk_event_header *)ev);
+#define ZMK_EVENT_RELEASE(ev) \
+ zmk_event_manager_release((struct zmk_event_header *)ev);
+
int zmk_event_manager_raise(struct zmk_event_header *event);
+int zmk_event_manager_release(struct zmk_event_header *event);