Split event code value into major and minor components

This commit is contained in:
Vftdan 2024-08-14 14:53:17 +02:00
parent 65769a7442
commit 8f49752bab
4 changed files with 9 additions and 5 deletions

View File

@ -9,7 +9,8 @@ typedef uint32_t EventNamespace;
typedef struct { typedef struct {
EventNamespace ns; EventNamespace ns;
uint32_t value; uint16_t major;
uint16_t minor;
} EventCode; } EventCode;
typedef struct { typedef struct {

View File

@ -46,7 +46,8 @@ handle_io(EventPositionBase * self, int fd, bool is_output)
EventData data = { EventData data = {
.code = { .code = {
.ns = 1, .ns = 1,
.value = (((int32_t) buf.type) << 16) | buf.code, .major = buf.type,
.minor = buf.code,
}, },
.ttl = 100, .ttl = 100,
.priority = 10, .priority = 10,

View File

@ -22,7 +22,8 @@ handle_io(EventPositionBase * self, int fd, bool is_output)
EventData data = { EventData data = {
.code = { .code = {
.ns = 0, .ns = 0,
.value = 1, .major = 0,
.minor = 1,
}, },
.ttl = 100, .ttl = 100,
.priority = 10, .priority = 10,
@ -32,7 +33,7 @@ handle_io(EventPositionBase * self, int fd, bool is_output)
}; };
if (status == 0) { if (status == 0) {
node->subscription.enabled = false; node->subscription.enabled = false;
data.code.value = 2; data.code.minor = 2;
data.payload = 0; data.payload = 0;
} }
for (size_t i = 0; i < node->as_GraphNode.outputs.length; ++i) { for (size_t i = 0; i < node->as_GraphNode.outputs.length; ++i) {

View File

@ -9,7 +9,8 @@ handle_event(EventPositionBase * self, EventNode * event)
EventData data = event->data; EventData data = event->data;
printf("Event from connector %ld:\n", event->input_index); printf("Event from connector %ld:\n", event->input_index);
PRINT_FIELD("%d", code.ns); 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", ttl);
PRINT_FIELD("%d", priority); PRINT_FIELD("%d", priority);
PRINT_FIELD("%ld", payload); PRINT_FIELD("%ld", payload);