From 8f49752babfff805b3eeb1b157c41032de55c07b Mon Sep 17 00:00:00 2001 From: Vftdan Date: Wed, 14 Aug 2024 14:53:17 +0200 Subject: [PATCH] Split event code value into major and minor components --- events.h | 3 ++- nodes/evdev.c | 3 ++- nodes/getchar.c | 5 +++-- nodes/print.c | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/events.h b/events.h index 3e2217a..134e6c4 100644 --- a/events.h +++ b/events.h @@ -9,7 +9,8 @@ typedef uint32_t EventNamespace; typedef struct { EventNamespace ns; - uint32_t value; + uint16_t major; + uint16_t minor; } EventCode; typedef struct { diff --git a/nodes/evdev.c b/nodes/evdev.c index d56c8a4..da2197c 100644 --- a/nodes/evdev.c +++ b/nodes/evdev.c @@ -46,7 +46,8 @@ handle_io(EventPositionBase * self, int fd, bool is_output) EventData data = { .code = { .ns = 1, - .value = (((int32_t) buf.type) << 16) | buf.code, + .major = buf.type, + .minor = buf.code, }, .ttl = 100, .priority = 10, diff --git a/nodes/getchar.c b/nodes/getchar.c index 90e5d85..da55c66 100644 --- a/nodes/getchar.c +++ b/nodes/getchar.c @@ -22,7 +22,8 @@ handle_io(EventPositionBase * self, int fd, bool is_output) EventData data = { .code = { .ns = 0, - .value = 1, + .major = 0, + .minor = 1, }, .ttl = 100, .priority = 10, @@ -32,7 +33,7 @@ handle_io(EventPositionBase * self, int fd, bool is_output) }; if (status == 0) { node->subscription.enabled = false; - data.code.value = 2; + data.code.minor = 2; data.payload = 0; } for (size_t i = 0; i < node->as_GraphNode.outputs.length; ++i) { diff --git a/nodes/print.c b/nodes/print.c index 9bd2632..1512672 100644 --- a/nodes/print.c +++ b/nodes/print.c @@ -9,7 +9,8 @@ handle_event(EventPositionBase * self, EventNode * event) EventData data = event->data; printf("Event from connector %ld:\n", event->input_index); PRINT_FIELD("%d", code.ns); - PRINT_FIELD("%d", code.value); + PRINT_FIELD("%d", code.major); + PRINT_FIELD("%d", code.minor); PRINT_FIELD("%d", ttl); PRINT_FIELD("%d", priority); PRINT_FIELD("%ld", payload);