Skip to content

Display and control your Android device

Make control_event_serialize() return size_t

Romain Vimontbf5e54b2e9c5
diff --git a/app/src/control_event.c b/app/src/control_event.c
index e836f506..ea6585a4 100644
--- a/app/src/control_event.c
+++ b/app/src/control_event.c
@@ -13,7 +13,7 @@ write_position(uint8_t *buf, const struct position *position) {
buffer_write16be(&buf[10], position->screen_size.height);
}
-int
+size_t
control_event_serialize(const struct control_event *event, unsigned char *buf) {
buf[0] = event->type;
switch (event->type) {
diff --git a/app/src/control_event.h b/app/src/control_event.h
index 70d8d494..49ec7020 100644
--- a/app/src/control_event.h
+++ b/app/src/control_event.h
@@ -2,6 +2,7 @@
#define CONTROLEVENT_H
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
#include "android/input.h"
@@ -60,7 +61,8 @@ struct control_event_queue {
};
// buf size must be at least CONTROL_EVENT_SERIALIZED_MAX_SIZE
-int
+// return the number of bytes written
+size_t
control_event_serialize(const struct control_event *event, unsigned char *buf);
bool